From 62d11861ca8f39d7b5c25c771897b493a2dfb408 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 7 Dec 2016 20:17:18 +0100 Subject: [PATCH] update mediastore after deleted files manually --- .../gallery/activities/ViewPagerActivity.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index b0e8ec9e2..390505321 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -1,6 +1,7 @@ package com.simplemobiletools.gallery.activities import android.app.Activity +import android.content.ContentValues import android.content.Intent import android.content.res.Configuration import android.database.Cursor @@ -219,8 +220,17 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } - scanFile(file) { + val values = ContentValues() + values.put(MediaStore.MediaColumns.DATA, file.absolutePath) + val uri = if (file.isImageSlow()) MediaStore.Images.Media.EXTERNAL_CONTENT_URI else MediaStore.Video.Media.EXTERNAL_CONTENT_URI + val updated = contentResolver.delete(uri, "${MediaStore.MediaColumns.DATA} = '${file.absolutePath}'", null) == 1 + + if (updated) { reloadViewPager() + } else { + scanFile(file) { + reloadViewPager() + } } }