Skip to content

Commit 55d0f23

Browse files
committed
fix: simplify app list refresh logic with single refreshAppList function
1 parent ae0c983 commit 55d0f23

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

app/src/main/java/com/appcontrolx/ui/AppListFragment.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ class AppListFragment : Fragment() {
198198
private fun setupSwipeRefresh() {
199199
val b = binding ?: return
200200
b.swipeRefresh.setOnRefreshListener {
201-
clearCache() // Clear cache first to ensure fresh data
202-
loadApps(forceRefresh = true)
201+
refreshAppList()
203202
}
204203
b.swipeRefresh.setColorSchemeResources(
205204
R.color.primary,
@@ -211,8 +210,7 @@ class AppListFragment : Fragment() {
211210
private fun showAppDetail(app: AppInfo) {
212211
val bottomSheet = AppDetailBottomSheet.newInstance(app)
213212
bottomSheet.onActionCompleted = {
214-
clearCache()
215-
loadApps()
213+
refreshAppList()
216214
}
217215
bottomSheet.show(childFragmentManager, AppDetailBottomSheet.TAG)
218216
}
@@ -429,7 +427,7 @@ class AppListFragment : Fragment() {
429427
}
430428
},
431429
onComplete = { successCount, failCount ->
432-
// Log action - always log regardless of action type
430+
// Log action
433431
rm?.let { manager ->
434432
lifecycleScope.launch(Dispatchers.IO) {
435433
manager.logAction(ActionLog(
@@ -441,9 +439,8 @@ class AppListFragment : Fragment() {
441439
}
442440
}
443441

444-
adapter.deselectAll()
445-
clearCache()
446-
loadApps(forceRefresh = true)
442+
// Refresh list immediately
443+
refreshAppList()
447444
}
448445
)
449446

@@ -485,6 +482,13 @@ class AppListFragment : Fragment() {
485482
cachedUserApps = null
486483
cachedSystemApps = null
487484
}
485+
486+
// Single refresh function - call this after any action
487+
fun refreshAppList() {
488+
adapter.deselectAll()
489+
clearCache()
490+
loadApps(forceRefresh = true)
491+
}
488492

489493
private fun loadApps(forceRefresh: Boolean = false) {
490494
val b = binding ?: return

0 commit comments

Comments
 (0)