Launch Toasts on UI thread. (#868)

Launch Toasts on UI thread.

Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/868
Reviewed-by: M M Arif <mmarif@noreply.codeberg.org>
Co-Authored-By: opyale <opyale@noreply.codeberg.org>
Co-Committed-By: opyale <opyale@noreply.codeberg.org>
This commit is contained in:
opyale 2021-03-31 19:36:11 +02:00 committed by M M Arif
parent 4b140f3195
commit a384128c8f
2 changed files with 10 additions and 10 deletions

View File

@ -106,23 +106,23 @@ public class FileDiffActivity extends BaseActivity {
break; break;
case 401: case 401:
AlertDialogs.authorizationTokenRevokedDialog(ctx, runOnUiThread(() -> AlertDialogs.authorizationTokenRevokedDialog(ctx,
getString(R.string.alertDialogTokenRevokedTitle), getString(R.string.alertDialogTokenRevokedTitle),
getString(R.string.alertDialogTokenRevokedMessage), getString(R.string.alertDialogTokenRevokedMessage),
getString(R.string.alertDialogTokenRevokedCopyNegativeButton), getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
getString(R.string.alertDialogTokenRevokedCopyPositiveButton)); getString(R.string.alertDialogTokenRevokedCopyPositiveButton)));
break; break;
case 403: case 403:
Toasty.error(ctx, ctx.getString(R.string.authorizeError)); runOnUiThread(() -> Toasty.error(ctx, ctx.getString(R.string.authorizeError)));
break; break;
case 404: case 404:
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound)); runOnUiThread(() -> Toasty.warning(ctx, ctx.getString(R.string.apiNotFound)));
break; break;
default: default:
Toasty.error(ctx, getString(R.string.labelGeneralError)); runOnUiThread(() -> Toasty.error(ctx, getString(R.string.labelGeneralError)));
} }
} catch(IOException ignored) {} } catch(IOException ignored) {}

View File

@ -240,23 +240,23 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
switch(response.code()) { switch(response.code()) {
case 401: case 401:
AlertDialogs.authorizationTokenRevokedDialog(ctx, runOnUiThread(() -> AlertDialogs.authorizationTokenRevokedDialog(ctx,
getResources().getString(R.string.alertDialogTokenRevokedTitle), getResources().getString(R.string.alertDialogTokenRevokedTitle),
getResources().getString(R.string.alertDialogTokenRevokedMessage), getResources().getString(R.string.alertDialogTokenRevokedMessage),
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton)); getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton)));
break; break;
case 403: case 403:
Toasty.error(ctx, ctx.getString(R.string.authorizeError)); runOnUiThread(() -> Toasty.error(ctx, ctx.getString(R.string.authorizeError)));
break; break;
case 404: case 404:
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound)); runOnUiThread(() -> Toasty.warning(ctx, ctx.getString(R.string.apiNotFound)));
break; break;
default: default:
Toasty.error(ctx, getString(R.string.labelGeneralError)); runOnUiThread(() -> Toasty.error(ctx, getString(R.string.labelGeneralError)));
} }
} }