From 6715a4c353cc5252b13bf2f8daeeea4510896cb5 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 18 Nov 2018 11:21:52 +0100 Subject: [PATCH] make change nick toast use showToast helper method. fixes #3279 --- .../ui/ConferenceDetailsActivity.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index 5b3707b03..a6fa255d6 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -17,12 +17,14 @@ import android.support.v7.widget.Toolbar; import android.text.Editable; import android.text.SpannableStringBuilder; import android.text.TextWatcher; +import android.util.Log; import android.view.ContextMenu; import android.view.LayoutInflater; 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; @@ -92,8 +94,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(); }); @@ -101,7 +103,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 @@ -695,7 +697,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) {