Skip to content

Commit 580cd1f

Browse files
committed
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.
1 parent afdc8c9 commit 580cd1f

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -373,24 +373,6 @@ class MainActivity : SimpleActivity() {
373373
openPath(config.homeFolder)
374374
}
375375

376-
val isPickRingtoneIntent = intent.action == RingtoneManager.ACTION_RINGTONE_PICKER
377-
val isGetContentIntent = intent.action == Intent.ACTION_GET_CONTENT || intent.action == Intent.ACTION_PICK
378-
val isCreateDocumentIntent = intent.action == Intent.ACTION_CREATE_DOCUMENT
379-
val allowPickingMultipleIntent = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false)
380-
val getContentMimeType = if (isGetContentIntent) {
381-
intent.type ?: ""
382-
} else {
383-
""
384-
}
385-
386-
getAllFragments().forEach {
387-
it?.isGetRingtonePicker = isPickRingtoneIntent
388-
it?.isPickMultipleIntent = allowPickingMultipleIntent
389-
it?.isGetContentIntent = isGetContentIntent
390-
it?.wantedMimeType = getContentMimeType
391-
it?.updateIsCreateDocumentIntent(isCreateDocumentIntent)
392-
}
393-
394376
if (refreshRecents) {
395377
recents_fragment?.refreshFragment()
396378
}

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/adapters/ViewPagerAdapter.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.simplemobiletools.filemanager.pro.adapters
22

3+
import android.content.Intent
4+
import android.media.RingtoneManager
35
import android.view.View
46
import android.view.ViewGroup
57
import androidx.viewpager.widget.PagerAdapter
@@ -19,6 +21,22 @@ class ViewPagerAdapter(val activity: SimpleActivity, val tabsToShow: ArrayList<I
1921
container.addView(view)
2022

2123
(view as MyViewPagerFragment).apply {
24+
val isPickRingtoneIntent = activity.intent.action == RingtoneManager.ACTION_RINGTONE_PICKER
25+
val isGetContentIntent = activity.intent.action == Intent.ACTION_GET_CONTENT || activity.intent.action == Intent.ACTION_PICK
26+
val isCreateDocumentIntent = activity.intent.action == Intent.ACTION_CREATE_DOCUMENT
27+
val allowPickingMultipleIntent = activity.intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false)
28+
val getContentMimeType = if (isGetContentIntent) {
29+
activity.intent.type ?: ""
30+
} else {
31+
""
32+
}
33+
34+
this.isGetRingtonePicker = isPickRingtoneIntent
35+
this.isPickMultipleIntent = allowPickingMultipleIntent
36+
this.isGetContentIntent = isGetContentIntent
37+
this.wantedMimeType = getContentMimeType
38+
this.updateIsCreateDocumentIntent(isCreateDocumentIntent)
39+
2240
setupFragment(activity)
2341
onResume(activity.getProperTextColor())
2442
}

0 commit comments

Comments
 (0)