Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
desperateCoder committed Mar 16, 2019
1 parent 659bf66 commit 7cfcebd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public void synchronize(IResponseCallback<Boolean> responseCallback) {
Date lastSyncDate = new Date(lastSync);
Date now = DateUtil.nowInGMT();

BoardDataProvider boardDataProvider = new BoardDataProvider();
final SyncHelper syncHelper = new SyncHelper(serverAdapter, dataBaseAdapter, lastSyncDate);

IResponseCallback<Boolean> callback = new IResponseCallback<Boolean>(responseCallback.getAccount()) {
Expand All @@ -80,7 +79,7 @@ public void onError(Throwable throwable) {
responseCallback.onError(throwable);
}
});
// syncHelper.doUpSyncFor(boardDataProvider);
syncHelper.doUpSyncFor(new BoardDataProvider());
}

@Override
Expand All @@ -92,7 +91,7 @@ public void onError(Throwable throwable) {

syncHelper.setResponseCallback(callback);

syncHelper.doSyncFor(boardDataProvider);
syncHelper.doSyncFor(new BoardDataProvider());
});
}

Expand Down Expand Up @@ -166,14 +165,8 @@ public void createBoard(long accountId, Board board) {
public void onResponse(FullBoard response) {
DeckLog.log(response.toString());
}

@Override
public void onError(Throwable throwable) {
DeckLog.logError(throwable);
}
})
);
// return dataBaseAdapter.createBoard(accountId, board);
}

public void deleteBoard(Board board) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void onResponse(List<T> response) {

@Override
public void onError(Throwable throwable) {
provider.onError(throwable, responseCallback);
DeckLog.logError(throwable);
responseCallback.onError(throwable);
}
Expand All @@ -72,9 +73,8 @@ public void onError(Throwable throwable) {
// Sync App -> Server
public <T extends IRemoteEntity> void doUpSyncFor(AbstractSyncDataProvider<T> provider){
List<T> allFromDB = provider.getAllFromDB(dataBaseAdapter, accountId, lastSync);
boolean hadSomethingToSync = false;
if (allFromDB != null && !allFromDB.isEmpty()) {
hadSomethingToSync = true;
provider.goingDeeper();
for (T entity : allFromDB) {
IResponseCallback<T> updateCallback = new IResponseCallback<T>(account) {
@Override
Expand Down Expand Up @@ -104,8 +104,10 @@ public void onResponse(T response) {
provider.createOnServer(serverAdapter, accountId, updateCallback, entity);
}
}
provider.doneGoingDeeper(responseCallback, true);
} else {
provider.childDone(provider, responseCallback, false);
}
provider.childDone(provider, responseCallback, hadSomethingToSync);
}

public void fixRelations(IRelationshipProvider relationshipProvider) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,10 @@ public void goingDeeper(){
public abstract List<T> getAllFromDB(DataBaseAdapter dataBaseAdapter, long accountId, Date lastSync);

public abstract void goDeeperForUpSync(SyncHelper syncHelper, T entity, T response);

public void onError(Throwable error, IResponseCallback<Boolean> responseCallback){
parent.childDone(this, responseCallback, false);
//TODO: what to do? what side effect would the following have:
// responseCallback.onError(error);
}
}

0 comments on commit 7cfcebd

Please sign in to comment.