diff options
author | Andrew Dolgov <[email protected]> | 2013-04-29 22:59:12 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2013-04-29 22:59:12 +0400 |
commit | 66d78b6602d2c5199a743012abfcdddfe0091c11 (patch) | |
tree | a73cad3aba3b53a1c7494256f868c4bd8c06b765 /src | |
parent | 390c52972824af084c289ab630e471aa683b42de (diff) |
implement duplicate checking for headlinesrequest
Diffstat (limited to 'src')
-rw-r--r-- | src/org/fox/ttrss/types/ArticleList.java | 8 | ||||
-rw-r--r-- | src/org/fox/ttrss/util/HeadlinesRequest.java | 6 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/org/fox/ttrss/types/ArticleList.java b/src/org/fox/ttrss/types/ArticleList.java index 5fe36d95..fe70a15c 100644 --- a/src/org/fox/ttrss/types/ArticleList.java +++ b/src/org/fox/ttrss/types/ArticleList.java @@ -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() { diff --git a/src/org/fox/ttrss/util/HeadlinesRequest.java b/src/org/fox/ttrss/util/HeadlinesRequest.java index 9ad5ef91..8f0814c5 100644 --- a/src/org/fox/ttrss/util/HeadlinesRequest.java +++ b/src/org/fox/ttrss/util/HeadlinesRequest.java @@ -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; @@ -48,8 +49,9 @@ public class HeadlinesRequest extends ApiRequest { if (m_articles.get(m_articles.size()-1).id == -1) m_articles.remove(m_articles.size()-1); // remove previous placeholder - for (Article f : articles) - m_articles.add(f); + for (Article f : articles) + if (!m_articles.containsId(f.id)) + m_articles.add(f); if (articles.size() == HEADLINES_REQUEST_SIZE) { Article placeholder = new Article(-1); |