我偶尔会看到我不太了解的例外情况.这是我的工作:我有一个界面
public interface IResultProcessor<T> extends Serializable {
void processResult(T result);
}
Run Code Online (Sandbox Code Playgroud)
,我在这个课程中使用的实例:
public class ConfirmationDialogFragment extends DialogFragment {
public static void executeAfterConfirmation(FragmentActivity activity, IResultProcessor<Void> runnable,
String title, String message, int icon, String positiveButtonText, String negativeButtonText) {
ConfirmationDialogFragment fragment = new ConfirmationDialogFragment();
Bundle args = new Bundle();
args.putSerializable(ARG_RUNNABLE, runnable);
fragment.setArguments(args);
fragment.show(activity.getSupportFragmentManager(), "dialog");
}
}
Run Code Online (Sandbox Code Playgroud)
在该onCreateDialog()方法中,我接收IProcessResult实例并在用户确认后执行它.
然后我在一个活动中使用所有这些,如下所示:
@SuppressWarnings("serial")
IResultProcessor<Void> processor = new IResultProcessor<Void>() {
@Override
public void processResult(Void result) {
new AsyncTask<Void, Void, String>() {
@Override
protected String …Run Code Online (Sandbox Code Playgroud)