Refactor repositories to put item read state request in it

Put account variable needed for most request directly in the constructor instead in each method as a variable. Put item read state request code in the repository instead of the viewModel
This commit is contained in:
Shinokuni 2019-08-17 12:23:06 +02:00
parent 75e9323177
commit 5eb4353f8a
9 changed files with 88 additions and 85 deletions

View File

@ -532,7 +532,7 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
if (viewModel.getCurrentAccount().getPassword() == null) if (viewModel.getCurrentAccount().getPassword() == null)
account.setPassword(SharedPreferencesManager.readString(this, account.getPasswordKey())); account.setPassword(SharedPreferencesManager.readString(this, account.getPasswordKey()));
viewModel.sync(feeds, account) viewModel.sync(feeds)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<Feed>() { .subscribe(new Observer<Feed>() {

View File

@ -4,12 +4,15 @@ import android.app.Application;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.util.Patterns; import android.util.Patterns;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.palette.graphics.Palette; import androidx.palette.graphics.Palette;
import com.readrops.app.database.Database; import com.readrops.app.database.Database;
import com.readrops.app.database.entities.Account; import com.readrops.app.database.entities.Account;
import com.readrops.app.database.entities.Feed; import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.Folder; import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.entities.Item;
import com.readrops.app.utils.FeedInsertionResult; import com.readrops.app.utils.FeedInsertionResult;
import com.readrops.app.utils.HtmlParser; import com.readrops.app.utils.HtmlParser;
import com.readrops.app.utils.ParsingResult; import com.readrops.app.utils.ParsingResult;
@ -26,26 +29,35 @@ import io.reactivex.schedulers.Schedulers;
public abstract class ARepository { public abstract class ARepository {
protected Database database; protected Database database;
protected Account account;
protected ARepository(Application application) { protected ARepository(@NonNull Application application, @Nullable Account account) {
this.database = Database.getInstance(application); this.database = Database.getInstance(application);
this.account = account;
} }
public abstract Single<Boolean> login(Account account, boolean insert); public abstract Single<Boolean> login(Account account, boolean insert);
public abstract Observable<Feed> sync(List<Feed> feeds, Account account); public abstract Observable<Feed> sync(List<Feed> feeds);
public abstract Single<List<FeedInsertionResult>> addFeeds(List<ParsingResult> results, Account account); public abstract Single<List<FeedInsertionResult>> addFeeds(List<ParsingResult> results);
public abstract Completable updateFeed(Feed feed, Account account); public abstract Completable updateFeed(Feed feed);
public abstract Completable deleteFeed(Feed feed, Account account); public abstract Completable deleteFeed(Feed feed);
public abstract Completable addFolder(Folder folder, Account account); public abstract Completable addFolder(Folder folder);
public abstract Completable updateFolder(Folder folder, Account account); public abstract Completable updateFolder(Folder folder);
public abstract Completable deleteFolder(Folder folder, Account account); public abstract Completable deleteFolder(Folder folder);
public Completable setItemReadState(Item item, boolean read) {
return Completable.create(emitter -> {
database.itemDao().setReadState(item.getId(), read ? 1 : 0, !item.isReadChanged() ? 1 : 0);
emitter.onComplete();
});
}
public Single<Integer> getFeedCount(int accountId) { public Single<Integer> getFeedCount(int accountId) {
return Single.create(emitter -> emitter.onSuccess(database.feedDao().getFeedCount(accountId))); return Single.create(emitter -> emitter.onSuccess(database.feedDao().getFeedCount(accountId)));

View File

@ -2,11 +2,13 @@ package com.readrops.app.repositories;
import android.app.Application; import android.app.Application;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.readrops.app.database.entities.Account; import com.readrops.app.database.entities.Account;
import com.readrops.app.database.entities.Feed; import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.Folder; import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.entities.Item; import com.readrops.app.database.entities.Item;
import com.readrops.app.database.pojo.ItemWithFeed;
import com.readrops.app.utils.FeedInsertionResult; import com.readrops.app.utils.FeedInsertionResult;
import com.readrops.app.utils.FeedMatcher; import com.readrops.app.utils.FeedMatcher;
import com.readrops.app.utils.ItemMatcher; import com.readrops.app.utils.ItemMatcher;
@ -32,8 +34,8 @@ import io.reactivex.Single;
public class FreshRSSRepository extends ARepository { public class FreshRSSRepository extends ARepository {
public FreshRSSRepository(Application application) { public FreshRSSRepository(@NonNull Application application, @Nullable Account account) {
super(application); super(application, account);
} }
@Override @Override
@ -58,7 +60,7 @@ public class FreshRSSRepository extends ARepository {
} }
@Override @Override
public Observable<Feed> sync(List<Feed> feeds, Account account) { public Observable<Feed> sync(List<Feed> feeds) {
FreshRSSAPI api = new FreshRSSAPI(account.toFreshRSSCredentials()); FreshRSSAPI api = new FreshRSSAPI(account.toFreshRSSCredentials());
FreshRSSSyncData syncData = new FreshRSSSyncData(); FreshRSSSyncData syncData = new FreshRSSSyncData();
@ -84,47 +86,46 @@ public class FreshRSSRepository extends ARepository {
} }
@Override @Override
public Single<List<FeedInsertionResult>> addFeeds(List<ParsingResult> results, Account account) { public Single<List<FeedInsertionResult>> addFeeds(List<ParsingResult> results) {
return null; return null;
} }
@Override @Override
public Completable updateFeed(Feed feed, Account account) { public Completable updateFeed(Feed feed) {
return null; return null;
} }
@Override @Override
public Completable deleteFeed(Feed feed, Account account) { public Completable deleteFeed(Feed feed) {
return null; return null;
} }
@Override @Override
public Completable addFolder(Folder folder, Account account) { public Completable addFolder(Folder folder) {
return null; return null;
} }
@Override @Override
public Completable updateFolder(Folder folder, Account account) { public Completable updateFolder(Folder folder) {
return null; return null;
} }
@Override @Override
public Completable deleteFolder(Folder folder, Account account) { public Completable deleteFolder(Folder folder) {
return null; return null;
} }
public Completable markItemReadUnread(ItemWithFeed itemWithFeed, Boolean read, Account account) { @Override
public Completable setItemReadState(Item item, boolean read) {
FreshRSSAPI api = new FreshRSSAPI(account.toFreshRSSCredentials()); FreshRSSAPI api = new FreshRSSAPI(account.toFreshRSSCredentials());
if (account.getWriteToken() == null) { if (account.getWriteToken() == null) {
return api.getWriteToken() return api.getWriteToken()
.flatMapCompletable(writeToken -> api. .flatMapCompletable(writeToken -> api.
markItemReadUnread(read, itemWithFeed.getItem().getRemoteId(), writeToken)); markItemReadUnread(read, item.getRemoteId(), writeToken));
} else { } else {
return api.markItemReadUnread(read, itemWithFeed.getItem().getRemoteId(), account.getWriteToken()); return api.markItemReadUnread(read, item.getRemoteId(), account.getWriteToken());
} }
} }
private List<Feed> insertFeeds(List<FreshRSSFeed> freshRSSFeeds, Account account) { private List<Feed> insertFeeds(List<FreshRSSFeed> freshRSSFeeds, Account account) {

View File

@ -3,6 +3,7 @@ package com.readrops.app.repositories;
import android.accounts.NetworkErrorException; import android.accounts.NetworkErrorException;
import android.app.Application; import android.app.Application;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.readrops.app.database.entities.Account; import com.readrops.app.database.entities.Account;
@ -40,8 +41,8 @@ public class LocalFeedRepository extends ARepository {
private static final String TAG = LocalFeedRepository.class.getSimpleName(); private static final String TAG = LocalFeedRepository.class.getSimpleName();
public LocalFeedRepository(Application application) { public LocalFeedRepository(@NonNull Application application, @Nullable Account account) {
super(application); super(application, account);
} }
@ -51,7 +52,7 @@ public class LocalFeedRepository extends ARepository {
} }
@Override @Override
public Observable<Feed> sync(@Nullable List<Feed> feeds, Account account) { public Observable<Feed> sync(@Nullable List<Feed> feeds) {
return Observable.create(emitter -> { return Observable.create(emitter -> {
List<Feed> feedList; List<Feed> feedList;
@ -104,7 +105,7 @@ public class LocalFeedRepository extends ARepository {
} }
@Override @Override
public Single<List<FeedInsertionResult>> addFeeds(List<ParsingResult> results, Account account) { public Single<List<FeedInsertionResult>> addFeeds(List<ParsingResult> results) {
return Single.create(emitter -> { return Single.create(emitter -> {
List<FeedInsertionResult> insertionResults = new ArrayList<>(); List<FeedInsertionResult> insertionResults = new ArrayList<>();
@ -116,7 +117,7 @@ public class LocalFeedRepository extends ARepository {
RSSQueryResult queryResult = rssNet.queryUrl(parsingResult.getUrl(), new HashMap<>()); RSSQueryResult queryResult = rssNet.queryUrl(parsingResult.getUrl(), new HashMap<>());
if (queryResult != null && queryResult.getException() == null) { if (queryResult != null && queryResult.getException() == null) {
Feed feed = insertFeed(queryResult.getFeed(), queryResult.getRssType(), account); Feed feed = insertFeed(queryResult.getFeed(), queryResult.getRssType());
if (feed != null) { if (feed != null) {
insertionResult.setFeed(feed); insertionResult.setFeed(feed);
insertionResults.add(insertionResult); insertionResults.add(insertionResult);
@ -145,7 +146,7 @@ public class LocalFeedRepository extends ARepository {
} }
@Override @Override
public Completable updateFeed(Feed feed, Account account) { public Completable updateFeed(Feed feed) {
return Completable.create(emitter -> { return Completable.create(emitter -> {
database.feedDao().updateFeedFields(feed.getId(), feed.getName(), feed.getUrl(), feed.getFolderId()); database.feedDao().updateFeedFields(feed.getId(), feed.getName(), feed.getUrl(), feed.getFolderId());
emitter.onComplete(); emitter.onComplete();
@ -153,7 +154,7 @@ public class LocalFeedRepository extends ARepository {
} }
@Override @Override
public Completable deleteFeed(Feed feed, Account account) { public Completable deleteFeed(Feed feed) {
return Completable.create(emitter -> { return Completable.create(emitter -> {
database.feedDao().delete(feed.getId()); database.feedDao().delete(feed.getId());
emitter.onComplete(); emitter.onComplete();
@ -161,7 +162,7 @@ public class LocalFeedRepository extends ARepository {
} }
@Override @Override
public Completable addFolder(Folder folder, Account account) { public Completable addFolder(Folder folder) {
return Completable.create(emitter -> { return Completable.create(emitter -> {
database.folderDao().insert(folder); database.folderDao().insert(folder);
emitter.onComplete(); emitter.onComplete();
@ -169,7 +170,7 @@ public class LocalFeedRepository extends ARepository {
} }
@Override @Override
public Completable updateFolder(Folder folder, Account account) { public Completable updateFolder(Folder folder) {
return Completable.create(emitter -> { return Completable.create(emitter -> {
database.folderDao().update(folder); database.folderDao().update(folder);
emitter.onComplete(); emitter.onComplete();
@ -177,7 +178,7 @@ public class LocalFeedRepository extends ARepository {
} }
@Override @Override
public Completable deleteFolder(Folder folder, Account account) { public Completable deleteFolder(Folder folder) {
return Completable.create(emitter -> { return Completable.create(emitter -> {
database.folderDao().delete(folder); database.folderDao().delete(folder);
emitter.onComplete(); emitter.onComplete();
@ -209,7 +210,7 @@ public class LocalFeedRepository extends ARepository {
insertItems(items, dbFeed); insertItems(items, dbFeed);
} }
private Feed insertFeed(AFeed feed, RSSQuery.RSSType type, Account account) throws IOException { private Feed insertFeed(AFeed feed, RSSQuery.RSSType type) throws IOException {
Feed dbFeed = null; Feed dbFeed = null;
switch (type) { switch (type) {
case RSS_2: case RSS_2:

View File

@ -4,6 +4,9 @@ import android.app.Application;
import android.database.sqlite.SQLiteConstraintException; import android.database.sqlite.SQLiteConstraintException;
import android.util.TimingLogger; import android.util.TimingLogger;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.readrops.app.database.entities.Account; import com.readrops.app.database.entities.Account;
import com.readrops.app.database.entities.Feed; import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.Folder; import com.readrops.app.database.entities.Folder;
@ -41,8 +44,8 @@ public class NextNewsRepository extends ARepository {
private static final String TAG = NextNewsRepository.class.getSimpleName(); private static final String TAG = NextNewsRepository.class.getSimpleName();
public NextNewsRepository(Application application) { public NextNewsRepository(@NonNull Application application, @Nullable Account account) {
super(application); super(application, account);
} }
@Override @Override
@ -64,7 +67,7 @@ public class NextNewsRepository extends ARepository {
} }
@Override @Override
public Observable<Feed> sync(List<Feed> feeds, Account account) { public Observable<Feed> sync(List<Feed> feeds) {
return Observable.create(emitter -> { return Observable.create(emitter -> {
try { try {
NextNewsAPI newsAPI = new NextNewsAPI(account.toNextNewsCredentials()); NextNewsAPI newsAPI = new NextNewsAPI(account.toNextNewsCredentials());
@ -90,13 +93,13 @@ public class NextNewsRepository extends ARepository {
if (!syncResult.isError()) { if (!syncResult.isError()) {
insertFolders(syncResult.getFolders(), account); insertFolders(syncResult.getFolders());
timings.addSplit("insert folders"); timings.addSplit("insert folders");
insertFeeds(syncResult.getFeeds(), account); insertFeeds(syncResult.getFeeds());
timings.addSplit("insert feeds"); timings.addSplit("insert feeds");
insertItems(syncResult.getItems(), account, syncType == SyncType.INITIAL_SYNC); insertItems(syncResult.getItems(), syncType == SyncType.INITIAL_SYNC);
timings.addSplit("insert items"); timings.addSplit("insert items");
timings.dumpToLog(); timings.dumpToLog();
@ -116,7 +119,7 @@ public class NextNewsRepository extends ARepository {
} }
@Override @Override
public Single<List<FeedInsertionResult>> addFeeds(List<ParsingResult> results, Account account) { public Single<List<FeedInsertionResult>> addFeeds(List<ParsingResult> results) {
return Single.create(emitter -> { return Single.create(emitter -> {
List<FeedInsertionResult> feedInsertionResults = new ArrayList<>(); List<FeedInsertionResult> feedInsertionResults = new ArrayList<>();
NextNewsAPI newsAPI = new NextNewsAPI(account.toNextNewsCredentials()); NextNewsAPI newsAPI = new NextNewsAPI(account.toNextNewsCredentials());
@ -128,7 +131,7 @@ public class NextNewsRepository extends ARepository {
NextNewsFeeds nextNewsFeeds = newsAPI.createFeed(result.getUrl(), 0); NextNewsFeeds nextNewsFeeds = newsAPI.createFeed(result.getUrl(), 0);
if (nextNewsFeeds != null) { if (nextNewsFeeds != null) {
List<Feed> newFeeds = insertFeeds(nextNewsFeeds.getFeeds(), account); List<Feed> newFeeds = insertFeeds(nextNewsFeeds.getFeeds());
// there is always only one object in the list, see nextcloud news api doc // there is always only one object in the list, see nextcloud news api doc
insertionResult.setFeed(newFeeds.get(0)); insertionResult.setFeed(newFeeds.get(0));
@ -154,7 +157,7 @@ public class NextNewsRepository extends ARepository {
} }
@Override @Override
public Completable updateFeed(Feed feed, Account account) { public Completable updateFeed(Feed feed) {
return Completable.create(emitter -> { return Completable.create(emitter -> {
NextNewsAPI api = new NextNewsAPI(account.toNextNewsCredentials()); NextNewsAPI api = new NextNewsAPI(account.toNextNewsCredentials());
@ -185,7 +188,7 @@ public class NextNewsRepository extends ARepository {
} }
@Override @Override
public Completable deleteFeed(Feed feed, Account account) { public Completable deleteFeed(Feed feed) {
return Completable.create(emitter -> { return Completable.create(emitter -> {
NextNewsAPI api = new NextNewsAPI(account.toNextNewsCredentials()); NextNewsAPI api = new NextNewsAPI(account.toNextNewsCredentials());
@ -204,7 +207,7 @@ public class NextNewsRepository extends ARepository {
} }
@Override @Override
public Completable addFolder(Folder folder, Account account) { public Completable addFolder(Folder folder) {
return Completable.create(emitter -> { return Completable.create(emitter -> {
NextNewsAPI api = new NextNewsAPI(account.toNextNewsCredentials()); NextNewsAPI api = new NextNewsAPI(account.toNextNewsCredentials());
@ -212,7 +215,7 @@ public class NextNewsRepository extends ARepository {
NextNewsFolders folders = api.createFolder(new NextNewsFolder(Integer.parseInt(folder.getRemoteId()), folder.getName())); NextNewsFolders folders = api.createFolder(new NextNewsFolder(Integer.parseInt(folder.getRemoteId()), folder.getName()));
if (folders != null) if (folders != null)
insertFolders(folders.getFolders(), account); insertFolders(folders.getFolders());
else else
emitter.onError(new Exception("Unknown error")); emitter.onError(new Exception("Unknown error"));
} catch (Exception e) { } catch (Exception e) {
@ -224,7 +227,7 @@ public class NextNewsRepository extends ARepository {
} }
@Override @Override
public Completable updateFolder(Folder folder, Account account) { public Completable updateFolder(Folder folder) {
return Completable.create(emitter -> { return Completable.create(emitter -> {
NextNewsAPI api = new NextNewsAPI(account.toNextNewsCredentials()); NextNewsAPI api = new NextNewsAPI(account.toNextNewsCredentials());
@ -244,7 +247,7 @@ public class NextNewsRepository extends ARepository {
} }
@Override @Override
public Completable deleteFolder(Folder folder, Account account) { public Completable deleteFolder(Folder folder) {
return Completable.create(emitter -> { return Completable.create(emitter -> {
NextNewsAPI api = new NextNewsAPI(account.toNextNewsCredentials()); NextNewsAPI api = new NextNewsAPI(account.toNextNewsCredentials());
@ -263,7 +266,7 @@ public class NextNewsRepository extends ARepository {
}); });
} }
private List<Feed> insertFeeds(List<NextNewsFeed> nextNewsFeeds, Account account) { private List<Feed> insertFeeds(List<NextNewsFeed> nextNewsFeeds) {
List<Feed> feeds = new ArrayList<>(); List<Feed> feeds = new ArrayList<>();
for (NextNewsFeed nextNewsFeed : nextNewsFeeds) { for (NextNewsFeed nextNewsFeed : nextNewsFeeds) {
@ -281,7 +284,7 @@ public class NextNewsRepository extends ARepository {
return insertedFeeds; return insertedFeeds;
} }
private void insertFolders(List<NextNewsFolder> nextNewsFolders, Account account) { private void insertFolders(List<NextNewsFolder> nextNewsFolders) {
List<Folder> folders = new ArrayList<>(); List<Folder> folders = new ArrayList<>();
for (NextNewsFolder nextNewsFolder : nextNewsFolders) { for (NextNewsFolder nextNewsFolder : nextNewsFolders) {
@ -295,7 +298,7 @@ public class NextNewsRepository extends ARepository {
database.folderDao().foldersUpsert(folders, account); database.folderDao().foldersUpsert(folders, account);
} }
private void insertItems(List<NextNewsItem> items, Account account, boolean initialSync) { private void insertItems(List<NextNewsItem> items, boolean initialSync) {
List<Item> newItems = new ArrayList<>(); List<Item> newItems = new ArrayList<>();
for (NextNewsItem nextNewsItem : items) { for (NextNewsItem nextNewsItem : items) {

View File

@ -28,10 +28,10 @@ public class AccountViewModel extends AndroidViewModel {
public void setAccountType(Account.AccountType accountType) throws Exception { public void setAccountType(Account.AccountType accountType) throws Exception {
switch (accountType) { switch (accountType) {
case NEXTCLOUD_NEWS: case NEXTCLOUD_NEWS:
repository = new NextNewsRepository(getApplication()); repository = new NextNewsRepository(getApplication(), null);
break; break;
case FRESHRSS: case FRESHRSS:
repository = new FreshRSSRepository(getApplication()); repository = new FreshRSSRepository(getApplication(), null);
break; break;
default: default:
throw new Exception("unknown account type"); throw new Exception("unknown account type");
@ -64,10 +64,6 @@ public class AccountViewModel extends AndroidViewModel {
}); });
} }
public Single<Integer> getAccountCountByAccountType(int accountTypeCode) {
return Single.create(emitter -> emitter.onSuccess(database.accountDao().getAccountCountByType(accountTypeCode)));
}
public Single<Integer> getAccountCount() { public Single<Integer> getAccountCount() {
return Single.create(emitter -> emitter.onSuccess(database.accountDao().getAccountCount())); return Single.create(emitter -> emitter.onSuccess(database.accountDao().getAccountCount()));
} }

View File

@ -34,14 +34,14 @@ public class AddFeedsViewModel extends AndroidViewModel {
public Single<List<FeedInsertionResult>> addFeeds(List<ParsingResult> results, Account account) { public Single<List<FeedInsertionResult>> addFeeds(List<ParsingResult> results, Account account) {
switch (account.getAccountType()) { switch (account.getAccountType()) {
case LOCAL: case LOCAL:
repository = new LocalFeedRepository(getApplication()); repository = new LocalFeedRepository(getApplication(), account);
break; break;
case NEXTCLOUD_NEWS: case NEXTCLOUD_NEWS:
repository = new NextNewsRepository(getApplication()); repository = new NextNewsRepository(getApplication(), account);
break; break;
} }
return repository.addFeeds(results, account); return repository.addFeeds(results);
} }
public Single<List<ParsingResult>> parseUrl(String url) { public Single<List<ParsingResult>> parseUrl(String url) {

View File

@ -63,13 +63,13 @@ public class MainViewModel extends AndroidViewModel {
private void setRepository(Account.AccountType accountType) { private void setRepository(Account.AccountType accountType) {
switch (accountType) { switch (accountType) {
case LOCAL: case LOCAL:
repository = new LocalFeedRepository(getApplication()); repository = new LocalFeedRepository(getApplication(), currentAccount);
break; break;
case NEXTCLOUD_NEWS: case NEXTCLOUD_NEWS:
repository = new NextNewsRepository(getApplication()); repository = new NextNewsRepository(getApplication(), currentAccount);
break; break;
case FRESHRSS: case FRESHRSS:
repository = new FreshRSSRepository(getApplication()); repository = new FreshRSSRepository(getApplication(), currentAccount);
break; break;
} }
} }
@ -125,8 +125,8 @@ public class MainViewModel extends AndroidViewModel {
return itemsWithFeed; return itemsWithFeed;
} }
public Observable<Feed> sync(List<Feed> feeds, Account account) { public Observable<Feed> sync(List<Feed> feeds) {
return repository.sync(feeds, account); return repository.sync(feeds);
} }
public Single<Integer> getFeedCount() { public Single<Integer> getFeedCount() {
@ -250,18 +250,8 @@ public class MainViewModel extends AndroidViewModel {
//region Item read state //region Item read state
public Completable setItemReadState(ItemWithFeed item, boolean read) { public Completable setItemReadState(ItemWithFeed itemWithFeed, boolean read) {
Completable completable = Completable.create(emitter -> { return repository.setItemReadState(itemWithFeed.getItem(), read);
db.itemDao().setReadState(item.getItem().getId(), read ? 1 : 0, !item.getItem().isReadChanged() ? 1 : 0);
emitter.onComplete();
});
// TODO : temporary until a better idea comes out
if (currentAccount.getAccountType() == Account.AccountType.FRESHRSS) {
return completable.andThen(((FreshRSSRepository) repository).
markItemReadUnread(item, read, currentAccount));
} else
return completable;
} }
public Completable setItemsReadState(List<ItemWithFeed> items, boolean read) { public Completable setItemsReadState(List<ItemWithFeed> items, boolean read) {

View File

@ -36,10 +36,10 @@ public class ManageFeedsFoldersViewModel extends AndroidViewModel {
private void setup() { private void setup() {
switch (account.getAccountType()) { switch (account.getAccountType()) {
case LOCAL: case LOCAL:
repository = new LocalFeedRepository(getApplication()); repository = new LocalFeedRepository(getApplication(), account);
break; break;
case NEXTCLOUD_NEWS: case NEXTCLOUD_NEWS:
repository = new NextNewsRepository(getApplication()); repository = new NextNewsRepository(getApplication(), account);
break; break;
} }
@ -52,7 +52,7 @@ public class ManageFeedsFoldersViewModel extends AndroidViewModel {
} }
public Completable updateFeedWithFolder(Feed feed) { public Completable updateFeedWithFolder(Feed feed) {
return repository.updateFeed(feed, account); return repository.updateFeed(feed);
} }
public Account getAccount() { public Account getAccount() {
@ -69,18 +69,18 @@ public class ManageFeedsFoldersViewModel extends AndroidViewModel {
} }
public Completable addFolder(Folder folder) { public Completable addFolder(Folder folder) {
return repository.addFolder(folder, account); return repository.addFolder(folder);
} }
public Completable updateFolder(Folder folder) { public Completable updateFolder(Folder folder) {
return repository.updateFolder(folder, account); return repository.updateFolder(folder);
} }
public Completable deleteFolder(Folder folder) { public Completable deleteFolder(Folder folder) {
return repository.deleteFolder(folder, account); return repository.deleteFolder(folder);
} }
public Completable deleteFeed(Feed feed) { public Completable deleteFeed(Feed feed) {
return repository.deleteFeed(feed, account); return repository.deleteFeed(feed);
} }
} }