Skip to content

Commit

Permalink
Hide scrollbar in Awesome bar suggestion list if all the content fits. (
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored and keianhzo committed Aug 29, 2019
1 parent 42af969 commit 03e3303
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
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
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
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

0 comments on commit 03e3303

Please sign in to comment.