From f19d6ada1f0401ba575640b7ded3cf8893a619b3 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 22 Jan 2018 23:43:42 +0100 Subject: [PATCH] add a broadcast receiver for refreshing media at received broadcast --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 8 ++++++++ .../gallery/receivers/RefreshMediaReceiver.kt | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 app/src/main/kotlin/com/simplemobiletools/gallery/receivers/RefreshMediaReceiver.kt diff --git a/app/build.gradle b/app/build.gradle index 5a1c8d795..4661f6b2a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -43,7 +43,7 @@ ext { } dependencies { - implementation 'com.simplemobiletools:commons:3.8.0' + implementation 'com.simplemobiletools:commons:3.8.1' implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0' implementation 'com.android.support:multidex:1.0.2' implementation 'com.google.code.gson:gson:2.8.2' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c49d7cf4d..8eead3683 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -207,5 +207,13 @@ + + + + + + diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/receivers/RefreshMediaReceiver.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/receivers/RefreshMediaReceiver.kt new file mode 100644 index 000000000..589f98b45 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/receivers/RefreshMediaReceiver.kt @@ -0,0 +1,16 @@ +package com.simplemobiletools.gallery.receivers + +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import com.google.gson.Gson +import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask +import com.simplemobiletools.gallery.extensions.config + +class RefreshMediaReceiver : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent) { + GetDirectoriesAsynctask(context, false, false) { + context.config.directories = Gson().toJson(it) + }.execute() + } +}