Search in sources :

Example 1 with BookmarkModel

use of org.mozilla.focus.persistence.BookmarkModel in project Rocket by mozilla-tw.

the class BookmarkRepository method addBookmark.

public String addBookmark(String title, String url) {
    final BookmarkModel bookmark = new BookmarkModel(UUID.randomUUID().toString(), title, url);
    ThreadUtils.postToBackgroundThread(() -> bookmarksDatabase.bookmarkDao().addBookmarks(bookmark));
    return bookmark.getId();
}
Also used : BookmarkModel(org.mozilla.focus.persistence.BookmarkModel)

Example 2 with BookmarkModel

use of org.mozilla.focus.persistence.BookmarkModel in project Rocket by mozilla-tw.

the class BookmarkAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull SiteItemViewHolder holder, int position) {
    final BookmarkModel item = getItem(position);
    if (item == null) {
        return;
    }
    holder.rootView.setTag(item.getId());
    holder.textMain.setText(item.getTitle());
    holder.textSecondary.setText(item.getUrl());
    holder.rootView.setOnClickListener(v -> {
        listener.onItemClicked(item.getUrl());
    });
    final PopupMenu popupMenu = new PopupMenu(holder.btnMore.getContext(), holder.btnMore);
    popupMenu.setOnMenuItemClickListener(menuItem -> {
        if (menuItem.getItemId() == R.id.remove) {
            listener.onItemDeleted(item);
        }
        if (menuItem.getItemId() == R.id.edit) {
            listener.onItemEdited(item);
        }
        return false;
    });
    popupMenu.inflate(R.menu.menu_bookmarks);
    holder.btnMore.setOnClickListener(v -> {
        popupMenu.show();
        TelemetryWrapper.showBookmarkContextMenu();
    });
}
Also used : BookmarkModel(org.mozilla.focus.persistence.BookmarkModel) PopupMenu(androidx.appcompat.widget.PopupMenu)

Aggregations

BookmarkModel (org.mozilla.focus.persistence.BookmarkModel)2 PopupMenu (androidx.appcompat.widget.PopupMenu)1