From a384128c8f6d1f2e9c2c9b8e11ed27e46cba2748 Mon Sep 17 00:00:00 2001 From: opyale Date: Wed, 31 Mar 2021 19:36:11 +0200 Subject: [PATCH] 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 Co-Authored-By: opyale Co-Committed-By: opyale --- .../org/mian/gitnex/activities/FileDiffActivity.java | 10 +++++----- .../org/mian/gitnex/activities/FileViewActivity.java | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/org/mian/gitnex/activities/FileDiffActivity.java b/app/src/main/java/org/mian/gitnex/activities/FileDiffActivity.java index a186dc06..f5966bc8 100644 --- a/app/src/main/java/org/mian/gitnex/activities/FileDiffActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/FileDiffActivity.java @@ -106,23 +106,23 @@ public class FileDiffActivity extends BaseActivity { break; case 401: - AlertDialogs.authorizationTokenRevokedDialog(ctx, + runOnUiThread(() -> AlertDialogs.authorizationTokenRevokedDialog(ctx, getString(R.string.alertDialogTokenRevokedTitle), getString(R.string.alertDialogTokenRevokedMessage), getString(R.string.alertDialogTokenRevokedCopyNegativeButton), - getString(R.string.alertDialogTokenRevokedCopyPositiveButton)); + getString(R.string.alertDialogTokenRevokedCopyPositiveButton))); break; case 403: - Toasty.error(ctx, ctx.getString(R.string.authorizeError)); + runOnUiThread(() -> Toasty.error(ctx, ctx.getString(R.string.authorizeError))); break; case 404: - Toasty.warning(ctx, ctx.getString(R.string.apiNotFound)); + runOnUiThread(() -> Toasty.warning(ctx, ctx.getString(R.string.apiNotFound))); break; default: - Toasty.error(ctx, getString(R.string.labelGeneralError)); + runOnUiThread(() -> Toasty.error(ctx, getString(R.string.labelGeneralError))); } } catch(IOException ignored) {} diff --git a/app/src/main/java/org/mian/gitnex/activities/FileViewActivity.java b/app/src/main/java/org/mian/gitnex/activities/FileViewActivity.java index 02a7d140..229ab3c8 100644 --- a/app/src/main/java/org/mian/gitnex/activities/FileViewActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/FileViewActivity.java @@ -240,23 +240,23 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie switch(response.code()) { case 401: - AlertDialogs.authorizationTokenRevokedDialog(ctx, + runOnUiThread(() -> AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle), getResources().getString(R.string.alertDialogTokenRevokedMessage), getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), - getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton)); + getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton))); break; case 403: - Toasty.error(ctx, ctx.getString(R.string.authorizeError)); + runOnUiThread(() -> Toasty.error(ctx, ctx.getString(R.string.authorizeError))); break; case 404: - Toasty.warning(ctx, ctx.getString(R.string.apiNotFound)); + runOnUiThread(() -> Toasty.warning(ctx, ctx.getString(R.string.apiNotFound))); break; default: - Toasty.error(ctx, getString(R.string.labelGeneralError)); + runOnUiThread(() -> Toasty.error(ctx, getString(R.string.labelGeneralError))); } }