|
18 | 18 |
|
19 | 19 | import com.fox2code.mmm.compat.CompatActivity; |
20 | 20 | import com.fox2code.mmm.installer.InstallerInitializer; |
| 21 | +import com.fox2code.mmm.manager.LocalModuleInfo; |
21 | 22 | import com.fox2code.mmm.manager.ModuleManager; |
22 | 23 | import com.fox2code.mmm.repo.RepoManager; |
23 | 24 | import com.fox2code.mmm.settings.SettingsActivity; |
@@ -115,16 +116,42 @@ public void commonNext() { |
115 | 116 | progressIndicator.setMax(PRECISION); |
116 | 117 | }); |
117 | 118 | Log.i(TAG, "Scanning for modules!"); |
118 | | - RepoManager.getINSTANCE().update(value -> runOnUiThread(() -> |
119 | | - progressIndicator.setProgressCompat((int) (value * PRECISION), true))); |
| 119 | + final int max = ModuleManager.getINSTANCE().getUpdatableModuleCount(); |
| 120 | + RepoManager.getINSTANCE().update(value -> runOnUiThread(max == 0 ? () -> |
| 121 | + progressIndicator.setProgressCompat( |
| 122 | + (int) (value * PRECISION), true) :() -> |
| 123 | + progressIndicator.setProgressCompat( |
| 124 | + (int) (value * PRECISION * 0.75F), true))); |
| 125 | + if (!RepoManager.getINSTANCE().hasConnectivity()) { |
| 126 | + moduleViewListBuilder.addNotification(NotificationType.NO_INTERNET); |
| 127 | + } else { |
| 128 | + if (AppUpdateManager.getAppUpdateManager().checkUpdate(true)) |
| 129 | + moduleViewListBuilder.addNotification(NotificationType.UPDATE_AVAILABLE); |
| 130 | + if (max != 0) { |
| 131 | + int current = 0; |
| 132 | + for (LocalModuleInfo localModuleInfo : |
| 133 | + ModuleManager.getINSTANCE().getModules().values()) { |
| 134 | + if (localModuleInfo.updateJson != null) { |
| 135 | + try { |
| 136 | + localModuleInfo.checkModuleUpdate(); |
| 137 | + } catch (Exception e) { |
| 138 | + Log.e("MainActivity", "Failed to fetch update of: " |
| 139 | + + localModuleInfo.id, e); |
| 140 | + } |
| 141 | + current++; |
| 142 | + final int currentTmp = current; |
| 143 | + runOnUiThread(() -> progressIndicator.setProgressCompat( |
| 144 | + (int) ((1F * currentTmp / max) * PRECISION * 0.25F |
| 145 | + + (PRECISION * 0.75F)), true)); |
| 146 | + } |
| 147 | + } |
| 148 | + } |
| 149 | + } |
120 | 150 | runOnUiThread(() -> { |
| 151 | + progressIndicator.setProgressCompat(PRECISION, true); |
121 | 152 | progressIndicator.setVisibility(View.GONE); |
122 | 153 | searchView.setEnabled(true); |
123 | 154 | }); |
124 | | - if (!RepoManager.getINSTANCE().hasConnectivity()) |
125 | | - moduleViewListBuilder.addNotification(NotificationType.NO_INTERNET); |
126 | | - else if (AppUpdateManager.getAppUpdateManager().checkUpdate(true)) |
127 | | - moduleViewListBuilder.addNotification(NotificationType.UPDATE_AVAILABLE); |
128 | 155 | moduleViewListBuilder.appendRemoteModules(); |
129 | 156 | moduleViewListBuilder.applyTo(moduleList, moduleViewAdapter); |
130 | 157 | Log.i(TAG, "Finished app opening state!"); |
@@ -156,6 +183,7 @@ public void refreshUI() { |
156 | 183 | this.cardIconifyUpdate(); |
157 | 184 | this.moduleViewListBuilder.setQuery(null); |
158 | 185 | Log.i(TAG, "Item After"); |
| 186 | + this.moduleViewListBuilder.refreshNotificationsUI(this.moduleViewAdapter); |
159 | 187 | InstallerInitializer.tryGetMagiskPathAsync(new InstallerInitializer.Callback() { |
160 | 188 | @Override |
161 | 189 | public void onPathReceived(String path) { |
|
0 commit comments