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

Fixes #2250 Fixes #2431 Library panels polishing #2657

Merged
merged 2 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,7 @@ private void initialize(Context aContext) {
mBinding.setCallback(mBookmarksCallback);
mBookmarkAdapter = new BookmarkAdapter(mBookmarkItemCallback, aContext);
mBinding.bookmarksList.setAdapter(mBookmarkAdapter);
mBinding.bookmarksList.setOnTouchListener((v, event) -> {
v.requestFocusFromTouch();
return false;
});
mBinding.bookmarksList.setOnScrollChangeListener((v, scrollX, scrollY, oldScrollX, oldScrollY) -> mBookmarksViewListeners.forEach((listener) -> listener.onHideContextMenu(v)));
mBinding.bookmarksList.addOnScrollListener(mScrollListener);
mBinding.bookmarksList.setHasFixedSize(true);
mBinding.bookmarksList.setItemViewCacheSize(20);
mBinding.bookmarksList.setDrawingCacheEnabled(true);
Expand Down Expand Up @@ -143,12 +139,25 @@ public void onShow() {
public void onDestroy() {
SessionStore.get().getBookmarkStore().removeListener(this);

mBinding.bookmarksList.removeOnScrollListener(mScrollListener);

if (ACCOUNTS_UI_ENABLED) {
mAccounts.removeAccountListener(mAccountListener);
mAccounts.removeSyncListener(mSyncListener);
}
}

private RecyclerView.OnScrollListener mScrollListener = new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);

if (recyclerView.getScrollState() != RecyclerView.SCROLL_STATE_SETTLING) {
recyclerView.requestFocus();
}
}
};

private final BookmarkItemCallback mBookmarkItemCallback = new BookmarkItemCallback() {
@Override
public void onClick(@NonNull View view, @NonNull Bookmark item) {
Expand Down Expand Up @@ -183,8 +192,10 @@ public void onMore(@NonNull View view, @NonNull Bookmark item) {
boolean isLastVisibleItem = false;
if (mBinding.bookmarksList.getLayoutManager() instanceof LinearLayoutManager) {
LinearLayoutManager layoutManager = (LinearLayoutManager) mBinding.bookmarksList.getLayoutManager();
int lastVisibleItem = layoutManager.findLastCompletelyVisibleItemPosition();
if (rowPosition == layoutManager.findLastVisibleItemPosition() && rowPosition != lastVisibleItem) {
int lastItem = mBookmarkAdapter.getItemCount();
if ((rowPosition == layoutManager.findLastVisibleItemPosition() || rowPosition == layoutManager.findLastCompletelyVisibleItemPosition() ||
rowPosition == layoutManager.findLastVisibleItemPosition()-1 || rowPosition == layoutManager.findLastCompletelyVisibleItemPosition()-1)
&& rowPosition != lastItem) {
isLastVisibleItem = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.OnScrollListener;

import org.mozilla.geckoview.GeckoSessionSettings;
import org.mozilla.vrbrowser.R;
Expand Down Expand Up @@ -99,11 +100,7 @@ private void initialize(Context aContext) {
mBinding.setCallback(mHistoryCallback);
mHistoryAdapter = new HistoryAdapter(mHistoryItemCallback, aContext);
mBinding.historyList.setAdapter(mHistoryAdapter);
mBinding.historyList.setOnTouchListener((v, event) -> {
v.requestFocusFromTouch();
return false;
});
mBinding.historyList.setOnScrollChangeListener((v, scrollX, scrollY, oldScrollX, oldScrollY) -> mHistoryViewListeners.forEach((listener) -> listener.onHideContextMenu(v)));
mBinding.historyList.addOnScrollListener(mScrollListener);
mBinding.historyList.setHasFixedSize(true);
mBinding.historyList.setItemViewCacheSize(20);
mBinding.historyList.setDrawingCacheEnabled(true);
Expand Down Expand Up @@ -142,6 +139,8 @@ private void initialize(Context aContext) {
public void onDestroy() {
SessionStore.get().getHistoryStore().removeListener(this);

mBinding.historyList.removeOnScrollListener(mScrollListener);

if (ACCOUNTS_UI_ENABLED) {
mAccounts.removeAccountListener(mAccountListener);
mAccounts.removeSyncListener(mSyncListener);
Expand All @@ -152,6 +151,17 @@ public void onShow() {
updateLayout();
}

private OnScrollListener mScrollListener = new OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);

if (recyclerView.getScrollState() != RecyclerView.SCROLL_STATE_SETTLING) {
recyclerView.requestFocus();
}
}
};

private final HistoryItemCallback mHistoryItemCallback = new HistoryItemCallback() {
@Override
public void onClick(View view, VisitInfo item) {
Expand Down Expand Up @@ -186,8 +196,10 @@ public void onMore(View view, VisitInfo item) {
boolean isLastVisibleItem = false;
if (mBinding.historyList.getLayoutManager() instanceof LinearLayoutManager) {
LinearLayoutManager layoutManager = (LinearLayoutManager) mBinding.historyList.getLayoutManager();
int lastVisibleItem = layoutManager.findLastCompletelyVisibleItemPosition();
if (rowPosition == layoutManager.findLastVisibleItemPosition() && rowPosition != lastVisibleItem) {
int lastItem = mHistoryAdapter.getItemCount();
if ((rowPosition == layoutManager.findLastVisibleItemPosition() || rowPosition == layoutManager.findLastCompletelyVisibleItemPosition() ||
rowPosition == layoutManager.findLastVisibleItemPosition()-1 || rowPosition == layoutManager.findLastCompletelyVisibleItemPosition()-1)
&& rowPosition != lastItem) {
isLastVisibleItem = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ public void onUnstackSession(Session aSession, Session aParent) {
public InputConnection onCreateInputConnection(final EditorInfo outAttrs) {
Log.d(LOGTAG, "BrowserWidget onCreateInputConnection");
GeckoSession session = mSession.getGeckoSession();
if (session == null) {
if (session == null || mView != null) {
return null;
}
return session.getTextInput().onCreateInputConnection(outAttrs);
Expand Down