Android Open Source - checkit Custom Dialog Fragment






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

/**
 * Dialog Fragment interacting with OnDialogDoneListener.
 *//from w w  w  .  ja  v  a2s .  c  om
 * @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.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;

public abstract class CustomDialogFragment extends DialogFragment
  implements DialogInterface.OnClickListener {
  protected int titleId;

  /** Return the message from user input. */
  public abstract CharSequence getMessage();

  /** Inflate the dialog. */
  public abstract View onInflateDialog(Bundle icicle);

  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    this.setCancelable(true);
    int style = DialogFragment.STYLE_NORMAL; 
    int theme = 0;
    setStyle(style, theme);
  }

  public Dialog onCreateDialog(Bundle icicle) {
    View v = onInflateDialog(icicle);

    // Use AlertDialog instead of building a normal dialog since I
    // like the style of the former especially the TextView like
    // OK/Cancel button.
    return new AlertDialog.Builder(getActivity())
      .setTitle(titleId)
      .setView(v)
      .setPositiveButton(getString(R.string.ok), this)
      .setNegativeButton(getString(R.string.cancel), this)
      .create();
  }

  public void onClick(DialogInterface dialog, int which) {
    OnDialogDoneListener act = (OnDialogDoneListener)getActivity();
    boolean cancelled = (which == AlertDialog.BUTTON_NEGATIVE);
    act.onDialogDone(this.getTag(), cancelled, getMessage());
  }
}




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