Search in sources :

Example 1 with ActivityHelper

use of ru.sash0k.thriftbox.ActivityHelper in project Thrift-box by Sash0k.

the class DeleteConfirmDialog method onCreateDialog.

// ============================================================================
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context context = getActivity();
    String[] categories = context.getResources().getStringArray(R.array.categories);
    final Bundle args = getArguments();
    final int id = args.getInt(BaseColumns._ID);
    final String date = args.getString(DB.DATE);
    final int category = args.getInt(DB.CATEGORY);
    final String value = Utils.formatValue(args.getLong(DB.VALUE)) + Utils.ROUBLE + "?";
    final String title = getString(R.string.delete_label) + " " + value;
    final String msg = context.getString(R.string.delete_msg) + '\n' + date + divider + categories[category] + divider + value;
    android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(context).setTitle(((ActivityHelper) getActivity()).parseRouble(title)).setMessage(((ActivityHelper) getActivity()).parseRouble(msg)).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            new DB(context).deleteItem(context, id);
            Utils.updateWidgets(context);
        }
    }).setNegativeButton(android.R.string.no, null);
    return builder.create();
}
Also used : Context(android.content.Context) DialogInterface(android.content.DialogInterface) Bundle(android.os.Bundle) ActivityHelper(ru.sash0k.thriftbox.ActivityHelper) DB(ru.sash0k.thriftbox.database.DB)

Aggregations

Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 Bundle (android.os.Bundle)1 ActivityHelper (ru.sash0k.thriftbox.ActivityHelper)1 DB (ru.sash0k.thriftbox.database.DB)1