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.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import one.nem.lacerta.component.common.LacertaSelectDirDialogInternalEventListener;
|
|
||||||
import one.nem.lacerta.model.LibraryItemPage;
|
import one.nem.lacerta.model.LibraryItemPage;
|
||||||
import one.nem.lacerta.model.ListItem;
|
import one.nem.lacerta.model.ListItem;
|
||||||
import one.nem.lacerta.model.ListItemType;
|
import one.nem.lacerta.model.ListItemType;
|
||||||
|
|
||||||
public class LacertaFilePickerAdapterBase extends RecyclerView.Adapter<LacertaFilePickerAdapterBase.LacertaFilePickerViewHolder> {
|
public class LacertaFilePickerAdapterBase extends RecyclerView.Adapter<LacertaFilePickerAdapterBase.LacertaFilePickerViewHolder> {
|
||||||
|
|
||||||
|
// Listener
|
||||||
|
public interface LacertaFilePickerAdapterListener {
|
||||||
|
void onItemSelected(String dirId);
|
||||||
|
void onBackSelected(String dirId);
|
||||||
|
}
|
||||||
|
|
||||||
private LibraryItemPage libraryItemPage;
|
private LibraryItemPage libraryItemPage;
|
||||||
LacertaSelectDirDialogInternalEventListener listener;
|
|
||||||
|
|
||||||
public LacertaFilePickerAdapterBase(LacertaSelectDirDialogInternalEventListener listener) {
|
private LacertaFilePickerAdapterListener listener;
|
||||||
this.listener = listener;
|
|
||||||
|
// Empty constructor
|
||||||
|
public LacertaFilePickerAdapterBase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setListItems(LibraryItemPage libraryItemPage) {
|
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
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public LacertaFilePickerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
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) {
|
if(listItem.getItemType() == ListItemType.ITEM_TYPE_ACTION_BACK) {
|
||||||
holder.itemView.setOnClickListener(v -> listener.onBackSelected(this.libraryItemPage.getParentId()));
|
holder.itemView.setOnClickListener(v -> listener.onBackSelected(this.libraryItemPage.getParentId()));
|
||||||
} else {
|
} 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
|
// Methods
|
||||||
protected void updateList(LacertaFilePickerAdapterBase adapter, LibraryItemPage libraryItemPage) {
|
protected void updateList(LacertaFilePickerAdapterBase adapter, LibraryItemPage libraryItemPage, int currentCount, String currentDirId) {
|
||||||
int currentCount = adapter.getItemCount();
|
|
||||||
String currentDirId = adapter.getCurrentId();
|
|
||||||
if (currentDirId == null) {
|
if (currentDirId == null) {
|
||||||
// Rootが関わる推移 (Rootからの推移)
|
// Rootが関わる推移 (Rootからの推移)
|
||||||
adapter.setListItems(libraryItemPage);
|
adapter.setListItems(libraryItemPage);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user