Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Open the mobile bookmarks folder by default (#2164)
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo authored and bluemarvin committed Nov 7, 2019
1 parent f012da3 commit f2e90af
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
import org.mozilla.vrbrowser.utils.AnimationHelper;
import org.mozilla.vrbrowser.utils.SystemUtils;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import mozilla.appservices.places.BookmarkRoot;
import mozilla.components.concept.storage.BookmarkNode;
import mozilla.components.concept.storage.BookmarkNodeType;

Expand Down Expand Up @@ -74,8 +77,15 @@ public void setBookmarkList(final List<BookmarkNode> bookmarkList) {

List<Bookmark> newDisplayList;
if (mDisplayList == null || mDisplayList.isEmpty()) {
newDisplayList = Bookmark.getRootDisplayListTree(mBookmarksList);
newDisplayList = Bookmark.getDisplayListTree(mBookmarksList, Collections.singletonList(BookmarkRoot.Mobile.getId()));
mDisplayList = newDisplayList;
for (Bookmark node : mDisplayList) {
if (node.isExpanded()) {
if (mBookmarkItemCallback != null) {
mBookmarkItemCallback.onFolderOpened(node);
}
}
}
notifyItemRangeInserted(0, mDisplayList.size());

} else {
Expand Down Expand Up @@ -198,7 +208,9 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
switch (ev) {
case MotionEvent.ACTION_UP:
binding.setIsHovered(true);
mBookmarkItemCallback.onMore(view, binding.getItem());
if (mBookmarkItemCallback != null) {
mBookmarkItemCallback.onMore(view, binding.getItem());
}
return true;

case MotionEvent.ACTION_DOWN:
Expand All @@ -213,7 +225,9 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
switch (ev) {
case MotionEvent.ACTION_UP:
binding.setIsHovered(true);
mBookmarkItemCallback.onDelete(view, binding.getItem());
if (mBookmarkItemCallback != null) {
mBookmarkItemCallback.onDelete(view, binding.getItem());
}
return true;

case MotionEvent.ACTION_DOWN:
Expand Down Expand Up @@ -349,7 +363,9 @@ public void onClick(View view, Bookmark item) {
List<Bookmark> newDisplayList = Bookmark.getDisplayListTree(mBookmarksList, openFoldersGuid);
notifyDiff(newDisplayList);

mBookmarkItemCallback.onFolderOpened(item);
if (mBookmarkItemCallback != null) {
mBookmarkItemCallback.onFolderOpened(item);
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
switch (ev) {
case MotionEvent.ACTION_UP:
binding.setIsHovered(true);
mHistoryItemCallback.onMore(view, binding.getItem());
if (mHistoryItemCallback != null) {
mHistoryItemCallback.onMore(view, binding.getItem());
}
return true;

case MotionEvent.ACTION_DOWN:
Expand All @@ -193,7 +195,9 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
switch (ev) {
case MotionEvent.ACTION_UP:
binding.setIsHovered(true);
mHistoryItemCallback.onDelete(view, binding.getItem());
if (mHistoryItemCallback != null) {
mHistoryItemCallback.onDelete(view, binding.getItem());
}
return true;

case MotionEvent.ACTION_DOWN:
Expand Down

0 comments on commit f2e90af

Please sign in to comment.