Java Code Examples for eu.davidea.flexibleadapter.FlexibleAdapter#isLastItemInActionMode()

The following examples show how to use eu.davidea.flexibleadapter.FlexibleAdapter#isLastItemInActionMode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExpandableLevel1Item.java    From FlexibleAdapter with Apache License 2.0 5 votes vote down vote up
@Override
public void bindViewHolder(final FlexibleAdapter adapter, ExpandableItem.ParentViewHolder holder, int position, List payloads) {
    Context context = holder.itemView.getContext();

    setSubtitle(adapter.getCurrentChildren(this).size() + " subItems");
    holder.mSubtitle.setText(getSubtitle());

    // Background, when bound the first time
    if (payloads.size() == 0) {
        holder.mTitle.setText(getTitle());

        Drawable drawable = DrawableUtils.getSelectableBackgroundCompat(
                Color.WHITE, Color.parseColor("#dddddd"), // Same color of divider
                DrawableUtils.getColorControlHighlight(context));
        DrawableUtils.setBackgroundCompat(holder.itemView, drawable);
        DrawableUtils.setBackgroundCompat(holder.frontView, drawable);
    } else {
        Log.d(this.getClass().getSimpleName(), "ExpandableHeaderItem Payload " + payloads);
    }

    // ANIMATION EXAMPLE!! ImageView - Handle Flip Animation on Select ALL and Deselect ALL
    if (adapter.isSelectAll() || adapter.isLastItemInActionMode()) {
        // Consume the Animation
        holder.mFlipView.flip(adapter.isSelected(position), 200L);
    } else {
        // Display the current flip status
        holder.mFlipView.flipSilently(adapter.isSelected(position));
    }
}
 
Example 2
Source File: ExpandableItem.java    From FlexibleAdapter with Apache License 2.0 4 votes vote down vote up
@Override
public void bindViewHolder(final FlexibleAdapter<IFlexible> adapter, ParentViewHolder holder, int position, List<Object> payloads) {
    Context context = holder.itemView.getContext();

    // Subtitle
    setSubtitle(adapter.getCurrentChildren(this).size() + " subItems"
            + (getHeader() != null ? " - " + getHeader().getId() : "")
            + (getUpdates() > 0 ? " - u" + getUpdates() : ""));

    // Background, when bound the first time
    if (payloads.size() == 0) {
        Drawable drawable = DrawableUtils.getSelectableBackgroundCompat(
                Color.WHITE, Color.parseColor("#dddddd"), // Same color of divider
                DrawableUtils.getColorControlHighlight(context));
        DrawableUtils.setBackgroundCompat(holder.itemView, drawable);
        DrawableUtils.setBackgroundCompat(holder.frontView, drawable);
    }

    if (payloads.size() > 0) {
        Log.d(this.getClass().getSimpleName(), "ExpandableItem Payload " + payloads);
        if (adapter.hasFilter()) {
            FlexibleUtils.highlightText(holder.mSubtitle, getSubtitle(), adapter.getFilter(String.class));
        } else {
            holder.mSubtitle.setText(getSubtitle());
        }
        // We stop the process here, we only want to update the subtitle

    } else {
        // DemoApp: INNER ANIMATION EXAMPLE! ImageView - Handle Flip Animation on
        // Select ALL and Deselect ALL
        if (adapter.isSelectAll() || adapter.isLastItemInActionMode()) {
            // Consume the Animation
            holder.mFlipView.flip(adapter.isSelected(position), 200L);
        } else {
            // Display the current flip status
            holder.mFlipView.flipSilently(adapter.isSelected(position));
        }

        // In case of searchText matches with Title or with a field this will be highlighted
        if (adapter.hasFilter()) {
            String filter = adapter.getFilter(String.class);
            FlexibleUtils.highlightWords(holder.mTitle, getTitle(), filter);
            FlexibleUtils.highlightWords(holder.mSubtitle, getSubtitle(), filter);
        } else {
            holder.mTitle.setText(getTitle());
            holder.mSubtitle.setText(getSubtitle());
        }
    }
}