@Override public void run() { toast.cancel(); } });
/** Hide the toast, if any. */ public static void hideToast() { if (null != toast) { toast.cancel(); } } }
/** * Hide the toast, if any. */ public static void hideToast() { if (null != toast) { toast.cancel(); } } }
/** Hide the toast, if any. */ public static void hideToast() { if (null != toast) { toast.cancel(); } } }
private void showToast(CharSequence text) { if (mCurrentToast != null) { mCurrentToast.cancel(); } mCurrentToast = Toast.makeText(SimpleSampleActivity.this, text, Toast.LENGTH_SHORT); mCurrentToast.show(); }
Toast m_currentToast; void showToast(String text) { if(m_currentToast != null) { m_currentToast.cancel(); } m_currentToast = Toast.makeText(this, text, Toast.LENGTH_LONG); m_currentToast.show(); }
public class SingleToast { private static Toast mToast; public static void show(Context context, String text, int duration) { if (mToast != null) mToast.cancel(); mToast = Toast.makeText(context, text, duration); mToast.show(); } }
protected void showToast(String message) { if (toast != null) toast.cancel(); toast = Toast.makeText(this, message, Toast.LENGTH_SHORT); toast.show(); }
public void showUnrecoverableError(Exception exception) { exception.printStackTrace(); if (errorToast != null) { errorToast.cancel(); } errorToast = Toast.makeText(context, R.string.player_unrecoverable_failure, Toast.LENGTH_SHORT); errorToast.show(); }
private void showTooltip(@StringRes int message) { if (tooltip!=null) { tooltip.cancel(); } tooltip=Toast.makeText(this, message, Toast.LENGTH_LONG); tooltip.show(); }
/** Show a toast and dismiss the last one if still visible. */ void showToast(String text, boolean longDuration) { if (mLastToast != null) mLastToast.cancel(); mLastToast = Toast.makeText(TermuxActivity.this, text, longDuration ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT); mLastToast.setGravity(Gravity.TOP, 0, 0); mLastToast.show(); }
public static void showShortText(Context context, CharSequence text) { if(context==null)return; if(toast != null) toast.cancel(); toast = Toast.makeText(context, text, Toast.LENGTH_SHORT); toast.show(); }
public static void showLongText(Context context, int resId) { try { if(context==null)return; if(toast != null) toast.cancel(); toast = Toast.makeText(context, resId, Toast.LENGTH_LONG); toast.show(); } catch (Exception e) { } }
public static void showShortText(Context context, int resId) { try { if(context==null)return; if(toast != null) toast.cancel(); toast = Toast.makeText(context, resId, Toast.LENGTH_SHORT); toast.show(); } catch (Exception e) { } }
public static void makeShortToast(Context context, String content) { if(context==null)return; if(toast != null) toast.cancel(); toast = Toast.makeText(context, content, Toast.LENGTH_SHORT); toast.show(); }
private Toast mToastText; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Create the object once. mToastText = Toast.makeText(this, "", Toast.LENGTH_SHORT); } private void displayText(final String message) { mToastText.cancel(); mToastText.setText(message); mToastText.show(); }
/** * Adds one to the water count and shows a toast */ public void incrementWater(View view) { if (mToast != null) mToast.cancel(); mToast = Toast.makeText(this, R.string.water_chug_toast, Toast.LENGTH_SHORT); mToast.show(); Intent incrementWaterCountIntent = new Intent(this, WaterReminderIntentService.class); incrementWaterCountIntent.setAction(ReminderTasks.ACTION_INCREMENT_WATER_COUNT); startService(incrementWaterCountIntent); }
/** * Adds one to the water count and shows a toast */ public void incrementWater(View view) { if (mToast != null) mToast.cancel(); mToast = Toast.makeText(this, R.string.water_chug_toast, Toast.LENGTH_SHORT); mToast.show(); Intent incrementWaterCountIntent = new Intent(this, WaterReminderIntentService.class); incrementWaterCountIntent.setAction(ReminderTasks.ACTION_INCREMENT_WATER_COUNT); startService(incrementWaterCountIntent); }
@Override public void onClickOk(@NonNull View view) { if (mode == MODE_NEW_FILE && getNewFileName().isEmpty()) { if (mToast != null) mToast.cancel(); mToast = Toast.makeText(getActivity(), R.string.file_name_empty_error, Toast.LENGTH_SHORT); mToast.show(); return; } super.onClickOk(view); }
@Test public void shouldBeCancelled() throws Exception { Toast toast = Toast.makeText(context, "short toast", Toast.LENGTH_SHORT); toast.cancel(); ShadowToast shadowToast = shadowOf(toast); assertThat(shadowToast.isCancelled()).isTrue(); } }