GitHub地址:https://github.com/pengjianbo/GalleryFinal
Android图片单选/多选、拍照、裁剪、压缩。视频选择和录制。
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
ThemeConfig theme = new ThemeConfig.Builder()
.setTitleBarBgColor(Color.rgb(0xFF, 0x57, 0x22))
.setTitleBarTextColor(Color.BLACK)
.setTitleBarIconColor(Color.BLACK)
.setFabNornalColor(Color.RED)
.setFabPressedColor(Color.BLUE)
.setCheckNornalColor(Color.WHITE)
.setCheckSelectedColor(Color.BLACK)
.build();
//配置功能
FunctionConfig functionConfig = new FunctionConfig.Builder()
.setEnableCamera(true)
.setEnableEdit(true)
.setEnableCrop(true)
.setEnableRotate(true)
.setCropSquare(true)
.setEnablePreview(true)
.build();
//配置imageloader
ImageLoader imageloader = new ImageLoader() {
@Override
public void displayImage(Activity activity, String path, GFImageView imageView, Drawable defaultDrawable, int width, int height) {
imageView.setImageBitmap(BitmapFactory.decodeFile(path));
}
@Override
public void clearMemoryCache() {
}
};
CoreConfig coreConfig = new CoreConfig.Builder(this, imageloader, theme)
.setFunctionConfig(functionConfig)
.build();
GalleryFinal.init(coreConfig);
}
}
调用:
GalleryFinal.openGallerySingle(REQUEST_CODE_GALLERY, mOnHanlderResultCallback);
回调接口:
mOnHanlderResultCallback = new GalleryFinal.OnHanlderResultCallback() {
@Override
public void onHanlderSuccess(int reqeustCode, List<PhotoInfo> resultList) {
if (reqeustCode == REQUEST_CODE_GALLERY) {
mUserIcon.setImageBitmap(BitmapFactory.decodeFile(resultList.get(0).getPhotoPath()));
}
}
@Override
public void onHanlderFailure(int requestCode, String errorMsg) {
}
};
详细配置,参考上述github