try prefetching directories after install, before first app launch

This commit is contained in:
tibbi 2017-04-25 23:23:36 +02:00
parent 1f64427ef7
commit a05ecbe861
3 changed files with 27 additions and 0 deletions

View file

@ -174,5 +174,13 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
<receiver
android:name=".receivers.InstallReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER"/>
</intent-filter>
</receiver>
</application>
</manifest>

View file

@ -20,6 +20,9 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
var shouldStop = false
override fun doInBackground(vararg params: Void): ArrayList<Directory> {
if (!context.hasWriteStoragePermission())
return ArrayList()
val media = ArrayList<Medium>()
val showMedia = config.showMedia
val fileSorting = config.fileSorting

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 InstallReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
GetDirectoriesAsynctask(context, false, false) {
context.config.directories = Gson().toJson(it)
}.execute()
}
}