簡化從相冊或照相獲取圖片的Android庫:EasyImage

jopen 9年前發布 | 23K 次閱讀 EasyImage Android開發 移動開發

EasyImage是一個能夠簡化從相冊或照相獲取圖片的Android庫。

如何使用?

Here are buttons click listeners for picking picture from gallery or taking with camera:

@OnClick(R.id.camera_button)
protected void onTakePhotoClicked() {
    EasyImage.openCamera(this);
}

@OnClick(R.id.gallery_button)
protected void onPickFromGaleryClicked() {
    EasyImage.openGalleryPicker(this);
}

Now there is only one thing left to do:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    EasyImage.handleActivityResult(requestCode, resultCode, data, this, new EasyImage.Callbacks() {
        @Override
        public void onImagePickerError(Exception e, EasyImage.ImageSource source) {
            //Some error handling
        }

        @Override
        public void onImagePicked(File imageFile, EasyImage.ImageSource source) {
            //Handle the image
            onPhotoReturned(imageFile);
        }
    });
}

安裝


Library requires permission from your app. Declare it in yourAndroidMnifest.xml

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Please note that for devices running API 23 (marshmallow) you have to request this permission in the runtime, beofre callingEasyImage.openCamera(). It's demonstrated in the sample app.

This library will help you with that.

repositories {
    maven { url "https://jitpack.io" }
}

dependencies {
    compile 'com.github.jkwiecien:EasyImage:1.0.4'
}

項目主頁:http://www.baiduhome.net/lib/view/home/1446710908670

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!