Add feed insertion result display for Freshrss account
This commit is contained in:
parent
3418d5401c
commit
6e2786e233
@ -103,14 +103,25 @@ public class FreshRSSRepository extends ARepository<FreshRSSAPI> {
|
||||
@Override
|
||||
public Single<List<FeedInsertionResult>> addFeeds(List<ParsingResult> results) {
|
||||
List<Completable> completableList = new ArrayList<>();
|
||||
List<FeedInsertionResult> insertionResults = new ArrayList<>();
|
||||
|
||||
for (ParsingResult result : results) {
|
||||
completableList.add(api.createFeed(account.getWriteToken(), result.getUrl()));
|
||||
completableList.add(api.createFeed(account.getWriteToken(), result.getUrl())
|
||||
.doOnTerminate(() -> {
|
||||
FeedInsertionResult feedInsertionResult = new FeedInsertionResult();
|
||||
feedInsertionResult.setParsingResult(result);
|
||||
insertionResults.add(feedInsertionResult);
|
||||
}).onErrorResumeNext(throwable -> {
|
||||
FeedInsertionResult feedInsertionResult = new FeedInsertionResult();
|
||||
feedInsertionResult.setInsertionError(FeedInsertionResult.FeedInsertionError.UNKNOWN_ERROR);
|
||||
insertionResults.add(feedInsertionResult);
|
||||
|
||||
return Completable.complete();
|
||||
}));
|
||||
}
|
||||
|
||||
// TODO : see how to handle exceptions/errors like the others repositories
|
||||
return Completable.concat(completableList)
|
||||
.andThen(Single.just(new ArrayList<>()));
|
||||
.andThen(Single.just(insertionResults));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -120,6 +120,7 @@ public class LocalFeedRepository extends ARepository<Void> {
|
||||
Feed feed = insertFeed(queryResult.getFeed(), queryResult.getRssType());
|
||||
if (feed != null) {
|
||||
insertionResult.setFeed(feed);
|
||||
insertionResult.setParsingResult(parsingResult);
|
||||
insertionResults.add(insertionResult);
|
||||
}
|
||||
} else if (queryResult != null && queryResult.getException() != null) {
|
||||
|
@ -7,10 +7,10 @@ import android.util.TimingLogger;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.readrops.app.database.entities.account.Account;
|
||||
import com.readrops.app.database.entities.Feed;
|
||||
import com.readrops.app.database.entities.Folder;
|
||||
import com.readrops.app.database.entities.Item;
|
||||
import com.readrops.app.database.entities.account.Account;
|
||||
import com.readrops.app.utils.FeedInsertionResult;
|
||||
import com.readrops.app.utils.FeedMatcher;
|
||||
import com.readrops.app.utils.ItemMatcher;
|
||||
@ -137,12 +137,12 @@ public class NextNewsRepository extends ARepository<NextNewsAPI> {
|
||||
|
||||
if (nextNewsFeeds != null) {
|
||||
List<Feed> newFeeds = insertFeeds(nextNewsFeeds.getFeeds());
|
||||
|
||||
// there is always only one object in the list, see nextcloud news api doc
|
||||
insertionResult.setFeed(newFeeds.get(0));
|
||||
} else
|
||||
insertionResult.setInsertionError(FeedInsertionResult.FeedInsertionError.UNKNOWN_ERROR);
|
||||
|
||||
insertionResult.setParsingResult(result);
|
||||
} catch (Exception e) {
|
||||
if (e instanceof IOException)
|
||||
insertionResult.setInsertionError(FeedInsertionResult.FeedInsertionError.NETWORK_ERROR);
|
||||
|
@ -94,11 +94,12 @@ public class FeedInsertionResult extends AbstractItem<FeedInsertionResult, FeedI
|
||||
|
||||
@Override
|
||||
public void bindView(FeedInsertionResult item, List<Object> payloads) {
|
||||
if (item.getFeed() != null) {
|
||||
feedInsertionRes.setText(itemView.getContext().getString(R.string.feed_insertion_successfull, item.feed.getName()));
|
||||
if (item.getInsertionError() == null) {
|
||||
feedInsertionRes.setText(itemView.getContext().getString(R.string.feed_insertion_successfull,
|
||||
parsingResult.getLabel() != null ? parsingResult.getLabel() :
|
||||
parsingResult.getUrl()));
|
||||
feedInsertionIcon.setImageResource(R.drawable.ic_check_green);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch (item.getInsertionError()) {
|
||||
case NETWORK_ERROR:
|
||||
setErrorText(R.string.feed_insertion_network_failed, item.parsingResult);
|
||||
|
Loading…
x
Reference in New Issue
Block a user