Back to project page SyncFrameworkAndroid.
The source code is released under:
Apache License
If you think the Android project SyncFrameworkAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/*** Copyright (c) 2014 Selvin// w ww. ja va 2 s . c o m Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package pl.selvin.android.listsyncsample.ui; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.net.Uri; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.widget.Toast; import pl.selvin.android.listsyncsample.R; public class ConfirmDeleteDialog extends DialogFragment { static final String URI = "uri"; static final String TITLE = "title"; public static ConfirmDeleteDialog newInstance(int title, Uri uri) { ConfirmDeleteDialog frag = new ConfirmDeleteDialog(); Bundle args = new Bundle(); args.putParcelable(URI, uri); args.putInt(TITLE, title); frag.setArguments(args); return frag; } @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { int title = getArguments().getInt(TITLE); final Uri uri = getArguments().getParcelable(URI); return new AlertDialog.Builder(getActivity()) .setTitle(title) .setMessage(R.string.ui_alert_confirm) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { getActivity().getContentResolver().delete(uri, null, null); Toast.makeText(getActivity(), "Deleted!", Toast.LENGTH_SHORT).show(); } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Toast.makeText(getActivity(), "Deletion canceled!", Toast.LENGTH_SHORT).show(); } }).create(); } }