Skip to content

Commit

Permalink
Added loading. Removed unused method.
Browse files Browse the repository at this point in the history
  • Loading branch information
waqas committed Apr 22, 2022
1 parent 4e4fdb5 commit a018d47
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ import android.view.View
import android.view.Window
import android.view.WindowManager
import android.view.animation.AnticipateOvershootInterpolator
import android.widget.Button
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import android.widget.*
import androidx.annotation.NonNull
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AlertDialog
Expand Down Expand Up @@ -84,6 +81,7 @@ open class PhotoEditorActivity : AppCompatActivity(), OnPhotoEditorListener, Vie
private var imgPath: String? = ""
private var cropFragment: UCropFragment? = null
private var mIsCropVisible = false
private var isShowCropLoading = false
private var mIsCropSetup = false

@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
Expand Down Expand Up @@ -168,6 +166,7 @@ open class PhotoEditorActivity : AppCompatActivity(), OnPhotoEditorListener, Vie
// .placeholder(drawable)
.into(mPhotoEditorView!!.source)

isShowCropLoading = false
val uCrop: UCrop? = UCrop.of(Uri.fromFile(File(imgPath!!)), Uri.fromFile(File(getTmpDir(), "TempCropImage.jpg")))
cropFragment = uCrop?.getFragment(uCrop.getIntent(this).extras)
supportFragmentManager.beginTransaction()
Expand Down Expand Up @@ -274,7 +273,8 @@ open class PhotoEditorActivity : AppCompatActivity(), OnPhotoEditorListener, Vie
}
R.id.btnSave -> {
if (mIsCropVisible) {
cropFragment?.cropAndSaveImage();
isShowCropLoading = true
cropFragment?.cropAndSaveImage()
} else {
saveImage()
}
Expand Down Expand Up @@ -448,14 +448,19 @@ open class PhotoEditorActivity : AppCompatActivity(), OnPhotoEditorListener, Vie
val cropError = UCrop.getError(result)
if (cropError != null) {
Log.e(TAG, "handleCropError: ", cropError)
// Toast.makeText(this@SampleActivity, cropError.message, Toast.LENGTH_LONG).show()
} else {
// Toast.makeText(this@SampleActivity, R.string.toast_unexpected_error, Toast.LENGTH_SHORT).show()
}
hideCropFragment()
Toast.makeText(this, "Unable to crop image. Something went wrong.", Toast.LENGTH_SHORT).show()
}

override fun loadingProgress(showLoader: Boolean) {
Log.d(TAG, "Loading triggered.")
if (isShowCropLoading && showLoader) {
Log.d(TAG, "Loading triggered.")
showLoading("Cropping...")
} else if(isShowCropLoading) {
isShowCropLoading = false
hideLoading()
}
}

override fun onCropFinish(result: UCropResult) {
Expand All @@ -478,11 +483,6 @@ open class PhotoEditorActivity : AppCompatActivity(), OnPhotoEditorListener, Vie
fragment.show(supportFragmentManager, fragment.tag)
}

fun hideAll(showLoader: Boolean) {
mPhotoEditorView!!.visibility = View.GONE
mRvTools!!.visibility = View.GONE
}

fun showFilter(isVisible: Boolean) {
mIsFilterVisible = isVisible
mConstraintSet.clone(mRootView)
Expand Down

0 comments on commit a018d47

Please sign in to comment.