use of org.wikipedia.readinglist.database.ReadingList in project apps-android-wikipedia by wikimedia.
the class AddToReadingListDialog method showCreateListDialog.
private void showCreateListDialog() {
String title = getString(R.string.reading_list_name_sample);
List<String> existingTitles = new ArrayList<>();
for (ReadingList tempList : readingLists) {
existingTitles.add(tempList.title());
}
ReadingListTitleDialog.readingListTitleDialog(requireContext(), title, "", existingTitles, (text, description) -> {
ReadingList list = ReadingListDbHelper.instance().createList(text, description);
addAndDismiss(list, titles);
}).show();
}
use of org.wikipedia.readinglist.database.ReadingList in project apps-android-wikipedia by wikimedia.
the class ReadingListsFragment method showDeleteListUndoSnackbar.
private void showDeleteListUndoSnackbar(final ReadingList readingList) {
Snackbar snackbar = FeedbackUtil.makeSnackbar(getActivity(), String.format(getString(R.string.reading_list_deleted), readingList.title()), FeedbackUtil.LENGTH_DEFAULT);
snackbar.setAction(R.string.reading_list_item_delete_undo, v -> {
ReadingList newList = ReadingListDbHelper.instance().createList(readingList.title(), readingList.description());
List<ReadingListPage> newPages = new ArrayList<>();
for (ReadingListPage page : readingList.pages()) {
newPages.add(new ReadingListPage(ReadingListPage.toPageTitle(page)));
}
ReadingListDbHelper.instance().addPagesToList(newList, newPages, true);
updateLists();
});
snackbar.show();
}
use of org.wikipedia.readinglist.database.ReadingList in project apps-android-wikipedia by wikimedia.
the class ReadingListsFragment method maybeDeleteListFromIntent.
private void maybeDeleteListFromIntent() {
if (requireActivity().getIntent().hasExtra(Constants.INTENT_EXTRA_DELETE_READING_LIST)) {
String titleToDelete = requireActivity().getIntent().getStringExtra(Constants.INTENT_EXTRA_DELETE_READING_LIST);
requireActivity().getIntent().removeExtra(Constants.INTENT_EXTRA_DELETE_READING_LIST);
for (ReadingList list : readingLists) {
if (list.title().equals(titleToDelete)) {
deleteList(list);
}
}
}
}
use of org.wikipedia.readinglist.database.ReadingList in project apps-android-wikipedia by wikimedia.
the class ReadingListFragment method rename.
private void rename() {
if (readingList == null) {
return;
} else if (readingList.isDefault()) {
L.w("Attempted to rename default list.");
return;
}
List<ReadingList> tempLists = ReadingListDbHelper.instance().getAllListsWithoutContents();
List<String> existingTitles = new ArrayList<>();
for (ReadingList list : tempLists) {
existingTitles.add(list.title());
}
existingTitles.remove(readingList.title());
ReadingListTitleDialog.readingListTitleDialog(requireContext(), readingList.title(), readingList.description(), existingTitles, (text, description) -> {
readingList.title(text);
readingList.description(description);
readingList.dirty(true);
ReadingListDbHelper.instance().updateList(readingList, true);
update();
funnel.logModifyList(readingList, 0);
}).show();
}
use of org.wikipedia.readinglist.database.ReadingList in project apps-android-wikipedia by wikimedia.
the class ReadingListsFragment method applySearchQuery.
@NonNull
private List<ReadingList> applySearchQuery(@Nullable String searchQuery, @NonNull List<ReadingList> lists) {
List<ReadingList> newList = new ArrayList<>();
if (TextUtils.isEmpty(searchQuery)) {
newList.addAll(lists);
return newList;
}
String normalizedQuery = StringUtils.stripAccents(searchQuery).toLowerCase();
for (ReadingList list : lists) {
if (StringUtils.stripAccents(list.title()).toLowerCase().contains(normalizedQuery)) {
newList.add(list);
}
}
return newList;
}
Aggregations