mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-22 16:03:15 +00:00
パスをサブタイトルに表示するように
This commit is contained in:
parent
c2f62a5a84
commit
e96d213c33
|
@ -23,6 +23,7 @@ import dagger.hilt.android.AndroidEntryPoint;
|
||||||
import one.nem.lacerta.component.viewer.ViewerMainActivity;
|
import one.nem.lacerta.component.viewer.ViewerMainActivity;
|
||||||
import one.nem.lacerta.data.LacertaLibrary;
|
import one.nem.lacerta.data.LacertaLibrary;
|
||||||
import one.nem.lacerta.model.LibraryItemPage;
|
import one.nem.lacerta.model.LibraryItemPage;
|
||||||
|
import one.nem.lacerta.model.ListItemType;
|
||||||
import one.nem.lacerta.utils.FeatureSwitch;
|
import one.nem.lacerta.utils.FeatureSwitch;
|
||||||
import one.nem.lacerta.utils.LacertaLogger;
|
import one.nem.lacerta.utils.LacertaLogger;
|
||||||
|
|
||||||
|
@ -43,6 +44,7 @@ public class LibraryPageFragment extends Fragment {
|
||||||
String folderId;
|
String folderId;
|
||||||
String title;
|
String title;
|
||||||
String parentId;
|
String parentId;
|
||||||
|
Toolbar toolbar;
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -128,12 +130,19 @@ public class LibraryPageFragment extends Fragment {
|
||||||
logger.debug("LibraryTopFragment", "getArguments() is null(maybe root)");
|
logger.debug("LibraryTopFragment", "getArguments() is null(maybe root)");
|
||||||
this.libraryItemPage = new LibraryItemPage();
|
this.libraryItemPage = new LibraryItemPage();
|
||||||
}
|
}
|
||||||
|
this.toolbar = view.findViewById(R.id.library_toolbar);
|
||||||
|
|
||||||
// Toolbar Setup
|
// Toolbar Setup
|
||||||
toolbarSetup(view.findViewById(R.id.library_toolbar), this.folderId != null, this.title != null ? this.title : "ライブラリ");
|
toolbarSetup(this.toolbar, this.folderId != null, this.title != null ? this.title : "ライブラリ");
|
||||||
|
if(this.folderId == null) {
|
||||||
|
updateToolbarSubtitle(this.toolbar, null); //負荷軽減のため+邪魔なので(folderIdがnullの場合は、ルートフォルダを表示しているので)
|
||||||
|
} else {
|
||||||
|
lacertaLibrary.getPublicPath(this.folderId, ListItemType.ITEM_TYPE_FOLDER).thenAccept(publicPath -> {
|
||||||
|
updateToolbarSubtitle(this.toolbar, "/" + publicPath.parent().getStringPath());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// RecyclerView Setup
|
// RecyclerView Setup
|
||||||
|
|
||||||
RecyclerView recyclerView = view.findViewById(R.id.library_item_recycler_view);
|
RecyclerView recyclerView = view.findViewById(R.id.library_item_recycler_view);
|
||||||
this.listItemAdapter = new ListItemAdapter(new DocumentSelectListener() {
|
this.listItemAdapter = new ListItemAdapter(new DocumentSelectListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -168,6 +177,7 @@ public class LibraryPageFragment extends Fragment {
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
|
||||||
// Get library page and update RecyclerView items
|
// Get library page and update RecyclerView items
|
||||||
|
|
||||||
lacertaLibrary.getLibraryPage(this.folderId, 10).thenAccept(libraryItemPage -> {
|
lacertaLibrary.getLibraryPage(this.folderId, 10).thenAccept(libraryItemPage -> {
|
||||||
this.libraryItemPage = libraryItemPage;
|
this.libraryItemPage = libraryItemPage;
|
||||||
|
|
||||||
|
@ -216,6 +226,7 @@ public class LibraryPageFragment extends Fragment {
|
||||||
lacertaLibrary.createFolder(pageId, input.getText().toString()).thenAccept(folderId -> {
|
lacertaLibrary.createFolder(pageId, input.getText().toString()).thenAccept(folderId -> {
|
||||||
// Refresh
|
// Refresh
|
||||||
updateItem(pageId);
|
updateItem(pageId);
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
builder.setNegativeButton("キャンセル", (dialog, which) -> {
|
builder.setNegativeButton("キャンセル", (dialog, which) -> {
|
||||||
|
@ -226,7 +237,7 @@ public class LibraryPageFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RecyclerViewのアイテムを更新する
|
* RecyclerViewのアイテムとUIを更新する
|
||||||
*/
|
*/
|
||||||
private void updateItem(String pageId) {
|
private void updateItem(String pageId) {
|
||||||
lacertaLibrary.getLibraryPage(pageId, 10).thenAccept(libraryItemPage -> {
|
lacertaLibrary.getLibraryPage(pageId, 10).thenAccept(libraryItemPage -> {
|
||||||
|
@ -242,6 +253,16 @@ public class LibraryPageFragment extends Fragment {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toolbarのサブタイトルを更新
|
||||||
|
* @param subtitle サブタイトル
|
||||||
|
*/
|
||||||
|
private void updateToolbarSubtitle(Toolbar toolbar, String subtitle) {
|
||||||
|
getActivity().runOnUiThread(() -> {
|
||||||
|
toolbar.setSubtitle(subtitle);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ToolbarをInitする
|
* ToolbarをInitする
|
||||||
*
|
*
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
<com.google.android.material.appbar.SubtitleCollapsingToolbarLayout
|
||||||
android:id="@+id/collapsing_toolbar"
|
android:id="@+id/collapsing_toolbar"
|
||||||
app:contentScrim="@color/colorSecondaryContainer"
|
app:contentScrim="@color/colorSecondaryContainer"
|
||||||
android:background="@color/colorSurface"
|
android:background="@color/colorSurface"
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
app:layout_collapseMode="pin"
|
app:layout_collapseMode="pin"
|
||||||
app:title="HOGE" />
|
app:title="HOGE" />
|
||||||
|
|
||||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
</com.google.android.material.appbar.SubtitleCollapsingToolbarLayout>
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user