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

Hide scrollbar in Awesome bar suggestion list if all the content fits. #1701

Merged
merged 1 commit into from
Aug 29, 2019
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 @@ -45,18 +45,18 @@ public boolean isInTouchMode() {
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);

boolean scrollVisible = false;

if (getChildCount() > 0) {
View first = getChildAt(0);
View last = getChildAt(getChildCount() - 1);
if (first.getTop() < 0 || last.getBottom() > getHeight()) {
scrollVisible = true;
}
boolean fits = getCount() == 0;

// Check if all the items fit on the ListView
int last = getLastVisiblePosition();
int first = getFirstVisiblePosition();
if (!fits && first == 0 && last == getCount() - 1) {
fits = getChildAt(first).getTop() >= 0 && getChildAt(last).getBottom() <= getHeight();
}

setVerticalScrollBarEnabled(scrollVisible);
setFastScrollAlwaysVisible(scrollVisible);
// Hide scrollbar is all item fit.
setVerticalScrollBarEnabled(!fits);
setFastScrollAlwaysVisible(!fits);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
import org.mozilla.gecko.util.ThreadUtils;
import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.audio.AudioEngine;
import org.mozilla.vrbrowser.ui.views.CustomListView;

import java.util.ArrayList;
import java.util.List;

public class SuggestionsWidget extends UIWidget implements WidgetManagerDelegate.FocusChangeListener {

private ListView mList;
private CustomListView mList;
private SuggestionsAdapter mAdapter;
private Animation mScaleUpAnimation;
private Animation mScaleDownAnimation;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/list_popup_window.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_height="match_parent"
android:layout_width="match_parent">

<ListView
<org.mozilla.vrbrowser.ui.views.CustomListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down