Exemplo n.º 1
0
 /**
  * presents AlertDialog for editing an existing category if label is already used, shows an error
  *
  * @param label
  * @param cat_id
  */
 public void editCat(String label, Long catId) {
   Bundle args = new Bundle();
   args.putLong("catId", catId);
   args.putString("dialogTitle", getString(R.string.menu_edit_cat));
   args.putString("value", label);
   EditTextDialog.newInstance(args).show(getSupportFragmentManager(), "EDIT_CATEGORY");
 }
Exemplo n.º 2
0
 /**
  * presents AlertDialog for adding a new category if label is already used, shows an error
  *
  * @param parent_id
  */
 public void createCat(Long parentId) {
   Bundle args = new Bundle();
   int dialogTitle;
   if (parentId != null) {
     args.putLong("parentId", parentId);
     dialogTitle = R.string.menu_create_sub_cat;
   } else dialogTitle = R.string.menu_create_main_cat;
   args.putString("dialogTitle", getString(dialogTitle));
   EditTextDialog.newInstance(args).show(getSupportFragmentManager(), "CREATE_CATEGORY");
 }
Exemplo n.º 3
0
 @Override
 public boolean dispatchCommandSingle(int command, ContextMenu.ContextMenuInfo info) {
   AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) info;
   MyExpenses ctx = (MyExpenses) getActivity();
   switch (command) {
     case R.id.EDIT_COMMAND:
       mTransactionsCursor.moveToPosition(acmi.position);
       if (DbUtils.getLongOrNull(mTransactionsCursor, "transfer_peer_parent") != null) {
         Toast.makeText(
                 getActivity(),
                 getString(R.string.warning_splitpartcategory_context),
                 Toast.LENGTH_LONG)
             .show();
       } else {
         Intent i = new Intent(ctx, ExpenseEdit.class);
         i.putExtra(KEY_ROWID, acmi.id);
         i.putExtra(DatabaseConstants.KEY_TRANSFER_ENABLED, ctx.transferEnabled());
         ctx.startActivityForResult(i, MyExpenses.EDIT_TRANSACTION_REQUEST);
       }
       // super is handling deactivation of mActionMode
       break;
     case R.id.CREATE_TEMPLATE_COMMAND:
       mTransactionsCursor.moveToPosition(acmi.position);
       String label = mTransactionsCursor.getString(columnIndexPayee);
       if (TextUtils.isEmpty(label)) label = mTransactionsCursor.getString(columnIndexLabelSub);
       if (TextUtils.isEmpty(label)) label = mTransactionsCursor.getString(columnIndexLabelMain);
       Bundle args = new Bundle();
       args.putLong(KEY_ROWID, acmi.id);
       args.putString(
           EditTextDialog.KEY_DIALOG_TITLE, getString(R.string.dialog_title_template_title));
       args.putString(EditTextDialog.KEY_VALUE, label);
       EditTextDialog.newInstance(args).show(ctx.getSupportFragmentManager(), "TEMPLATE_TITLE");
       return true;
   }
   return super.dispatchCommandSingle(command, info);
 }