Passed alertDialogShower in bundle

This commit is contained in:
Sonu Sourav 2020-03-26 17:27:22 +05:30
parent 92e92eafcb
commit b470198d79
3 changed files with 8 additions and 1 deletions

View File

@ -243,6 +243,9 @@ public class AddNoteDialog extends DialogFragment
// Custom AlertDialog for taking user confirmation before closing note dialog in case of unsaved changes
DialogFragment newFragment = new ConfirmationAlertDialogFragment(sharedPreferenceUtil, TAG,
R.string.confirmation_alert_dialog_message, alertDialogShower);
Bundle bundle = new Bundle();
bundle.putSerializable("alertDialogShower", alertDialogShower);
newFragment.setArguments(bundle);
newFragment.show(getActivity().getSupportFragmentManager(),
ConfirmationAlertDialogFragment.TAG);
}

View File

@ -63,6 +63,8 @@ public class ConfirmationAlertDialogFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Fragment parentDialogFragment = getFragmentManager().findFragmentByTag(parentDialogFragmentTAG);
Bundle bundle = getArguments();
alertDialogShower = (AlertDialogShower) bundle.getSerializable("alertDialogShower");
return alertDialogShower.create(new KiwixDialog.ConfirmationAlertDialogFragment(stringResourceId),
() -> {
if (parentDialogFragment != null) {

View File

@ -21,9 +21,11 @@ package org.kiwix.kiwixmobile.core.utils
import android.app.Activity
import android.app.Dialog
import androidx.appcompat.app.AlertDialog
import java.io.Serializable
import javax.inject.Inject
class AlertDialogShower @Inject constructor(private val activity: Activity) : DialogShower {
class AlertDialogShower @Inject constructor(private val activity: Activity) : DialogShower,
Serializable {
override fun show(dialog: KiwixDialog, vararg clickListeners: () -> Unit) {
create(dialog, *clickListeners).show()
}