Created
March 21, 2016 11:04
-
-
Save devrath/6273a542d0a350b6ae8a to your computer and use it in GitHub Desktop.
Util Class For The Toast Functionality In Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.content.Context; | |
| import android.widget.Toast; | |
| /** | |
| * Some utility methods related with the Toast class. | |
| * | |
| * @author Devrath | |
| */ | |
| public class ToastUtils { | |
| private ToastUtils() { | |
| //Empty | |
| } | |
| public static void showError(final String message, final Context context) { | |
| getToast(message, context).show(); | |
| } | |
| public static void showShortMessage(String message, Context context) { | |
| getToast(message, context, Toast.LENGTH_SHORT).show(); | |
| } | |
| private static Toast getToast(String message, Context context) { | |
| return getToast(message, context, Toast.LENGTH_LONG); | |
| } | |
| private static Toast getToast(String message, Context context, int length) { | |
| return Toast.makeText(context, message, length); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment