Skip to content

Commit

Permalink
workaround list not being updated
Browse files Browse the repository at this point in the history
  • Loading branch information
dic1911 committed Feb 10, 2024
1 parent a4f185f commit 3763189
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/src/main/java/moe/dic1911/autodnd/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import rikka.shizuku.Shizuku.OnRequestPermissionResultListener
class MainActivity : AppCompatActivity() {
private lateinit var notiMan: NotificationManager
private lateinit var fab: FloatingActionButton
private var restartOnResume = false

private val TAG = "030"

Expand Down Expand Up @@ -72,6 +73,14 @@ class MainActivity : AppCompatActivity() {
override fun onResume() {
super.onResume()
Log.d(TAG, "onResume()")

if (restartOnResume) {
val intent = Intent(this, MainActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
startActivity(intent)
finish()
}

// check if necessary permission granted / service enabled
Storage.setupStatus = 0
if (!notiMan.isNotificationPolicyAccessGranted) {
Expand Down Expand Up @@ -138,6 +147,7 @@ class MainActivity : AppCompatActivity() {
startActivity(Intent(Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS))
}
2 -> {
restartOnResume = true
Toast.makeText(applicationContext, R.string.accessbility_svc_tip, Toast.LENGTH_LONG).show()
val settingsIntent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
if (settingsIntent !is Activity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class MainFragment(val index: Int) : Fragment() {
}
Storage.prefs_str.observe(viewLifecycleOwner) {
if (pageViewModel.getIndex() == 0) {
Log.d("030-list", it.size.toString())
(recyclerView.adapter as AppListAdapter?)?.appList = Storage.getAppList(0)!!
(recyclerView.adapter as AppListAdapter?)?.notifyDataSetChanged()
}
Expand Down

0 comments on commit 3763189

Please sign in to comment.