diff --git a/app/src/main/java/com/readrops/app/repositories/NextNewsRepository.java b/app/src/main/java/com/readrops/app/repositories/NextNewsRepository.java index 3c1857a2..3553fcef 100644 --- a/app/src/main/java/com/readrops/app/repositories/NextNewsRepository.java +++ b/app/src/main/java/com/readrops/app/repositories/NextNewsRepository.java @@ -15,10 +15,10 @@ import com.readrops.readropsdb.entities.Folder; import com.readrops.readropsdb.entities.Item; import com.readrops.readropsdb.entities.account.Account; import com.readrops.readropslibrary.services.Credentials; +import com.readrops.readropslibrary.services.SyncResult; import com.readrops.readropslibrary.services.SyncType; import com.readrops.readropslibrary.services.nextcloudnews.NextNewsAPI; import com.readrops.readropslibrary.services.nextcloudnews.NextNewsSyncData; -import com.readrops.readropslibrary.services.nextcloudnews.NextNewsSyncResult; import com.readrops.readropslibrary.services.nextcloudnews.json.NextNewsUser; import com.readrops.readropslibrary.utils.UnknownFormatException; @@ -100,7 +100,7 @@ public class NextNewsRepository extends ARepository { } TimingLogger timings = new TimingLogger(TAG, "nextcloud news " + syncType.name().toLowerCase()); - NextNewsSyncResult syncResult = api.sync(syncType, syncData); + SyncResult syncResult = api.sync(syncType, syncData); timings.addSplit("server queries"); if (!syncResult.isError()) { diff --git a/readropslibrary/src/main/java/com/readrops/readropslibrary/services/SyncResult.kt b/readropslibrary/src/main/java/com/readrops/readropslibrary/services/SyncResult.kt new file mode 100644 index 00000000..306eeb75 --- /dev/null +++ b/readropslibrary/src/main/java/com/readrops/readropslibrary/services/SyncResult.kt @@ -0,0 +1,16 @@ +package com.readrops.readropslibrary.services + +import com.readrops.readropsdb.entities.Feed +import com.readrops.readropsdb.entities.Folder +import com.readrops.readropsdb.entities.Item + +class SyncResult { + + var items: List = listOf() + + var feeds: List = listOf() + + var folders: List = listOf() + + var isError: Boolean = false +} diff --git a/readropslibrary/src/main/java/com/readrops/readropslibrary/services/freshrss/FreshRSSAPI.java b/readropslibrary/src/main/java/com/readrops/readropslibrary/services/freshrss/FreshRSSAPI.java index 1206dbde..551251e7 100644 --- a/readropslibrary/src/main/java/com/readrops/readropslibrary/services/freshrss/FreshRSSAPI.java +++ b/readropslibrary/src/main/java/com/readrops/readropslibrary/services/freshrss/FreshRSSAPI.java @@ -8,6 +8,7 @@ import com.readrops.readropsdb.entities.Folder; import com.readrops.readropsdb.entities.Item; import com.readrops.readropslibrary.services.API; import com.readrops.readropslibrary.services.Credentials; +import com.readrops.readropslibrary.services.SyncResult; import com.readrops.readropslibrary.services.SyncType; import com.readrops.readropslibrary.services.freshrss.adapters.FreshRSSFeedsAdapter; import com.readrops.readropslibrary.services.freshrss.adapters.FreshRSSFoldersAdapter; @@ -94,8 +95,8 @@ public class FreshRSSAPI extends API { * @param writeToken token for making modifications on the server * @return the result of the synchronization */ - public Single sync(@NonNull SyncType syncType, @NonNull FreshRSSSyncData syncData, @NonNull String writeToken) { - FreshRSSSyncResult syncResult = new FreshRSSSyncResult(); + public Single sync(@NonNull SyncType syncType, @NonNull FreshRSSSyncData syncData, @NonNull String writeToken) { + SyncResult syncResult = new SyncResult(); return setItemsReadState(syncData, writeToken) .andThen(getFolders() diff --git a/readropslibrary/src/main/java/com/readrops/readropslibrary/services/freshrss/FreshRSSSyncResult.java b/readropslibrary/src/main/java/com/readrops/readropslibrary/services/freshrss/FreshRSSSyncResult.java deleted file mode 100644 index e3f4c300..00000000 --- a/readropslibrary/src/main/java/com/readrops/readropslibrary/services/freshrss/FreshRSSSyncResult.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.readrops.readropslibrary.services.freshrss; - -import com.readrops.readropsdb.entities.Feed; -import com.readrops.readropsdb.entities.Folder; -import com.readrops.readropsdb.entities.Item; - -import java.util.ArrayList; -import java.util.List; - -public class FreshRSSSyncResult { - - private List folders; - - private List feeds; - - private List items; - - private long lastUpdated; - - public FreshRSSSyncResult() { - feeds = new ArrayList<>(); - items = new ArrayList<>(); - } - - public List getFeeds() { - return feeds; - } - - public void setFeeds(List feeds) { - this.feeds = feeds; - } - - public List getItems() { - return items; - } - - public void setItems(List items) { - this.items = items; - } - - public long getLastUpdated() { - return lastUpdated; - } - - public void setLastUpdated(long lastUpdated) { - this.lastUpdated = lastUpdated; - } - - public List getFolders() { - return folders; - } - - public void setFolders(List folders) { - this.folders = folders; - } -} diff --git a/readropslibrary/src/main/java/com/readrops/readropslibrary/services/nextcloudnews/NextNewsAPI.java b/readropslibrary/src/main/java/com/readrops/readropslibrary/services/nextcloudnews/NextNewsAPI.java index f7245e55..b8c62d5a 100644 --- a/readropslibrary/src/main/java/com/readrops/readropslibrary/services/nextcloudnews/NextNewsAPI.java +++ b/readropslibrary/src/main/java/com/readrops/readropslibrary/services/nextcloudnews/NextNewsAPI.java @@ -10,6 +10,7 @@ import com.readrops.readropsdb.entities.Folder; import com.readrops.readropsdb.entities.Item; import com.readrops.readropslibrary.services.API; import com.readrops.readropslibrary.services.Credentials; +import com.readrops.readropslibrary.services.SyncResult; import com.readrops.readropslibrary.services.SyncType; import com.readrops.readropslibrary.services.nextcloudnews.adapters.NextNewsFeedsAdapter; import com.readrops.readropslibrary.services.nextcloudnews.adapters.NextNewsFoldersAdapter; @@ -70,8 +71,8 @@ public class NextNewsAPI extends API { return response.body(); } - public NextNewsSyncResult sync(@NonNull SyncType syncType, @Nullable NextNewsSyncData data) throws IOException { - NextNewsSyncResult syncResult = new NextNewsSyncResult(); + public SyncResult sync(@NonNull SyncType syncType, @Nullable NextNewsSyncData data) throws IOException { + SyncResult syncResult = new SyncResult(); switch (syncType) { case INITIAL_SYNC: initialSync(syncResult); @@ -87,7 +88,7 @@ public class NextNewsAPI extends API { return syncResult; } - private void initialSync(NextNewsSyncResult syncResult) throws IOException { + private void initialSync(SyncResult syncResult) throws IOException { getFeedsAndFolders(syncResult); Response> itemsResponse = api.getItems(3, false, MAX_ITEMS).execute(); @@ -100,7 +101,7 @@ public class NextNewsAPI extends API { syncResult.setItems(itemList); } - private void classicSync(NextNewsSyncResult syncResult, NextNewsSyncData data) throws IOException { + private void classicSync(SyncResult syncResult, NextNewsSyncData data) throws IOException { putModifiedItems(data, syncResult); getFeedsAndFolders(syncResult); @@ -114,7 +115,7 @@ public class NextNewsAPI extends API { syncResult.setItems(itemList); } - private void getFeedsAndFolders(NextNewsSyncResult syncResult) throws IOException { + private void getFeedsAndFolders(SyncResult syncResult) throws IOException { Response> feedResponse = api.getFeeds().execute(); List feedList = feedResponse.body(); @@ -135,7 +136,7 @@ public class NextNewsAPI extends API { } - private void putModifiedItems(NextNewsSyncData data, NextNewsSyncResult syncResult) throws IOException { + private void putModifiedItems(NextNewsSyncData data, SyncResult syncResult) throws IOException { if (!data.getReadItems().isEmpty()) { Map> itemIdsMap = new HashMap<>(); itemIdsMap.put("items", data.getReadItems()); diff --git a/readropslibrary/src/main/java/com/readrops/readropslibrary/services/nextcloudnews/NextNewsSyncResult.java b/readropslibrary/src/main/java/com/readrops/readropslibrary/services/nextcloudnews/NextNewsSyncResult.java deleted file mode 100644 index 2af97bce..00000000 --- a/readropslibrary/src/main/java/com/readrops/readropslibrary/services/nextcloudnews/NextNewsSyncResult.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.readrops.readropslibrary.services.nextcloudnews; - -import com.readrops.readropsdb.entities.Feed; -import com.readrops.readropsdb.entities.Folder; -import com.readrops.readropsdb.entities.Item; - -import java.util.List; - -public class NextNewsSyncResult { - - private List folders; - - private List feeds; - - private List items; - - private boolean error; - - public NextNewsSyncResult() { - // empty constructor - } - - public List getFolders() { - return folders; - } - - public void setFolders(List folders) { - this.folders = folders; - } - - public List getFeeds() { - return feeds; - } - - public void setFeeds(List feeds) { - this.feeds = feeds; - } - - public List getItems() { - return items; - } - - public void setItems(List items) { - this.items = items; - } - - public boolean isError() { - return error; - } - - public void setError(boolean error) { - this.error = error; - } -}