diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-07-29 19:59:41 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-07-29 19:59:41 +0300 |
commit | 94418602133c1352a807fb68ac18af6ccfb68af0 (patch) | |
tree | 0048d5aef0561550c578fb13b6019333d0416c80 /app/src/main/java/it/niedermann/nextcloud/deck/ui/MainViewModel.java | |
parent | 73a9d833e5ecef42697729961afc1111a301373b (diff) |
Only allow filtering when a board has been set to avoid errors
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/MainViewModel.java')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/MainViewModel.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainViewModel.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainViewModel.java index e5bd4f482..b73b86b33 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainViewModel.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainViewModel.java @@ -15,6 +15,7 @@ import it.niedermann.nextcloud.deck.model.Board; public class MainViewModel extends AndroidViewModel { private MutableLiveData<Account> currentAccount = new MutableLiveData<>(); + @Nullable private Board currentBoard; private boolean currentAccountHasArchivedBoards = false; @@ -37,16 +38,21 @@ public class MainViewModel extends AndroidViewModel { this.currentAccountIsSupportedVersion = currentAccount.getServerDeckVersionAsObject().isSupported(getApplication().getApplicationContext()); } - public void setCurrentBoard(Board currentBoard) { + public void setCurrentBoard(@NonNull Board currentBoard) { this.currentBoard = currentBoard; } public Long getCurrentBoardLocalId() { + if(currentBoard == null) { + throw new IllegalStateException("getCurrentBoardLocalId() called before setCurrentBoard()"); + } return this.currentBoard.getLocalId(); } - @Nullable public Long getCurrentBoardRemoteId() { + if(currentBoard == null) { + throw new IllegalStateException("getCurrentBoardRemoteId() called before setCurrentBoard()"); + } return this.currentBoard.getId(); } |