Android Open Source - RZAndroidBaseUtils View Holder Strategy






From Project

Back to project page RZAndroidBaseUtils.

License

The source code is released under:

MIT License

If you think the Android project RZAndroidBaseUtils listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.raizlabs.widget.utils;
//  w  w w  . ja va2s.c o m
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

/**
 * Interface which indicates that this object provides methods to create
 * and populate view holder objects for some type of item. This class is
 * often used with a List Adapter. The view holders keep references to
 * the sub views that may need to be updated to prevent looking them up
 * multiple times.
 * 
 * @see SimpleViewHolderStrategy
 * @author Dylan James
 *
 *@param <Item> The type of item to create views for.
 *@param <Holder> The type of the view holder this class uses.
 */
public interface ViewHolderStrategy<Item, Holder> {  
  /**
   * @see BaseAdapter#areAllItemsEnabled()
   * @return True if all items are enabled.
   */
  public boolean areAllItemsEnabled();
  /**
   * Gets whether the given item is enabled.
   * @see BaseAdapter#isEnabled(int)
   * @param item The item being looked up.
   * @return True if the item is enabled.
   */
  public boolean isEnabled(Item item);
  
  /**
   * Gets an integer representing the view type for the given item.
   * @see BaseAdapter#getItemViewType(int)
   * @param item The item to get the view type for.
   * @return An integer representing the view type.
   */
  public int getItemViewType(Item item);
  
  /**
   * @see BaseAdapter#getViewTypeCount()
   * 
   * @return The total number of view types for this strategy.
   */
  public int getViewTypeCount();
  
  /**
   * Inflates a View for the given item.
   * @param item The item to inflate a View for.
   * @param inflater The inflater to use to inflate the view.
   * @param container The container the {@link View} will be added to. The
   * implementation should not add the view itself.
   * @return The inflated View.
   */
  public View inflateView(Item item, LayoutInflater inflater, ViewGroup container);
  
  
  
  /**
   * Creates a view holder object for the given item.
   * @param item The item to create a view holder for.
   * @return The created view holder.
   */
  public Holder createHolder(Item item);
  
  /**
   * Checks if the given view holder is a valid view holder for the given
   * item. In simple cases, this just needs to be an instanceof check on the holder.
   * @param item The item the view holder should be valid for.
   * @param holder The view holder to check for validity.
   * @return True if the view holder is valid.
   */
  public boolean isValidViewHolder(Item item, Object holder);
  
  /**
   * Populates the view pointers in the given view holder to point
   * to the views in the given {@link View}. 
   * @param view The {@link View} to populate the view holder from.
   * @param holder The view holder to populate.
   */
  public void populateHolder(View view, Holder holder);
  
  /**
   * Updates the views in the given view holder to represent the given
   * item.
   * @param item The item the view holder should represent.
   * @param holder The view holder to update.
   */
  public void updateView(Item item, Holder holder);
}




Java Source Code List

com.raizlabs.baseutils.CompatibilityUtils.java
com.raizlabs.baseutils.IOUtils.java
com.raizlabs.baseutils.Logger.java
com.raizlabs.baseutils.Math.java
com.raizlabs.baseutils.StringUtils.java
com.raizlabs.baseutils.ThreadingUtils.java
com.raizlabs.baseutils.Wrapper.java
com.raizlabs.baseutils.examples.MainActivity.java
com.raizlabs.baseutils.examples.asyncdrawable.AsyncDrawableExampleActivity.java
com.raizlabs.baseutils.examples.asyncdrawable.AsyncDrawableListExampleActivity.java
com.raizlabs.baseutils.examples.simplegenericadapter.SimpleGenericAdapterExampleActivity.java
com.raizlabs.baseutils.examples.viewgroupadapter.ViewGroupAdapterExampleActivity.java
com.raizlabs.baseutils.examples.viewholderstrategy.SimpleViewHolderStrategyExampleActivity.java
com.raizlabs.collections.ListUtils.java
com.raizlabs.collections.MappableSet.java
com.raizlabs.collections.TransactionalHashSet.java
com.raizlabs.concurrent.BasePrioritizedRunnable.java
com.raizlabs.concurrent.ConcurrencyUtils.java
com.raizlabs.concurrent.PrioritizedRunnable.java
com.raizlabs.concurrent.Prioritized.java
com.raizlabs.content.sharing.SharingUtils.java
com.raizlabs.database.CursorIterable.java
com.raizlabs.database.CursorIterator.java
com.raizlabs.events.EventListener.java
com.raizlabs.events.Event.java
com.raizlabs.events.ProgressListener.java
com.raizlabs.events.SimpleEventListener.java
com.raizlabs.functions.Delegate.java
com.raizlabs.functions.Predicate.java
com.raizlabs.functions.Provider.java
com.raizlabs.graphics.ImageFactory.java
com.raizlabs.graphics.drawable.async.AsyncDrawableTask.java
com.raizlabs.graphics.drawable.async.AsyncDrawableUtils.java
com.raizlabs.graphics.drawable.async.AsyncDrawableWrapper.java
com.raizlabs.graphics.drawable.async.AsyncDrawable.java
com.raizlabs.graphics.drawable.async.BaseAsyncDrawableTask.java
com.raizlabs.imagecaching.ImageCache.java
com.raizlabs.imagecaching.PrefixedImageCacheAdapter.java
com.raizlabs.imagecaching.StubImageCache.java
com.raizlabs.json.JSONArrayParserDelegate.java
com.raizlabs.json.JSONHelper.java
com.raizlabs.synchronization.OneShotLock.java
com.raizlabs.tasks.RZAsyncTaskEvent.java
com.raizlabs.tasks.RZAsyncTaskListener.java
com.raizlabs.tasks.RZAsyncTask.java
com.raizlabs.util.observable.ObservableData.java
com.raizlabs.util.observable.ObservableListAdapter.java
com.raizlabs.util.observable.ObservableList.java
com.raizlabs.view.ViewCompatibility.java
com.raizlabs.view.animation.AnimationListenerWrapper.java
com.raizlabs.view.animation.RelativeLayoutParamsAnimation.java
com.raizlabs.view.animation.ResizeAnimation.java
com.raizlabs.widget.EvenLinearLayout.java
com.raizlabs.widget.ImageMixView.java
com.raizlabs.widget.SlideRevealLayout.java
com.raizlabs.widget.ViewUtils.java
com.raizlabs.widget.adapters.ListBasedAdapter.java
com.raizlabs.widget.adapters.SimpleGenericAdapter.java
com.raizlabs.widget.adapters.ViewGroupAdapter.java
com.raizlabs.widget.adapters.ViewHolderStrategyAdapter.java
com.raizlabs.widget.utils.SimpleViewHolderStrategy.java
com.raizlabs.widget.utils.ViewHolderStrategyConverter.java
com.raizlabs.widget.utils.ViewHolderStrategyUtils.java
com.raizlabs.widget.utils.ViewHolderStrategy.java