public final class PageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Modifier and Type | Class and Description |
---|---|
static interface |
PageAdapter.ContentCallbacks |
static interface |
PageAdapter.PreviewArea |
Constructor and Description |
---|
PageAdapter(Context context,
PageAdapter.ContentCallbacks callbacks,
PageAdapter.PreviewArea previewArea) |
Modifier and Type | Method and Description |
---|---|
void |
close(Runnable callback) |
void |
destroy(Runnable callback) |
protected void |
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
int |
getFilePageCount() |
int |
getItemCount()
Returns the total number of items in the data set held by the adapter.
|
long |
getItemId(int position)
Return the stable ID for the item at
position . |
PageRange[] |
getRequestedPages() |
PageRange[] |
getSelectedPages() |
boolean |
isOpened() |
void |
onBindViewHolder(RecyclerView.ViewHolder holder,
int position)
Called by RecyclerView to display the data at the specified position.
|
RecyclerView.ViewHolder |
onCreateViewHolder(ViewGroup parent,
int viewType)
Called when RecyclerView needs a new
RecyclerView.ViewHolder of the given type to represent
an item. |
void |
onOrientationChanged() |
void |
onPreviewAreaSizeChanged() |
void |
onViewRecycled(RecyclerView.ViewHolder holder)
Called when a view created by this adapter has been recycled.
|
void |
open(ParcelFileDescriptor source,
Runnable callback) |
void |
startPreloadContent(PageRange pageRangeInAdapter) |
void |
stopPreloadContent() |
void |
update(PageRange[] writtenPages,
PageRange[] selectedPages,
int documentPageCount,
PrintAttributes.MediaSize mediaSize,
PrintAttributes.Margins minMargins) |
bindViewHolder, createViewHolder, getItemViewType, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onBindViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, registerAdapterDataObserver, setHasStableIds, unregisterAdapterDataObserver
public PageAdapter(Context context, PageAdapter.ContentCallbacks callbacks, PageAdapter.PreviewArea previewArea)
public void onOrientationChanged()
public boolean isOpened()
public int getFilePageCount()
public void open(ParcelFileDescriptor source, Runnable callback)
public void update(PageRange[] writtenPages, PageRange[] selectedPages, int documentPageCount, PrintAttributes.MediaSize mediaSize, PrintAttributes.Margins minMargins)
public void close(Runnable callback)
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
RecyclerView.Adapter
RecyclerView.ViewHolder
of the given type to represent
an item.
This new ViewHolder should be constructed with a new View that can represent the items of the given type. You can either create a new View manually or inflate it from an XML layout file.
The new ViewHolder will be used to display items of the adapter using
#onBindViewHolder(ViewHolder, int, List)
. Since it will be re-used to display
different items in the data set, it is a good idea to cache references to sub views of
the View to avoid unnecessary View.findViewById(int)
calls.
onCreateViewHolder
in class RecyclerView.Adapter<RecyclerView.ViewHolder>
parent
- The ViewGroup into which the new View will be added after it is bound to
an adapter position.viewType
- The view type of the new View.RecyclerView.Adapter.getItemViewType(int)
,
#onBindViewHolder(ViewHolder, int)
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position)
RecyclerView.Adapter
RecyclerView.ViewHolder.itemView
to reflect the item at the given
position.
Note that unlike ListView
, RecyclerView will not call this method
again if the position of the item changes in the data set unless the item itself is
invalidated or the new position cannot be determined. For this reason, you should only
use the position
parameter while acquiring the related data item inside
this method and should not keep a copy of it. If you need the position of an item later
on (e.g. in a click listener), use RecyclerView.ViewHolder.getAdapterPosition()
which will
have the updated adapter position.
Override #onBindViewHolder(ViewHolder, int, List)
instead if Adapter can
handle efficient partial bind.
onBindViewHolder
in class RecyclerView.Adapter<RecyclerView.ViewHolder>
holder
- The ViewHolder which should be updated to represent the contents of the
item at the given position in the data set.position
- The position of the item within the adapter's data set.public int getItemCount()
RecyclerView.Adapter
getItemCount
in class RecyclerView.Adapter<RecyclerView.ViewHolder>
public long getItemId(int position)
RecyclerView.Adapter
position
. If RecyclerView.Adapter.hasStableIds()
would return false this method should return RecyclerView.NO_ID
. The default implementation
of this method returns RecyclerView.NO_ID
.getItemId
in class RecyclerView.Adapter<RecyclerView.ViewHolder>
position
- Adapter position to querypublic void onViewRecycled(RecyclerView.ViewHolder holder)
RecyclerView.Adapter
A view is recycled when a RecyclerView.LayoutManager
decides that it no longer
needs to be attached to its parent RecyclerView
. This can be because it has
fallen out of visibility or a set of cached views represented by views still
attached to the parent RecyclerView. If an item view has large or expensive data
bound to it such as large bitmaps, this may be a good place to release those
resources.
RecyclerView calls this method right before clearing ViewHolder's internal data and
sending it to RecycledViewPool. This way, if ViewHolder was holding valid information
before being recycled, you can call RecyclerView.ViewHolder.getAdapterPosition()
to get
its adapter position.
onViewRecycled
in class RecyclerView.Adapter<RecyclerView.ViewHolder>
holder
- The ViewHolder for the view being recycledpublic PageRange[] getRequestedPages()
public PageRange[] getSelectedPages()
public void onPreviewAreaSizeChanged()
public void destroy(Runnable callback)
protected void finalize() throws Throwable
Object
finalize
method to dispose of
system resources or to perform other cleanup.
The general contract of finalize
is that it is invoked
if and when the JavaTM virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The finalize
method may take any action, including
making this object available again to other threads; the usual purpose
of finalize
, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.
The finalize
method of class Object
performs no
special action; it simply returns normally. Subclasses of
Object
may override this definition.
The Java programming language does not guarantee which thread will
invoke the finalize
method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.
After the finalize
method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.
The finalize
method is never invoked more than once by a Java
virtual machine for any given object.
Any exception thrown by the finalize
method causes
the finalization of this object to be halted, but is otherwise
ignored.
public void startPreloadContent(PageRange pageRangeInAdapter)
public void stopPreloadContent()