implement duplicate checking for headlinesrequest
This commit is contained in:
parent
390c529728
commit
66d78b6602
@ -44,6 +44,14 @@ public class ArticleList extends ArrayList<Article> implements Parcelable {
|
|||||||
readFromParcel(in);
|
readFromParcel(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean containsId(int id) {
|
||||||
|
for (Article a : this) {
|
||||||
|
if (a.id == id)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Parcelable.Creator CREATOR =
|
public static final Parcelable.Creator CREATOR =
|
||||||
new Parcelable.Creator() {
|
new Parcelable.Creator() {
|
||||||
|
@ -11,6 +11,7 @@ import org.fox.ttrss.types.Article;
|
|||||||
import org.fox.ttrss.types.ArticleList;
|
import org.fox.ttrss.types.ArticleList;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
@ -48,8 +49,9 @@ public class HeadlinesRequest extends ApiRequest {
|
|||||||
if (m_articles.get(m_articles.size()-1).id == -1)
|
if (m_articles.get(m_articles.size()-1).id == -1)
|
||||||
m_articles.remove(m_articles.size()-1); // remove previous placeholder
|
m_articles.remove(m_articles.size()-1); // remove previous placeholder
|
||||||
|
|
||||||
for (Article f : articles)
|
for (Article f : articles)
|
||||||
m_articles.add(f);
|
if (!m_articles.containsId(f.id))
|
||||||
|
m_articles.add(f);
|
||||||
|
|
||||||
if (articles.size() == HEADLINES_REQUEST_SIZE) {
|
if (articles.size() == HEADLINES_REQUEST_SIZE) {
|
||||||
Article placeholder = new Article(-1);
|
Article placeholder = new Article(-1);
|
||||||
|
Loading…
Reference in New Issue
Block a user