If you think the Android project Thrift-box 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 ru.sash0k.thriftbox.fragments;
/*fromwww.java2s.com*/import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.provider.BaseColumns;
import android.support.v4.app.DialogFragment;
import android.view.ContextThemeWrapper;
import ru.sash0k.thriftbox.MainActivity;
import ru.sash0k.thriftbox.R;
import ru.sash0k.thriftbox.Utils;
import ru.sash0k.thriftbox.database.DB;
/**
* ?????? ?????????????? ?????????
* Created by sash0k on 11.03.14.
*/publicclass DeleteConfirmDialog extends DialogFragment {
publicstaticfinal String TAG = "DeleteConfirmDialog";
privatestaticfinal String divider = " ";
publicstatic DeleteConfirmDialog newInstance(int id, String date, int category, long value) {
DeleteConfirmDialog f = new DeleteConfirmDialog();
Bundle arguments = new Bundle();
arguments.putInt(BaseColumns._ID, id);
arguments.putString(DB.DATE, date);
arguments.putInt(DB.CATEGORY, category);
arguments.putLong(DB.VALUE, value);
f.setArguments(arguments);
return f;
}
// ============================================================================
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = new ContextThemeWrapper(getActivity(), android.R.style.Theme_Holo_Light_Dialog_NoActionBar);
String[] categories = context.getResources().getStringArray(R.array.categories);
final Bundle args = getArguments();
finalint id = args.getInt(BaseColumns._ID);
final String date = args.getString(DB.DATE);
finalint 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(((MainActivity) getActivity()).parseRouble(title))
.setMessage(((MainActivity) getActivity()).parseRouble(msg))
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
@Override
publicvoid onClick(DialogInterface dialogInterface, int i) {
DB.deleteItem(context, id);
Utils.updateWidgets(context);
}
})
.setNegativeButton(android.R.string.no, null);
return builder.create();
}
// ============================================================================
}