Simplification

pull/157/head
M66B 6 years ago
parent 5354e4eadd
commit 4b1da12f81

@ -120,27 +120,28 @@ public class FragmentDialogDuration extends DialogFragment {
if (duration < 0)
duration = 0;
Log.i("Set duration=" + duration + " time=" + new Date(cal.getTimeInMillis()));
sendResult(RESULT_OK, duration, cal.getTimeInMillis());
Bundle args = getArguments();
args.putLong("duration", duration);
args.putLong("time", cal.getTimeInMillis());
sendResult(RESULT_OK);
}
})
.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
sendResult(RESULT_CANCELED, 0, 0);
sendResult(RESULT_CANCELED);
}
})
.create();
}
private void sendResult(int result, long duration, long time) {
Bundle args = getArguments();
args.putLong("duration", duration);
args.putLong("time", time);
private void sendResult(int result) {
Fragment target = getTargetFragment();
if (target != null) {
Intent data = new Intent();
data.putExtra("args", args);
data.putExtra("args", getArguments());
target.onActivityResult(getTargetRequestCode(), result, data);
}
}

@ -82,7 +82,11 @@ public class FragmentDialogFolder extends DialogFragment {
@Override
public void onFolderSelected(TupleFolderEx folder) {
dismiss();
sendResult(RESULT_OK, folder.id);
Bundle args = getArguments();
args.putLong("folder", folder.id);
sendResult(RESULT_OK);
}
});
@ -107,20 +111,17 @@ public class FragmentDialogFolder extends DialogFragment {
.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
sendResult(RESULT_CANCELED, -1);
sendResult(RESULT_CANCELED);
}
})
.create();
}
private void sendResult(int result, long folder) {
Bundle args = getArguments();
args.putLong("folder", folder);
private void sendResult(int result) {
Fragment target = getTargetFragment();
if (target != null) {
Intent data = new Intent();
data.putExtra("args", args);
data.putExtra("args", getArguments());
target.onActivityResult(getTargetRequestCode(), result, data);
}
}

Loading…
Cancel
Save