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(); Type listType = new TypeToken<List<Article>>() {}.getType();
final List<Article> articles = new Gson().fromJson(content, listType); final List<Article> articles = new Gson().fromJson(content, listType);
while (m_articles.size() > HEADLINES_BUFFER_MAX) if (m_offset == 0) {
m_articles.remove(0);
if (m_offset == 0)
m_articles.clear(); m_articles.clear();
else } else {
if (m_articles.get(m_articles.size()-1).id == -1) 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 m_articles.remove(m_articles.size()-1); // remove previous placeholder
}
}
for (Article f : articles) for (Article f : articles)
if (!m_articles.containsId(f.id)) if (!m_articles.containsId(f.id))