-
Notifications
You must be signed in to change notification settings - Fork 2
Edit Module Wiki
A library that helps you edit images imported from your gallery.
CropImageEditView | FlexibleImageEditView |
---|---|
![]() |
![]() |
Reference https://github.com/ArthurHub/Android-Image-Cropper
Sets a Bitmap as the content of the CropImageView.
A function that returns things that are being edited to an object
- Return Type
- CropImageEditModel.
data class CropImageEditModel( val bitmap: Bitmap?, val points: FloatArray, val degreesRotated: Int, val fixAspectRatio: Boolean, val aspectRatioX: Int, val aspectRatioY: Int, val flipHorizontally: Boolean, val flipVertically: Boolean )
This is a view class that allows you to zoom in, zoom out, and move through gestures. When the image is out of the area, there is a logic to reposition it. It's similar to adding an Instagram story.
Load Contents Bitmap
While loading the bitmap, adjust the scale and translation to the desired value.
This is a listener who calls back whenever the image status value changes.
This is the 'Flexible ImageEdit GuideView' exclusive listener.
Like ImageView ScaleType centerCrop Animation
Like ImageView FitCenter Animation
A function that returns the currently edited state value.
- Return Type
- RectF (Nullable)
ImageView Bitmap Getter Origin Bitmap
- xml
<com.gallery.edit.CropImageEditView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cropScaleType="centerCrop"
app:imageBitmap="@{vm.selectPhotoBitmap}" />
- Databinding Sample Function
@JvmStatic
@BindingAdapter("imageBitmap")
fun setCropImageEditBitmap(
view: CropImageEditView,
bitmap: Bitmap?
) {
view.setImageBitmap(bitmap)
}
- xml
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<com.gallery.edit.FlexibleImageEditView
android:id="@+id/ivFlexible"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:imageBitmap="@{vm.selectPhotoBitmap.first}"
app:onStateUpdated="@{(item) -> vm.onStateItem(item)}"
app:stateItem="@{vm.selectPhotoBitmap.second}" />
<com.gallery.edit.FlexibleImageEditGuideView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:targetEditView="@{ivFlexible}" />
</androidx.constraintlayout.widget.ConstraintLayout>
- Databinding Sample
internal object FlexibleImageEditBindingAdapter {
interface FlexibleStateUpdateListener {
fun callback(newItem: FlexibleStateItem)
}
@JvmStatic
@BindingAdapter("imageBitmap", "stateItem", requireAll = false)
fun setFlexibleEditImageBitmap(
view: FlexibleImageEditView,
bitmap: Bitmap?,
stateItem: FlexibleStateItem?
) {
if (stateItem == null) {
view.loadBitmap(bitmap)
} else {
view.loadBitmap(bitmap, stateItem)
}
}
@JvmStatic
@BindingAdapter("onStateUpdated", requireAll = false)
fun setFlexibleEditImageListener(
view: FlexibleImageEditView,
updateStateListener: FlexibleStateUpdateListener?
) {
view.listener = object : FlexibleImageEditListener {
override fun onUpdateStateItem(newItem: FlexibleStateItem) {
try {
updateStateListener?.callback(newItem)
} catch (ex: Exception) {
}
}
}
}
@JvmStatic
@BindingAdapter("targetEditView")
fun setTargetEditView(
view: FlexibleImageEditGuideView,
targetView: FlexibleImageEditView
) {
view.setImageEditView(targetView)
}
}