Search in sources :

Example 1 with EmptySpaceView

use of com.android.launcher3.widget.picker.WidgetsSpaceViewHolderBinder.EmptySpaceView in project android_packages_apps_Launcher3 by ArrowOS.

the class SearchAndRecommendationsScrollController method findCurrentEmptyView.

private void findCurrentEmptyView() {
    if (mCurrentEmptySpaceView != null) {
        mCurrentEmptySpaceView.setOnYChangeCallback(null);
        mCurrentEmptySpaceView = null;
    }
    int childCount = mCurrentRecyclerView.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View view = mCurrentRecyclerView.getChildAt(i);
        if (view instanceof EmptySpaceView) {
            mCurrentEmptySpaceView = (EmptySpaceView) view;
            mCurrentEmptySpaceView.setFixedHeight(getHeaderHeight());
            mCurrentEmptySpaceView.setOnYChangeCallback(this::updateHeaderScroll);
            return;
        }
    }
}
Also used : EmptySpaceView(com.android.launcher3.widget.picker.WidgetsSpaceViewHolderBinder.EmptySpaceView) EmptySpaceView(com.android.launcher3.widget.picker.WidgetsSpaceViewHolderBinder.EmptySpaceView) TextView(android.widget.TextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 2 with EmptySpaceView

use of com.android.launcher3.widget.picker.WidgetsSpaceViewHolderBinder.EmptySpaceView in project android_packages_apps_Launcher3 by ArrowOS.

the class WidgetsRecyclerView method getCurrentScrollY.

@Override
public int getCurrentScrollY() {
    // Skip early if widgets are not bound.
    if (isModelNotReady() || getChildCount() == 0) {
        return -1;
    }
    int rowIndex = -1;
    View child = null;
    LayoutManager layoutManager = getLayoutManager();
    if (layoutManager instanceof LinearLayoutManager) {
        // Use the LayoutManager as the source of truth for visible positions. During
        // animations, the view group child may not correspond to the visible views that appear
        // at the top.
        rowIndex = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
        child = layoutManager.findViewByPosition(rowIndex);
    }
    if (child == null) {
        // If the layout manager returns null for any reason, which can happen before layout
        // has occurred for the position, then look at the child of this view as a ViewGroup.
        child = getChildAt(0);
        rowIndex = getChildPosition(child);
    }
    for (int i = 0; i < getChildCount(); i++) {
        View view = getChildAt(i);
        if (view instanceof TableLayout) {
            // This assumes there is ever only one content shown in this recycler view.
            mLastVisibleWidgetContentTableHeight = view.getMeasuredHeight();
        } else if (view instanceof WidgetsListHeader && mWidgetHeaderHeight == 0 && view.getMeasuredHeight() > 0) {
            // This assumes all header views are of the same height.
            mWidgetHeaderHeight = view.getMeasuredHeight();
        } else if (view instanceof EmptySpaceView && view.getMeasuredHeight() > 0) {
            mWidgetEmptySpaceHeight = view.getMeasuredHeight();
        }
    }
    int scrollPosition = getItemsHeight(rowIndex);
    int offset = getLayoutManager().getDecoratedTop(child);
    return getPaddingTop() + scrollPosition - offset;
}
Also used : LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) EmptySpaceView(com.android.launcher3.widget.picker.WidgetsSpaceViewHolderBinder.EmptySpaceView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) EmptySpaceView(com.android.launcher3.widget.picker.WidgetsSpaceViewHolderBinder.EmptySpaceView) BaseRecyclerView(com.android.launcher3.BaseRecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TableLayout(android.widget.TableLayout) Point(android.graphics.Point)

Example 3 with EmptySpaceView

use of com.android.launcher3.widget.picker.WidgetsSpaceViewHolderBinder.EmptySpaceView in project android_packages_apps_Launcher3 by ProtonAOSP.

the class WidgetsRecyclerView method getCurrentScrollY.

@Override
public int getCurrentScrollY() {
    // Skip early if widgets are not bound.
    if (isModelNotReady() || getChildCount() == 0) {
        return -1;
    }
    int rowIndex = -1;
    View child = null;
    LayoutManager layoutManager = getLayoutManager();
    if (layoutManager instanceof LinearLayoutManager) {
        // Use the LayoutManager as the source of truth for visible positions. During
        // animations, the view group child may not correspond to the visible views that appear
        // at the top.
        rowIndex = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
        child = layoutManager.findViewByPosition(rowIndex);
    }
    if (child == null) {
        // If the layout manager returns null for any reason, which can happen before layout
        // has occurred for the position, then look at the child of this view as a ViewGroup.
        child = getChildAt(0);
        rowIndex = getChildPosition(child);
    }
    for (int i = 0; i < getChildCount(); i++) {
        View view = getChildAt(i);
        if (view instanceof TableLayout) {
            // This assumes there is ever only one content shown in this recycler view.
            mLastVisibleWidgetContentTableHeight = view.getMeasuredHeight();
        } else if (view instanceof WidgetsListHeader && mWidgetHeaderHeight == 0 && view.getMeasuredHeight() > 0) {
            // This assumes all header views are of the same height.
            mWidgetHeaderHeight = view.getMeasuredHeight();
        } else if (view instanceof EmptySpaceView && view.getMeasuredHeight() > 0) {
            mWidgetEmptySpaceHeight = view.getMeasuredHeight();
        }
    }
    int scrollPosition = getItemsHeight(rowIndex);
    int offset = getLayoutManager().getDecoratedTop(child);
    return getPaddingTop() + scrollPosition - offset;
}
Also used : LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) EmptySpaceView(com.android.launcher3.widget.picker.WidgetsSpaceViewHolderBinder.EmptySpaceView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) EmptySpaceView(com.android.launcher3.widget.picker.WidgetsSpaceViewHolderBinder.EmptySpaceView) BaseRecyclerView(com.android.launcher3.BaseRecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TableLayout(android.widget.TableLayout) Point(android.graphics.Point)

Example 4 with EmptySpaceView

use of com.android.launcher3.widget.picker.WidgetsSpaceViewHolderBinder.EmptySpaceView in project android_packages_apps_Launcher3 by ProtonAOSP.

the class SearchAndRecommendationsScrollController method findCurrentEmptyView.

private void findCurrentEmptyView() {
    if (mCurrentEmptySpaceView != null) {
        mCurrentEmptySpaceView.setOnYChangeCallback(null);
        mCurrentEmptySpaceView = null;
    }
    int childCount = mCurrentRecyclerView.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View view = mCurrentRecyclerView.getChildAt(i);
        if (view instanceof EmptySpaceView) {
            mCurrentEmptySpaceView = (EmptySpaceView) view;
            mCurrentEmptySpaceView.setFixedHeight(getHeaderHeight());
            mCurrentEmptySpaceView.setOnYChangeCallback(this::updateHeaderScroll);
            return;
        }
    }
}
Also used : EmptySpaceView(com.android.launcher3.widget.picker.WidgetsSpaceViewHolderBinder.EmptySpaceView) EmptySpaceView(com.android.launcher3.widget.picker.WidgetsSpaceViewHolderBinder.EmptySpaceView) TextView(android.widget.TextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 5 with EmptySpaceView

use of com.android.launcher3.widget.picker.WidgetsSpaceViewHolderBinder.EmptySpaceView in project android_packages_apps_404Launcher by P-404.

the class SearchAndRecommendationsScrollController method findCurrentEmptyView.

private void findCurrentEmptyView() {
    if (mCurrentEmptySpaceView != null) {
        mCurrentEmptySpaceView.setOnYChangeCallback(null);
        mCurrentEmptySpaceView = null;
    }
    int childCount = mCurrentRecyclerView.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View view = mCurrentRecyclerView.getChildAt(i);
        if (view instanceof EmptySpaceView) {
            mCurrentEmptySpaceView = (EmptySpaceView) view;
            mCurrentEmptySpaceView.setFixedHeight(getHeaderHeight());
            mCurrentEmptySpaceView.setOnYChangeCallback(this::updateHeaderScroll);
            return;
        }
    }
}
Also used : EmptySpaceView(com.android.launcher3.widget.picker.WidgetsSpaceViewHolderBinder.EmptySpaceView) EmptySpaceView(com.android.launcher3.widget.picker.WidgetsSpaceViewHolderBinder.EmptySpaceView) TextView(android.widget.TextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Aggregations

View (android.view.View)8 RecyclerView (androidx.recyclerview.widget.RecyclerView)8 EmptySpaceView (com.android.launcher3.widget.picker.WidgetsSpaceViewHolderBinder.EmptySpaceView)8 Point (android.graphics.Point)4 TableLayout (android.widget.TableLayout)4 TextView (android.widget.TextView)4 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)4 BaseRecyclerView (com.android.launcher3.BaseRecyclerView)4