Merge "Simplifying some scrollbar binding logic in all-apps" into tm-qpr-dev
This commit is contained in:
@@ -20,7 +20,6 @@ import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -53,21 +52,9 @@ public abstract class FastScrollRecyclerView extends RecyclerView {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
if (mScrollbar == null || !mScrollbar.hasRecyclerView()) {
|
||||
bindFastScrollbar();
|
||||
}
|
||||
}
|
||||
|
||||
public void bindFastScrollbar() {
|
||||
ViewGroup parent = (ViewGroup) getParent().getParent();
|
||||
if (parent.findViewById(R.id.fast_scroller) == null) {
|
||||
parent = (ViewGroup) parent.getParent();
|
||||
}
|
||||
mScrollbar = parent.findViewById(R.id.fast_scroller);
|
||||
mScrollbar.setRecyclerView(this, parent.findViewById(R.id.fast_scroller_popup));
|
||||
public void bindFastScrollbar(RecyclerViewFastScroller scrollbar) {
|
||||
mScrollbar = scrollbar;
|
||||
mScrollbar.setRecyclerView(this);
|
||||
onUpdateScrollbar(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -134,6 +134,8 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
protected AllAppsPagedView mViewPager;
|
||||
protected FloatingHeaderView mHeader;
|
||||
protected View mBottomSheetBackground;
|
||||
protected RecyclerViewFastScroller mFastScroller;
|
||||
|
||||
/**
|
||||
* View that defines the search box. Result is rendered inside {@link #mSearchRecyclerView}.
|
||||
*/
|
||||
@@ -219,6 +221,8 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
mBottomSheetBackground = findViewById(R.id.bottom_sheet_background);
|
||||
mBottomSheetHandleArea = findViewById(R.id.bottom_sheet_handle_area);
|
||||
mSearchRecyclerView = findViewById(R.id.search_results_list_view);
|
||||
mFastScroller = findViewById(R.id.fast_scroller);
|
||||
mFastScroller.setPopupView(findViewById(R.id.fast_scroller_popup));
|
||||
|
||||
// Add the search box above everything else.
|
||||
mSearchContainer = inflateSearchBox();
|
||||
@@ -302,6 +306,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
if (!mSearchTransitionController.isRunning() && goingToSearch == isSearching()) {
|
||||
return;
|
||||
}
|
||||
mFastScroller.setVisibility(goingToSearch ? INVISIBLE : VISIBLE);
|
||||
if (goingToSearch) {
|
||||
// Fade out the button to pause work apps.
|
||||
mWorkManager.onActivePageChanged(SEARCH);
|
||||
@@ -411,7 +416,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
return;
|
||||
}
|
||||
if (mAH.get(currentActivePage).mRecyclerView != null) {
|
||||
mAH.get(currentActivePage).mRecyclerView.bindFastScrollbar();
|
||||
mAH.get(currentActivePage).mRecyclerView.bindFastScrollbar(mFastScroller);
|
||||
}
|
||||
// Header keeps track of active recycler view to properly render header protection.
|
||||
mHeader.setActiveRV(currentActivePage);
|
||||
@@ -494,7 +499,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
if (isSearchBarOnBottom()) {
|
||||
// Keep the scroller above the search bar.
|
||||
RelativeLayout.LayoutParams scrollerLayoutParams =
|
||||
(LayoutParams) findViewById(R.id.fast_scroller).getLayoutParams();
|
||||
(LayoutParams) mFastScroller.getLayoutParams();
|
||||
scrollerLayoutParams.addRule(RelativeLayout.ABOVE, R.id.search_container_all_apps);
|
||||
scrollerLayoutParams.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
|
||||
scrollerLayoutParams.bottomMargin = getResources().getDimensionPixelSize(
|
||||
@@ -1055,12 +1060,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
: mViewPager == null ? AdapterHolder.MAIN : mViewPager.getNextPage();
|
||||
}
|
||||
|
||||
/** The scroll bar for the active apps recycler view. */
|
||||
public RecyclerViewFastScroller getScrollBar() {
|
||||
AllAppsRecyclerView rv = getActiveAppsRecyclerView();
|
||||
return rv == null ? null : rv.getScrollbar();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an update listener to animator that adds springs to the animation.
|
||||
*/
|
||||
@@ -1252,6 +1251,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
void setup(@NonNull View rv, @Nullable Predicate<ItemInfo> matcher) {
|
||||
mAppsList.updateItemFilter(matcher);
|
||||
mRecyclerView = (AllAppsRecyclerView) rv;
|
||||
mRecyclerView.bindFastScrollbar(mFastScroller);
|
||||
mRecyclerView.setEdgeEffectFactory(createEdgeEffectFactory());
|
||||
mRecyclerView.setApps(mAppsList);
|
||||
mRecyclerView.setLayoutManager(mLayoutManager);
|
||||
|
||||
@@ -43,7 +43,6 @@ import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.logging.StatsLogManager;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
import com.android.launcher3.views.RecyclerViewFastScroller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -274,10 +273,6 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
|
||||
: getRootWindowInsets().getSystemWindowInsetBottom();
|
||||
}
|
||||
|
||||
public RecyclerViewFastScroller getScrollbar() {
|
||||
return mScrollbar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlappingRendering() {
|
||||
return false;
|
||||
|
||||
@@ -171,12 +171,14 @@ public class RecyclerViewFastScroller extends View {
|
||||
ta.recycle();
|
||||
}
|
||||
|
||||
/** @return whether there is a RecyclerView bound to this scroller. */
|
||||
public boolean hasRecyclerView() {
|
||||
return mRv != null;
|
||||
/** Sets the popup view to show while the scroller is being dragged */
|
||||
public void setPopupView(TextView popupView) {
|
||||
mPopupView = popupView;
|
||||
mPopupView.setBackground(
|
||||
new FastScrollThumbDrawable(mThumbPaint, Utilities.isRtl(getResources())));
|
||||
}
|
||||
|
||||
public void setRecyclerView(FastScrollRecyclerView rv, TextView popupView) {
|
||||
public void setRecyclerView(FastScrollRecyclerView rv) {
|
||||
if (mRv != null && mOnScrollListener != null) {
|
||||
mRv.removeOnScrollListener(mOnScrollListener);
|
||||
}
|
||||
@@ -194,10 +196,6 @@ public class RecyclerViewFastScroller extends View {
|
||||
mRv.onUpdateScrollbar(dy);
|
||||
}
|
||||
});
|
||||
|
||||
mPopupView = popupView;
|
||||
mPopupView.setBackground(
|
||||
new FastScrollThumbDrawable(mThumbPaint, Utilities.isRtl(getResources())));
|
||||
}
|
||||
|
||||
public void reattachThumbToScroll() {
|
||||
@@ -336,7 +334,7 @@ public class RecyclerViewFastScroller extends View {
|
||||
}
|
||||
|
||||
public void onDraw(Canvas canvas) {
|
||||
if (mThumbOffsetY < 0) {
|
||||
if (mThumbOffsetY < 0 || mRv == null) {
|
||||
return;
|
||||
}
|
||||
int saveCount = canvas.save();
|
||||
|
||||
@@ -159,7 +159,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet
|
||||
WidgetsRecyclerView searchRecyclerView =
|
||||
mAdapters.get(AdapterHolder.SEARCH).mWidgetsRecyclerView;
|
||||
if (mIsInSearchMode && searchRecyclerView != null) {
|
||||
searchRecyclerView.bindFastScrollbar();
|
||||
searchRecyclerView.bindFastScrollbar(mFastScroller);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,6 +253,8 @@ public class WidgetsFullSheet extends BaseWidgetSheet
|
||||
if (mIsTwoPane) {
|
||||
mFastScroller.setVisibility(GONE);
|
||||
}
|
||||
mFastScroller.setPopupView(findViewById(R.id.fast_scroller_popup));
|
||||
|
||||
mAdapters.get(AdapterHolder.PRIMARY).setup(findViewById(R.id.primary_widgets_list_view));
|
||||
mAdapters.get(AdapterHolder.SEARCH).setup(findViewById(R.id.search_widgets_list_view));
|
||||
if (mHasWorkProfile) {
|
||||
@@ -373,7 +375,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet
|
||||
}
|
||||
|
||||
private void attachScrollbarToRecyclerView(WidgetsRecyclerView recyclerView) {
|
||||
recyclerView.bindFastScrollbar();
|
||||
recyclerView.bindFastScrollbar(mFastScroller);
|
||||
if (mCurrentWidgetsRecyclerView != recyclerView) {
|
||||
// Only reset the scroll position & expanded apps if the currently shown recycler view
|
||||
// has been updated.
|
||||
@@ -583,7 +585,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet
|
||||
workUserAdapterHolder.mWidgetsListAdapter.setWidgets(allWidgets);
|
||||
onActivePageChanged(mViewPager.getCurrentPage());
|
||||
} else {
|
||||
updateRecyclerViewVisibility(primaryUserAdapterHolder);
|
||||
onActivePageChanged(0);
|
||||
}
|
||||
// Update recommended widgets section so that it occupies appropriate space on screen to
|
||||
// leave enough space for presence/absence of mNoWidgetsView.
|
||||
@@ -1021,6 +1023,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet
|
||||
mWidgetsRecyclerView.setClipToOutline(true);
|
||||
mWidgetsRecyclerView.setClipChildren(false);
|
||||
mWidgetsRecyclerView.setAdapter(mWidgetsListAdapter);
|
||||
mWidgetsRecyclerView.bindFastScrollbar(mFastScroller);
|
||||
mWidgetsRecyclerView.setItemAnimator(mWidgetsListItemAnimator);
|
||||
mWidgetsRecyclerView.setHeaderViewDimensionsProvider(WidgetsFullSheet.this);
|
||||
if (!mIsTwoPane) {
|
||||
|
||||
Reference in New Issue
Block a user