headlinesrequest: do not try to remove excess items if requested with

offset=0
This commit is contained in:
Andrew Dolgov 2013-10-16 13:35:49 +04:00
parent 294eeeb9cd
commit 9ae3f3c50a

View File

@ -40,14 +40,18 @@ public class HeadlinesRequest extends ApiRequest {
Type listType = new TypeToken<List<Article>>() {}.getType();
final List<Article> articles = new Gson().fromJson(content, listType);
while (m_articles.size() > HEADLINES_BUFFER_MAX)
m_articles.remove(0);
if (m_offset == 0)
if (m_offset == 0) {
m_articles.clear();
else
if (m_articles.get(m_articles.size()-1).id == -1)
} else {
while (m_articles.size() > HEADLINES_BUFFER_MAX) {
m_articles.remove(0);
}
if (m_articles.get(m_articles.size()-1).id == -1) {
m_articles.remove(m_articles.size()-1); // remove previous placeholder
}
}
for (Article f : articles)
if (!m_articles.containsId(f.id))