예제 #1
0
  /**
   * Using factory design pattern to create a new custom DialogFragment.
   *
   * <p>params should at least contain the dialog type under the key Const.DIALOG_TYPE Other
   * parameters are optional and based on specific dialog needs
   *
   * @param params
   * @return
   */
  public static HoloNoteDialog newInstance(Map<String, Object> params) {

    HoloNoteDialog frag = new HoloNoteDialog();
    Bundle args = new Bundle();
    if (params.get(Const.DIALOG_TYPE) != null) {
      args.putInt(Const.DIALOG_TYPE, (Integer) params.get(Const.DIALOG_TYPE));
    }
    if (params.get(DatabaseAdapter.ID_COL) != null) {
      args.putLong(DatabaseAdapter.ID_COL, (Long) params.get(DatabaseAdapter.ID_COL));
    }
    if (params.get(DatabaseAdapter.TEXT_COL) != null) {
      args.putString(DatabaseAdapter.TEXT_COL, (String) params.get(DatabaseAdapter.TEXT_COL));
    }
    if (params.get(Const.FRAG_RSRC_ID) != null) {
      args.putInt(Const.FRAG_RSRC_ID, (Integer) params.get(Const.FRAG_RSRC_ID));
    }
    frag.setArguments(args);
    return frag;
  }
예제 #2
0
 private void showDialogFragment(int type) {
   Map<String, Object> params = new HashMap<String, Object>();
   params.put(Const.DIALOG_TYPE, type);
   DialogFragment frag = HoloNoteDialog.newInstance(params);
   frag.show(this.getFragmentManager(), "view_note_activity_dialog");
 }