|
| 1 | +//package com.reactnativemultipleimagepicker |
| 2 | +// |
| 3 | +//import android.content.Context |
| 4 | +//import android.graphics.Bitmap |
| 5 | +//import android.net.Uri |
| 6 | +//import android.widget.ImageView |
| 7 | +//import androidx.core.content.ContextCompat |
| 8 | +//import androidx.fragment.app.Fragment |
| 9 | +//import com.bumptech.glide.Glide |
| 10 | +//import com.luck.picture.lib.engine.CropFileEngine |
| 11 | +//import com.luck.picture.lib.interfaces.OnCallbackListener |
| 12 | +//import com.luck.picture.lib.style.TitleBarStyle |
| 13 | +//import com.luck.picture.lib.utils.StyleUtils |
| 14 | +//import com.yalantis.ucrop.UCrop |
| 15 | +//import com.yalantis.ucrop.UCropImageEngine |
| 16 | +//import java.security.AccessController.getContext |
| 17 | +// |
| 18 | +//class ImageFileCropEngine : CropFileEngine { |
| 19 | +// fun onStartCrop( |
| 20 | +// fragment: Fragment, |
| 21 | +// srcUri: Uri?, |
| 22 | +// destinationUri: Uri?, |
| 23 | +// dataSource: ArrayList<String?>?, |
| 24 | +// requestCode: Int |
| 25 | +// ) { |
| 26 | +// val options: UCrop.Options = buildOptions() |
| 27 | +// val uCrop: UCrop = UCrop.of(srcUri, destinationUri, dataSource) |
| 28 | +// uCrop.withOptions(options) |
| 29 | +// uCrop.setImageEngine(object : UCropImageEngine() { |
| 30 | +// fun loadImage(context: Context?, url: String?, imageView: ImageView?) { |
| 31 | +// if (!ImageLoaderUtils.assertValidRequest(context)) { |
| 32 | +// return |
| 33 | +// } |
| 34 | +// GlideEngine.with(context).load(url).override(180, 180).into(imageView) |
| 35 | +// } |
| 36 | +// |
| 37 | +// fun loadImage( |
| 38 | +// context: Context?, |
| 39 | +// url: Uri?, |
| 40 | +// maxWidth: Int, |
| 41 | +// maxHeight: Int, |
| 42 | +// call: OnCallbackListener<Bitmap?>? |
| 43 | +// ) { |
| 44 | +// Glide.with(context).asBitmap().load(url).override(maxWidth, maxHeight) |
| 45 | +// .into(object : CustomTarget<Bitmap?>() { |
| 46 | +// fun onResourceReady( |
| 47 | +// @NonNull resource: Bitmap?, |
| 48 | +// @Nullable transition: Transition<in Bitmap?>? |
| 49 | +// ) { |
| 50 | +// if (call != null) { |
| 51 | +// call.onCall(resource) |
| 52 | +// } |
| 53 | +// } |
| 54 | +// |
| 55 | +// fun onLoadCleared(@Nullable placeholder: Drawable?) { |
| 56 | +// if (call != null) { |
| 57 | +// call.onCall(null) |
| 58 | +// } |
| 59 | +// } |
| 60 | +// }) |
| 61 | +// } |
| 62 | +// }) |
| 63 | +// uCrop.start(fragment.requireActivity(), fragment, requestCode) |
| 64 | +// } |
| 65 | +//} |
| 66 | +// |
| 67 | +//private fun buildOptions(): UCrop.Options { |
| 68 | +// val options = UCrop.Options() |
| 69 | +//// options.setHideBottomControls(!cb_hide.isChecked()) |
| 70 | +//// options.setFreeStyleCropEnabled(cb_styleCrop.isChecked()) |
| 71 | +//// options.setShowCropFrame(cb_showCropFrame.isChecked()) |
| 72 | +//// options.setShowCropGrid(cb_showCropGrid.isChecked()) |
| 73 | +//// options.setCircleDimmedLayer(cb_crop_circular.isChecked()) |
| 74 | +//// options.withAspectRatio(aspect_ratio_x, aspect_ratio_y) |
| 75 | +//// options.setCropOutputPathDir(getSandboxPath()) |
| 76 | +//// options.isCropDragSmoothToCenter(false) |
| 77 | +//// options.setSkipCropMimeType(getNotSupportCrop()) |
| 78 | +//// options.isForbidCropGifWebp(cb_not_gif.isChecked()) |
| 79 | +//// options.isForbidSkipMultipleCrop(true) |
| 80 | +//// options.setMaxScaleMultiplier(100f) |
| 81 | +// |
| 82 | +// if (selectorStyle != null && selectorStyle.getSelectMainStyle().getStatusBarColor() !== 0) { |
| 83 | +// val mainStyle: SelectMainStyle = selectorStyle.getSelectMainStyle() |
| 84 | +// val isDarkStatusBarBlack: Boolean = mainStyle.isDarkStatusBarBlack() |
| 85 | +// val statusBarColor: Int = mainStyle.getStatusBarColor() |
| 86 | +// options.isDarkStatusBarBlack(isDarkStatusBarBlack) |
| 87 | +// if (StyleUtils.checkStyleValidity(statusBarColor)) { |
| 88 | +// options.setStatusBarColor(statusBarColor) |
| 89 | +// options.setToolbarColor(statusBarColor) |
| 90 | +// } else { |
| 91 | +// options.setStatusBarColor(ContextCompat.getColor(getContext(), R.color.ps_color_grey)) |
| 92 | +// options.setToolbarColor(ContextCompat.getColor(getContext(), R.color.ps_color_grey)) |
| 93 | +// } |
| 94 | +// val titleBarStyle: TitleBarStyle = selectorStyle.getTitleBarStyle() |
| 95 | +// if (StyleUtils.checkStyleValidity(titleBarStyle.getTitleTextColor())) { |
| 96 | +// options.setToolbarWidgetColor(titleBarStyle.getTitleTextColor()) |
| 97 | +// } else { |
| 98 | +// options.setToolbarWidgetColor( |
| 99 | +// ContextCompat.getColor( |
| 100 | +// getContext(), |
| 101 | +// R.color.ps_color_white |
| 102 | +// ) |
| 103 | +// ) |
| 104 | +// } |
| 105 | +// } else { |
| 106 | +// options.setStatusBarColor(ContextCompat.getColor(getContext(), R.color.ps_color_grey)) |
| 107 | +// options.setToolbarColor(ContextCompat.getColor(getContext(), R.color.ps_color_grey)) |
| 108 | +// options.setToolbarWidgetColor(ContextCompat.getColor(getContext(), R.color.ps_color_white)) |
| 109 | +// } |
| 110 | +// return options |
| 111 | +//} |
0 commit comments