diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-03-23 22:46:12 +0300 |
---|---|---|
committer | Niedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com> | 2020-03-24 12:06:45 +0300 |
commit | a054d8972223eb8e292dc382c67a88af8d019b31 (patch) | |
tree | fa3ce41593dbe00d7981246ec7bb6579764b1951 /app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardTabAdapter.java | |
parent | 04ed6d1604640672c97e9ab417670fbe57e2685d (diff) |
Move Comments fragment into own tab
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardTabAdapter.java')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardTabAdapter.java | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardTabAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardTabAdapter.java index 405baeb06..1992d78dd 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardTabAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardTabAdapter.java @@ -6,19 +6,31 @@ import androidx.fragment.app.FragmentManager; import androidx.lifecycle.Lifecycle; import androidx.viewpager2.adapter.FragmentStateAdapter; +import it.niedermann.nextcloud.deck.ui.card.comments.CardCommentsFragment; + public class CardTabAdapter extends FragmentStateAdapter { - private long accountId; - private long localId; - private long boardId; - private boolean canEdit; + private final long accountId; + private final long localId; + private final long boardId; + private final boolean canEdit; + private final boolean hasCommentsAbility; - public CardTabAdapter(@NonNull FragmentManager fm, @NonNull Lifecycle lifecycle, long accountId, long localId, long boardId, boolean canEdit) { + public CardTabAdapter( + @NonNull FragmentManager fm, + @NonNull Lifecycle lifecycle, + long accountId, + long localId, + long boardId, + boolean canEdit, + boolean hasCommentsAbility + ) { super(fm, lifecycle); this.accountId = accountId; this.localId = localId; this.boardId = boardId; this.canEdit = canEdit; + this.hasCommentsAbility = hasCommentsAbility; } @NonNull @@ -30,14 +42,20 @@ public class CardTabAdapter extends FragmentStateAdapter { case 1: return CardAttachmentsFragment.newInstance(accountId, localId, boardId, canEdit); case 2: - return CardActivityFragment.newInstance(accountId, localId, boardId, canEdit); + return hasCommentsAbility + ? CardCommentsFragment.newInstance(accountId, localId, canEdit) + : CardActivityFragment.newInstance(accountId, localId, boardId, canEdit); + case 3: + if (hasCommentsAbility) { + return CardActivityFragment.newInstance(accountId, localId, boardId, canEdit); + } default: - throw new IllegalArgumentException("position " + position + "is not available"); + throw new IllegalArgumentException("position " + position + " is not available"); } } @Override public int getItemCount() { - return 3; + return hasCommentsAbility ? 4 : 3; } } |