Simplification

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

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

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

Loading…
Cancel
Save