Browse Source

1.将清理缓存和一键加速放到协程执行

20241218TB223FC(测试jar包)
wangwanlei 8 months ago
parent
commit
1ffbcbd302

+ 8
- 4
app/src/main/java/com/xhly/manageapp/AppAdapter.kt View File

@@ -43,11 +43,13 @@ class AppAdapter(var context: Context, var data: ArrayList<AppInfo>) :
43 43
         holder.mBinding.itemCv.setText(appInfo.name)
44 44
         holder.mBinding.itemCv.setOnClickListener {
45 45
             if (appInfo.packageName.equals(Const.CUSTOMSPEEDAPP)){
46
-                StrategyUtils.clearMemory(context,data)
47
-                Toaster.show(context.getString(R.string.speedend))
46
+                changePwdListener?.let {
47
+                    it.clearMemory(context,data)
48
+                }
48 49
             }else if (appInfo.packageName.equals(Const.CUSTOMCLEARAPP)){
49
-                StrategyUtils.clearAppData(context)
50
-                Toaster.show(context.getString(R.string.clearend))
50
+                changePwdListener?.let {
51
+                    it.clearAppData(context)
52
+                }
51 53
             }else if (appInfo.packageName.equals(Const.CUSTOMROTATIONAPP)){
52 54
                 val rotationAllowed = SystemUtil.isRotationAllowed(context)
53 55
                 ManageApplication.disallowSetAutoRotation(!rotationAllowed)
@@ -138,5 +140,7 @@ class AppAdapter(var context: Context, var data: ArrayList<AppInfo>) :
138 140
     }
139 141
    interface ChangePwdListener{
140 142
        fun changeCode()
143
+       fun clearMemory(context: Context,data: List<AppInfo>)
144
+       fun clearAppData(context: Context)
141 145
    }
142 146
 }

+ 20
- 0
app/src/main/java/com/xhly/manageapp/ui/main/activity/MainActivity.kt View File

@@ -667,6 +667,26 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
667 667
                 }
668 668
             }
669 669
 
670
+            override fun clearMemory(context: Context, data: List<AppInfo>) {
671
+                lifecycleScope.launch(Dispatchers.IO){
672
+                    delay(500)
673
+                    withContext(Dispatchers.Main){
674
+                        StrategyUtils.clearMemory(context,data)
675
+                        Toaster.show(context.getString(R.string.speedend))
676
+                    }
677
+                }
678
+            }
679
+
680
+            override fun clearAppData(context: Context) {
681
+                lifecycleScope.launch(Dispatchers.IO){
682
+                    delay(500)
683
+                    withContext(Dispatchers.Main){
684
+                        StrategyUtils.clearAppData(context)
685
+                        Toaster.show(context.getString(R.string.clearend))
686
+                    }
687
+                }
688
+            }
689
+
670 690
         }
671 691
     }
672 692
 

Loading…
Cancel
Save