refresh thumbnail items after rotating

This commit is contained in:
tibbi 2019-01-13 22:21:17 +01:00
parent 040d6357c9
commit c0e4176779
3 changed files with 11 additions and 3 deletions

View File

@ -587,8 +587,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
val currPath = getCurrentPath()
SaveAsDialog(this, currPath, false) {
handleSAFDialog(it) {
toast(R.string.saving)
Thread {
saveRotatedImageToFile(currPath, it, mRotationDegrees) {
toast(R.string.file_saved)
mRotationDegrees = 0
invalidateOptionsMenu()
}

View File

@ -277,11 +277,19 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
}
private fun rotateSelection(degrees: Int) {
activity.toast(R.string.saving)
Thread {
val paths = getSelectedPaths()
var fileCnt = paths.size
paths.forEach {
activity.saveRotatedImageToFile(it, it, degrees) {
fileCnt--
if (fileCnt == 0) {
activity.runOnUiThread {
listener?.refreshItems()
finishActMode()
}
}
}
}
}.start()

View File

@ -374,7 +374,6 @@ fun Activity.fixDateTaken(paths: ArrayList<String>, callback: (() -> Unit)? = nu
}
fun BaseSimpleActivity.saveRotatedImageToFile(oldPath: String, newPath: String, degrees: Int, callback: () -> Unit) {
toast(R.string.saving)
if (oldPath == newPath && oldPath.isJpg()) {
if (tryRotateByExif(oldPath, degrees, callback)) {
return
@ -406,7 +405,6 @@ fun BaseSimpleActivity.saveRotatedImageToFile(oldPath: String, newPath: String,
copyFile(tmpPath, newPath)
scanPathRecursively(newPath)
toast(R.string.file_saved)
fileRotatedSuccessfully(newPath, oldLastModified)
it.flush()