add a broadcast receiver for refreshing media at received broadcast

This commit is contained in:
tibbi 2018-01-22 23:43:42 +01:00
parent c15b7310e9
commit f19d6ada1f
3 changed files with 25 additions and 1 deletions

View File

@ -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'

View File

@ -207,5 +207,13 @@
<action android:name="com.android.vending.INSTALL_REFERRER"/>
</intent-filter>
</receiver>
<receiver
android:name=".receivers.RefreshMediaReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.simplemobiletools.REFRESH_MEDIA"/>
</intent-filter>
</receiver>
</application>
</manifest>

View File

@ -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()
}
}