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();
}
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();
});
}
Aggregations