Search in sources :

Example 6 with WidgetListSpaceEntry

use of com.android.launcher3.widget.model.WidgetListSpaceEntry in project android_packages_apps_Launcher3 by ArrowOS.

the class WidgetsListAdapter method updateVisibleEntries.

private void updateVisibleEntries() {
    // Get the current top of the header with the matching key before adjusting the visible
    // entries.
    OptionalInt previousPositionForPackageUserKey = getPositionForPackageUserKey(mPendingClickHeader);
    OptionalInt topForPackageUserKey = getOffsetForPosition(previousPositionForPackageUserKey);
    List<WidgetsListBaseEntry> newVisibleEntries = mAllEntries.stream().filter(entry -> ((mFilter == null || mFilter.test(entry)) && mHeaderAndSelectedContentFilter.test(entry)) || entry instanceof WidgetListSpaceEntry).map(entry -> {
        if (entry instanceof WidgetsListBaseEntry.Header<?> && matchesKey(entry, mWidgetsContentVisiblePackageUserKey)) {
            // Adjust the original entries to expand headers for the selected content.
            return ((WidgetsListBaseEntry.Header<?>) entry).withWidgetListShown();
        } else if (entry instanceof WidgetsListContentEntry) {
            // maxSpanSize.
            return ((WidgetsListContentEntry) entry).withMaxSpanSize(mMaxSpanSize);
        }
        return entry;
    }).collect(Collectors.toList());
    mDiffReporter.process(mVisibleEntries, newVisibleEntries, mRowComparator);
    if (mPendingClickHeader != null) {
        // Get the position for the clicked header after adjusting the visible entries. The
        // position may have changed if another header had previously been expanded.
        OptionalInt positionForPackageUserKey = getPositionForPackageUserKey(mPendingClickHeader);
        scrollToPositionAndMaintainOffset(positionForPackageUserKey, topForPackageUserKey);
        mPendingClickHeader = null;
    }
}
Also used : POSITION_LAST(com.android.launcher3.recyclerview.ViewHolderBinder.POSITION_LAST) IntStream(java.util.stream.IntStream) Context(android.content.Context) Rect(android.graphics.Rect) Arrays(java.util.Arrays) NonNull(androidx.annotation.NonNull) LabelComparator(com.android.launcher3.util.LabelComparator) IconCache(com.android.launcher3.icons.IconCache) OptionalInt(java.util.OptionalInt) Process(android.os.Process) PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) ArrayList(java.util.ArrayList) POSITION_FIRST(com.android.launcher3.recyclerview.ViewHolderBinder.POSITION_FIRST) WidgetListSpaceEntry(com.android.launcher3.widget.model.WidgetListSpaceEntry) POSITION_DEFAULT(com.android.launcher3.recyclerview.ViewHolderBinder.POSITION_DEFAULT) Map(java.util.Map) View(android.view.View) ViewHolder(androidx.recyclerview.widget.RecyclerView.ViewHolder) RecyclerView(androidx.recyclerview.widget.RecyclerView) Log(android.util.Log) IntSupplier(java.util.function.IntSupplier) ActivityContext(com.android.launcher3.views.ActivityContext) WidgetsListHeaderEntry(com.android.launcher3.widget.model.WidgetsListHeaderEntry) LayoutInflater(android.view.LayoutInflater) Adapter(androidx.recyclerview.widget.RecyclerView.Adapter) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) Predicate(java.util.function.Predicate) LAUNCHER_WIDGETSTRAY_APP_EXPANDED(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WIDGETSTRAY_APP_EXPANDED) PackageUserKey(com.android.launcher3.util.PackageUserKey) WidgetsListSearchHeaderEntry(com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry) Collectors(java.util.stream.Collectors) ViewGroup(android.view.ViewGroup) ViewHolderBinder(com.android.launcher3.recyclerview.ViewHolderBinder) SparseArray(android.util.SparseArray) List(java.util.List) Nullable(androidx.annotation.Nullable) WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) R(com.android.launcher3.R) LayoutParams(androidx.recyclerview.widget.RecyclerView.LayoutParams) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) Comparator(java.util.Comparator) OnLongClickListener(android.view.View.OnLongClickListener) Collections(java.util.Collections) OnClickListener(android.view.View.OnClickListener) WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) WidgetListSpaceEntry(com.android.launcher3.widget.model.WidgetListSpaceEntry) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) OptionalInt(java.util.OptionalInt)

Example 7 with WidgetListSpaceEntry

use of com.android.launcher3.widget.model.WidgetListSpaceEntry in project android_packages_apps_Launcher3 by ProtonAOSP.

the class WidgetsListAdapter method updateVisibleEntries.

private void updateVisibleEntries() {
    // Get the current top of the header with the matching key before adjusting the visible
    // entries.
    OptionalInt previousPositionForPackageUserKey = getPositionForPackageUserKey(mPendingClickHeader);
    OptionalInt topForPackageUserKey = getOffsetForPosition(previousPositionForPackageUserKey);
    List<WidgetsListBaseEntry> newVisibleEntries = mAllEntries.stream().filter(entry -> ((mFilter == null || mFilter.test(entry)) && mHeaderAndSelectedContentFilter.test(entry)) || entry instanceof WidgetListSpaceEntry).map(entry -> {
        if (entry instanceof WidgetsListBaseEntry.Header<?> && matchesKey(entry, mWidgetsContentVisiblePackageUserKey)) {
            // Adjust the original entries to expand headers for the selected content.
            return ((WidgetsListBaseEntry.Header<?>) entry).withWidgetListShown();
        } else if (entry instanceof WidgetsListContentEntry) {
            // maxSpanSize.
            return ((WidgetsListContentEntry) entry).withMaxSpanSize(mMaxSpanSize);
        }
        return entry;
    }).collect(Collectors.toList());
    mDiffReporter.process(mVisibleEntries, newVisibleEntries, mRowComparator);
    if (mPendingClickHeader != null) {
        // Get the position for the clicked header after adjusting the visible entries. The
        // position may have changed if another header had previously been expanded.
        OptionalInt positionForPackageUserKey = getPositionForPackageUserKey(mPendingClickHeader);
        scrollToPositionAndMaintainOffset(positionForPackageUserKey, topForPackageUserKey);
        mPendingClickHeader = null;
    }
}
Also used : POSITION_LAST(com.android.launcher3.recyclerview.ViewHolderBinder.POSITION_LAST) IntStream(java.util.stream.IntStream) Context(android.content.Context) Rect(android.graphics.Rect) Arrays(java.util.Arrays) NonNull(androidx.annotation.NonNull) LabelComparator(com.android.launcher3.util.LabelComparator) IconCache(com.android.launcher3.icons.IconCache) OptionalInt(java.util.OptionalInt) Process(android.os.Process) PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) ArrayList(java.util.ArrayList) POSITION_FIRST(com.android.launcher3.recyclerview.ViewHolderBinder.POSITION_FIRST) WidgetListSpaceEntry(com.android.launcher3.widget.model.WidgetListSpaceEntry) POSITION_DEFAULT(com.android.launcher3.recyclerview.ViewHolderBinder.POSITION_DEFAULT) Map(java.util.Map) View(android.view.View) ViewHolder(androidx.recyclerview.widget.RecyclerView.ViewHolder) RecyclerView(androidx.recyclerview.widget.RecyclerView) Log(android.util.Log) IntSupplier(java.util.function.IntSupplier) ActivityContext(com.android.launcher3.views.ActivityContext) WidgetsListHeaderEntry(com.android.launcher3.widget.model.WidgetsListHeaderEntry) LayoutInflater(android.view.LayoutInflater) Adapter(androidx.recyclerview.widget.RecyclerView.Adapter) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) Predicate(java.util.function.Predicate) LAUNCHER_WIDGETSTRAY_APP_EXPANDED(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WIDGETSTRAY_APP_EXPANDED) PackageUserKey(com.android.launcher3.util.PackageUserKey) WidgetsListSearchHeaderEntry(com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry) Collectors(java.util.stream.Collectors) ViewGroup(android.view.ViewGroup) ViewHolderBinder(com.android.launcher3.recyclerview.ViewHolderBinder) SparseArray(android.util.SparseArray) List(java.util.List) Nullable(androidx.annotation.Nullable) WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) R(com.android.launcher3.R) LayoutParams(androidx.recyclerview.widget.RecyclerView.LayoutParams) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) Comparator(java.util.Comparator) OnLongClickListener(android.view.View.OnLongClickListener) Collections(java.util.Collections) OnClickListener(android.view.View.OnClickListener) WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) WidgetListSpaceEntry(com.android.launcher3.widget.model.WidgetListSpaceEntry) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) OptionalInt(java.util.OptionalInt)

Example 8 with WidgetListSpaceEntry

use of com.android.launcher3.widget.model.WidgetListSpaceEntry in project android_packages_apps_Launcher3 by AOSPA.

the class WidgetsListAdapter method updateVisibleEntries.

private void updateVisibleEntries() {
    // Get the current top of the header with the matching key before adjusting the visible
    // entries.
    OptionalInt previousPositionForPackageUserKey = getPositionForPackageUserKey(mPendingClickHeader);
    OptionalInt topForPackageUserKey = getOffsetForPosition(previousPositionForPackageUserKey);
    List<WidgetsListBaseEntry> newVisibleEntries = mAllEntries.stream().filter(entry -> ((mFilter == null || mFilter.test(entry)) && mHeaderAndSelectedContentFilter.test(entry)) || entry instanceof WidgetListSpaceEntry).map(entry -> {
        if (entry instanceof WidgetsListBaseEntry.Header<?> && matchesKey(entry, mWidgetsContentVisiblePackageUserKey)) {
            // Adjust the original entries to expand headers for the selected content.
            return ((WidgetsListBaseEntry.Header<?>) entry).withWidgetListShown();
        } else if (entry instanceof WidgetsListContentEntry) {
            // maxSpanSize.
            return ((WidgetsListContentEntry) entry).withMaxSpanSize(mMaxSpanSize);
        }
        return entry;
    }).collect(Collectors.toList());
    mDiffReporter.process(mVisibleEntries, newVisibleEntries, mRowComparator);
    if (mPendingClickHeader != null) {
        // Get the position for the clicked header after adjusting the visible entries. The
        // position may have changed if another header had previously been expanded.
        OptionalInt positionForPackageUserKey = getPositionForPackageUserKey(mPendingClickHeader);
        scrollToPositionAndMaintainOffset(positionForPackageUserKey, topForPackageUserKey);
        mPendingClickHeader = null;
    }
}
Also used : POSITION_LAST(com.android.launcher3.recyclerview.ViewHolderBinder.POSITION_LAST) IntStream(java.util.stream.IntStream) Context(android.content.Context) Rect(android.graphics.Rect) Arrays(java.util.Arrays) NonNull(androidx.annotation.NonNull) LabelComparator(com.android.launcher3.util.LabelComparator) IconCache(com.android.launcher3.icons.IconCache) OptionalInt(java.util.OptionalInt) Process(android.os.Process) PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) ArrayList(java.util.ArrayList) POSITION_FIRST(com.android.launcher3.recyclerview.ViewHolderBinder.POSITION_FIRST) WidgetListSpaceEntry(com.android.launcher3.widget.model.WidgetListSpaceEntry) POSITION_DEFAULT(com.android.launcher3.recyclerview.ViewHolderBinder.POSITION_DEFAULT) Map(java.util.Map) View(android.view.View) ViewHolder(androidx.recyclerview.widget.RecyclerView.ViewHolder) RecyclerView(androidx.recyclerview.widget.RecyclerView) Log(android.util.Log) IntSupplier(java.util.function.IntSupplier) ActivityContext(com.android.launcher3.views.ActivityContext) WidgetsListHeaderEntry(com.android.launcher3.widget.model.WidgetsListHeaderEntry) LayoutInflater(android.view.LayoutInflater) Adapter(androidx.recyclerview.widget.RecyclerView.Adapter) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) Predicate(java.util.function.Predicate) LAUNCHER_WIDGETSTRAY_APP_EXPANDED(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WIDGETSTRAY_APP_EXPANDED) PackageUserKey(com.android.launcher3.util.PackageUserKey) WidgetsListSearchHeaderEntry(com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry) Collectors(java.util.stream.Collectors) ViewGroup(android.view.ViewGroup) ViewHolderBinder(com.android.launcher3.recyclerview.ViewHolderBinder) SparseArray(android.util.SparseArray) List(java.util.List) Nullable(androidx.annotation.Nullable) WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) R(com.android.launcher3.R) LayoutParams(androidx.recyclerview.widget.RecyclerView.LayoutParams) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) Comparator(java.util.Comparator) OnLongClickListener(android.view.View.OnLongClickListener) Collections(java.util.Collections) OnClickListener(android.view.View.OnClickListener) WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) WidgetListSpaceEntry(com.android.launcher3.widget.model.WidgetListSpaceEntry) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) OptionalInt(java.util.OptionalInt)

Aggregations

WidgetListSpaceEntry (com.android.launcher3.widget.model.WidgetListSpaceEntry)8 Context (android.content.Context)4 Rect (android.graphics.Rect)4 Process (android.os.Process)4 Log (android.util.Log)4 SparseArray (android.util.SparseArray)4 LayoutInflater (android.view.LayoutInflater)4 View (android.view.View)4 OnClickListener (android.view.View.OnClickListener)4 OnLongClickListener (android.view.View.OnLongClickListener)4 ViewGroup (android.view.ViewGroup)4 NonNull (androidx.annotation.NonNull)4 Nullable (androidx.annotation.Nullable)4 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)4 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 Adapter (androidx.recyclerview.widget.RecyclerView.Adapter)4 LayoutParams (androidx.recyclerview.widget.RecyclerView.LayoutParams)4 ViewHolder (androidx.recyclerview.widget.RecyclerView.ViewHolder)4 R (com.android.launcher3.R)4 IconCache (com.android.launcher3.icons.IconCache)4