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
c06d7e6b15
commit
305cbcd679
|
@ -16,6 +16,7 @@ import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import one.nem.lacerta.model.FragmentNavigation;
|
||||||
import one.nem.lacerta.model.pref.FeatureSwitchOverride;
|
import one.nem.lacerta.model.pref.FeatureSwitchOverride;
|
||||||
import one.nem.lacerta.utils.FeatureSwitch;
|
import one.nem.lacerta.utils.FeatureSwitch;
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ import one.nem.lacerta.utils.repository.SharedPrefUtils;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity implements FragmentNavigation {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
SharedPrefUtils sharedPrefUtils;
|
SharedPrefUtils sharedPrefUtils;
|
||||||
|
@ -88,11 +89,11 @@ public class MainActivity extends AppCompatActivity {
|
||||||
if (!isEnabled) bottomNavigationView.getMenu().removeItem(menuId);
|
if (!isEnabled) bottomNavigationView.getMenu().removeItem(menuId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
@Override
|
||||||
// public void navigateToFragment(Fragment fragment) {
|
public void navigateToFragment(Fragment fragment) {
|
||||||
// getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
// .replace(R.id.nav_host_fragment, fragment)
|
.replace(R.id.nav_host_fragment, fragment)
|
||||||
// .addToBackStack(null)
|
.addToBackStack(null)
|
||||||
// .commit();
|
.commit();
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import dagger.hilt.android.AndroidEntryPoint;
|
||||||
import one.nem.lacerta.data.Document;
|
import one.nem.lacerta.data.Document;
|
||||||
import one.nem.lacerta.data.LacertaLibrary;
|
import one.nem.lacerta.data.LacertaLibrary;
|
||||||
import one.nem.lacerta.model.FragmentNavigation;
|
import one.nem.lacerta.model.FragmentNavigation;
|
||||||
|
import one.nem.lacerta.model.PublicPath;
|
||||||
import one.nem.lacerta.utils.LacertaLogger;
|
import one.nem.lacerta.utils.LacertaLogger;
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,6 +51,8 @@ public class LibraryPageFragment extends Fragment {
|
||||||
// Param
|
// Param
|
||||||
private String folderId;
|
private String folderId;
|
||||||
private String title;
|
private String title;
|
||||||
|
private String publicPath;
|
||||||
|
private PublicPath currentPublicPath;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
LacertaLibrary lacertaLibrary;
|
LacertaLibrary lacertaLibrary;
|
||||||
|
@ -65,11 +68,12 @@ public class LibraryPageFragment extends Fragment {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LibraryPageFragment newInstance(String folderId, String title) {
|
public static LibraryPageFragment newInstance(String folderId, String title, String publicPath) {
|
||||||
LibraryPageFragment fragment = new LibraryPageFragment();
|
LibraryPageFragment fragment = new LibraryPageFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString("folderId", folderId);
|
args.putString("folderId", folderId);
|
||||||
args.putString("title", title);
|
args.putString("title", title);
|
||||||
|
args.putString("publicPath", publicPath);
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
@ -79,6 +83,7 @@ public class LibraryPageFragment extends Fragment {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString("folderId", null);
|
args.putString("folderId", null);
|
||||||
args.putString("title", null);
|
args.putString("title", null);
|
||||||
|
args.putString("publicPath", null);
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +98,6 @@ public class LibraryPageFragment extends Fragment {
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View view = inflater.inflate(R.layout.fragment_library_top, container, false);
|
View view = inflater.inflate(R.layout.fragment_library_top, container, false);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +115,7 @@ public class LibraryPageFragment extends Fragment {
|
||||||
Toast.makeText(getContext(), "Folder selected! folderId: " + folderId + ", folderName: " + folderName, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "Folder selected! folderId: " + folderId + ", folderName: " + folderName, Toast.LENGTH_SHORT).show();
|
||||||
FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity();
|
FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity();
|
||||||
assert fragmentNavigation != null;
|
assert fragmentNavigation != null;
|
||||||
fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName));
|
fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, currentPublicPath.resolve(folderName).getStringPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -124,11 +128,20 @@ public class LibraryPageFragment extends Fragment {
|
||||||
|
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
this.folderId = getArguments().getString("folderId");
|
this.folderId = getArguments().getString("folderId");
|
||||||
|
this.title = getArguments().getString("title");
|
||||||
|
this.publicPath = getArguments().getString("publicPath");
|
||||||
|
// Log
|
||||||
|
logger.debug("LibraryTopFragment", "args"
|
||||||
|
+ ", folderId: " + this.folderId
|
||||||
|
+ ", title: " + this.title
|
||||||
|
+ ", publicPath: " + this.publicPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.folderId == null) { // Root
|
if (this.folderId == null) { // Root
|
||||||
toolbarSetup(view.findViewById(R.id.library_toolbar), false, "ライブラリ", "Placeholder");
|
toolbarSetup(view.findViewById(R.id.library_toolbar), false, "ライブラリ", "Placeholder");
|
||||||
lacertaLibrary.getLibraryPage(10).thenAccept(libraryItemPage -> {
|
lacertaLibrary.getLibraryPage(10).thenAccept(libraryItemPage -> {
|
||||||
|
this.currentPublicPath = new PublicPath().resolve("/");
|
||||||
|
logger.debug("LibraryInit(ROOT)",currentPublicPath.getStringPath());
|
||||||
logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
|
logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
|
||||||
listItemAdapter.setLibraryItemPage(libraryItemPage);
|
listItemAdapter.setLibraryItemPage(libraryItemPage);
|
||||||
getActivity().runOnUiThread(() -> {
|
getActivity().runOnUiThread(() -> {
|
||||||
|
@ -139,6 +152,8 @@ public class LibraryPageFragment extends Fragment {
|
||||||
} else { // Root以外
|
} else { // Root以外
|
||||||
toolbarSetup(view.findViewById(R.id.library_toolbar), true, this.title, "Placeholder");
|
toolbarSetup(view.findViewById(R.id.library_toolbar), true, this.title, "Placeholder");
|
||||||
lacertaLibrary.getLibraryPage(this.folderId, 10).thenAccept(libraryItemPage -> {
|
lacertaLibrary.getLibraryPage(this.folderId, 10).thenAccept(libraryItemPage -> {
|
||||||
|
this.currentPublicPath = new PublicPath().parse(this.publicPath);
|
||||||
|
logger.debug("LibraryInit(NON_ROOT)",currentPublicPath.getStringPath());
|
||||||
logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
|
logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
|
||||||
listItemAdapter.setLibraryItemPage(libraryItemPage);
|
listItemAdapter.setLibraryItemPage(libraryItemPage);
|
||||||
getActivity().runOnUiThread(() -> {
|
getActivity().runOnUiThread(() -> {
|
||||||
|
@ -180,7 +195,6 @@ public class LibraryPageFragment extends Fragment {
|
||||||
toolbar.setNavigationIcon(null);
|
toolbar.setNavigationIcon(null);
|
||||||
}
|
}
|
||||||
toolbar.setTitle(title);
|
toolbar.setTitle(title);
|
||||||
if (subtitle != null) toolbar.setSubtitle(subtitle);
|
|
||||||
toolbar.inflateMenu(R.menu.dir_menu);
|
toolbar.inflateMenu(R.menu.dir_menu);
|
||||||
toolbar.setOnMenuItemClickListener(item -> {
|
toolbar.setOnMenuItemClickListener(item -> {
|
||||||
if (item.getItemId() == R.id.menu_item_create_new_folder) {
|
if (item.getItemId() == R.id.menu_item_create_new_folder) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user