@@ -346,7 +346,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
346346 NotificationType .NO_INTERNET .autoAdd(moduleViewListBuilderOnline)
347347 val progressIndicator = progressIndicator!!
348348 // hide progress bar is repo-manager says we have no internet
349- if (! RepoManager .getINSTANCE().hasConnectivity()) {
349+ if (! RepoManager .getINSTANCE()!! .hasConnectivity()) {
350350 Timber .i(" No connection, hiding progress" )
351351 runOnUiThread {
352352 progressIndicator.visibility = View .GONE
@@ -377,9 +377,9 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
377377 Timber .i(" Scanning for modules!" )
378378 if (BuildConfig .DEBUG ) Timber .i(" Initialize Update" )
379379 val max = instance!! .getUpdatableModuleCount()
380- if (RepoManager .getINSTANCE().customRepoManager != null && RepoManager .getINSTANCE().customRepoManager.needUpdate()) {
380+ if (RepoManager .getINSTANCE()!! .customRepoManager != null && RepoManager .getINSTANCE()!! .customRepoManager!! .needUpdate()) {
381381 Timber .w(" Need update on create" )
382- } else if (RepoManager .getINSTANCE().customRepoManager == null ) {
382+ } else if (RepoManager .getINSTANCE()!! .customRepoManager == null ) {
383383 Timber .w(" CustomRepoManager is null" )
384384 }
385385 // update compat metadata
@@ -388,7 +388,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
388388 if (BuildConfig .DEBUG ) Timber .i(" Check Update" )
389389 // update repos
390390 if (hasWebView()) {
391- RepoManager .getINSTANCE().update { value: Double ->
391+ RepoManager .getINSTANCE()!! .update { value: Double ->
392392 runOnUiThread(if (max == 0 ) Runnable {
393393 progressIndicator.setProgressCompat(
394394 (value * PRECISION ).toInt(), true
@@ -452,7 +452,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
452452 }
453453 if (BuildConfig .DEBUG ) Timber .i(" Apply" )
454454 RepoManager .getINSTANCE()
455- .runAfterUpdate { moduleViewListBuilderOnline.appendRemoteModules() }
455+ ? .runAfterUpdate { moduleViewListBuilderOnline.appendRemoteModules() }
456456 moduleViewListBuilder.applyTo(moduleList, moduleViewAdapter!! )
457457 moduleViewListBuilder.applyTo(moduleListOnline, moduleViewAdapterOnline!! )
458458 moduleViewListBuilderOnline.applyTo(moduleListOnline, moduleViewAdapterOnline!! )
@@ -599,14 +599,14 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
599599 if (appUpdateManager.checkUpdate(false )) moduleViewListBuilder.addNotification(
600600 NotificationType .UPDATE_AVAILABLE
601601 )
602- RepoManager .getINSTANCE().updateEnabledStates()
603- if (RepoManager .getINSTANCE().customRepoManager.needUpdate()) {
602+ RepoManager .getINSTANCE()!! .updateEnabledStates()
603+ if (RepoManager .getINSTANCE()!! .customRepoManager!! .needUpdate()) {
604604 runOnUiThread {
605605 progressIndicator!! .isIndeterminate = false
606606 progressIndicator!! .max = PRECISION
607607 }
608608 if (BuildConfig .DEBUG ) Timber .i(" Check Update" )
609- RepoManager .getINSTANCE().update { value: Double ->
609+ RepoManager .getINSTANCE()!! .update { value: Double ->
610610 runOnUiThread {
611611 progressIndicator!! .setProgressCompat(
612612 (value * PRECISION ).toInt(), true
@@ -620,7 +620,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
620620 }
621621 if (BuildConfig .DEBUG ) Timber .i(" Apply" )
622622 RepoManager .getINSTANCE()
623- .runAfterUpdate { moduleViewListBuilderOnline.appendRemoteModules() }
623+ ? .runAfterUpdate { moduleViewListBuilderOnline.appendRemoteModules() }
624624 Timber .i(" Common Before applyTo" )
625625 moduleViewListBuilder.applyTo(moduleList!! , moduleViewAdapter!! )
626626 moduleViewListBuilderOnline.applyTo(moduleListOnline!! , moduleViewAdapterOnline!! )
@@ -647,7 +647,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
647647 Thread ({
648648 cleanDnsCache() // Allow DNS reload from network
649649 val max = instance!! .getUpdatableModuleCount()
650- RepoManager .getINSTANCE().update { value: Double ->
650+ RepoManager .getINSTANCE()!! .update { value: Double ->
651651 runOnUiThread(if (max == 0 ) Runnable {
652652 progressIndicator!! .setProgressCompat(
653653 (value * PRECISION ).toInt(), true
@@ -699,11 +699,11 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
699699 swipeRefreshLayout!! .isRefreshing = false
700700 }
701701 NotificationType .NEED_CAPTCHA_ANDROIDACY .autoAdd(moduleViewListBuilder)
702- RepoManager .getINSTANCE().updateEnabledStates()
702+ RepoManager .getINSTANCE()!! .updateEnabledStates()
703703 RepoManager .getINSTANCE()
704- .runAfterUpdate { moduleViewListBuilder.appendInstalledModules() }
704+ ? .runAfterUpdate { moduleViewListBuilder.appendInstalledModules() }
705705 RepoManager .getINSTANCE()
706- .runAfterUpdate { moduleViewListBuilderOnline.appendRemoteModules() }
706+ ? .runAfterUpdate { moduleViewListBuilderOnline.appendRemoteModules() }
707707 moduleViewListBuilder.applyTo(moduleList!! , moduleViewAdapter!! )
708708 moduleViewListBuilderOnline.applyTo(moduleListOnline!! , moduleViewAdapterOnline!! )
709709 }, " Repo update thread" ).start()
@@ -784,21 +784,13 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
784784 }
785785
786786 fun maybeShowUpgrade () {
787- if (AndroidacyRepoData .getInstance() == null || AndroidacyRepoData .getInstance() .memberLevel == null ) {
787+ if (AndroidacyRepoData .instance .memberLevel == null ) {
788788 // wait for up to 10 seconds for AndroidacyRepoData to be initialized
789- var i = 0
790- while (AndroidacyRepoData .getInstance() == null && i < 10 ) {
791- try {
792- Thread .sleep(1000 )
793- } catch (e: InterruptedException ) {
794- Timber .e(e)
795- }
796- i++
797- }
798- if (AndroidacyRepoData .getInstance().isEnabled && AndroidacyRepoData .getInstance().memberLevel == null ) {
789+ var i: Int
790+ if (AndroidacyRepoData .instance.isEnabled && AndroidacyRepoData .instance.memberLevel == null ) {
799791 Timber .d(" Member level is null, waiting for it to be initialized" )
800792 i = 0
801- while (AndroidacyRepoData .getInstance() .memberLevel == null && i < 20 ) {
793+ while (AndroidacyRepoData .instance .memberLevel == null && i < 20 ) {
802794 i++
803795 try {
804796 Thread .sleep(500 )
@@ -808,32 +800,32 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
808800 }
809801 }
810802 // if it's still null, but it's enabled, throw an error
811- if (AndroidacyRepoData .getInstance() .isEnabled && AndroidacyRepoData .getInstance() .memberLevel == null ) {
803+ if (AndroidacyRepoData .instance .isEnabled && AndroidacyRepoData .instance .memberLevel == null ) {
812804 Timber .e(" AndroidacyRepoData is enabled, but member level is null" )
813805 }
814- if (AndroidacyRepoData .getInstance() != null && AndroidacyRepoData .getInstance(). isEnabled && AndroidacyRepoData .getInstance() .memberLevel == " Guest" ) {
806+ if (AndroidacyRepoData .instance. isEnabled && AndroidacyRepoData .instance .memberLevel == " Guest" ) {
815807 runtimeUtils!! .showUpgradeSnackbar(this , this )
816808 } else {
817- if (! AndroidacyRepoData .getInstance() .isEnabled) {
809+ if (! AndroidacyRepoData .instance .isEnabled) {
818810 Timber .i(" AndroidacyRepoData is disabled, not showing upgrade snackbar 1" )
819- } else if (AndroidacyRepoData .getInstance() .memberLevel != " Guest" ) {
811+ } else if (AndroidacyRepoData .instance .memberLevel != " Guest" ) {
820812 Timber .i(
821813 " AndroidacyRepoData is not Guest, not showing upgrade snackbar 1. Level: %s" ,
822- AndroidacyRepoData .getInstance() .memberLevel
814+ AndroidacyRepoData .instance .memberLevel
823815 )
824816 } else {
825817 Timber .i(" Unknown error, not showing upgrade snackbar 1" )
826818 }
827819 }
828- } else if (AndroidacyRepoData .getInstance() .isEnabled && AndroidacyRepoData .getInstance() .memberLevel == " Guest" ) {
820+ } else if (AndroidacyRepoData .instance .isEnabled && AndroidacyRepoData .instance .memberLevel == " Guest" ) {
829821 runtimeUtils!! .showUpgradeSnackbar(this , this )
830822 } else {
831- if (! AndroidacyRepoData .getInstance() .isEnabled) {
823+ if (! AndroidacyRepoData .instance .isEnabled) {
832824 Timber .i(" AndroidacyRepoData is disabled, not showing upgrade snackbar 2" )
833- } else if (AndroidacyRepoData .getInstance() .memberLevel != " Guest" ) {
825+ } else if (AndroidacyRepoData .instance .memberLevel != " Guest" ) {
834826 Timber .i(
835827 " AndroidacyRepoData is not Guest, not showing upgrade snackbar 2. Level: %s" ,
836- AndroidacyRepoData .getInstance() .memberLevel
828+ AndroidacyRepoData .instance .memberLevel
837829 )
838830 } else {
839831 Timber .i(" Unknown error, not showing upgrade snackbar 2" )
0 commit comments