Android Open Source - dejalist Confirm Back Res Dialog Fragment






From Project

Back to project page dejalist.

License

The source code is released under:

Apache License

If you think the Android project dejalist 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.luboganev.dejalist.ui;
//ww w .  j a v a 2 s  . co  m
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import com.luboganev.dejalist.R;
import com.luboganev.dejalist.data.BackupIntentService;
import com.luboganev.dejalist.data.BackupIntentService.Action;

public class ConfirmBackResDialogFragment extends DialogFragment {
  public static final String ARG_MODE = "mode";
  
  public ConfirmBackResDialogFragment() {}
  
  public static interface ConfirmBackResCallback {
    public void onConfirmBackup();
    public void onConfirmRestore();
  }
  
  private ConfirmBackResCallback mConfirmBackResCallback;
  
  public static ConfirmBackResDialogFragment getBackupInstance() {
    ConfirmBackResDialogFragment fragment = new ConfirmBackResDialogFragment();
    Bundle arguments = new Bundle();
    arguments.putSerializable(ARG_MODE, BackupIntentService.Action.BACKUP);
    fragment.setArguments(arguments);
    return fragment;
  }
  
  public static ConfirmBackResDialogFragment getRestoreInstance() {
    ConfirmBackResDialogFragment fragment = new ConfirmBackResDialogFragment();
    Bundle arguments = new Bundle();
    arguments.putSerializable(ARG_MODE, BackupIntentService.Action.RESTORE);
    fragment.setArguments(arguments);
    return fragment;
  }
  
    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        try {
          mConfirmBackResCallback = (ConfirmBackResCallback) getActivity();
        } catch (ClassCastException e) {
            throw new ClassCastException(getActivity().toString()
                    + " must implement ConfirmBackResCallback");
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        mConfirmBackResCallback = null;
    }
    
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    BackupIntentService.Action action = (BackupIntentService.Action)getArguments().getSerializable(ARG_MODE);
    if(action == Action.BACKUP) {
      builder.setTitle(R.string.backup_confirm_title)
        .setMessage(R.string.backup_confirm_message)
        .setPositiveButton(R.string.backup_confirm_button_positive, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                  if(mConfirmBackResCallback != null) mConfirmBackResCallback.onConfirmBackup();
                }
            })
            .setNegativeButton(R.string.backup_confirm_button_negative, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                  // do nothing
                }
            });
    }
    else if(action == Action.RESTORE) {
      builder.setTitle(R.string.restore_confirm_title)
      .setMessage(R.string.restore_confirm_message)
      .setPositiveButton(R.string.restore_confirm_button_positive, new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                if(mConfirmBackResCallback != null) mConfirmBackResCallback.onConfirmRestore();
              }
          })
          .setNegativeButton(R.string.restore_confirm_button_negative, new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                // do nothing
              }
          });
    }
      return builder.create();
  }
}




Java Source Code List

com.larswerkman.colorpicker.ColorPicker.java
com.larswerkman.colorpicker.OpacityBar.java
com.larswerkman.colorpicker.SVBar.java
com.larswerkman.colorpicker.SaturationBar.java
com.larswerkman.colorpicker.ValueBar.java
com.luboganev.dejalist.Utils.java
com.luboganev.dejalist.crop.CropActivity.java
com.luboganev.dejalist.crop.CropDialogSave.java
com.luboganev.dejalist.crop.CropHighlightView.java
com.luboganev.dejalist.crop.CropUtils.java
com.luboganev.dejalist.crop.CropView.java
com.luboganev.dejalist.crop.ImageViewTouchBase.java
com.luboganev.dejalist.crop.RotateBitmap.java
com.luboganev.dejalist.data.BackupIntentService.java
com.luboganev.dejalist.data.CacheManager.java
com.luboganev.dejalist.data.DejalistContract.java
com.luboganev.dejalist.data.DejalistDatabase.java
com.luboganev.dejalist.data.DejalistProvider.java
com.luboganev.dejalist.data.ProductImageFileHelper.java
com.luboganev.dejalist.data.SelectionBuilder.java
com.luboganev.dejalist.data.entities.Category.java
com.luboganev.dejalist.data.entities.Product.java
com.luboganev.dejalist.ui.AboutActivity.java
com.luboganev.dejalist.ui.CategoriesListCursorAdapter$ViewHolder$$ViewInjector.java
com.luboganev.dejalist.ui.CategoriesListCursorAdapter.java
com.luboganev.dejalist.ui.CategoryDialogFragment$$ViewInjector.java
com.luboganev.dejalist.ui.CategoryDialogFragment.java
com.luboganev.dejalist.ui.CheckableRelativeLayout.java
com.luboganev.dejalist.ui.ChecklistActionTaker.java
com.luboganev.dejalist.ui.ChecklistController.java
com.luboganev.dejalist.ui.ChecklistCursorAdapter$ViewHolder$$ViewInjector.java
com.luboganev.dejalist.ui.ChecklistCursorAdapter.java
com.luboganev.dejalist.ui.ChecklistFragment$$ViewInjector.java
com.luboganev.dejalist.ui.ChecklistFragment.java
com.luboganev.dejalist.ui.ConfirmBackResDialogFragment.java
com.luboganev.dejalist.ui.MainActivity$$ViewInjector.java
com.luboganev.dejalist.ui.MainActivity.java
com.luboganev.dejalist.ui.NavigationCursorAdapter$ViewHolder$$ViewInjector.java
com.luboganev.dejalist.ui.NavigationCursorAdapter.java
com.luboganev.dejalist.ui.ProductActivity$$ViewInjector.java
com.luboganev.dejalist.ui.ProductActivity.java
com.luboganev.dejalist.ui.ProductsGalleryActionTaker.java
com.luboganev.dejalist.ui.ProductsGalleryController.java
com.luboganev.dejalist.ui.ProductsGalleryCursorAdapter$ViewHolder$$ViewInjector.java
com.luboganev.dejalist.ui.ProductsGalleryCursorAdapter.java
com.luboganev.dejalist.ui.ProductsGalleryFragment$$ViewInjector.java
com.luboganev.dejalist.ui.ProductsGalleryFragment.java
com.luboganev.dejalist.ui.SetProductsCategoryDialogFragment.java
com.luboganev.dejalist.ui.UndoBarController.java