Search in sources :

Example 6 with AppBookmark

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;
    }
}
Also used : AppBookmark(com.foobnix.pdf.info.wrapper.AppBookmark) ArrayList(java.util.ArrayList)

Example 7 with AppBookmark

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;
}
Also used : AppBookmark(com.foobnix.pdf.info.wrapper.AppBookmark) BookmarksAdapter2(com.foobnix.ui2.adapter.BookmarksAdapter2) OnClickListener(android.view.View.OnClickListener) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) File(java.io.File)

Example 8 with AppBookmark

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));
}
Also used : SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) AppBookmark(com.foobnix.pdf.info.wrapper.AppBookmark) Bitmap(android.graphics.Bitmap) OnClickListener(android.view.View.OnClickListener) CardView(android.support.v7.widget.CardView) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 9 with AppBookmark

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();
}
Also used : AppBookmark(com.foobnix.pdf.info.wrapper.AppBookmark) SuppressLint(android.annotation.SuppressLint)

Example 10 with AppBookmark

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)));
}
Also used : AppBookmark(com.foobnix.pdf.info.wrapper.AppBookmark) Intent(android.content.Intent)

Aggregations

AppBookmark (com.foobnix.pdf.info.wrapper.AppBookmark)12 View (android.view.View)5 OnClickListener (android.view.View.OnClickListener)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 ArrayList (java.util.ArrayList)5 RecyclerView (android.support.v7.widget.RecyclerView)3 File (java.io.File)3 SuppressLint (android.annotation.SuppressLint)2 List (java.util.List)2 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 OnDismissListener (android.content.DialogInterface.OnDismissListener)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 CardView (android.support.v7.widget.CardView)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 LayoutInflater (android.view.LayoutInflater)1 AbsListView (android.widget.AbsListView)1