From 27e0e93a690fec773aa296288243e46b345a43b7 Mon Sep 17 00:00:00 2001 From: androidacy-user Date: Mon, 11 Sep 2023 18:52:16 -0400 Subject: [PATCH] auto refresh repos on api key reset Signed-off-by: androidacy-user --- app/src/main/kotlin/com/fox2code/mmm/MainActivity.kt | 7 +++++++ app/src/main/kotlin/com/fox2code/mmm/repo/RepoManager.kt | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/app/src/main/kotlin/com/fox2code/mmm/MainActivity.kt b/app/src/main/kotlin/com/fox2code/mmm/MainActivity.kt index 55fdddd5..458d3c3f 100644 --- a/app/src/main/kotlin/com/fox2code/mmm/MainActivity.kt +++ b/app/src/main/kotlin/com/fox2code/mmm/MainActivity.kt @@ -117,6 +117,7 @@ class MainActivity : AppCompatActivity(), OnRefreshListener, OverScrollHelper { } onMainActivityCreate(this) super.onCreate(savedInstanceState) + INSTANCE = this TrackHelper.track().screen(this).with(MainApplication.INSTANCE!!.tracker) // hide this behind a buildconfig flag for now, but crash the app if it's not an official build and not debug if (BuildConfig.ENABLE_PROTECTION && !MainApplication.o && !BuildConfig.DEBUG) { @@ -814,6 +815,11 @@ class MainActivity : AppCompatActivity(), OnRefreshListener, OverScrollHelper { return super.dispatchTouchEvent(event) } + override fun onDestroy() { + super.onDestroy() + INSTANCE = null + } + companion object { fun getAppCompatActivity(activity: AppCompatActivity): AppCompatActivity { return activity @@ -831,5 +837,6 @@ class MainActivity : AppCompatActivity(), OnRefreshListener, OverScrollHelper { var localModuleInfoList: List = ArrayList() var onlineModuleInfoList: List = ArrayList() var isShowingWeblateSb = false // race condition + var INSTANCE: MainActivity? = null } } \ No newline at end of file diff --git a/app/src/main/kotlin/com/fox2code/mmm/repo/RepoManager.kt b/app/src/main/kotlin/com/fox2code/mmm/repo/RepoManager.kt index 8a06a39b..0382a0ca 100644 --- a/app/src/main/kotlin/com/fox2code/mmm/repo/RepoManager.kt +++ b/app/src/main/kotlin/com/fox2code/mmm/repo/RepoManager.kt @@ -266,6 +266,10 @@ class RepoManager private constructor(mainApplication: MainApplication) : SyncMa R.string.api_key_removed, Toast.LENGTH_SHORT ).show() + // refresh by faking user pull down + if (MainActivity.INSTANCE != null) { + MainActivity.INSTANCE!!.onRefresh() + } } } builder.show()