This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android" | |
android:contentAuthority="com.acme.provider.visiostorm" | |
android:accountType="com.acme.app.authenticator" | |
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SyncService extends Service { | |
/** Lock to synchronize access to SyncAdapter*/ | |
private static final Object syncLock = new Object(); | |
/** SyncAdapter used to sync data with server */ | |
private static SyncAdapter sSyncAdapter = null; | |
@Override | |
public void onCreate(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void syncLog(Context context, String user, String authToken) { | |
Log.i(TAG, "Syncing VisioStorm log"); | |
ContentResolver cr = context.getContentResolver(); | |
Cursor cursor = PendingMovie.getAll(cr); | |
API.setUser(user); | |
API.setAuthToken(authToken); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SyncAdapter extends AbstractThreadedSyncAdapter { | |
private final static String TAG = "SyncAdapter"; | |
private AccountManager mAccountManager; | |
public SyncAdapter(Context context, boolean autoInitialize) { | |
super(context, autoInitialize); | |
mAccountManager = AccountManager.get(context); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<service | |
android:name=".authenticator.AuthenticationService" | |
android:exported="true" > | |
<intent-filter> | |
<action android:name="android.accounts.AccountAuthenticator" /> | |
</intent-filter> | |
<meta-data | |
android:name="android.accounts.AccountAuthenticator" | |
android:resource="@xml/authenticator" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RestClient { | |
private static final String TAG = "RestClient"; | |
private static final String USER_AGENT = "VisioStorm Android"; | |
/** Methods supported by RestClient */ | |
public enum RequestMethod { | |
GET, POST | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<provider | |
android:name=".provider.AcmeProvider" | |
android:authorities="com.acme.provider.myapp" | |
android:label="Log" | |
android:enabled="true"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public int delete(Uri uri, String selection, String[] selectionArgs) { | |
int count; | |
switch (uriMatcher.match(uri)) { | |
case LOG_LIST: | |
count = dbLogs.delete(TABLE_NAME, selection, selectionArgs); | |
break; | |
case LOG_ITEM: | |
String segment = uri.getPathSegments().get(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean onCreate() { | |
Context context = getContext(); | |
AcmeDatabaseHelper helper = new AcmeDatabaseHelper(context); | |
dbLogs = helper.getWritableDatabase(); | |
return dbLogs == null ? false : true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public String getType(Uri uri) { | |
switch (uriMatcher.match(uri)) { | |
case LOG_LIST: return CONTENT_TYPE_LIST; | |
case LOG_ITEM: return CONTENT_TYPE_ITEM; | |
default: throw new IllegalArgumentException("Unsupported URI: " + uri); | |
} | |
} |