mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-22 16:03:15 +00:00
WIP
This commit is contained in:
parent
58f9d81555
commit
5f89955d80
|
@ -21,6 +21,7 @@ import javax.inject.Inject;
|
|||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
import one.nem.lacerta.data.LacertaLibrary;
|
||||
import one.nem.lacerta.model.ListItemType;
|
||||
import one.nem.lacerta.utils.LacertaLogger;
|
||||
|
||||
@AndroidEntryPoint
|
||||
public class LacertaSelectDirDialog extends DialogFragment {
|
||||
|
@ -28,6 +29,9 @@ public class LacertaSelectDirDialog extends DialogFragment {
|
|||
@Inject
|
||||
LacertaLibrary lacertaLibrary;
|
||||
|
||||
@Inject
|
||||
LacertaLogger logger;
|
||||
|
||||
private SelectDirDialogItemAdapter adapter;
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
|
@ -83,14 +87,29 @@ public class LacertaSelectDirDialog extends DialogFragment {
|
|||
lacertaLibrary.getFolderList(targetDirId).thenAccept(libraryItemPage -> {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
int currentCount = adapter.getItemCount();
|
||||
if (targetDirId == null) { // When root folder
|
||||
String currentDirId = adapter.getCurrentId();
|
||||
if (currentDirId == null && libraryItemPage.getPageId() != null) {
|
||||
// Rootから推移してきた場合
|
||||
adapter.setListItems(libraryItemPage);
|
||||
adapter.notifyItemRangeRemoved(0, currentCount);
|
||||
adapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size());
|
||||
} else { // When child folder
|
||||
} else if (libraryItemPage.getPageId() == null) {
|
||||
// Rootに推移した場合
|
||||
adapter.setListItems(libraryItemPage);
|
||||
adapter.notifyItemRangeRemoved(0, currentCount);
|
||||
adapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size());
|
||||
} else if (currentDirId != null && libraryItemPage.getPageId() != null) {
|
||||
// 通常の遷移
|
||||
adapter.setListItems(libraryItemPage);
|
||||
adapter.notifyItemRangeRemoved(1, currentCount);
|
||||
adapter.notifyItemRangeInserted(1, libraryItemPage.getListItems().size());
|
||||
} else {
|
||||
// その他の遷移(安全側に倒すため全アイテム更新)
|
||||
logger.warn("LacertaSelectDirDialog", "Unknown transition.");
|
||||
logger.warn("LacertaSelectDirDialog", "currentDirId: " + currentDirId + ", libraryItemPage.getPageId(): " + libraryItemPage.getPageId());
|
||||
adapter.setListItems(libraryItemPage);
|
||||
adapter.notifyItemRangeRemoved(0, currentCount);
|
||||
adapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -58,6 +58,10 @@ public class SelectDirDialogItemAdapter extends RecyclerView.Adapter<SelectDirDi
|
|||
return this.libraryItemPage == null ? 0 : this.libraryItemPage.getListItems().size();
|
||||
}
|
||||
|
||||
public String getCurrentId() {
|
||||
return this.libraryItemPage == null ? null : this.libraryItemPage.getPageId();
|
||||
}
|
||||
|
||||
public static class SelectDirDialogItemViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView title;
|
||||
|
|
|
@ -136,7 +136,7 @@ public class LacertaLibraryImpl implements LacertaLibrary {
|
|||
if (targetDirId == null) { // When root folder
|
||||
folderEntities = database.folderDao().findRootFolders();
|
||||
libraryItemPage.setParentId(null);
|
||||
libraryItemPage.setPageId(targetDirId);
|
||||
libraryItemPage.setPageId(null);
|
||||
libraryItemPage.setPageTitle("ライブラリ");
|
||||
} else {
|
||||
folderEntities = database.folderDao().findByParentId(targetDirId);
|
||||
|
|
Loading…
Reference in New Issue
Block a user