public class

DataBufferAdapter

extends BaseAdapter
java.lang.Object
   ↳ android.widget.BaseAdapter
     ↳ com.google.android.gms.drive.widget.DataBufferAdapter<T>

Class Overview

A concrete BaseAdapter that is backed by concatenated DataBuffers. The assumptions and behaviors of this adapter parallel those of the ArrayAdapter:

  • that the provided resource id in the simple constructors references a single TextView
  • that more complex layouts use constructors taking a field id that references a TextView in the larger layout resource
  • that the objects in the DataBuffer have an appropriate toString() method, which will be used to populate the TextView

If you need to modify how the objects display in the TextView, override their toString() method.

In addition, any DataBuffers added to this adapter are managed entirely by this adapter, including their life cycle. Be sure to call clear() anywhere you would otherwise close the data buffers used here, and if you want to manage their life cycles more granularly, you will need to override the behavior of clear(), as well as add your own management methods to ensure resources are properly managed within your application.

If you need something other than a single TextView for the data in this adapter, override getView(int, View, ViewGroup) to populate and return the type of view you want.

Summary

[Expand]
Inherited Constants
From interface android.widget.Adapter
Public Constructors
DataBufferAdapter(Context context, int resource, int textViewResourceId, List<DataBuffer<T>> objects)
DataBufferAdapter(Context context, int resource, int textViewResourceId)
DataBufferAdapter(Context context, int resource, List<DataBuffer<T>> objects)
DataBufferAdapter(Context context, int resource)
DataBufferAdapter(Context context, int resource, int textViewResourceId, DataBuffer...<T> buffers)
DataBufferAdapter(Context context, int resource, DataBuffer...<T> buffers)
Public Methods
void append(DataBuffer<T> buffer)
Appends the specified buffer to the end of the adapter.
void clear()
Closes and removes all buffers, and so all elements, from the adapter.
Context getContext()
int getCount()
View getDropDownView(int position, View convertView, ViewGroup parent)
T getItem(int position)
long getItemId(int position)
View getView(int position, View convertView, ViewGroup parent)
void notifyDataSetChanged()
This will also re-enable automatic notifications.
void setDropDownViewResource(int resource)
Sets the layout resource to create the drop down views.
void setNotifyOnChange(boolean notifyOnChange)

Control whether methods that change the list (append(DataBuffer), clear()) automatically call notifyDataSetChanged().

[Expand]
Inherited Methods
From class android.widget.BaseAdapter
From class java.lang.Object
From interface android.widget.ListAdapter
From interface android.widget.SpinnerAdapter
From interface android.widget.Adapter

Public Constructors

public DataBufferAdapter (Context context, int resource, int textViewResourceId, List<DataBuffer<T>> objects)

Parameters
context Context
resource int
textViewResourceId int
objects List

public DataBufferAdapter (Context context, int resource, int textViewResourceId)

Parameters
context Context
resource int
textViewResourceId int

public DataBufferAdapter (Context context, int resource, List<DataBuffer<T>> objects)

Parameters
context Context
resource int
objects List

public DataBufferAdapter (Context context, int resource)

Parameters
context Context
resource int

public DataBufferAdapter (Context context, int resource, int textViewResourceId, DataBuffer...<T> buffers)

Parameters
context Context
resource int
textViewResourceId int
buffers DataBuffer

public DataBufferAdapter (Context context, int resource, DataBuffer...<T> buffers)

Parameters
context Context
resource int
buffers DataBuffer

Public Methods

public void append (DataBuffer<T> buffer)

Appends the specified buffer to the end of the adapter.

Parameters
buffer DataBuffer

public void clear ()

Closes and removes all buffers, and so all elements, from the adapter.

public Context getContext ()

Returns
Context

public int getCount ()

Returns
int

public View getDropDownView (int position, View convertView, ViewGroup parent)

Parameters
position int
convertView View
parent ViewGroup
Returns
View

public T getItem (int position)

Parameters
position int
Returns
T
Throws
CursorIndexOutOfBoundsException

public long getItemId (int position)

Parameters
position int
Returns
long

public View getView (int position, View convertView, ViewGroup parent)

Parameters
position int
convertView View
parent ViewGroup
Returns
View

public void notifyDataSetChanged ()

This will also re-enable automatic notifications. Pairing this with setNotifyOnChange(boolean) gives the ability to make a series of changes to the adapter without triggering multiple notifications at the same time. Use these two methods together to temporarily disable notifications for the purpose of batching operations on the adapter.

public void setDropDownViewResource (int resource)

Sets the layout resource to create the drop down views.

Parameters
resource int

public void setNotifyOnChange (boolean notifyOnChange)

Control whether methods that change the list (append(DataBuffer), clear()) automatically call notifyDataSetChanged(). If set to false, caller must manually call notifyDataSetChanged() to have the changes reflected in the attached view.

The default is true, and calling notifyDataSetChanged() resets the flag to true. Use this method if you want to make several changes to the adapter in a row, and don't need the view to update in between changes. This reduces the processing load for each operation significantly.

Parameters
notifyOnChange boolean: if true, modifications to the list will automatically call notifyDataSetChanged()