Skip to content

Instantly share code, notes, and snippets.

@rburgosnavas
Last active August 29, 2015 14:12
Show Gist options
  • Save rburgosnavas/fda688f13671faa2a3bf to your computer and use it in GitHub Desktop.
Save rburgosnavas/fda688f13671faa2a3bf to your computer and use it in GitHub Desktop.
A simple Toast helper class for Android.
import android.content.Context;
import android.widget.Toast;
/**
* Helper class to make Toasts with.
*/
public class Skal {
/**
* Creates a Toast.
*
* @param context The context.
* @param isLong Whether the Toast should have a Toast.LENGTH_LONG or Toast.LENGTH_SHORT.
* @param text The text to display in the Toast.
*/
public static void make(Context context, boolean isLong, String text) {
int duration = isLong ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT;
Toast.makeText(context, text, duration).show();
}
/**
* Creates a Toast with duration = Toast.LENGTH_LONG.
*
* @param context The context.
* @param text The text to display in the Toast.
*/
public static void make(Context context, String text) {
make(context, true, text);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment