diff --git a/src/org/fox/ttrss/ArticlePager.java b/src/org/fox/ttrss/ArticlePager.java index e9c3f57a..1a376b74 100644 --- a/src/org/fox/ttrss/ArticlePager.java +++ b/src/org/fox/ttrss/ArticlePager.java @@ -150,7 +150,7 @@ public class ArticlePager extends Fragment { append = false; } - HeadlinesRequest req = new HeadlinesRequest(getActivity().getApplicationContext(), m_activity) { + HeadlinesRequest req = new HeadlinesRequest(getActivity().getApplicationContext(), m_activity, m_feed) { @Override protected void onProgressUpdate(Integer... progress) { m_activity.setProgress(progress[0] / progress[1] * 10000); diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index a7ae32ad..e3f70102 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -388,7 +388,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, final String sessionId = m_activity.getSessionId(); final boolean isCat = m_feed.is_cat; - HeadlinesRequest req = new HeadlinesRequest(getActivity().getApplicationContext(), m_activity) { + HeadlinesRequest req = new HeadlinesRequest(getActivity().getApplicationContext(), m_activity, m_feed) { @Override protected void onProgressUpdate(Integer... progress) { m_activity.setProgress(Math.round((((float)progress[0] / (float)progress[1]) * 10000))); diff --git a/src/org/fox/ttrss/util/HeadlinesRequest.java b/src/org/fox/ttrss/util/HeadlinesRequest.java index fb8aed1b..551c0add 100644 --- a/src/org/fox/ttrss/util/HeadlinesRequest.java +++ b/src/org/fox/ttrss/util/HeadlinesRequest.java @@ -9,6 +9,7 @@ import org.fox.ttrss.OnlineActivity; import org.fox.ttrss.R; import org.fox.ttrss.types.Article; import org.fox.ttrss.types.ArticleList; +import org.fox.ttrss.types.Feed; import android.content.Context; import android.util.Log; @@ -22,19 +23,30 @@ public class HeadlinesRequest extends ApiRequest { public static final int HEADLINES_REQUEST_SIZE = 30; public static final int HEADLINES_BUFFER_MAX = 1500; + private final String TAG = this.getClass().getSimpleName(); + private int m_offset = 0; private OnlineActivity m_activity; private ArticleList m_articles = GlobalState.getInstance().m_loadedArticles; + private Feed m_feed; - public HeadlinesRequest(Context context, OnlineActivity activity) { + public HeadlinesRequest(Context context, OnlineActivity activity, final Feed feed) { super(context); m_activity = activity; + m_feed = feed; } protected void onPostExecute(JsonElement result) { if (result != null) { - try { + try { + + // check if we are returning results for correct feed + if (GlobalState.getInstance().m_activeFeed != null && !m_feed.equals(GlobalState.getInstance().m_activeFeed)) { + Log.d(TAG, "received results for wrong feed, bailing out."); + return; + } + JsonArray content = result.getAsJsonArray(); if (content != null) { Type listType = new TypeToken>() {}.getType();