Android Open Source - checkit Alert






From Project

Back to project page checkit.

License

The source code is released under:

GNU General Public License

If you think the Android project checkit 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

/**
 * Show simple alert dialogs which only accept OK/Cancel like input.
 */*from   w  w  w .  j a v  a  2s.co m*/
 * @author  Yujian Zhang <yujian{dot}zhang[at]gmail(dot)com>
 *
 * License: 
 *   GNU General Public License v2
 *   http://www.gnu.org/licenses/gpl-2.0.html
 * Copyright (C) 2011-2012 Yujian Zhang
 */

package net.whily.android.checkit;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

public final class Alert {
  /**
   * Show alert dialog without title.
   */
  public static void show(Context context, int messageId, int positiveTextId, 
                          int negativeTextId,
                          DialogInterface.OnClickListener positiveListener) {
    showTitle(context, -1, messageId, positiveTextId, negativeTextId, 
              positiveListener);
  }

  /**
   * Show alert dialog with title but without icon. If titleId < 0,
   * title itself is not shown.
   */
  public static void showTitle(Context context, int titleId, int messageId, 
                               int positiveTextId, int negativeTextId,
                               DialogInterface.OnClickListener positiveListener) {
    showTitleIcon(context, -1, titleId, messageId, positiveTextId, 
                  negativeTextId, positiveListener);
  }

  /**
   * Show alert dialog with title and icon. If iconId < 0, icon is not
   * show. If titleId < 0, title is not shown.
   */
  public static void showTitleIcon(Context context, int iconId, int titleId, 
                                   int messageId, int positiveTextId, 
                                   int negativeTextId,
                                   DialogInterface.OnClickListener positiveListener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage(messageId)
      .setCancelable(true)
      .setPositiveButton(positiveTextId, positiveListener)
      .setNegativeButton(negativeTextId, null);
    if (titleId >= 0) {
      builder.setTitle(titleId);
      if (iconId >= 0) {
        builder.setIcon(iconId);
      }
    }
    builder.create().show();
  }
}




Java Source Code List

net.whily.android.checkit.AboutActivity.java
net.whily.android.checkit.Alert.java
net.whily.android.checkit.CheckActivity.java
net.whily.android.checkit.CheckedItem.java
net.whily.android.checkit.ChecklistMetadata.java
net.whily.android.checkit.ChecklistProvider.java
net.whily.android.checkit.CustomDialogFragment.java
net.whily.android.checkit.ExternalStorage.java
net.whily.android.checkit.HomeActivity.java
net.whily.android.checkit.OnDialogDoneListener.java
net.whily.android.checkit.PromptDialogFragment.java
net.whily.android.checkit.SelectionDialogFragment.java
net.whily.android.checkit.SettingsActivity.java
net.whily.android.checkit.Util.java