Skip to content

Commit

Permalink
showToast methods now return a Toast object
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme committed Jul 23, 2014
1 parent 3e93210 commit c6b0ff9
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@ private ToastUtils() {
throw new AssertionError();
}

public static void showToast(Context context, int stringResId) {
showToast(context, stringResId, Duration.SHORT);
public static Toast showToast(Context context, int stringResId) {
return showToast(context, stringResId, Duration.SHORT);
}

public static void showToast(Context context, int stringResId, Duration duration) {
showToast(context, context.getString(stringResId), duration);
public static Toast showToast(Context context, int stringResId, Duration duration) {
return showToast(context, context.getString(stringResId), duration);
}

public static void showToast(Context context, String text) {
showToast(context, text, Duration.SHORT);
public static Toast showToast(Context context, String text) {
return showToast(context, text, Duration.SHORT);
}

public static void showToast(Context context, String text, Duration duration) {
public static Toast showToast(Context context, String text, Duration duration) {
Toast toast = Toast.makeText(context, text,
(duration == Duration.SHORT ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG));
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
return toast;
}
}

0 comments on commit c6b0ff9

Please sign in to comment.