@@ -170,42 +170,58 @@ public boolean onOptionsItemSelected(MenuItem item) {
170
170
}
171
171
172
172
@ Override
173
- public void onFinished (Update update , boolean isUpdateAvailable ) {
173
+ public void onFinished (final Update update , final boolean isUpdateAvailable ) {
174
174
this .mUpdate = update ;
175
- progressWheel .setVisibility (View .GONE );
176
- whatsapp_latest_version .setVisibility (View .VISIBLE );
177
- whatsapp_latest_version .setText (update .getLatestVersion ());
178
-
179
- boolean isWhatsAppInstalled = UtilsWhatsApp .isWhatsAppInstalled (MainActivity .this );
180
- if (isWhatsAppInstalled && isUpdateAvailable ) {
181
- UtilsUI .showFAB (fab , true );
182
- toolbar_subtitle .setText (String .format (getResources ().getString (R .string .update_available ), update .getLatestVersion ()));
183
- if (appPreferences .getAutoDownload ()) {
184
- new UtilsAsync .DownloadFile (MainActivity .this , UtilsEnum .DownloadType .WHATSAPP_APK , update ).execute ();
175
+ final boolean isWhatsAppInstalled = UtilsWhatsApp .isWhatsAppInstalled (MainActivity .this );
176
+
177
+ runOnUiThread (new Runnable () {
178
+ @ Override
179
+ public void run () {
180
+ progressWheel .setVisibility (View .GONE );
181
+ whatsapp_latest_version .setVisibility (View .VISIBLE );
182
+ whatsapp_latest_version .setText (update .getLatestVersion ());
183
+
184
+ if (isWhatsAppInstalled && isUpdateAvailable ) {
185
+ UtilsUI .showFAB (fab , true );
186
+ toolbar_subtitle .setText (String .format (getResources ().getString (R .string .update_available ), update .getLatestVersion ()));
187
+ if (appPreferences .getAutoDownload ()) {
188
+ new UtilsAsync .DownloadFile (MainActivity .this , UtilsEnum .DownloadType .WHATSAPP_APK , update ).execute ();
189
+ }
190
+ } else if (!isWhatsAppInstalled ) {
191
+ UtilsUI .showFAB (fab , true );
192
+ toolbar_subtitle .setText (String .format (getResources ().getString (R .string .update_not_installed ), update .getLatestVersion ()));
193
+ } else {
194
+ UtilsUI .showFAB (fab , false );
195
+ toolbar_subtitle .setText (getResources ().getString (R .string .update_not_available ));
196
+ }
185
197
}
186
- } else if (!isWhatsAppInstalled ) {
187
- UtilsUI .showFAB (fab , true );
188
- toolbar_subtitle .setText (String .format (getResources ().getString (R .string .update_not_installed ), update .getLatestVersion ()));
189
- } else {
190
- UtilsUI .showFAB (fab , false );
191
- toolbar_subtitle .setText (getResources ().getString (R .string .update_not_available ));
192
- }
198
+ });
193
199
}
194
200
195
201
@ Override
196
202
public void onLoading () {
197
- checkInstalledWhatsAppVersion ();
198
- whatsapp_latest_version .setVisibility (View .GONE );
199
- progressWheel .setVisibility (View .VISIBLE );
203
+ runOnUiThread (new Runnable () {
204
+ @ Override
205
+ public void run () {
206
+ checkInstalledWhatsAppVersion ();
207
+ whatsapp_latest_version .setVisibility (View .GONE );
208
+ progressWheel .setVisibility (View .VISIBLE );
209
+ }
210
+ });
200
211
}
201
212
202
213
@ Override
203
- public void onError (UpdaterError error ) {
204
- if (error == UpdaterError .NO_INTERNET_CONNECTION )
205
- toolbar_subtitle .setText (getResources ().getString (R .string .update_not_connection ));
206
- progressWheel .setVisibility (View .GONE );
207
- whatsapp_latest_version .setVisibility (View .VISIBLE );
208
- whatsapp_latest_version .setText (getString (R .string .whatsapp_not_available ));
214
+ public void onError (final UpdaterError error ) {
215
+ runOnUiThread (new Runnable () {
216
+ @ Override
217
+ public void run () {
218
+ if (error == UpdaterError .NO_INTERNET_CONNECTION )
219
+ toolbar_subtitle .setText (getResources ().getString (R .string .update_not_connection ));
220
+ progressWheel .setVisibility (View .GONE );
221
+ whatsapp_latest_version .setVisibility (View .VISIBLE );
222
+ whatsapp_latest_version .setText (getString (R .string .whatsapp_not_available ));
223
+ }
224
+ });
209
225
}
210
226
211
227
}
0 commit comments