Search in sources :

Example 1 with POSITION_LAST

use of com.android.launcher3.recyclerview.ViewHolderBinder.POSITION_LAST in project android_packages_apps_Launcher3 by AOSPA.

the class WidgetsListTableViewHolderBinder method bindViewHolder.

@Override
public void bindViewHolder(WidgetsRowViewHolder holder, WidgetsListContentEntry entry, @ListPosition int position, List<Object> payloads) {
    for (Object payload : payloads) {
        Pair<WidgetItem, Bitmap> pair = (Pair) payload;
        holder.previewCache.put(pair.first, pair.second);
    }
    WidgetsListTableView table = holder.tableContainer;
    if (DEBUG) {
        Log.d(TAG, String.format("onBindViewHolder [widget#=%d, table.getChildCount=%d]", entry.mWidgets.size(), table.getChildCount()));
    }
    table.setListDrawableState(((position & POSITION_LAST) != 0) ? LAST : MIDDLE);
    List<ArrayList<WidgetItem>> widgetItemsTable = WidgetsTableUtils.groupWidgetItemsIntoTableWithReordering(entry.mWidgets, entry.getMaxSpanSizeInCells());
    recycleTableBeforeBinding(table, widgetItemsTable);
    // Bind the widget items.
    for (int i = 0; i < widgetItemsTable.size(); i++) {
        List<WidgetItem> widgetItemsPerRow = widgetItemsTable.get(i);
        for (int j = 0; j < widgetItemsPerRow.size(); j++) {
            TableRow row = (TableRow) table.getChildAt(i);
            row.setVisibility(View.VISIBLE);
            WidgetCell widget = (WidgetCell) row.getChildAt(j);
            widget.clear();
            WidgetItem widgetItem = widgetItemsPerRow.get(j);
            widget.setVisibility(View.VISIBLE);
            // When preview loads, notify adapter to rebind the item and possibly animate
            widget.applyFromCellItem(widgetItem, 1f, bitmap -> {
                if (holder.getBindingAdapter() != null) {
                    holder.getBindingAdapter().notifyItemChanged(holder.getBindingAdapterPosition(), Pair.create(widgetItem, bitmap));
                }
            }, holder.previewCache.get(widgetItem));
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) TableRow(android.widget.TableRow) ArrayList(java.util.ArrayList) WidgetItem(com.android.launcher3.model.WidgetItem) WidgetCell(com.android.launcher3.widget.WidgetCell) Pair(android.util.Pair)

Example 2 with POSITION_LAST

use of com.android.launcher3.recyclerview.ViewHolderBinder.POSITION_LAST in project android_packages_apps_Launcher3 by ProtonAOSP.

the class WidgetsListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ViewHolder holder, int pos, List<Object> payloads) {
    ViewHolderBinder viewHolderBinder = mViewHolderBinders.get(getItemViewType(pos));
    WidgetsListBaseEntry entry = mVisibleEntries.get(pos);
    // The first entry has an empty space, count from second entries.
    int listPos = (pos > 1) ? POSITION_DEFAULT : POSITION_FIRST;
    if (pos == (getItemCount() - 1)) {
        listPos |= POSITION_LAST;
    }
    viewHolderBinder.bindViewHolder(holder, mVisibleEntries.get(pos), listPos, payloads);
    holder.itemView.setTag(R.id.tag_widget_entry, entry);
}
Also used : WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) ViewHolderBinder(com.android.launcher3.recyclerview.ViewHolderBinder)

Example 3 with POSITION_LAST

use of com.android.launcher3.recyclerview.ViewHolderBinder.POSITION_LAST in project android_packages_apps_404Launcher by P-404.

the class WidgetsListTableViewHolderBinder method bindViewHolder.

@Override
public void bindViewHolder(WidgetsRowViewHolder holder, WidgetsListContentEntry entry, @ListPosition int position, List<Object> payloads) {
    for (Object payload : payloads) {
        Pair<WidgetItem, Bitmap> pair = (Pair) payload;
        holder.previewCache.put(pair.first, pair.second);
    }
    WidgetsListTableView table = holder.tableContainer;
    if (DEBUG) {
        Log.d(TAG, String.format("onBindViewHolder [widget#=%d, table.getChildCount=%d]", entry.mWidgets.size(), table.getChildCount()));
    }
    table.setListDrawableState(((position & POSITION_LAST) != 0) ? LAST : MIDDLE);
    List<ArrayList<WidgetItem>> widgetItemsTable = WidgetsTableUtils.groupWidgetItemsIntoTableWithReordering(entry.mWidgets, entry.getMaxSpanSizeInCells());
    recycleTableBeforeBinding(table, widgetItemsTable);
    // Bind the widget items.
    for (int i = 0; i < widgetItemsTable.size(); i++) {
        List<WidgetItem> widgetItemsPerRow = widgetItemsTable.get(i);
        for (int j = 0; j < widgetItemsPerRow.size(); j++) {
            TableRow row = (TableRow) table.getChildAt(i);
            row.setVisibility(View.VISIBLE);
            WidgetCell widget = (WidgetCell) row.getChildAt(j);
            widget.clear();
            WidgetItem widgetItem = widgetItemsPerRow.get(j);
            widget.setVisibility(View.VISIBLE);
            // When preview loads, notify adapter to rebind the item and possibly animate
            widget.applyFromCellItem(widgetItem, 1f, bitmap -> {
                if (holder.getBindingAdapter() != null) {
                    holder.getBindingAdapter().notifyItemChanged(holder.getBindingAdapterPosition(), Pair.create(widgetItem, bitmap));
                }
            }, holder.previewCache.get(widgetItem));
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) TableRow(android.widget.TableRow) ArrayList(java.util.ArrayList) WidgetItem(com.android.launcher3.model.WidgetItem) WidgetCell(com.android.launcher3.widget.WidgetCell) Pair(android.util.Pair)

Example 4 with POSITION_LAST

use of com.android.launcher3.recyclerview.ViewHolderBinder.POSITION_LAST in project android_packages_apps_404Launcher by P-404.

the class WidgetsListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ViewHolder holder, int pos, List<Object> payloads) {
    ViewHolderBinder viewHolderBinder = mViewHolderBinders.get(getItemViewType(pos));
    WidgetsListBaseEntry entry = mVisibleEntries.get(pos);
    // The first entry has an empty space, count from second entries.
    int listPos = (pos > 1) ? POSITION_DEFAULT : POSITION_FIRST;
    if (pos == (getItemCount() - 1)) {
        listPos |= POSITION_LAST;
    }
    viewHolderBinder.bindViewHolder(holder, mVisibleEntries.get(pos), listPos, payloads);
    holder.itemView.setTag(R.id.tag_widget_entry, entry);
}
Also used : WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) ViewHolderBinder(com.android.launcher3.recyclerview.ViewHolderBinder)

Example 5 with POSITION_LAST

use of com.android.launcher3.recyclerview.ViewHolderBinder.POSITION_LAST in project android_packages_apps_Launcher3 by ArrowOS.

the class WidgetsListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ViewHolder holder, int pos, List<Object> payloads) {
    ViewHolderBinder viewHolderBinder = mViewHolderBinders.get(getItemViewType(pos));
    WidgetsListBaseEntry entry = mVisibleEntries.get(pos);
    // The first entry has an empty space, count from second entries.
    int listPos = (pos > 1) ? POSITION_DEFAULT : POSITION_FIRST;
    if (pos == (getItemCount() - 1)) {
        listPos |= POSITION_LAST;
    }
    viewHolderBinder.bindViewHolder(holder, mVisibleEntries.get(pos), listPos, payloads);
    holder.itemView.setTag(R.id.tag_widget_entry, entry);
}
Also used : WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) ViewHolderBinder(com.android.launcher3.recyclerview.ViewHolderBinder)

Aggregations

Bitmap (android.graphics.Bitmap)4 Pair (android.util.Pair)4 TableRow (android.widget.TableRow)4 WidgetItem (com.android.launcher3.model.WidgetItem)4 ViewHolderBinder (com.android.launcher3.recyclerview.ViewHolderBinder)4 WidgetCell (com.android.launcher3.widget.WidgetCell)4 WidgetsListBaseEntry (com.android.launcher3.widget.model.WidgetsListBaseEntry)4 ArrayList (java.util.ArrayList)4