Android Open Source - SampleAlertDialog Toast Utils






From Project

Back to project page SampleAlertDialog.

License

The source code is released under:

MIT License

If you think the Android project SampleAlertDialog listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.neetpiq.android.samplealertdialog.util;
// www  .j  a v a 2 s  .  c  om
import android.content.Context;
import android.widget.Toast;


/**
 * Created by nbradbury on 6/20/13.
 * Provides a simplified way to show toast messages without having to create the toast, set the
 * desired gravity, etc.
 */
public class ToastUtils {

  public enum Duration {
    SHORT, LONG
  }

  private ToastUtils() {
    throw new AssertionError();
  }

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

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

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

  public static void 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();
  }

}




Java Source Code List

com.neetpiq.android.samplealertdialog.MainActivity.java
com.neetpiq.android.samplealertdialog.MainApplication.java
com.neetpiq.android.samplealertdialog.NothingSelectedSpinnerAdapter.java
com.neetpiq.android.samplealertdialog.OtherActivity.java
com.neetpiq.android.samplealertdialog.data.DatabaseHelper.java
com.neetpiq.android.samplealertdialog.data.DatabaseManager.java
com.neetpiq.android.samplealertdialog.model.Speaker.java
com.neetpiq.android.samplealertdialog.model.TimeSlot.java
com.neetpiq.android.samplealertdialog.model.Topic.java
com.neetpiq.android.samplealertdialog.util.AlertUtil.java
com.neetpiq.android.samplealertdialog.util.ToastUtils.java