abort if received headlines for the feed which is no longer active
(because of request taking too long?) (refs #785)
This commit is contained in:
parent
9ae3f3c50a
commit
8bb1ccbb24
@ -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);
|
||||
|
@ -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)));
|
||||
|
@ -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<List<Article>>() {}.getType();
|
||||
|
Loading…
Reference in New Issue
Block a user