mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-26 09:43:15 +00:00
フォルダを作成できるように
This commit is contained in:
parent
b2c6085933
commit
81fa259985
|
@ -157,12 +157,11 @@ public class LacertaLibraryImpl implements LacertaLibrary {
|
||||||
} else {
|
} else {
|
||||||
publicPath = new PublicPath().resolve(parentFolderEntity.publicPath);
|
publicPath = new PublicPath().resolve(parentFolderEntity.publicPath);
|
||||||
}
|
}
|
||||||
publicPath = publicPath.resolve(name);
|
|
||||||
|
|
||||||
FolderEntity folderEntity = new FolderEntity();
|
FolderEntity folderEntity = new FolderEntity();
|
||||||
folderEntity.id = UUID.randomUUID().toString();
|
folderEntity.id = UUID.randomUUID().toString();
|
||||||
folderEntity.name = name;
|
folderEntity.name = name;
|
||||||
folderEntity.publicPath = publicPath.toString();
|
folderEntity.publicPath = publicPath.getStringPath();
|
||||||
database.folderDao().insert(folderEntity);
|
database.folderDao().insert(folderEntity);
|
||||||
return folderEntity.id;
|
return folderEntity.id;
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,6 +13,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
@ -51,6 +52,10 @@ public class LibraryTopFragment extends Fragment {
|
||||||
@Inject
|
@Inject
|
||||||
LacertaLogger logger;
|
LacertaLogger logger;
|
||||||
|
|
||||||
|
ListItemAdapter listItemAdapter;
|
||||||
|
|
||||||
|
int currentTotalItemCount = 0;
|
||||||
|
|
||||||
public LibraryTopFragment() {
|
public LibraryTopFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
}
|
}
|
||||||
|
@ -83,7 +88,7 @@ public class LibraryTopFragment extends Fragment {
|
||||||
|
|
||||||
RecyclerView recyclerView = view.findViewById(R.id.library_item_recycler_view);
|
RecyclerView recyclerView = view.findViewById(R.id.library_item_recycler_view);
|
||||||
|
|
||||||
ListItemAdapter listItemAdapter = new ListItemAdapter(documentId -> {
|
this.listItemAdapter = new ListItemAdapter(documentId -> {
|
||||||
Toast.makeText(getContext(), documentId, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), documentId, Toast.LENGTH_SHORT).show();
|
||||||
});
|
});
|
||||||
recyclerView.setAdapter(listItemAdapter);
|
recyclerView.setAdapter(listItemAdapter);
|
||||||
|
@ -92,8 +97,9 @@ public class LibraryTopFragment extends Fragment {
|
||||||
lacertaLibrary.getLibraryPage(10).thenAccept(libraryItemPage -> {
|
lacertaLibrary.getLibraryPage(10).thenAccept(libraryItemPage -> {
|
||||||
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);
|
||||||
|
this.currentTotalItemCount = libraryItemPage.getListItems().size();
|
||||||
getActivity().runOnUiThread(() -> {
|
getActivity().runOnUiThread(() -> {
|
||||||
listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1);
|
listItemAdapter.notifyItemRangeInserted(0, this.currentTotalItemCount - 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -103,4 +109,33 @@ public class LibraryTopFragment extends Fragment {
|
||||||
inflater.inflate(R.menu.dir_menu, menu);
|
inflater.inflate(R.menu.dir_menu, menu);
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Selected
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
|
if (item.getItemId() == R.id.menu_item_create_new_folder) {
|
||||||
|
lacertaLibrary.createFolder(null, "New Folder").thenAccept(folderId -> {
|
||||||
|
logger.debug("LibraryTopFragment", "folderId: " + folderId);
|
||||||
|
});
|
||||||
|
// Refresh
|
||||||
|
updateItem();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateItem() {
|
||||||
|
lacertaLibrary.getLibraryPage(10).thenAccept(libraryItemPage -> {
|
||||||
|
logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
|
||||||
|
getActivity().runOnUiThread(() -> {
|
||||||
|
listItemAdapter.notifyItemRangeRemoved(0, this.currentTotalItemCount - 1);
|
||||||
|
});
|
||||||
|
listItemAdapter.setLibraryItemPage(libraryItemPage);
|
||||||
|
getActivity().runOnUiThread(() -> {
|
||||||
|
listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1);
|
||||||
|
});
|
||||||
|
this.currentTotalItemCount = libraryItemPage.getListItems().size();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user