diff options
author | David-Development <david-dev@live.de> | 2022-02-19 10:56:43 +0300 |
---|---|---|
committer | David Luhmer <david-dev@live.de> | 2022-02-19 10:56:43 +0300 |
commit | 8c2399d19379616d05194735170bd091395009da (patch) | |
tree | 1e284f8850456bb4bf988abde1b831f95e5e271f /News-Android-App/src/main/java | |
parent | e7fb9a4952ef1fdaf6335a8fa7f2ac707da1c807 (diff) |
reduce number of items per sync
Signed-off-by: David Luhmer <david-dev@live.de>
Diffstat (limited to 'News-Android-App/src/main/java')
-rw-r--r-- | News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/reader/nextcloud/RssItemObservable.java | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/reader/nextcloud/RssItemObservable.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/reader/nextcloud/RssItemObservable.java index 314703bb..65de602e 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/reader/nextcloud/RssItemObservable.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/reader/nextcloud/RssItemObservable.java @@ -39,7 +39,7 @@ public class RssItemObservable implements Publisher<Integer> { private final NewsAPI mNewsApi; private final SharedPreferences mPrefs; private static final String TAG = RssItemObservable.class.getCanonicalName(); - private static final int maxSizePerSync = 300; + private static final int maxSizePerSync = 200; public RssItemObservable(DatabaseConnectionOrm dbConn, NewsAPI newsApi, SharedPreferences prefs) { this.mDbConn = dbConn; @@ -62,9 +62,8 @@ public class RssItemObservable implements Publisher<Integer> { try { InputStreamReader isr = new InputStreamReader(source.inputStream()); BufferedReader br = new BufferedReader(isr); - JsonReader reader = new JsonReader(br); - try { + try (isr; br; JsonReader reader = new JsonReader(br)) { reader.beginObject(); String currentName; @@ -83,10 +82,6 @@ public class RssItemObservable implements Publisher<Integer> { e.onNext(item); } reader.endArray(); - } finally { - reader.close(); - br.close(); - isr.close(); } } catch (IOException | NullPointerException err) { err.printStackTrace(); @@ -177,8 +172,8 @@ public class RssItemObservable implements Publisher<Integer> { .flatMap((Function<ResponseBody, ObservableSource<RssItem>>) responseBody -> events(responseBody.source())) .subscribe(new Observer<>() { int totalUpdatedUnreadItemCount = 0; - final int bufferSize = 150; - final List<RssItem> buffer = new ArrayList<>(bufferSize); //Buffer of size X + final int bufferSize = maxSizePerSync / 2; + final List<RssItem> buffer = new ArrayList<>(bufferSize); // Buffer of size X @Override public void onSubscribe(@NonNull Disposable d) { |