Skip to content

Commit

Permalink
#60 implemented Method to reorder stacks: SyncManager::reorderStacks
Browse files Browse the repository at this point in the history
  • Loading branch information
desperateCoder committed Dec 27, 2019
1 parent f0407a5 commit 95ff069
Showing 1 changed file with 21 additions and 2 deletions.
Expand Up @@ -426,15 +426,34 @@ public LiveData<FullStack> updateStack(FullStack stack) {
doAsync(() -> {
Account account = dataBaseAdapter.getAccountByIdDirectly(stack.getAccountId());
FullBoard board = dataBaseAdapter.getFullBoardByLocalIdDirectly(stack.getAccountId(), stack.getStack().getBoardId());
updateStack(account, board, stack, liveData);
});
return liveData;

}
private void updateStack(Account account, FullBoard board, FullStack stack, MutableLiveData<FullStack> liveData) {
doAsync(() -> {
new DataPropagationHelper(serverAdapter, dataBaseAdapter).updateEntity(new StackDataProvider(null, board), stack, new IResponseCallback<FullStack>(account) {
@Override
public void onResponse(FullStack response) {
liveData.postValue(response);
if (liveData != null) {
liveData.postValue(response);
}
}
});
});
return liveData;
}

public void reorderStacks(Board board, List<Stack> stacksInNewOrder) {
doAsync(() -> {
Account account = dataBaseAdapter.getAccountByIdDirectly(board.getAccountId());
FullBoard fullBoard = dataBaseAdapter.getFullBoardByLocalIdDirectly(board.getAccountId(), board.getLocalId());
for (int i = 0; i < stacksInNewOrder.size(); i++) {
FullStack s = dataBaseAdapter.getFullStackByLocalIdDirectly(stacksInNewOrder.get(i).getLocalId());
s.getStack().setOrder(i);
updateStack(account, fullBoard, s, null);
}
});
}

public LiveData<FullCard> getCardByLocalId(long accountId, long cardLocalId) {
Expand Down

0 comments on commit 95ff069

Please sign in to comment.