イベントをContainerまで伝達させるように

This commit is contained in:
r-ca 2024-01-29 00:47:34 +09:00
parent 8542869a63
commit 3715627c07
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9
2 changed files with 18 additions and 4 deletions

View File

@ -39,8 +39,8 @@ public class LacertaApplyTagDialog extends DialogFragment {
// Listener
public interface LacertaApplyTagDialogListener {
void onDialogPositiveClick(DialogFragment dialog);
void onDialogNegativeClick(DialogFragment dialog);
void onDialogPositiveClick(ArrayList<DocumentTag> appliedTags);
void onDialogNegativeClick();
}
// Variables
@ -121,11 +121,11 @@ public class LacertaApplyTagDialog extends DialogFragment {
.setView(view)
.setPositiveButton(positiveButtonText == null ? "OK" : positiveButtonText, (dialog, id) -> {
// Send the positive button event back to the host activity
listener.onDialogPositiveClick(LacertaApplyTagDialog.this);
listener.onDialogPositiveClick(this.appliedTags);
})
.setNegativeButton(negativeButtonText == null ? "Cancel" : negativeButtonText, (dialog, id) -> {
// Send the negative button event back to the host activity
listener.onDialogNegativeClick(LacertaApplyTagDialog.this);
listener.onDialogNegativeClick();
});
return builder.create();
}

View File

@ -19,6 +19,8 @@ import com.google.android.material.tabs.TabLayoutMediator;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import java.util.ArrayList;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
@ -27,6 +29,7 @@ import one.nem.lacerta.component.common.picker.LacertaFilePickerDialog;
import one.nem.lacerta.data.Document;
import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.model.document.page.Page;
import one.nem.lacerta.model.document.tag.DocumentTag;
import one.nem.lacerta.model.pref.ToxiDocumentModel;
import one.nem.lacerta.utils.LacertaLogger;
@ -205,6 +208,17 @@ public class ViewerContainerFragment extends Fragment {
.setMessage("タグを適用するファイルを選択してください")
.setNegativeButtonText("キャンセル")
.setDocumentId(documentId)
.setListener(new LacertaApplyTagDialog.LacertaApplyTagDialogListener() {
@Override
public void onDialogPositiveClick(ArrayList<DocumentTag> appliedTags) {
// 適用
}
@Override
public void onDialogNegativeClick() {
lacertaApplyTagDialog.dismiss();
}
})
.show(getChildFragmentManager(), "LacertaApplyTagDialog");
}