implement duplicate checking for headlinesrequest

This commit is contained in:
Andrew Dolgov 2013-04-29 22:59:12 +04:00
parent 390c529728
commit 66d78b6602
2 changed files with 12 additions and 2 deletions

View File

@ -44,6 +44,14 @@ public class ArticleList extends ArrayList<Article> implements Parcelable {
readFromParcel(in);
}
public boolean containsId(int id) {
for (Article a : this) {
if (a.id == id)
return true;
}
return false;
}
@SuppressWarnings("rawtypes")
public static final Parcelable.Creator CREATOR =
new Parcelable.Creator() {

View File

@ -11,6 +11,7 @@ import org.fox.ttrss.types.Article;
import org.fox.ttrss.types.ArticleList;
import android.content.Context;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
@ -49,6 +50,7 @@ public class HeadlinesRequest extends ApiRequest {
m_articles.remove(m_articles.size()-1); // remove previous placeholder
for (Article f : articles)
if (!m_articles.containsId(f.id))
m_articles.add(f);
if (articles.size() == HEADLINES_REQUEST_SIZE) {