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

Commit

Permalink
Fixes #2960 - Updated code to increase number/index of the last row i…
Browse files Browse the repository at this point in the history
…tem that would display menu below item instead of on top
  • Loading branch information
daron-walters committed Jun 12, 2020
1 parent b36aaa6 commit 49de625
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ public HistoryView(Context aContext, AttributeSet aAttrs, int aDefStyle) {
protected void initialize() {
super.initialize();

mAccounts = ((VRBrowserApplication)getContext().getApplicationContext()).getAccounts();
mAccounts = ((VRBrowserApplication) getContext().getApplicationContext()).getAccounts();
if (ACCOUNTS_UI_ENABLED) {
mAccounts.addAccountListener(mAccountListener);
mAccounts.addSyncListener(mSyncListener);
}

mViewModel = new ViewModelProvider(
(VRBrowserActivity)getContext(),
(VRBrowserActivity) getContext(),
ViewModelProvider.AndroidViewModelFactory.getInstance(((VRBrowserActivity) getContext()).getApplication()))
.get(HistoryViewModel.class);

Expand All @@ -120,7 +120,7 @@ public void updateUI() {

// Inflate this data binding layout
mBinding = DataBindingUtil.inflate(inflater, R.layout.history, this, true);
mBinding.setLifecycleOwner((VRBrowserActivity)getContext());
mBinding.setLifecycleOwner((VRBrowserActivity) getContext());
mBinding.setHistoryViewModel(mViewModel);
mBinding.setCallback(mHistoryCallback);
mHistoryAdapter = new HistoryAdapter(mHistoryItemCallback, getContext());
Expand Down Expand Up @@ -203,8 +203,8 @@ public void onMore(View view, VisitInfo item) {
LinearLayoutManager layoutManager = (LinearLayoutManager) mBinding.historyList.getLayoutManager();
int lastItem = mHistoryAdapter.getItemCount();
if ((rowPosition == layoutManager.findLastVisibleItemPosition() || rowPosition == layoutManager.findLastCompletelyVisibleItemPosition() ||
rowPosition == layoutManager.findLastVisibleItemPosition()-1 || rowPosition == layoutManager.findLastCompletelyVisibleItemPosition()-1)
&& (rowPosition != lastItem && rowPosition != 1)) {
rowPosition == layoutManager.findLastVisibleItemPosition() - 1 || rowPosition == layoutManager.findLastCompletelyVisibleItemPosition() - 1)
&& (rowPosition != lastItem && rowPosition > 2)) {
isLastVisibleItem = true;
}
}
Expand Down Expand Up @@ -372,7 +372,7 @@ private void updateHistory() {
SessionStore.get().getHistoryStore().getDetailedHistory().thenAcceptAsync((items) -> {
List<VisitInfo> orderedItems = items.stream()
.sorted(Comparator.comparing(VisitInfo::getVisitTime)
.reversed())
.reversed())
.filter(distinctByUrl(VisitInfo::getUrl))
.collect(Collectors.toList());

Expand All @@ -391,7 +391,7 @@ private void updateHistory() {
}

private void addSection(final @NonNull List<VisitInfo> items, @NonNull String section, long rangeStart, long rangeEnd) {
for (int i=0; i< items.size(); i++) {
for (int i = 0; i < items.size(); i++) {
if (items.get(i).getVisitTime() == rangeStart && items.get(i).getVisitType() == VisitType.NOT_A_VISIT)
break;

Expand Down Expand Up @@ -424,7 +424,7 @@ private void showHistory(List<VisitInfo> historyItems) {
@Override
protected void updateLayout() {
post(() -> {
double width = Math.ceil(getWidth()/getContext().getResources().getDisplayMetrics().density);
double width = Math.ceil(getWidth() / getContext().getResources().getDisplayMetrics().density);
boolean isNarrow = width < SettingsStore.WINDOW_WIDTH_DEFAULT;

if (isNarrow != mViewModel.getIsNarrow().getValue().get()) {
Expand Down

0 comments on commit 49de625

Please sign in to comment.