mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
RevDialog実装WIP
This commit is contained in:
parent
ffeb701b40
commit
3cfd54faf0
|
@ -0,0 +1,78 @@
|
|||
package one.nem.lacerta.component.common;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
public class LacertaSelectRevDialog extends DialogFragment {
|
||||
|
||||
String title;
|
||||
String message;
|
||||
String negativeButtonText;
|
||||
|
||||
LacertaSelectRevDialogListener listener;
|
||||
|
||||
public LacertaSelectRevDialog setTitle(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LacertaSelectRevDialog setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LacertaSelectRevDialog setNegativeButtonText(String negativeButtonText) {
|
||||
this.negativeButtonText = negativeButtonText;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LacertaSelectRevDialog setListener(LacertaSelectRevDialogListener listener) {
|
||||
this.listener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
super.onCreateDialog(savedInstanceState);
|
||||
|
||||
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity());
|
||||
LayoutInflater inflater = requireActivity().getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.lacerta_dialog_select_rev, null);
|
||||
|
||||
int height = (int) (getResources().getDisplayMetrics().heightPixels * 0.4);
|
||||
view.setMinimumHeight(height);
|
||||
|
||||
RecyclerView recyclerView = view.findViewById(R.id.select_rev_recycler_view);
|
||||
|
||||
SelectRevDialogItemAdapter adapter = new SelectRevDialogItemAdapter(revId -> {
|
||||
if (listener != null) {
|
||||
listener.onItemSelected(revId);
|
||||
}
|
||||
dismiss();
|
||||
});
|
||||
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
builder.setView(view);
|
||||
builder.setTitle(title == null ? "Select Rev" : title);
|
||||
builder.setMessage(message == null ? "Select Rev" : message);
|
||||
builder.setNegativeButton(negativeButtonText, (dialog, which) -> {
|
||||
if (listener != null) {
|
||||
listener.onDialogCanceled();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package one.nem.lacerta.component.common;
|
||||
|
||||
public interface LacertaSelectRevDialogInternalListener {
|
||||
|
||||
void onItemSelected(String revId);
|
||||
}
|
|
@ -2,6 +2,7 @@ package one.nem.lacerta.component.common;
|
|||
|
||||
public interface LacertaSelectRevDialogListener {
|
||||
|
||||
void onPositiveButtonClick(String rev);
|
||||
void onNegativeButtonClick();
|
||||
void onItemSelected(String revId);
|
||||
|
||||
void onDialogCanceled();
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ public class SelectRevDialogItemAdapter extends RecyclerView.Adapter<SelectRevDi
|
|||
|
||||
ArrayList<VcsRevModel> revList;
|
||||
|
||||
LacertaSelectRevDialogListener listener;
|
||||
LacertaSelectRevDialogInternalListener listener;
|
||||
|
||||
public SelectRevDialogItemAdapter(LacertaSelectRevDialogListener listener) {
|
||||
public SelectRevDialogItemAdapter(LacertaSelectRevDialogInternalListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import javax.inject.Inject;
|
|||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
import one.nem.lacerta.component.common.LacertaSelectDirDialog;
|
||||
import one.nem.lacerta.component.common.LacertaSelectDirDialogListener;
|
||||
import one.nem.lacerta.component.common.LacertaSelectRevDialog;
|
||||
import one.nem.lacerta.data.Document;
|
||||
import one.nem.lacerta.data.LacertaLibrary;
|
||||
import one.nem.lacerta.model.ListItemType;
|
||||
|
@ -176,9 +177,12 @@ public class ViewerListFragment extends Fragment {
|
|||
toolbar.setOnMenuItemClickListener(item -> {
|
||||
if (item.getItemId() == R.id.action_open_vcs_rev_list) {
|
||||
// Open vcs rev list
|
||||
getParentFragmentManager().beginTransaction()
|
||||
.replace(R.id.nav_host_fragment, ViewerVcsRevListFragment.newInstance(documentId, documentName))
|
||||
.commit();
|
||||
// getParentFragmentManager().beginTransaction()
|
||||
// .replace(R.id.nav_host_fragment, ViewerVcsRevListFragment.newInstance(documentId, documentName))
|
||||
// .commit();
|
||||
|
||||
LacertaSelectRevDialog lacertaSelectRevDialog = new LacertaSelectRevDialog();
|
||||
lacertaSelectRevDialog.show(getParentFragmentManager(), "select_rev_dialog");
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.action_rename) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user