List of usage examples for android.text.format DateFormat is24HourFormat
public static boolean is24HourFormat(Context context)
From source file:com.dwdesign.tweetings.util.Utils.java
public static void showErrorToast(final Context context, final String action, final Throwable t, final boolean long_message) { if (context == null) return;/* w w w . jav a 2 s.c o m*/ final String message; if (t != null) { final String t_message = trimLineBreak(unescape(t.getMessage())); if (action != null) { if (t instanceof TwitterException && ((TwitterException) t).exceededRateLimitation()) { final RateLimitStatus status = ((TwitterException) t).getRateLimitStatus(); final String next_reset_time_string = DateUtils.formatDateTime(context, status.getResetTime().getTime(), DateFormat.is24HourFormat(context) ? DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_24HOUR : DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_12HOUR); message = context.getString(R.string.error_message_rate_limit, action, next_reset_time_string); } else { message = context.getString(R.string.error_message_with_action, action, t_message); } } else { message = context.getString(R.string.error_message, t_message); } } else { message = context.getString(R.string.error_unknown_error); } final int length = long_message ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT; final Toast toast = Toast.makeText(context, message, length); toast.show(); }
From source file:org.mariotaku.twidere.util.Utils.java
@SuppressWarnings("deprecation") public static void showErrorToast(final Context context, final String action, final Throwable t, final boolean long_message) { if (context == null) return;//from ww w. ja v a 2 s . com final String message; if (t != null) { t.printStackTrace(); final String t_message = trimLineBreak(t.getMessage()); if (action != null) { if (t instanceof TwitterException) { final TwitterException te = (TwitterException) t; if (te.exceededRateLimitation()) { final RateLimitStatus status = te.getRateLimitStatus(); final String next_reset_time_string = DateUtils.formatDateTime(context, status.getResetTime().getTime(), DateFormat.is24HourFormat(context) ? DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_24HOUR : DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_12HOUR); message = context.getString(R.string.error_message_rate_limit, action, next_reset_time_string); } else { message = context.getString(R.string.error_message_with_action, action, t_message); } } else { message = context.getString(R.string.error_message_with_action, action, t_message); } } else { message = context.getString(R.string.error_message, t_message); } } else { message = context.getString(R.string.error_unknown_error); } final int length = long_message ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT; final Toast toast = Toast.makeText(context, message, length); toast.show(); }