From cd947bd22544fcade1598420855cf981e94b5c50 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Fri, 23 Nov 2018 14:26:45 +0100 Subject: make change nick toast use showToast helper method --- .../de/pixart/messenger/ui/ConferenceDetailsActivity.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java index fa83354c4..91b6cb698 100644 --- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java @@ -24,6 +24,7 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; +import android.view.WindowManager; import android.widget.ImageView; import android.widget.Toast; @@ -113,8 +114,8 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers private UiCallback renameCallback = new UiCallback() { @Override public void success(Conversation object) { + displayToast(getString(R.string.your_nick_has_been_changed)); runOnUiThread(() -> { - Toast.makeText(ConferenceDetailsActivity.this, getString(R.string.your_nick_has_been_changed), Toast.LENGTH_SHORT).show(); updateView(); }); @@ -122,7 +123,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers @Override public void error(final int errorCode, Conversation object) { - runOnUiThread(() -> Toast.makeText(ConferenceDetailsActivity.this, getString(errorCode), Toast.LENGTH_SHORT).show()); + displayToast(getString(errorCode)); } @Override @@ -785,7 +786,13 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers } private void displayToast(final String msg) { - runOnUiThread(() -> Toast.makeText(ConferenceDetailsActivity.this, msg, Toast.LENGTH_SHORT).show()); + runOnUiThread(() -> { + try { + Toast.makeText(ConferenceDetailsActivity.this, msg, Toast.LENGTH_SHORT).show(); + } catch (WindowManager.BadTokenException e) { + Log.e(Config.LOGTAG,"unable to display toast '"+msg+"'. Activity not running"); + } + }); } public void loadAvatar(User user, ImageView imageView) { -- cgit v1.2.3