mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-30 03:23:16 +00:00
タイトル, メッセージ, 選択肢のテキストを指定できるように, 決定されたらイベントを呼ぶように
This commit is contained in:
parent
4f864eb57d
commit
74ee492b49
|
@ -27,12 +27,49 @@ public class LacertaSelectDirDialog extends DialogFragment {
|
||||||
@Inject
|
@Inject
|
||||||
LacertaLogger logger;
|
LacertaLogger logger;
|
||||||
|
|
||||||
|
private LacertaSelectDirDialogListener listener;
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
private String positiveButtonText;
|
||||||
|
|
||||||
|
private String negativeButtonText;
|
||||||
|
|
||||||
private SelectDirDialogItemAdapter adapter;
|
private SelectDirDialogItemAdapter adapter;
|
||||||
|
|
||||||
private RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
|
|
||||||
private TextView current_dir_text_view;
|
private TextView current_dir_text_view;
|
||||||
|
|
||||||
|
// Setter
|
||||||
|
|
||||||
|
public LacertaSelectDirDialog setListener(LacertaSelectDirDialogListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LacertaSelectDirDialog setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LacertaSelectDirDialog setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LacertaSelectDirDialog setPositiveButtonText(String positiveButtonText) {
|
||||||
|
this.positiveButtonText = positiveButtonText;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LacertaSelectDirDialog setNegativeButtonText(String negativeButtonText) {
|
||||||
|
this.negativeButtonText = negativeButtonText;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
@ -66,10 +103,20 @@ public class LacertaSelectDirDialog extends DialogFragment {
|
||||||
|
|
||||||
showRecyclerViewItem(null); // get root folder
|
showRecyclerViewItem(null); // get root folder
|
||||||
|
|
||||||
builder.setTitle("Select Directory");
|
builder.setTitle(this.title == null ? "Select a directory" : this.title);
|
||||||
builder.setMessage("Please select a directory.");
|
builder.setMessage(this.message == null ? "Select a directory" : this.message);
|
||||||
builder.setPositiveButton("OK", null);
|
builder.setPositiveButton(this.positiveButtonText == null ? "OK" : this.positiveButtonText, (dialog, which) -> {
|
||||||
builder.setNegativeButton("Cancel", null);
|
if (listener != null) {
|
||||||
|
listener.onDirSelected(
|
||||||
|
adapter.getCurrentPageTitle() == null ? null : adapter.getCurrentPageTitle(),
|
||||||
|
adapter.getCurrentId() == null ? null : adapter.getCurrentId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton(this.negativeButtonText == null ? "Cancel" : this.negativeButtonText, (dialog, which) -> {
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onCanceled();
|
||||||
|
}
|
||||||
|
});
|
||||||
return builder.create();
|
return builder.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,18 @@ public class SelectDirDialogItemAdapter extends RecyclerView.Adapter<SelectDirDi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCurrentPageTitle() {
|
||||||
|
if (this.libraryItemPage == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
if (this.libraryItemPage.getPageId() == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return this.libraryItemPage.getPageTitle()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class SelectDirDialogItemViewHolder extends RecyclerView.ViewHolder {
|
public static class SelectDirDialogItemViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
TextView title;
|
TextView title;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user