restore proper file paths
This commit is contained in:
parent
dc7de93cf7
commit
84ebb59482
2 changed files with 49 additions and 49 deletions
|
@ -307,10 +307,12 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fixDateTaken() {
|
private fun fixDateTaken() {
|
||||||
|
Thread {
|
||||||
activity.fixDateTaken(getSelectedPaths()) {
|
activity.fixDateTaken(getSelectedPaths()) {
|
||||||
listener?.refreshItems()
|
listener?.refreshItems()
|
||||||
finishActMode()
|
finishActMode()
|
||||||
}
|
}
|
||||||
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkDeleteConfirmation() {
|
private fun checkDeleteConfirmation() {
|
||||||
|
|
|
@ -6,7 +6,6 @@ import android.content.Intent
|
||||||
import android.media.ExifInterface
|
import android.media.ExifInterface
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
import android.util.Log
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
|
@ -237,6 +236,7 @@ fun BaseSimpleActivity.restoreRecycleBinPath(path: String, callback: () -> Unit)
|
||||||
|
|
||||||
fun BaseSimpleActivity.restoreRecycleBinPaths(paths: ArrayList<String>, mediumDao: MediumDao = galleryDB.MediumDao(), callback: () -> Unit) {
|
fun BaseSimpleActivity.restoreRecycleBinPaths(paths: ArrayList<String>, mediumDao: MediumDao = galleryDB.MediumDao(), callback: () -> Unit) {
|
||||||
Thread {
|
Thread {
|
||||||
|
val newPaths = ArrayList<String>()
|
||||||
paths.forEach {
|
paths.forEach {
|
||||||
val source = it
|
val source = it
|
||||||
val destination = it.removePrefix(recycleBinPath)
|
val destination = it.removePrefix(recycleBinPath)
|
||||||
|
@ -250,6 +250,7 @@ fun BaseSimpleActivity.restoreRecycleBinPaths(paths: ArrayList<String>, mediumDa
|
||||||
if (File(source).length() == File(destination).length()) {
|
if (File(source).length() == File(destination).length()) {
|
||||||
mediumDao.updateDeleted(destination.removePrefix(recycleBinPath), 0, "$RECYCLE_BIN$destination")
|
mediumDao.updateDeleted(destination.removePrefix(recycleBinPath), 0, "$RECYCLE_BIN$destination")
|
||||||
}
|
}
|
||||||
|
newPaths.add(destination)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -262,7 +263,7 @@ fun BaseSimpleActivity.restoreRecycleBinPaths(paths: ArrayList<String>, mediumDa
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
|
|
||||||
fixDateTaken(paths)
|
fixDateTaken(newPaths)
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,7 +316,6 @@ fun Activity.hasNavBar(): Boolean {
|
||||||
fun Activity.fixDateTaken(paths: ArrayList<String>, callback: (() -> Unit)? = null) {
|
fun Activity.fixDateTaken(paths: ArrayList<String>, callback: (() -> Unit)? = null) {
|
||||||
val BATCH_SIZE = 50
|
val BATCH_SIZE = 50
|
||||||
toast(R.string.fixing)
|
toast(R.string.fixing)
|
||||||
Thread {
|
|
||||||
try {
|
try {
|
||||||
var didUpdateFile = false
|
var didUpdateFile = false
|
||||||
val operations = ArrayList<ContentProviderOperation>()
|
val operations = ArrayList<ContentProviderOperation>()
|
||||||
|
@ -346,7 +346,6 @@ fun Activity.fixDateTaken(paths: ArrayList<String>, callback: (() -> Unit)? = nu
|
||||||
operations.clear()
|
operations.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.e("DEBUG", "restoring $path")
|
|
||||||
mediumDao.updateFavoriteDateTaken(path, timestamp)
|
mediumDao.updateFavoriteDateTaken(path, timestamp)
|
||||||
didUpdateFile = true
|
didUpdateFile = true
|
||||||
}
|
}
|
||||||
|
@ -364,5 +363,4 @@ fun Activity.fixDateTaken(paths: ArrayList<String>, callback: (() -> Unit)? = nu
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
}
|
}
|
||||||
}.start()
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue