use of com.foobnix.pdf.info.wrapper.AppBookmark in project LibreraReader by foobnix.
the class BookmarksFragment2 method prepareDataInBackground.
@Override
public List<AppBookmark> prepareDataInBackground() {
handler.removeCallbacks(timer);
String text = bookmarksEditSearch.getText().toString().toLowerCase(Locale.US).trim();
if (TxtUtils.isEmpty(text)) {
List<AppBookmark> bookmarks = AppSharedPreferences.get().getBookmarks();
if (AppState.get().bookmarksMode == AppState.BOOKMARK_MODE_BY_BOOK) {
List<AppBookmark> filtered = new ArrayList<AppBookmark>();
List<String> unic = new ArrayList<String>();
for (AppBookmark bookmark : bookmarks) {
if (!unic.contains(bookmark.getPath())) {
unic.add(bookmark.getPath());
filtered.add(bookmark);
}
}
return filtered;
} else {
return bookmarks;
}
} else {
List<AppBookmark> filtered = new ArrayList<AppBookmark>();
List<AppBookmark> bookmarks = AppSharedPreferences.get().getBookmarks();
if (text.startsWith(BOOK_PREFIX)) {
text = text.replace(BOOK_PREFIX, "").trim();
for (final AppBookmark bookmark : bookmarks) {
if (bookmark.getTitle().toLowerCase(Locale.US).contains(text.toLowerCase(Locale.US))) {
filtered.add(bookmark);
}
}
Collections.sort(filtered, new Comparator<AppBookmark>() {
@Override
public int compare(AppBookmark o1, AppBookmark o2) {
return new Integer(o1.getPage()).compareTo(new Integer(o2.getPage()));
}
});
} else {
for (AppBookmark bookmark : bookmarks) {
if (bookmark.getText().toLowerCase(Locale.US).contains(text)) {
filtered.add(bookmark);
}
}
}
return filtered;
}
}
use of com.foobnix.pdf.info.wrapper.AppBookmark in project LibreraReader by foobnix.
the class BookmarksFragment2 method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_bookmarks2, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
topPanel = view.findViewById(R.id.topPanel);
bookmarksSearchContainer = view.findViewById(R.id.bookmarksSearchContainer);
bookmarksClearFilter = view.findViewById(R.id.bookmarksClearFilter);
bookmarksEditSearch = (EditText) view.findViewById(R.id.bookmarksEditSearch);
bookmarksEditSearch.addTextChangedListener(filterTextWatcher);
onListGrid = (ImageView) view.findViewById(R.id.onListGrid);
exportBookmarks = (TextView) view.findViewById(R.id.exportBookmarks);
importBookmarks = (TextView) view.findViewById(R.id.importBookmarks);
search = (TextView) view.findViewById(R.id.search);
allBookmarks = (TextView) view.findViewById(R.id.allBookmarks);
TxtUtils.underlineTextView(allBookmarks).setOnClickListener(onCleanSearch);
TxtUtils.underlineTextView(exportBookmarks).setOnClickListener(exportBookmarksClickListener);
TxtUtils.underlineTextView(importBookmarks).setOnClickListener(importBookmarksClickListener);
TxtUtils.underlineTextView(search).setOnClickListener(searchBookmarks);
bookmarksSearchContainer.setVisibility(View.GONE);
bookmarksClearFilter.setOnClickListener(onCleanSearch);
bookmarksAdapter = new BookmarksAdapter2();
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setAdapter(bookmarksAdapter);
bookmarksAdapter.setOnDeleteClickListener(onDeleteResponse);
bookmarksAdapter.setOnItemClickListener(onItemClickListener);
bookmarksAdapter.setOnItemLongClickListener(new ResultResponse<AppBookmark>() {
@Override
public boolean onResultRecive(AppBookmark result) {
FileInformationDialog.showFileInfoDialog(getActivity(), new File(result.getPath()), null);
return true;
}
});
onListGrid.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
popupMenu(onListGrid);
}
});
populate();
onTintChanged();
return view;
}
use of com.foobnix.pdf.info.wrapper.AppBookmark in project LibreraReader by foobnix.
the class BookmarksAdapter2 method onBindViewHolder.
@Override
public void onBindViewHolder(final BookmarksViewHolder holder, final int position) {
final AppBookmark item = getItem(position);
holder.page.setText("" + item.getPage());
holder.title.setText("" + item.getTitle());
holder.text.setText(item.getText());
holder.remove.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onDeleteClickListener.onResultRecive(item);
}
});
if (withTitle) {
holder.title.setVisibility(View.VISIBLE);
} else {
holder.title.setVisibility(View.GONE);
}
TintUtil.setTintBgSimple(holder.page, 240);
holder.page.setTextColor(Color.WHITE);
if (withPageNumber) {
holder.page.setVisibility(View.VISIBLE);
holder.remove.setVisibility(View.VISIBLE);
} else {
holder.page.setVisibility(View.GONE);
holder.remove.setVisibility(View.GONE);
}
IMG.getCoverPageWithEffectPos(holder.image, item.getPath(), IMG.getImageSize(), position, new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String arg0, View arg1, Bitmap arg2) {
}
});
if (!AppState.get().isBorderAndShadow) {
holder.parent.setBackgroundColor(Color.TRANSPARENT);
}
bindItemClickAndLongClickListeners(holder.parent, getItem(position));
}
use of com.foobnix.pdf.info.wrapper.AppBookmark in project LibreraReader by foobnix.
the class DragingDialogs method addBookmarksLong.
public static void addBookmarksLong(final FrameLayout anchor, final DocumentController controller) {
Vibro.vibrate();
List<AppBookmark> objects = AppSharedPreferences.get().getBookmarksByBook(controller.getCurrentBook());
int page = PageUrl.fakeToReal(controller.getCurentPageFirst1());
for (AppBookmark all : objects) {
if (all.getPage() == page) {
Toast.makeText(controller.getActivity(), R.string.bookmark_for_this_page_already_exists, Toast.LENGTH_LONG).show();
return;
}
}
final AppBookmark bookmark = new AppBookmark(controller.getCurrentBook().getPath(), controller.getString(R.string.fast_bookmark), page, controller.getTitle());
AppSharedPreferences.get().addBookMark(bookmark);
String TEXT = controller.getString(R.string.fast_bookmark) + " " + TxtUtils.LONG_DASH + " " + controller.getString(R.string.page) + " " + page + "";
Toast.makeText(controller.getActivity(), TEXT, Toast.LENGTH_SHORT).show();
}
use of com.foobnix.pdf.info.wrapper.AppBookmark in project LibreraReader by foobnix.
the class ExtUtils method sendBookmarksTo.
public static void sendBookmarksTo(final Activity a, final File file) {
if (!isValidFile(file)) {
Toast.makeText(a, R.string.file_not_found, Toast.LENGTH_LONG).show();
return;
}
final List<AppBookmark> bookmarksByBook = AppSharedPreferences.get().getBookmarksByBook(file);
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setType("text/plain");
if (bookmarksByBook != null && !bookmarksByBook.isEmpty()) {
final StringBuilder result = new StringBuilder();
result.append(a.getString(R.string.bookmarks) + "\n\n");
result.append(file.getName() + "\n");
for (final AppBookmark book : bookmarksByBook) {
result.append(String.format("%s. %s \n", book.getPage(), book.getText()));
}
intent.putExtra(Intent.EXTRA_TEXT, result.toString());
}
a.startActivity(Intent.createChooser(intent, a.getString(R.string.export_bookmarks)));
}
Aggregations