mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-22 16:03:15 +00:00
提出用: 代替処理実装
This commit is contained in:
parent
32b238df58
commit
ce4656558a
|
@ -1,6 +1,7 @@
|
|||
package one.nem.lacerta.data.impl;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -99,12 +100,14 @@ public class LacertaLibraryImpl implements LacertaLibrary {
|
|||
listItems.add(listItem);
|
||||
}
|
||||
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:");
|
||||
|
||||
for (DocumentEntity documentEntity : documentEntities) {
|
||||
logger.debug("LacertaLibraryImpl", "documentEntity.title: " + documentEntity.title);
|
||||
ListItem listItem = new ListItem();
|
||||
listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT);
|
||||
listItem.setTitle(documentEntity.title);
|
||||
// listItem.setDescription(DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm").format(documentEntity.updatedAt.toInstant()));
|
||||
listItem.setDescription(simpleDateFormat.format(documentEntity.updatedAt));
|
||||
listItem.setItemId(documentEntity.id);
|
||||
listItems.add(listItem);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,8 @@ import one.nem.lacerta.data.Document;
|
|||
import one.nem.lacerta.data.LacertaLibrary;
|
||||
import one.nem.lacerta.model.ListItem;
|
||||
import one.nem.lacerta.model.document.DocumentMeta;
|
||||
|
||||
import one.nem.lacerta.utils.FeatureSwitch;
|
||||
import one.nem.lacerta.utils.Store;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -99,7 +100,13 @@ public class HomeTopFragment extends Fragment {
|
|||
}
|
||||
listItemAdapter.setListItems(listItems);
|
||||
getActivity().runOnUiThread(() -> {
|
||||
listItemAdapter.notifyItemRangeInserted(0, listItems.size() - 1);
|
||||
Log.d("HomeTopFragment", "onViewCreated: " + listItems.size());
|
||||
if (FeatureSwitch.RecyclerView.useSimpleNotifyMethod) {
|
||||
listItemAdapter.notifyDataSetChanged();
|
||||
} else {
|
||||
// IndexOutOfBoundsExceptionを吐くことがあったので
|
||||
listItemAdapter.notifyItemRangeInserted(0, listItems.size() - 1);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -54,7 +54,11 @@ public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListIt
|
|||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return listItems == null ? 0 : listItems.size();
|
||||
if (listItems == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return listItems.size();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ListItemViewHolder extends RecyclerView.ViewHolder{
|
||||
|
|
|
@ -40,6 +40,7 @@ import one.nem.lacerta.data.LacertaLibrary;
|
|||
import one.nem.lacerta.model.FragmentNavigation;
|
||||
import one.nem.lacerta.model.LibraryItemPage;
|
||||
import one.nem.lacerta.model.PublicPath;
|
||||
import one.nem.lacerta.utils.FeatureSwitch;
|
||||
import one.nem.lacerta.utils.LacertaLogger;
|
||||
|
||||
|
||||
|
@ -199,12 +200,18 @@ public class LibraryPageFragment extends Fragment {
|
|||
}
|
||||
|
||||
logger.debug("LibraryTopFragment", "Item selected! Total item page: " + this.libraryItemPage.getListItems().size());
|
||||
getActivity().runOnUiThread(() -> { // TODO-rca: 実行条件を考える?
|
||||
listItemAdapter.notifyItemRangeRemoved(0, this.libraryItemPage.getListItems().size() - 1);
|
||||
});
|
||||
if (!FeatureSwitch.RecyclerView.useSimpleNotifyMethod) {
|
||||
getActivity().runOnUiThread(() -> { // TODO-rca: 実行条件を考える?
|
||||
listItemAdapter.notifyItemRangeRemoved(0, this.libraryItemPage.getListItems().size() - 1);
|
||||
});
|
||||
}
|
||||
listItemAdapter.setLibraryItemPage(this.libraryItemPage);
|
||||
getActivity().runOnUiThread(() -> {
|
||||
listItemAdapter.notifyItemRangeInserted(0, this.libraryItemPage.getListItems().size() - 1);
|
||||
if (FeatureSwitch.RecyclerView.useSimpleNotifyMethod) {
|
||||
listItemAdapter.notifyDataSetChanged();
|
||||
} else {
|
||||
listItemAdapter.notifyItemRangeInserted(0, this.libraryItemPage.getListItems().size() - 1);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -6,6 +6,10 @@ public class FeatureSwitch {
|
|||
public static boolean canOverrideSwitch = false;
|
||||
}
|
||||
|
||||
public static class RecyclerView {
|
||||
public static boolean useSimpleNotifyMethod = true;
|
||||
}
|
||||
|
||||
public static class FeatureMaster {
|
||||
public static boolean enableSearch = false;
|
||||
public static boolean enableDebugMenu = true;
|
||||
|
|
Loading…
Reference in New Issue
Block a user