Set intent data into fragments before starting them
This ensures that fragments have all data needed before doing initial data loading. This will ensure that Recents tab properly filters files by mime type immediately, instead of only after doing a pull to refresh.
This commit is contained in:
parent
afdc8c97a8
commit
580cd1f75a
2 changed files with 18 additions and 18 deletions
|
@ -373,24 +373,6 @@ class MainActivity : SimpleActivity() {
|
|||
openPath(config.homeFolder)
|
||||
}
|
||||
|
||||
val isPickRingtoneIntent = intent.action == RingtoneManager.ACTION_RINGTONE_PICKER
|
||||
val isGetContentIntent = intent.action == Intent.ACTION_GET_CONTENT || intent.action == Intent.ACTION_PICK
|
||||
val isCreateDocumentIntent = intent.action == Intent.ACTION_CREATE_DOCUMENT
|
||||
val allowPickingMultipleIntent = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false)
|
||||
val getContentMimeType = if (isGetContentIntent) {
|
||||
intent.type ?: ""
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
getAllFragments().forEach {
|
||||
it?.isGetRingtonePicker = isPickRingtoneIntent
|
||||
it?.isPickMultipleIntent = allowPickingMultipleIntent
|
||||
it?.isGetContentIntent = isGetContentIntent
|
||||
it?.wantedMimeType = getContentMimeType
|
||||
it?.updateIsCreateDocumentIntent(isCreateDocumentIntent)
|
||||
}
|
||||
|
||||
if (refreshRecents) {
|
||||
recents_fragment?.refreshFragment()
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.simplemobiletools.filemanager.pro.adapters
|
||||
|
||||
import android.content.Intent
|
||||
import android.media.RingtoneManager
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.viewpager.widget.PagerAdapter
|
||||
|
@ -19,6 +21,22 @@ class ViewPagerAdapter(val activity: SimpleActivity, val tabsToShow: ArrayList<I
|
|||
container.addView(view)
|
||||
|
||||
(view as MyViewPagerFragment).apply {
|
||||
val isPickRingtoneIntent = activity.intent.action == RingtoneManager.ACTION_RINGTONE_PICKER
|
||||
val isGetContentIntent = activity.intent.action == Intent.ACTION_GET_CONTENT || activity.intent.action == Intent.ACTION_PICK
|
||||
val isCreateDocumentIntent = activity.intent.action == Intent.ACTION_CREATE_DOCUMENT
|
||||
val allowPickingMultipleIntent = activity.intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false)
|
||||
val getContentMimeType = if (isGetContentIntent) {
|
||||
activity.intent.type ?: ""
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
this.isGetRingtonePicker = isPickRingtoneIntent
|
||||
this.isPickMultipleIntent = allowPickingMultipleIntent
|
||||
this.isGetContentIntent = isGetContentIntent
|
||||
this.wantedMimeType = getContentMimeType
|
||||
this.updateIsCreateDocumentIntent(isCreateDocumentIntent)
|
||||
|
||||
setupFragment(activity)
|
||||
onResume(activity.getProperTextColor())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue