diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-07-20 16:46:40 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-07-20 16:46:40 +0300 |
commit | 44b8192f5947ffccb2e19b2c900eb1f255b73c1d (patch) | |
tree | 90667e811e841d439a82910d0e2f0a71d933c130 /app/src/main/java/it/niedermann/nextcloud/deck/model | |
parent | f70327e9f00518b5a7b41025a4fce9e4706252b1 (diff) | |
parent | db4759076400e1f01420ba29540a62367dbf166b (diff) |
Merge branch '515-reduce-database-queries'
# Conflicts:
# app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java
# app/src/main/java/it/niedermann/nextcloud/deck/ui/preparecreate/PrepareCreateActivity.java
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/model')
8 files changed, 16 insertions, 37 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/Card.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/Card.java index 732ccfc50..f07f7ae91 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/model/Card.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/Card.java @@ -1,6 +1,5 @@ package it.niedermann.nextcloud.deck.model; -import androidx.annotation.NonNull; import androidx.room.Entity; import androidx.room.ForeignKey; import androidx.room.Ignore; @@ -31,7 +30,7 @@ import it.niedermann.nextcloud.deck.model.interfaces.AbstractRemoteEntity; public class Card extends AbstractRemoteEntity { private static Pattern PATTERN_MD_TASK = Pattern.compile("\\[([xX ])]"); - public class TaskStatus { + public static class TaskStatus { public int taskCount; public int doneCount; @@ -46,7 +45,6 @@ public class Card extends AbstractRemoteEntity { private String title; private String description; - @NonNull private Long stackId; private String type; private Date createdAt; diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/Stack.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/Stack.java index 330ec16d7..122b9ea30 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/model/Stack.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/Stack.java @@ -1,6 +1,5 @@ package it.niedermann.nextcloud.deck.model; -import androidx.annotation.NonNull; import androidx.room.Entity; import androidx.room.ForeignKey; import androidx.room.Ignore; @@ -35,12 +34,10 @@ public class Stack extends AbstractRemoteEntity { private String title; - @NonNull private long boardId; private Date deletedAt; - @NonNull private int order; // // @ToMany diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/full/FullBoard.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/full/FullBoard.java index 31ad21f16..95875d5a3 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/model/full/FullBoard.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/full/FullBoard.java @@ -1,5 +1,6 @@ package it.niedermann.nextcloud.deck.model.full; +import androidx.annotation.NonNull; import androidx.room.Embedded; import androidx.room.Ignore; import androidx.room.Relation; @@ -56,7 +57,7 @@ public class FullBoard implements IRemoteEntity { @Ignore @Override - public IRemoteEntity getEntity() { + public Board getEntity() { return board; } @@ -102,6 +103,7 @@ public class FullBoard implements IRemoteEntity { return result; } + @NonNull @Override public String toString() { return "FullBoard{" + diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/full/FullCard.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/full/FullCard.java index 6f3913f45..398ac9ccb 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/model/full/FullCard.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/full/FullCard.java @@ -124,7 +124,7 @@ public class FullCard implements IRemoteEntity, DragAndDropModel { @Ignore @Override - public IRemoteEntity getEntity() { + public Card getEntity() { return card; } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/full/FullStack.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/full/FullStack.java index eddbafce4..1c9e94899 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/model/full/FullStack.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/full/FullStack.java @@ -14,7 +14,7 @@ public class FullStack implements IRemoteEntity { @Embedded public Stack stack; - @Relation(entity = Card.class, parentColumn = "localId", entityColumn = "stackId") + @Relation(entity = Card.class, parentColumn = "localId", entityColumn = "stackId") public List<Card> cards; @@ -36,7 +36,7 @@ public class FullStack implements IRemoteEntity { @Ignore @Override - public IRemoteEntity getEntity() { + public Stack getEntity() { return stack; } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/interfaces/AbstractJoinEntity.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/interfaces/AbstractJoinEntity.java index 50057dfe4..ce14ac6be 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/model/interfaces/AbstractJoinEntity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/interfaces/AbstractJoinEntity.java @@ -1,21 +1,20 @@ package it.niedermann.nextcloud.deck.model.interfaces; -import androidx.annotation.NonNull; import androidx.room.Entity; import androidx.room.Ignore; + import it.niedermann.nextcloud.deck.model.enums.DBStatus; @Entity() public abstract class AbstractJoinEntity { - @NonNull protected int status = DBStatus.UP_TO_DATE.getId(); public int getStatus() { return status; } - public void setStatus(@NonNull int status) { + public void setStatus(int status) { this.status = status; } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/interfaces/AbstractRemoteEntity.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/interfaces/AbstractRemoteEntity.java index 328c642ae..c19e52970 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/model/interfaces/AbstractRemoteEntity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/interfaces/AbstractRemoteEntity.java @@ -1,6 +1,5 @@ package it.niedermann.nextcloud.deck.model.interfaces; -import androidx.annotation.NonNull; import androidx.room.Entity; import androidx.room.ForeignKey; import androidx.room.Ignore; @@ -27,7 +26,7 @@ import it.niedermann.nextcloud.deck.model.enums.DBStatus; ) } ) -public abstract class AbstractRemoteEntity implements IRemoteEntity { +public abstract class AbstractRemoteEntity implements IRemoteEntity{ @PrimaryKey(autoGenerate = true) protected Long localId; @@ -35,7 +34,6 @@ public abstract class AbstractRemoteEntity implements IRemoteEntity { protected Long id; - @NonNull protected int status = DBStatus.UP_TO_DATE.getId(); protected Date lastModified; @@ -102,7 +100,7 @@ public abstract class AbstractRemoteEntity implements IRemoteEntity { @Override - public void setStatus(@NonNull int status) { + public void setStatus(int status) { this.status = status; } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/interfaces/IRemoteEntity.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/interfaces/IRemoteEntity.java index 30a478808..c878c132f 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/model/interfaces/IRemoteEntity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/interfaces/IRemoteEntity.java @@ -1,7 +1,5 @@ package it.niedermann.nextcloud.deck.model.interfaces; -import androidx.annotation.NonNull; - import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -10,73 +8,62 @@ import it.niedermann.nextcloud.deck.model.enums.DBStatus; public interface IRemoteEntity { - default IRemoteEntity getEntity() {return this;} + default IRemoteEntity getEntity() { + return this; + } default Long getLocalId() { return getEntity().getLocalId(); } - default void setLocalId(Long localId) { getEntity().setLocalId(localId); } - default long getAccountId() { return getEntity().getAccountId(); } - default void setAccountId(long accountId) { getEntity().setAccountId(accountId); } - default Long getId() { return getEntity().getId(); } - default void setId(Long id) { getEntity().setId(id); } - default int getStatus() { return getEntity().getStatus(); } - - default void setStatus(@NonNull int status) { + default void setStatus(int status) { getEntity().setStatus(status); } - default Date getLastModified() { return getEntity().getLastModified(); } - default void setLastModified(Date lastModified) { getEntity().setLastModified(lastModified); } - default Date getLastModifiedLocal() { return getEntity().getLastModifiedLocal(); } - default void setLastModifiedLocal(Date lastModifiedLocal) { getEntity().setLastModifiedLocal(lastModifiedLocal); } - default DBStatus getStatusEnum() { return getEntity().getStatusEnum(); } - default void setStatusEnum(DBStatus status) { getEntity().setStatusEnum(status); } @@ -86,9 +73,7 @@ public interface IRemoteEntity { return null; } List<T> list = new ArrayList<>(listToCopy.size()); - for (T t : listToCopy) { - list.add(t); - } + list.addAll(listToCopy); return list; } } |