Back to project page filemanager.
The source code is released under:
MIT License
If you think the Android project filemanager listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.binkery.app.filemanager.fragments; /* ww w . j a va 2 s.c om*/ import java.io.File; import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.content.LocalBroadcastManager; import com.binkery.app.filemanager.R; import com.binkery.app.filemanager.commons.Constants; import com.binkery.app.filemanager.utils.Logs; import com.binkery.app.filemanager.utils.ToastUtils; public class DeleteDialogFragment extends BaseDialogFragment { private static final String TAG = DeleteDialogFragment.class .getSimpleName(); @Override public Dialog onCreateDialog(Bundle savedInstanceState) { String message = "" + mPaths.length + "????"; return new AlertDialog.Builder(getActivity()).setTitle(R.string.delete) .setMessage("???? " + message + " ?") .setPositiveButton(R.string.delete, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { new DeleteTask(getActivity()).execute(mPaths); } }).setNegativeButton(R.string.cancel, null).create(); } private class DeleteTask extends AsyncTask<String[], Integer, Boolean> { private ProgressDialog dialog = null; private Context mContext = null; public DeleteTask(Context context) { mContext = context; dialog = new ProgressDialog(context); } @Override protected void onPreExecute() { super.onPreExecute(); dialog.setMessage(mContext.getString(R.string.delete)); dialog.setCancelable(false); dialog.show(); } @Override protected void onPostExecute(Boolean result) { super.onPostExecute(result); dialog.dismiss(); if (result) { ToastUtils.show(mContext, R.string.delete_file_success); Intent intent = new Intent(Constants.INTENT_FILE_DELETED); LocalBroadcastManager.getInstance(mContext).sendBroadcast( intent); Uri uri = Uri.fromFile(mFile); Logs.i(TAG, "uri = " + uri.toString()); Intent i = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri); mContext.sendBroadcast(i); } else { ToastUtils.show(mContext, R.string.delete_file_failed); } } @Override protected Boolean doInBackground(String[]... params) { String[] paths = params[0]; for(int i = 0 , len = paths.length;i<len;i++){ Logs.i(TAG, "delete file " + paths[i]); // boolean delete = com.binkery.app.filemanager.utils.FileUtils.delete(paths[i]); } return true; } } }