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

Commit 03e3303

Browse files
MortimerGorokeianhzo
authored andcommitted
Hide scrollbar in Awesome bar suggestion list if all the content fits. (#1701)
1 parent 42af969 commit 03e3303

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

app/src/common/shared/org/mozilla/vrbrowser/ui/views/CustomListView.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ public boolean isInTouchMode() {
4545
protected void onLayout(boolean changed, int l, int t, int r, int b) {
4646
super.onLayout(changed, l, t, r, b);
4747

48-
boolean scrollVisible = false;
49-
50-
if (getChildCount() > 0) {
51-
View first = getChildAt(0);
52-
View last = getChildAt(getChildCount() - 1);
53-
if (first.getTop() < 0 || last.getBottom() > getHeight()) {
54-
scrollVisible = true;
55-
}
48+
boolean fits = getCount() == 0;
49+
50+
// Check if all the items fit on the ListView
51+
int last = getLastVisiblePosition();
52+
int first = getFirstVisiblePosition();
53+
if (!fits && first == 0 && last == getCount() - 1) {
54+
fits = getChildAt(first).getTop() >= 0 && getChildAt(last).getBottom() <= getHeight();
5655
}
5756

58-
setVerticalScrollBarEnabled(scrollVisible);
59-
setFastScrollAlwaysVisible(scrollVisible);
57+
// Hide scrollbar is all item fit.
58+
setVerticalScrollBarEnabled(!fits);
59+
setFastScrollAlwaysVisible(!fits);
6060
}
6161

6262

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/SuggestionsWidget.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@
2323
import org.mozilla.gecko.util.ThreadUtils;
2424
import org.mozilla.vrbrowser.R;
2525
import org.mozilla.vrbrowser.audio.AudioEngine;
26+
import org.mozilla.vrbrowser.ui.views.CustomListView;
2627

2728
import java.util.ArrayList;
2829
import java.util.List;
2930

3031
public class SuggestionsWidget extends UIWidget implements WidgetManagerDelegate.FocusChangeListener {
3132

32-
private ListView mList;
33+
private CustomListView mList;
3334
private SuggestionsAdapter mAdapter;
3435
private Animation mScaleUpAnimation;
3536
private Animation mScaleDownAnimation;

app/src/main/res/layout/list_popup_window.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
android:layout_height="match_parent"
55
android:layout_width="match_parent">
66

7-
<ListView
7+
<org.mozilla.vrbrowser.ui.views.CustomListView
88
android:id="@+id/list"
99
android:layout_width="match_parent"
1010
android:layout_height="match_parent"

0 commit comments

Comments
 (0)