Utilities.java :  » UnTagged » ull-etsii-geobloc » com » geobloc » shared » Android Open Source

Android Open Source » UnTagged » ull etsii geobloc 
ull etsii geobloc » com » geobloc » shared » Utilities.java
/**
 * 
 */
package com.geobloc.shared;

import android.app.AlertDialog;
import android.content.Context;
import android.widget.Toast;

/**
 * Common methods we keep calling again, again, and again all over our code.
 * Best if we keep it all here.
 * 
 * @author Dinesh Harjani (goldrunner192287@gmail.com)
 *
 */
public class Utilities {

  /*
   * Type for the "Widget"
   */
  public enum WidgetType {LABEL, STRING, INT, BUTTON, CHECKBOX};
  
  /* 
   * Displays a Toast. The context parameter is filled with getApplicationContext() from the Activity 
   * you're calling this from. Duration is with Toast.LENGTH_SHORT or Toast.LENGTH_LONG
  */
  public static void showToast(Context context, String message, int duration) {
    Toast toast = Toast.makeText(context, message, duration);
    toast.show();
  }
  
  /*
   * Displays a simple Dialog with an OK button. Used fot the common task of giving some information to the 
   * user without switching to another Activity. Needs Activity context, ApplicationContext will make 
   * the caller crash.
   */
  public static void showTitleAndMessageDialog(Context context, String title, String message) {
    AlertDialog.Builder alert = new AlertDialog.Builder(context);  
    alert.setTitle(title);  
    alert.setMessage(message);
    alert.setPositiveButton("OK", null);
    alert.show();
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.