120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn/* 220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * Copyright (C) 2014 The Android Open Source Project 320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * 420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 520c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * in compliance with the License. You may obtain a copy of the License at 620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * 720c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * http://www.apache.org/licenses/LICENSE-2.0 820c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * 920c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * Unless required by applicable law or agreed to in writing, software distributed under the License 1020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 1120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * or implied. See the License for the specific language governing permissions and limitations under 1220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * the License. 1320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 1420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbournpackage android.support.v17.leanback.widget; 1520c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 1620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbournimport android.database.Observable; 1720c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 1820c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn/** 19a00bada00bff4a58436a39472ab14ccb7a8f619dCraig Stout * Base class adapter to be used in leanback activities. Provides access to a data model and is 2020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * decoupled from the presentation of the items via {@link PresenterSelector}. 2120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 2220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbournpublic abstract class ObjectAdapter { 2347520b68e50572a9775a662410c5aff8300c8784Craig Stout 24beeaa973d1b5bd79ee8ae798141231d9a315eba7Tim Kilbourn /** Indicates that an id has not been set. */ 2547520b68e50572a9775a662410c5aff8300c8784Craig Stout public static final int NO_ID = -1; 2647520b68e50572a9775a662410c5aff8300c8784Craig Stout 2720c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn /** 2820c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * A DataObserver can be notified when an ObjectAdapter's underlying data 2920c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * changes. Separate methods provide notifications about different types of 3020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * changes. 3120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 3220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn public static abstract class DataObserver { 3320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn /** 3420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * Called whenever the ObjectAdapter's data has changed in some manner 35beeaa973d1b5bd79ee8ae798141231d9a315eba7Tim Kilbourn * outside of the set of changes covered by the other range-based change 3620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * notification methods. 3720c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 3820c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn public void onChanged() { 3920c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 4020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 4120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn /** 4220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * Called when a range of items in the ObjectAdapter has changed. The 4320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * basic ordering and structure of the ObjectAdapter has not changed. 4420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * 4520c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * @param positionStart The position of the first item that changed. 4620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * @param itemCount The number of items changed. 4720c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 4820c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn public void onItemRangeChanged(int positionStart, int itemCount) { 4920c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn onChanged(); 5020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 5120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 5220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn /** 5320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * Called when a range of items is inserted into the ObjectAdapter. 5420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * 5520c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * @param positionStart The position of the first inserted item. 5620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * @param itemCount The number of items inserted. 5720c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 5820c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn public void onItemRangeInserted(int positionStart, int itemCount) { 5920c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn onChanged(); 6020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 6120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 6220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn /** 6320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * Called when a range of items is removed from the ObjectAdapter. 6420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * 6520c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * @param positionStart The position of the first removed item. 6620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * @param itemCount The number of items removed. 6720c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 6820c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn public void onItemRangeRemoved(int positionStart, int itemCount) { 6920c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn onChanged(); 7020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 7120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 7220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 730f1fa0dfa946ddc8afb6af26a4dd1a4d01dca10fDake Gu private static final class DataObservable extends Observable<DataObserver> { 7420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 7520c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn public void notifyChanged() { 7620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn for (int i = mObservers.size() - 1; i >= 0; i--) { 7720c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn mObservers.get(i).onChanged(); 7820c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 7920c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 8020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 8120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn public void notifyItemRangeChanged(int positionStart, int itemCount) { 8220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn for (int i = mObservers.size() - 1; i >= 0; i--) { 8320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn mObservers.get(i).onItemRangeChanged(positionStart, itemCount); 8420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 8520c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 8620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 8720c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn public void notifyItemRangeInserted(int positionStart, int itemCount) { 8820c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn for (int i = mObservers.size() - 1; i >= 0; i--) { 8920c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn mObservers.get(i).onItemRangeInserted(positionStart, itemCount); 9020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 9120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 9220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 9320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn public void notifyItemRangeRemoved(int positionStart, int itemCount) { 9420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn for (int i = mObservers.size() - 1; i >= 0; i--) { 9520c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn mObservers.get(i).onItemRangeRemoved(positionStart, itemCount); 9620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 9720c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 9820c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 9920c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 10020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn private final DataObservable mObservable = new DataObservable(); 10120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn private boolean mHasStableIds; 10220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn private PresenterSelector mPresenterSelector; 10320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 10420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn /** 105a00bada00bff4a58436a39472ab14ccb7a8f619dCraig Stout * Constructs an adapter with the given {@link PresenterSelector}. 10620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 10720c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn public ObjectAdapter(PresenterSelector presenterSelector) { 10820c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn setPresenterSelector(presenterSelector); 10920c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 11020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 11120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn /** 112a00bada00bff4a58436a39472ab14ccb7a8f619dCraig Stout * Constructs an adapter that uses the given {@link Presenter} for all items. 11320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 11420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn public ObjectAdapter(Presenter presenter) { 11520c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn setPresenterSelector(new SinglePresenterSelector(presenter)); 11620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 11720c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 11820c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn /** 119a00bada00bff4a58436a39472ab14ccb7a8f619dCraig Stout * Constructs an adapter. 12020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 12120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn public ObjectAdapter() { 12220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 12320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 12420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn /** 125a00bada00bff4a58436a39472ab14ccb7a8f619dCraig Stout * Sets the presenter selector. May not be null. 12620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 1270f1fa0dfa946ddc8afb6af26a4dd1a4d01dca10fDake Gu public final void setPresenterSelector(PresenterSelector presenterSelector) { 12820c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn if (presenterSelector == null) { 12920c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn throw new IllegalArgumentException("Presenter selector must not be null"); 13020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 13120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn final boolean update = (mPresenterSelector != null); 132b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson final boolean selectorChanged = update && mPresenterSelector != presenterSelector; 133b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson 13420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn mPresenterSelector = presenterSelector; 135b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson 136b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson if (selectorChanged) { 137b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson onPresenterSelectorChanged(); 138b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson } 13920c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn if (update) { 14020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn notifyChanged(); 14120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 14220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 14320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 14420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn /** 145b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson * Called when {@link #setPresenterSelector(PresenterSelector)} is called 146b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson * and the PresenterSelector differs from the previous one. 147b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson */ 148b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson protected void onPresenterSelectorChanged() { 149b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson } 150b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson 151b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson /** 152beeaa973d1b5bd79ee8ae798141231d9a315eba7Tim Kilbourn * Returns the presenter selector for this ObjectAdapter. 15320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 1540f1fa0dfa946ddc8afb6af26a4dd1a4d01dca10fDake Gu public final PresenterSelector getPresenterSelector() { 15520c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn return mPresenterSelector; 15620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 15720c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 15820c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn /** 159a00bada00bff4a58436a39472ab14ccb7a8f619dCraig Stout * Registers a DataObserver for data change notifications. 16020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 1610f1fa0dfa946ddc8afb6af26a4dd1a4d01dca10fDake Gu public final void registerObserver(DataObserver observer) { 16220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn mObservable.registerObserver(observer); 16320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 16420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 16520c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn /** 166a00bada00bff4a58436a39472ab14ccb7a8f619dCraig Stout * Unregisters a DataObserver for data change notifications. 16720c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 1680f1fa0dfa946ddc8afb6af26a4dd1a4d01dca10fDake Gu public final void unregisterObserver(DataObserver observer) { 16920c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn mObservable.unregisterObserver(observer); 17020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 17120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 17220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn /** 173a00bada00bff4a58436a39472ab14ccb7a8f619dCraig Stout * Unregisters all DataObservers for this ObjectAdapter. 17420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 1750f1fa0dfa946ddc8afb6af26a4dd1a4d01dca10fDake Gu public final void unregisterAllObservers() { 17620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn mObservable.unregisterAll(); 17720c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 17820c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 17920c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn final protected void notifyItemRangeChanged(int positionStart, int itemCount) { 18020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn mObservable.notifyItemRangeChanged(positionStart, itemCount); 18120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 18220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 18320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn final protected void notifyItemRangeInserted(int positionStart, int itemCount) { 18420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn mObservable.notifyItemRangeInserted(positionStart, itemCount); 18520c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 18620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 18720c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn final protected void notifyItemRangeRemoved(int positionStart, int itemCount) { 18820c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn mObservable.notifyItemRangeRemoved(positionStart, itemCount); 18920c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 19020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 19120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn final protected void notifyChanged() { 19220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn mObservable.notifyChanged(); 19320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 19420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 19520c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn /** 196a00bada00bff4a58436a39472ab14ccb7a8f619dCraig Stout * Returns true if the item ids are stable across changes to the 197beeaa973d1b5bd79ee8ae798141231d9a315eba7Tim Kilbourn * underlying data. When this is true, clients of the ObjectAdapter can use 198beeaa973d1b5bd79ee8ae798141231d9a315eba7Tim Kilbourn * {@link #getId(int)} to correlate Objects across changes. 19920c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 2000f1fa0dfa946ddc8afb6af26a4dd1a4d01dca10fDake Gu public final boolean hasStableIds() { 20120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn return mHasStableIds; 20220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 20320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 20420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn /** 20520c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * Sets whether the item ids are stable across changes to the underlying 20620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * data. 20720c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 2080f1fa0dfa946ddc8afb6af26a4dd1a4d01dca10fDake Gu public final void setHasStableIds(boolean hasStableIds) { 209b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson boolean changed = mHasStableIds != hasStableIds; 21020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn mHasStableIds = hasStableIds; 211b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson 212b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson if (changed) { 213b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson onHasStableIdsChanged(); 214b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson } 215b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson } 216b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson 217b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson /** 218b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson * Called when {@link #setHasStableIds(boolean)} is called and the status 219b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson * of stable ids has changed. 220b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson */ 221b3451baf39c3b17972e7826baee90be4b1cd2626Justin Mattson protected void onHasStableIdsChanged() { 22220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 22320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 22420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn /** 22520c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * Returns the {@link Presenter} for the given item from the adapter. 22620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 2270f1fa0dfa946ddc8afb6af26a4dd1a4d01dca10fDake Gu public final Presenter getPresenter(Object item) { 22820c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn if (mPresenterSelector == null) { 22920c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn throw new IllegalStateException("Presenter selector must not be null"); 23020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 23120c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn return mPresenterSelector.getPresenter(item); 23220c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn } 23320c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 23420c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn /** 23520c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn * Returns the number of items in the adapter. 23620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 23720c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn public abstract int size(); 23820c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn 23920c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn /** 24047520b68e50572a9775a662410c5aff8300c8784Craig Stout * Returns the item for the given position. 24147520b68e50572a9775a662410c5aff8300c8784Craig Stout */ 24247520b68e50572a9775a662410c5aff8300c8784Craig Stout public abstract Object get(int position); 24347520b68e50572a9775a662410c5aff8300c8784Craig Stout 24447520b68e50572a9775a662410c5aff8300c8784Craig Stout /** 245a00bada00bff4a58436a39472ab14ccb7a8f619dCraig Stout * Returns the id for the given position. 24620c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn */ 24747520b68e50572a9775a662410c5aff8300c8784Craig Stout public long getId(int position) { 24847520b68e50572a9775a662410c5aff8300c8784Craig Stout return NO_ID; 24947520b68e50572a9775a662410c5aff8300c8784Craig Stout } 25020c094c196271089a7119a965b6a99786ea9ed36Tim Kilbourn} 251