Android Open Source - Locast-Core-Android Syncable Provider






From Project

Back to project page Locast-Core-Android.

License

The source code is released under:

GNU General Public License

If you think the Android project Locast-Core-Android 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 edu.mit.mobile.android.locast.sync;
/* ww w  .j  ava 2  s  . co  m*/
import android.content.ContentProvider;
import android.content.ContentProviderClient;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.RemoteException;
import edu.mit.mobile.android.content.SimpleContentProvider;
import edu.mit.mobile.android.locast.data.JsonSyncableItem;
import edu.mit.mobile.android.locast.data.NoPublicPath;
import edu.mit.mobile.android.locast.data.SyncMap;
import edu.mit.mobile.android.locast.data.SyncMapException;
import edu.mit.mobile.android.locast.net.NetworkClient;

/**
 * <p>
 * This interface is intended for a {@link ContentProvider} to make its content syncable with the
 * {@link SyncEngine}.
 * </p>
 *
 * <p>
 * If using {@link SimpleContentProvider}, you can instead use {@link SyncableSimpleContentProvider}
 * to gain sync functionality.
 * </p>
 *
 * <p>
 * Other classes implementing this interface have a few special details to handle in order to
 * interface with the {@link SyncEngine}.
 * </p>
 *
 * <p>
 * On {@link ContentProvider#insert(Uri, android.content.ContentValues)} and
 * {@link ContentProvider#update(Uri, android.content.ContentValues, String, String[])}
 * <ul>
 * <li>Handle {@link JsonSyncableItem#COL_DIRTY} and {@link JsonSyncableItem#COL_MODIFIED_DATE}. See
 * also {@link #FLAG_DO_NOT_CHANGE_DIRTY} for details on what needs to be handled and how.</li>
 * <li>Handle {@link JsonSyncableItem#COL_DELETED}. See also {@link #QUERY_RETURN_DELETED}.
 * </ul>
 *
 * @author <a href="mailto:spomeroy@mit.edu">Steve Pomeroy</a>
 * @see SyncableSimpleContentProvider
 *
 */
public interface SyncableProvider {

    /**
     * The {@link SyncEngine} will add this in as the value of {@link JsonSyncableItem#COL_DIRTY} to
     * {@link ContentProvider#insert(Uri, android.content.ContentValues)} and
     * {@link ContentProvider#update(Uri, android.content.ContentValues, String, String[])} calls
     * when the underlying provider should not update the modified date of the content item. When
     * this flag is missing, however, it's the responsibility of the {@link SyncableProvider} to
     * bump the {@link JsonSyncableItem#COL_MODIFIED_DATE} date.
     */
    public static final int FLAG_DO_NOT_CHANGE_DIRTY = -1;

    /**
     * <p>
     * Pass this in when querying a {@link SyncableProvider} in order to prevent it from
     * automatically filter out deleted items. This is passed to
     * {@link ContentProvider#query(Uri, String[], String, String[], String)} by adding it in as a
     * value in the {@code projection}. It will be removed from the {@code projection} if present.
     * If it is the only item in the {@code projection}, {@code projection} will be set to
     * {@code null}.
     * </p>
     * <p>
     * The {@link SyncEngine} will add this when querying the provider when it's processing the
     * local items.
     * </p>
     */
    public static final String QUERY_RETURN_DELETED = "edu.mit.mobile.android.locast.sync.query_return_deleted";

    /**
     * Retrieves the sync map from the class that maps to the given URL.
     *
     * @param provider
     * @param toSync
     * @return
     * @throws RemoteException
     * @throws SyncMapException
     */
    public SyncMap getSyncMap(ContentProviderClient provider, Uri toSync) throws RemoteException,
            SyncMapException;

    /**
     * Given a local content URL, comes up with a public URL for it. This URL should be resolvable
     * to the same data that are in the local content URL.
     *
     * @param context
     * @param uri
     *            local content URL
     * @param networkClient
     *            a instance of the network client
     * @return a URL or relative URL (based on the {@link NetworkClient} base URL) which represents
     *         the local URL
     * @throws NoPublicPath
     *             if there is no public path
     */
    public String getPublicPath(Context context, Uri uri, NetworkClient networkClient) throws NoPublicPath;

    /**
     * If this method returns true, the {@link SyncEngine} will attempt to sync it. If false, it
     * will skip over it entirely.
     *
     * @param uri
     * @return true if the given URI is syncable using this provider.
     */
    public boolean canSync(Uri uri);

    /**
     * @param uri
     * @param networkClient
     *            a instance of the network client
     * @param cr
     * @return The path that one should POST to for the given content item. Should always point to
     *         an item, not a dir.
     * @throws NoPublicPath
     */
    public String getPostPath(Context context, Uri uri, NetworkClient networkClient) throws NoPublicPath;

    /**
     * @return the authority that this provider handles
     */
    public String getAuthority();

    /**
     * Create an appropriate subclass of {@link JsonSyncableItem} and wrap the given cursor with it.
     *
     * @param item
     * @param c
     * @return
     */
    public JsonSyncableItem getWrappedContentItem(Uri item, Cursor c);

}




Java Source Code List

com.beoui.geocell.GeocellLogger.java
com.beoui.geocell.GeocellQueryEngine.java
com.beoui.geocell.GeocellUtils.java
com.beoui.geocell.annotations.Geocells.java
com.beoui.geocell.annotations.Latitude.java
com.beoui.geocell.annotations.Longitude.java
com.beoui.geocell.comparator.DoubleTupleComparator.java
com.beoui.geocell.comparator.LocationComparableTuple.java
com.beoui.geocell.model.BoundingBox.java
com.beoui.geocell.model.CostFunction.java
com.beoui.geocell.model.DefaultCostFunction.java
com.beoui.geocell.model.GeocellQuery.java
com.beoui.geocell.model.LocationCapable.java
com.beoui.geocell.model.Point.java
com.beoui.geocell.model.Tuple.java
com.stackoverflow.ArrayUtils.java
com.stackoverflow.CollectionUtils.java
com.stackoverflow.MediaUtils.java
com.stackoverflow.Predicate.java
edu.mit.mobile.android.MelAndroid.java
edu.mit.mobile.android.json.JSONArrayAdapter.java
edu.mit.mobile.android.locast.Constants.java
edu.mit.mobile.android.locast.accounts.AbsAccountChangeReceiver.java
edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticationService.java
edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticatorActivity.java
edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticator.java
edu.mit.mobile.android.locast.accounts.AbsRegisterActivity.java
edu.mit.mobile.android.locast.accounts.LogoutFragment.java
edu.mit.mobile.android.locast.app.LocastApplication.java
edu.mit.mobile.android.locast.data.AbsComment.java
edu.mit.mobile.android.locast.data.AbsResourcesSync.java
edu.mit.mobile.android.locast.data.CastMedia.java
edu.mit.mobile.android.locast.data.ImageContent.java
edu.mit.mobile.android.locast.data.JSONSyncableIdenticalChildFinder.java
edu.mit.mobile.android.locast.data.JsonSyncableItem.java
edu.mit.mobile.android.locast.data.MediaProcessingException.java
edu.mit.mobile.android.locast.data.NoPublicPath.java
edu.mit.mobile.android.locast.data.OrderedList.java
edu.mit.mobile.android.locast.data.ResourcesSync.java
edu.mit.mobile.android.locast.data.SyncException.java
edu.mit.mobile.android.locast.data.SyncItemDeletedException.java
edu.mit.mobile.android.locast.data.SyncMapException.java
edu.mit.mobile.android.locast.data.SyncMap.java
edu.mit.mobile.android.locast.data.VideoContent.java
edu.mit.mobile.android.locast.data.interfaces.AuthorableUtils.java
edu.mit.mobile.android.locast.data.interfaces.Authorable.java
edu.mit.mobile.android.locast.data.interfaces.CommentableUtils.java
edu.mit.mobile.android.locast.data.interfaces.Commentable.java
edu.mit.mobile.android.locast.data.interfaces.FavoritableUtils.java
edu.mit.mobile.android.locast.data.interfaces.Favoritable.java
edu.mit.mobile.android.locast.data.interfaces.LocatableUtils.java
edu.mit.mobile.android.locast.data.interfaces.Locatable.java
edu.mit.mobile.android.locast.data.interfaces.PrivatelyAuthorableUtils.java
edu.mit.mobile.android.locast.data.interfaces.PrivatelyAuthorable.java
edu.mit.mobile.android.locast.data.interfaces.TitledUtils.java
edu.mit.mobile.android.locast.data.interfaces.Titled.java
edu.mit.mobile.android.locast.data.tags.IdenticalTagFinder.java
edu.mit.mobile.android.locast.data.tags.TagSyncField.java
edu.mit.mobile.android.locast.data.tags.Tag.java
edu.mit.mobile.android.locast.data.tags.TaggableUtils.java
edu.mit.mobile.android.locast.data.tags.TaggableWrapper.java
edu.mit.mobile.android.locast.data.tags.Taggable.java
edu.mit.mobile.android.locast.net.ClientResponseException.java
edu.mit.mobile.android.locast.net.LocastApplicationCallbacks.java
edu.mit.mobile.android.locast.net.NetworkClient.java
edu.mit.mobile.android.locast.net.NetworkProtocolException.java
edu.mit.mobile.android.locast.sync.AbsLocastAccountSyncService.java
edu.mit.mobile.android.locast.sync.AbsMediaSync.java
edu.mit.mobile.android.locast.sync.LocastSimpleSyncService.java
edu.mit.mobile.android.locast.sync.LocastSyncService.java
edu.mit.mobile.android.locast.sync.LocastSyncStatusObserver.java
edu.mit.mobile.android.locast.sync.NotificationProgressListener.java
edu.mit.mobile.android.locast.sync.SyncColumns.java
edu.mit.mobile.android.locast.sync.SyncEngine.java
edu.mit.mobile.android.locast.sync.SyncableProvider.java
edu.mit.mobile.android.locast.sync.SyncableSimpleContentProvider.java
edu.mit.mobile.android.locast.sync.Syncable.java
edu.mit.mobile.android.locast.widget.RemoteTagsAdapter.java
edu.mit.mobile.android.locast.widget.TagButton.java
edu.mit.mobile.android.locast.widget.TagListView.java
edu.mit.mobile.android.locast.widget.TagList.java
edu.mit.mobile.android.locast.widget.TagsLoaderCallbacks.java
edu.mit.mobile.android.location.IncrementalLocator.java
se.fnord.android.layout.PredicateLayout.java