From 13e8ee7d87dea51e8c41e36ca79f4964ea009787 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 10:58:22 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=87=E3=83=BC=E3=82=BF=E3=82=BB=E3=83=83?= =?UTF-8?q?=E3=83=88=E6=9B=B4=E6=96=B0=E3=82=92Ui=E3=82=B9=E3=83=AC?= =?UTF-8?q?=E3=83=83=E3=83=89=E3=81=A7=E3=82=84=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB(IndexOutOfBounds=E5=AF=BE=E7=AD=96,=20=E3=83=87?= =?UTF-8?q?=E3=83=90=E3=82=A4=E3=82=B9=E3=81=AE=E3=82=B9=E3=83=9A=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=81=AA=E3=81=A9=E3=81=AE=E9=83=BD=E5=90=88=E3=81=A7?= =?UTF-8?q?=E6=8C=BF=E5=85=A5=E3=81=8C=E6=9B=B4=E6=96=B0=E3=81=AB=E8=BF=BD?= =?UTF-8?q?=E3=81=84=E3=81=A4=E3=81=8B=E3=81=AA=E3=81=84=E3=81=A8=E5=A3=8A?= =?UTF-8?q?=E3=82=8C=E3=82=8B=E3=81=9F=E3=82=81)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/picker/LacertaDirPickerDialog.java | 20 +++++++++++++++---- .../base/LacertaFilePickerDialogBase.java | 6 +++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java index 683f158a..5d135b10 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java @@ -18,6 +18,8 @@ import one.nem.lacerta.component.common.R; import one.nem.lacerta.component.common.picker.base.LacertaFilePickerAdapterBase; import one.nem.lacerta.component.common.picker.base.LacertaFilePickerDialogBase; import one.nem.lacerta.data.LacertaLibrary; +import one.nem.lacerta.model.ListItemType; +import one.nem.lacerta.model.PublicPath; @AndroidEntryPoint public class LacertaDirPickerDialog extends LacertaFilePickerDialogBase { @@ -53,13 +55,13 @@ public class LacertaDirPickerDialog extends LacertaFilePickerDialogBase { @Override public void onItemSelected(String dirId) { updateList(adapter, dirId); - currentDirTextView.setText(dirId); + updatePublicPath(currentDirTextView, dirId); } @Override public void onBackSelected(String dirId) { updateList(adapter, dirId); - currentDirTextView.setText(dirId); + updatePublicPath(currentDirTextView, dirId); } }); @@ -88,10 +90,20 @@ public class LacertaDirPickerDialog extends LacertaFilePickerDialogBase { return builder.create(); } + private void updatePublicPath(TextView currentDirTextView, String folderId) { + lacertaLibrary.getPublicPath(folderId, ListItemType.ITEM_TYPE_FOLDER).thenAccept(publicPath -> { + this.updatePathTextView(currentDirTextView, publicPath); + }); + } + private void updateList(LacertaFilePickerAdapterBase adapter, String folderId) { lacertaLibrary.getFolderList(folderId).thenAccept(libraryItemPage -> { - adapter.setListItems(libraryItemPage); - this.updateListView(adapter, libraryItemPage, adapter.getItemCount(), adapter.getCurrentId()); + int currentCount = adapter.getItemCount(); + String currentId = adapter.getCurrentId(); +// adapter.setListItems(libraryItemPage); + getActivity().runOnUiThread(() -> { + this.updateListView(adapter, libraryItemPage, currentCount, currentId); + }); }); } } diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java index b765690a..2fedd677 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java @@ -51,7 +51,11 @@ public class LacertaFilePickerDialogBase extends DialogFragment { } } protected void updateListView(LacertaFilePickerAdapterBase adapter, LibraryItemPage libraryItemPage, int currentCount, String currentDirId) { - if (currentDirId == null) { + if (currentCount == 0) { + // 初回表示 + adapter.setListItems(libraryItemPage); + adapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size()); + } else if (currentDirId == null) { // Rootが関わる推移 (Rootからの推移) adapter.setListItems(libraryItemPage); adapter.notifyItemRangeRemoved(0, currentCount);