All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.joanzapata.android.EnhancedQuickAdapter Maven / Gradle / Ivy

There is a newer version: 1.1.11
Show newest version
package com.joanzapata.android;

import android.content.Context;

import java.util.List;

/**
 * Same as QuickAdapter, but adds an "itemChanged" boolean in the
 * convert() method params, which allows you to know if you are
 * adapting the new view to the same item or not, and therefore
 * make a difference between dataset changed / dataset invalidated.
 * 

* Abstraction class of a BaseAdapter in which you only need * to provide the convert() implementation.
* Using the provided BaseAdapterHelper, your code is minimalist. * @param The type of the items in the list. */ public abstract class EnhancedQuickAdapter extends QuickAdapter { /** * Create a QuickAdapter. * @param context The context. * @param layoutResId The layout resource id of each item. */ public EnhancedQuickAdapter(Context context, int layoutResId) { super(context, layoutResId); } /** * Same as QuickAdapter#QuickAdapter(Context,int) but with * some initialization data. * @param context The context. * @param layoutResId The layout resource id of each item. * @param data A new list is created out of this one to avoid mutable list */ public EnhancedQuickAdapter(Context context, int layoutResId, List data) { super(context, layoutResId, data); } @Override protected final void convert(BaseAdapterHelper helper, T item) { boolean itemChanged = helper.associatedObject == null || !helper.associatedObject.equals(item); helper.associatedObject = item; convert(helper, item, itemChanged); } /** * @param helper The helper to use to adapt the view. * @param item The item you should adapt the view to. * @param itemChanged Whether or not the helper was bound to another object before. */ protected abstract void convert(BaseAdapterHelper helper, T item, boolean itemChanged); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy