mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
Adapter, Dialogベース実装
This commit is contained in:
parent
1654700ee0
commit
be64f5a186
|
@ -9,19 +9,24 @@ import android.widget.TextView;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import one.nem.lacerta.component.common.LacertaSelectDirDialogInternalEventListener;
|
||||
import one.nem.lacerta.model.LibraryItemPage;
|
||||
import one.nem.lacerta.model.ListItem;
|
||||
import one.nem.lacerta.model.ListItemType;
|
||||
|
||||
public class LacertaFilePickerAdapterBase extends RecyclerView.Adapter<LacertaFilePickerAdapterBase.LacertaFilePickerViewHolder> {
|
||||
|
||||
// Listener
|
||||
public interface LacertaFilePickerAdapterListener {
|
||||
void onItemSelected(String dirId);
|
||||
void onBackSelected(String dirId);
|
||||
}
|
||||
|
||||
private LibraryItemPage libraryItemPage;
|
||||
LacertaSelectDirDialogInternalEventListener listener;
|
||||
|
||||
public LacertaFilePickerAdapterBase(LacertaSelectDirDialogInternalEventListener listener) {
|
||||
this.listener = listener;
|
||||
private LacertaFilePickerAdapterListener listener;
|
||||
|
||||
// Empty constructor
|
||||
public LacertaFilePickerAdapterBase() {
|
||||
}
|
||||
|
||||
public void setListItems(LibraryItemPage libraryItemPage) {
|
||||
|
@ -31,6 +36,10 @@ public class LacertaFilePickerAdapterBase extends RecyclerView.Adapter<LacertaFi
|
|||
}
|
||||
}
|
||||
|
||||
public void setListener(LacertaFilePickerAdapterListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public LacertaFilePickerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
|
@ -47,7 +56,7 @@ public class LacertaFilePickerAdapterBase extends RecyclerView.Adapter<LacertaFi
|
|||
if(listItem.getItemType() == ListItemType.ITEM_TYPE_ACTION_BACK) {
|
||||
holder.itemView.setOnClickListener(v -> listener.onBackSelected(this.libraryItemPage.getParentId()));
|
||||
} else {
|
||||
holder.itemView.setOnClickListener(v -> listener.onDirSelected(listItem.getTitle(), listItem.getItemId()));
|
||||
holder.itemView.setOnClickListener(v -> listener.onItemSelected(listItem.getItemId()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,9 +48,7 @@ public class LacertaFilePickerDialogBase extends DialogFragment {
|
|||
}
|
||||
|
||||
// Methods
|
||||
protected void updateList(LacertaFilePickerAdapterBase adapter, LibraryItemPage libraryItemPage) {
|
||||
int currentCount = adapter.getItemCount();
|
||||
String currentDirId = adapter.getCurrentId();
|
||||
protected void updateList(LacertaFilePickerAdapterBase adapter, LibraryItemPage libraryItemPage, int currentCount, String currentDirId) {
|
||||
if (currentDirId == null) {
|
||||
// Rootが関わる推移 (Rootからの推移)
|
||||
adapter.setListItems(libraryItemPage);
|
||||
|
|
Loading…
Reference in New Issue
Block a user