AeroGear Android Library 1.1.0

org.jboss.aerogear.android.impl.pipeline
Class SupportLoaderAdapter<T>

java.lang.Object
  extended by org.jboss.aerogear.android.impl.pipeline.SupportLoaderAdapter<T>
All Implemented Interfaces:
android.support.v4.app.LoaderManager.LoaderCallbacks<T>, LoaderPipe<T>, Pipe<T>

public class SupportLoaderAdapter<T>
extends Object
implements LoaderPipe<T>, android.support.v4.app.LoaderManager.LoaderCallbacks<T>

This class wraps a Pipe in an asynchronous Loader. This classes uses Loaders from android.support. If you do not need to support Android devices < version 3.0, consider using LoaderAdapter


Field Summary
 
Fields inherited from interface org.jboss.aerogear.android.pipeline.LoaderPipe
CALLBACK, FILTER, ITEM, METHOD, REMOVE_ID
 
Constructor Summary
SupportLoaderAdapter(android.support.v4.app.FragmentActivity activity, Pipe<T> pipe, com.google.gson.Gson gson, String name)
          Deprecated. 
SupportLoaderAdapter(android.support.v4.app.FragmentActivity activity, Pipe<T> pipe, String name)
           
SupportLoaderAdapter(android.support.v4.app.Fragment fragment, android.content.Context applicationContext, Pipe<T> pipe, com.google.gson.Gson gson, String name)
          Deprecated. 
SupportLoaderAdapter(android.support.v4.app.Fragment fragment, android.content.Context applicationContext, Pipe<T> pipe, String name)
           
 
Method Summary
 com.google.gson.Gson getGson()
          Returns the GSON serializer used to serialized instances of objects.
 PipeHandler<T> getHandler()
          Returns the instance which is responsible for handling read, save, and remove.
 Class<T> getKlass()
           
 RequestBuilder<T> getRequestBuilder()
          The RequestBuilder is responsible for turning objects in bodies of requests.
 ResponseParser<T> getResponseParser()
          The ResponseParser is responsible for turning responses from a SAVE into an object
 PipeType getType()
          Returns the connection type of this Pipe object (e.g.
 URL getUrl()
          Returns the URL to which this Pipe object points.
 android.support.v4.content.Loader<T> onCreateLoader(int id, android.os.Bundle bundle)
           
 void onLoaderReset(android.support.v4.content.Loader<T> loader)
           
 void onLoadFinished(android.support.v4.content.Loader<T> loader, T data)
           
 void read(Callback<List<T>> callback)
          Sends a signal to the Pipe to read its data and return it via the callback.
 void read(ReadFilter filter, Callback<List<T>> callback)
          Reads all the data from the underlying server connection.
 void readWithFilter(ReadFilter filter, Callback<List<T>> callback)
          Reads all the data from the underlying server connection.
 void remove(String toRemoveId, Callback<Void> callback)
          Removes an object from the underlying server connection.
 void reset()
          Calls reset on all loaders associated with this pipe.
 void save(T item, Callback<T> callback)
          Saves or updates a given object on the server.
 void setLoaderIds(com.google.common.collect.Multimap<String,Integer> idsForNamedPipes)
          Passes in a multimap of ids for the named pipe.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SupportLoaderAdapter

@Deprecated
public SupportLoaderAdapter(android.support.v4.app.FragmentActivity activity,
                                       Pipe<T> pipe,
                                       com.google.gson.Gson gson,
                                       String name)
Deprecated. 


SupportLoaderAdapter

@Deprecated
public SupportLoaderAdapter(android.support.v4.app.Fragment fragment,
                                       android.content.Context applicationContext,
                                       Pipe<T> pipe,
                                       com.google.gson.Gson gson,
                                       String name)
Deprecated. 


SupportLoaderAdapter

public SupportLoaderAdapter(android.support.v4.app.Fragment fragment,
                            android.content.Context applicationContext,
                            Pipe<T> pipe,
                            String name)

SupportLoaderAdapter

public SupportLoaderAdapter(android.support.v4.app.FragmentActivity activity,
                            Pipe<T> pipe,
                            String name)
Method Detail

getType

public PipeType getType()
Description copied from interface: Pipe
Returns the connection type of this Pipe object (e.g. REST).

Specified by:
getType in interface Pipe<T>
Returns:
the connection type

getUrl

public URL getUrl()
Description copied from interface: Pipe
Returns the URL to which this Pipe object points.

Specified by:
getUrl in interface Pipe<T>
Returns:
the endpoint URL

read

public void read(Callback<List<T>> callback)
Description copied from interface: Pipe
Sends a signal to the Pipe to read its data and return it via the callback.

Specified by:
read in interface Pipe<T>
Parameters:
callback - The callback for consuming the result from the Pipe invocation.

readWithFilter

public void readWithFilter(ReadFilter filter,
                           Callback<List<T>> callback)
Description copied from interface: Pipe
Reads all the data from the underlying server connection.

Specified by:
readWithFilter in interface Pipe<T>
Parameters:
filter - a ReadFilter for performing pagination and querying.
callback - The callback for consuming the result from the Pipe invocation.

read

public void read(ReadFilter filter,
                 Callback<List<T>> callback)
Description copied from interface: Pipe
Reads all the data from the underlying server connection.

Specified by:
read in interface Pipe<T>
Parameters:
filter - a ReadFilter for performing pagination and querying.
callback - The callback for consuming the result from the Pipe invocation.

save

public void save(T item,
                 Callback<T> callback)
Description copied from interface: Pipe
Saves or updates a given object on the server.

Specified by:
save in interface Pipe<T>
Parameters:
item - the item to save or update
callback - The callback for consuming the result from the Pipe invocation.

remove

public void remove(String toRemoveId,
                   Callback<Void> callback)
Description copied from interface: Pipe
Removes an object from the underlying server connection. The given key argument is used as the objects ID.

Specified by:
remove in interface Pipe<T>
Parameters:
toRemoveId - representing the ‘id’ of the object to be removed
callback - The callback for consuming the result from the Pipe invocation.

getHandler

public PipeHandler<T> getHandler()
Description copied from interface: Pipe
Returns the instance which is responsible for handling read, save, and remove.

Specified by:
getHandler in interface Pipe<T>
Returns:
the handler performing operations for this Pipe. May be the Pipe itself.

onCreateLoader

public android.support.v4.content.Loader<T> onCreateLoader(int id,
                                                           android.os.Bundle bundle)
Specified by:
onCreateLoader in interface android.support.v4.app.LoaderManager.LoaderCallbacks<T>

getGson

public com.google.gson.Gson getGson()
Description copied from interface: Pipe
Returns the GSON serializer used to serialized instances of objects.

Specified by:
getGson in interface Pipe<T>
Returns:
the gson instance servicing this pipe.

getRequestBuilder

public RequestBuilder<T> getRequestBuilder()
Description copied from interface: Pipe
The RequestBuilder is responsible for turning objects in bodies of requests.

Specified by:
getRequestBuilder in interface Pipe<T>
Returns:
the current RequestBuilder instance

getResponseParser

public ResponseParser<T> getResponseParser()
Description copied from interface: Pipe
The ResponseParser is responsible for turning responses from a SAVE into an object

Specified by:
getResponseParser in interface Pipe<T>
Returns:
the current ResponseParser instance

getKlass

public Class<T> getKlass()
Specified by:
getKlass in interface Pipe<T>
Returns:
the class which travels on this pipe

onLoadFinished

public void onLoadFinished(android.support.v4.content.Loader<T> loader,
                           T data)
Specified by:
onLoadFinished in interface android.support.v4.app.LoaderManager.LoaderCallbacks<T>

onLoaderReset

public void onLoaderReset(android.support.v4.content.Loader<T> loader)
Specified by:
onLoaderReset in interface android.support.v4.app.LoaderManager.LoaderCallbacks<T>

reset

public void reset()
Description copied from interface: LoaderPipe
Calls reset on all loaders associated with this pipe.

Specified by:
reset in interface LoaderPipe<T>

setLoaderIds

public void setLoaderIds(com.google.common.collect.Multimap<String,Integer> idsForNamedPipes)
Description copied from interface: LoaderPipe
Passes in a multimap of ids for the named pipe. LoaderPipe should manage this collection.

Specified by:
setLoaderIds in interface LoaderPipe<T>

AeroGear Android Library 1.1.0

Copyright © 2013 JBoss by Red Hat. All Rights Reserved.