Skip to content

Commit 27e0e93

Browse files
auto refresh repos on api key reset
Signed-off-by: androidacy-user <opensource@androidacy.com>
1 parent b5d2d96 commit 27e0e93

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

app/src/main/kotlin/com/fox2code/mmm/MainActivity.kt

+7
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class MainActivity : AppCompatActivity(), OnRefreshListener, OverScrollHelper {
117117
}
118118
onMainActivityCreate(this)
119119
super.onCreate(savedInstanceState)
120+
INSTANCE = this
120121
TrackHelper.track().screen(this).with(MainApplication.INSTANCE!!.tracker)
121122
// hide this behind a buildconfig flag for now, but crash the app if it's not an official build and not debug
122123
if (BuildConfig.ENABLE_PROTECTION && !MainApplication.o && !BuildConfig.DEBUG) {
@@ -814,6 +815,11 @@ class MainActivity : AppCompatActivity(), OnRefreshListener, OverScrollHelper {
814815
return super.dispatchTouchEvent(event)
815816
}
816817

818+
override fun onDestroy() {
819+
super.onDestroy()
820+
INSTANCE = null
821+
}
822+
817823
companion object {
818824
fun getAppCompatActivity(activity: AppCompatActivity): AppCompatActivity {
819825
return activity
@@ -831,5 +837,6 @@ class MainActivity : AppCompatActivity(), OnRefreshListener, OverScrollHelper {
831837
var localModuleInfoList: List<LocalModuleInfo> = ArrayList()
832838
var onlineModuleInfoList: List<RepoModule> = ArrayList()
833839
var isShowingWeblateSb = false // race condition
840+
var INSTANCE: MainActivity? = null
834841
}
835842
}

app/src/main/kotlin/com/fox2code/mmm/repo/RepoManager.kt

+4
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,10 @@ class RepoManager private constructor(mainApplication: MainApplication) : SyncMa
266266
R.string.api_key_removed,
267267
Toast.LENGTH_SHORT
268268
).show()
269+
// refresh by faking user pull down
270+
if (MainActivity.INSTANCE != null) {
271+
MainActivity.INSTANCE!!.onRefresh()
272+
}
269273
}
270274
}
271275
builder.show()

0 commit comments

Comments
 (0)