use Glide for loading the initial image in the editor

This commit is contained in:
tibbi 2018-07-22 21:13:04 +02:00
parent 1adb178e88
commit d308dfb069
2 changed files with 22 additions and 13 deletions

View file

@ -115,19 +115,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
} }
isCropIntent = intent.extras?.get(CROP) == "true" isCropIntent = intent.extras?.get(CROP) == "true"
Glide.with(this).load(uri).into(default_image_view)
crop_image_view.apply {
setOnCropImageCompleteListener(this@EditActivity)
setImageUriAsync(uri)
guidelines = CropImageView.Guidelines.ON
if (isCropIntent && shouldCropSquare()) {
currAspectRatio = ASPECT_RATIO_ONE_ONE
setFixedAspectRatio(true)
bottom_aspect_ratio.beGone()
}
}
setupBottomActions() setupBottomActions()
} }
@ -157,6 +145,20 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
return true return true
} }
private fun loadCropImageView() {
crop_image_view.apply {
setOnCropImageCompleteListener(this@EditActivity)
setImageUriAsync(uri)
guidelines = CropImageView.Guidelines.ON
if (isCropIntent && shouldCropSquare()) {
currAspectRatio = ASPECT_RATIO_ONE_ONE
setFixedAspectRatio(true)
bottom_aspect_ratio.beGone()
}
}
}
private fun setupBottomActions() { private fun setupBottomActions() {
setupPrimaryActionButtons() setupPrimaryActionButtons()
setupCropRotateActionButtons() setupCropRotateActionButtons()

View file

@ -6,11 +6,18 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<ImageView
android:id="@+id/default_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_margin"/>
<com.theartofdev.edmodo.cropper.CropImageView <com.theartofdev.edmodo.cropper.CropImageView
android:id="@+id/crop_image_view" android:id="@+id/crop_image_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="@dimen/activity_margin" android:layout_margin="@dimen/activity_margin"
android:visibility="gone"
app:cropBackgroundColor="@color/crop_image_view_background" app:cropBackgroundColor="@color/crop_image_view_background"
app:cropInitialCropWindowPaddingRatio="0"/> app:cropInitialCropWindowPaddingRatio="0"/>