Skip to content

Commit

Permalink
Add a collection upload sync task (that currently does nothing)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccomeaux committed Nov 11, 2015
1 parent 841069a commit 0c9d2b9
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 10 deletions.
3 changes: 3 additions & 0 deletions app/src/main/java/com/boardgamegeek/service/SyncAdapter.java
Expand Up @@ -145,6 +145,9 @@ private boolean shouldContinueSync(boolean uploadOnly) {
private List<SyncTask> createTasks(Context context, final int type) {
BggService service = Adapter.createWithAuth(context);
List<SyncTask> tasks = new ArrayList<>();
if ((type & SyncService.FLAG_SYNC_COLLECTION_UPLOAD) == SyncService.FLAG_SYNC_COLLECTION_UPLOAD) {
tasks.add(new SyncCollectionUpload(context, service));
}
if ((type & SyncService.FLAG_SYNC_COLLECTION) == SyncService.FLAG_SYNC_COLLECTION) {
if (PreferencesUtils.isSyncStatus(context)) {
long lastCompleteSync = Authenticator.getLong(context, SyncService.TIMESTAMP_COLLECTION_COMPLETE);
Expand Down
Expand Up @@ -34,7 +34,7 @@ public SyncCollectionComplete(Context context, BggService service) {

@Override
public int getSyncType() {
return SyncService.FLAG_SYNC_COLLECTION;
return SyncService.FLAG_SYNC_COLLECTION_DOWNLOAD;
}

@Override
Expand Down
Expand Up @@ -28,7 +28,7 @@ public SyncCollectionModifiedSince(Context context, BggService service) {

@Override
public int getSyncType() {
return SyncService.FLAG_SYNC_COLLECTION;
return SyncService.FLAG_SYNC_COLLECTION_DOWNLOAD;
}

@Override
Expand Down
Expand Up @@ -32,7 +32,7 @@ public SyncCollectionUnupdated(Context context, BggService service) {

@Override
public int getSyncType() {
return SyncService.FLAG_SYNC_COLLECTION;
return SyncService.FLAG_SYNC_COLLECTION_DOWNLOAD;
}

@Override
Expand Down
@@ -0,0 +1,29 @@
package com.boardgamegeek.service;

import android.accounts.Account;
import android.content.Context;
import android.content.SyncResult;

import com.boardgamegeek.io.BggService;

import hugo.weaving.DebugLog;
import timber.log.Timber;

public class SyncCollectionUpload extends SyncTask {
@DebugLog
public SyncCollectionUpload(Context context, BggService service) {
super(context, service);
}

@DebugLog
@Override
public int getSyncType() {
return SyncService.FLAG_SYNC_COLLECTION_UPLOAD;
}

@DebugLog
@Override
public void execute(Account account, SyncResult syncResult) {
Timber.i("Collection uploading will go here.");
}
}
Expand Up @@ -20,7 +20,7 @@ public SyncGamesOldest(Context context, BggService service) {

@Override
public int getSyncType() {
return SyncService.FLAG_SYNC_COLLECTION;
return SyncService.FLAG_SYNC_COLLECTION_DOWNLOAD;
}

@NonNull
Expand Down
Expand Up @@ -32,7 +32,7 @@ public SyncGamesRemove(Context context, BggService service) {

@Override
public int getSyncType() {
return SyncService.FLAG_SYNC_COLLECTION;
return SyncService.FLAG_SYNC_COLLECTION_DOWNLOAD;
}

@Override
Expand Down
Expand Up @@ -21,7 +21,7 @@ public SyncGamesUnupdated(Context context, BggService service) {

@Override
public int getSyncType() {
return SyncService.FLAG_SYNC_COLLECTION;
return SyncService.FLAG_SYNC_COLLECTION_DOWNLOAD;
}

@NonNull
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/java/com/boardgamegeek/service/SyncService.java
Expand Up @@ -31,10 +31,12 @@
public class SyncService extends Service {
public static final String EXTRA_SYNC_TYPE = "com.boardgamegeek.SYNC_TYPE";
public static final int FLAG_SYNC_NONE = 0x00000000;
public static final int FLAG_SYNC_COLLECTION = 0x00000001;
public static final int FLAG_SYNC_BUDDIES = 0x00000002;
public static final int FLAG_SYNC_PLAYS_DOWNLOAD = 0x00000004;
public static final int FLAG_SYNC_PLAYS_UPLOAD = 0x00000008;
public static final int FLAG_SYNC_COLLECTION_DOWNLOAD = 0x00000001;
public static final int FLAG_SYNC_COLLECTION_UPLOAD = 0x00000002;
public static final int FLAG_SYNC_BUDDIES = 0x00000004;
public static final int FLAG_SYNC_PLAYS_DOWNLOAD = 0x00000008;
public static final int FLAG_SYNC_PLAYS_UPLOAD = 0x00000016;
public static final int FLAG_SYNC_COLLECTION = FLAG_SYNC_COLLECTION_DOWNLOAD | FLAG_SYNC_COLLECTION_UPLOAD;
public static final int FLAG_SYNC_PLAYS = FLAG_SYNC_PLAYS_DOWNLOAD | FLAG_SYNC_PLAYS_UPLOAD;
public static final int FLAG_SYNC_ALL = FLAG_SYNC_COLLECTION | FLAG_SYNC_BUDDIES | FLAG_SYNC_PLAYS;
public static final String ACTION_CANCEL_SYNC = "com.boardgamegeek.ACTION_SYNC_CANCEL";
Expand Down

0 comments on commit 0c9d2b9

Please sign in to comment.