first_id fixes
This commit is contained in:
parent
4083904781
commit
0be76abf87
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.fox.ttrss"
|
||||
android:versionCode="362"
|
||||
android:versionName="1.135" >
|
||||
android:versionCode="363"
|
||||
android:versionName="1.136" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="15"
|
||||
|
@ -36,7 +36,8 @@ public class ArticlePager extends Fragment {
|
||||
private String m_searchQuery = "";
|
||||
private Feed m_feed;
|
||||
private SharedPreferences m_prefs;
|
||||
|
||||
private int m_firstId = 0;
|
||||
|
||||
private class PagerAdapter extends ClassloaderWorkaroundFragmentStatePagerAdapter {
|
||||
|
||||
public PagerAdapter(FragmentManager fm) {
|
||||
@ -81,6 +82,7 @@ public class ArticlePager extends Fragment {
|
||||
m_article = savedInstanceState.getParcelable("article");
|
||||
m_articles = ((DetailActivity)m_activity).m_articles;
|
||||
m_feed = savedInstanceState.getParcelable("feed");
|
||||
m_firstId = savedInstanceState.getInt("firstId");
|
||||
}
|
||||
|
||||
m_adapter = new PagerAdapter(getActivity().getSupportFragmentManager());
|
||||
@ -156,10 +158,12 @@ public class ArticlePager extends Fragment {
|
||||
|
||||
if (result != null) {
|
||||
|
||||
if (m_topIdChanged) {
|
||||
if (m_firstIdChanged) {
|
||||
m_articles.add(new Article(HeadlinesFragment.ARTICLE_SPECIAL_TOP_CHANGED));
|
||||
}
|
||||
|
||||
ArticlePager.this.m_firstId = m_firstId;
|
||||
|
||||
try {
|
||||
m_adapter.notifyDataSetChanged();
|
||||
} catch (BadParcelableException e) {
|
||||
@ -223,16 +227,6 @@ public class ArticlePager extends Fragment {
|
||||
|
||||
req.setOffset(skip);
|
||||
|
||||
final int checkTopId;
|
||||
|
||||
if (skip != 0 && m_articles.size() > 1) {
|
||||
// m_articles[0] is the special spacer (id -2)
|
||||
//Log.d(TAG, "TOPID:" + m_articles.get(1).id);
|
||||
checkTopId = m_articles.get(1).id;
|
||||
} else {
|
||||
checkTopId = 0;
|
||||
}
|
||||
|
||||
HashMap<String,String> map = new HashMap<String,String>() {
|
||||
{
|
||||
put("op", "getHeadlines");
|
||||
@ -258,7 +252,7 @@ public class ArticlePager extends Fragment {
|
||||
put("match_on", "both");
|
||||
}
|
||||
|
||||
if (checkTopId > 0) put("check_top_id", String.valueOf(checkTopId));
|
||||
if (m_firstId > 0) put("check_first_id", String.valueOf(m_firstId));
|
||||
|
||||
if (m_activity.getApiLevel() >= 12) {
|
||||
put("include_header", "true");
|
||||
@ -267,7 +261,7 @@ public class ArticlePager extends Fragment {
|
||||
}
|
||||
};
|
||||
|
||||
Log.d(TAG, "[AP] request more headlines, topId=" + checkTopId);
|
||||
Log.d(TAG, "[AP] request more headlines, firstId=" + m_firstId);
|
||||
|
||||
req.execute(map);
|
||||
}
|
||||
@ -275,10 +269,11 @@ public class ArticlePager extends Fragment {
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle out) {
|
||||
super.onSaveInstanceState(out);
|
||||
|
||||
|
||||
out.setClassLoader(getClass().getClassLoader());
|
||||
out.putParcelable("article", m_article);
|
||||
out.putParcelable("feed", m_feed);
|
||||
out.putInt("firstId", m_firstId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,7 +83,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class HeadlinesFragment extends Fragment implements OnItemClickListener, OnScrollListener {
|
||||
public static enum ArticlesSelection { ALL, NONE, UNREAD }
|
||||
public static enum ArticlesSelection { ALL, NONE, UNREAD }
|
||||
|
||||
public static final int FLAVOR_IMG_MIN_SIZE = 128;
|
||||
public static final int THUMB_IMG_MIN_SIZE = 32;
|
||||
@ -102,7 +102,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
private String m_searchQuery = "";
|
||||
private boolean m_refreshInProgress = false;
|
||||
private boolean m_autoCatchupDisabled = false;
|
||||
|
||||
private int m_firstId = 0;
|
||||
|
||||
private SharedPreferences m_prefs;
|
||||
|
||||
private ArticleListAdapter m_adapter;
|
||||
@ -349,6 +350,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
//m_selectedArticles = savedInstanceState.getParcelable("selectedArticles");
|
||||
m_searchQuery = (String) savedInstanceState.getCharSequence("searchQuery");
|
||||
m_compactLayoutMode = savedInstanceState.getBoolean("compactLayoutMode");
|
||||
m_firstId = savedInstanceState.getInt("firstId");
|
||||
}
|
||||
|
||||
String headlineMode = m_prefs.getString("headline_mode", "HL_DEFAULT");
|
||||
@ -545,10 +547,12 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
if (m_articles.indexOf(m_activeArticle) == -1)
|
||||
m_activeArticle = null;
|
||||
|
||||
if (m_topIdChanged) {
|
||||
if (m_firstIdChanged) {
|
||||
m_articles.add(new Article(ARTICLE_SPECIAL_TOP_CHANGED));
|
||||
}
|
||||
|
||||
HeadlinesFragment.this.m_firstId = m_firstId;
|
||||
|
||||
m_adapter.notifyDataSetChanged();
|
||||
m_listener.onHeadlinesLoaded(fappend);
|
||||
|
||||
@ -608,16 +612,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
|
||||
req.setOffset(skip);
|
||||
|
||||
final int checkTopId;
|
||||
|
||||
if (skip != 0 && m_articles.size() > 1) {
|
||||
// m_articles[0] is the special spacer (id -2)
|
||||
//Log.d(TAG, "TOPID:" + m_articles.get(1).id);
|
||||
checkTopId = m_articles.get(1).id;
|
||||
} else {
|
||||
checkTopId = 0;
|
||||
}
|
||||
|
||||
HashMap<String,String> map = new HashMap<String,String>() {
|
||||
{
|
||||
put("op", "getHeadlines");
|
||||
@ -647,7 +641,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
put("match_on", "both");
|
||||
}
|
||||
|
||||
if (checkTopId > 0) put("check_top_id", String.valueOf(checkTopId));
|
||||
if (m_firstId > 0) put("check_first_id", String.valueOf(m_firstId));
|
||||
|
||||
if (m_activity.getApiLevel() >= 12) {
|
||||
put("include_header", "true");
|
||||
@ -655,7 +649,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
}
|
||||
};
|
||||
|
||||
Log.d(TAG, "[HP] request more headlines, topId=" + checkTopId);
|
||||
Log.d(TAG, "[HP] request more headlines, firstId=" + m_firstId);
|
||||
|
||||
req.execute(map);
|
||||
}
|
||||
@ -672,6 +666,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
//out.putParcelable("selectedArticles", m_selectedArticles);
|
||||
out.putCharSequence("searchQuery", m_searchQuery);
|
||||
out.putBoolean("compactLayoutMode", m_compactLayoutMode);
|
||||
out.putInt("firstId", m_firstId);
|
||||
}
|
||||
|
||||
static class HeadlineViewHolder {
|
||||
|
@ -15,7 +15,6 @@ import org.fox.ttrss.OnlineActivity;
|
||||
import org.fox.ttrss.types.Article;
|
||||
import org.fox.ttrss.types.ArticleList;
|
||||
import org.fox.ttrss.types.Feed;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
@ -31,7 +30,8 @@ public class HeadlinesRequest extends ApiRequest {
|
||||
private ArticleList m_articles; // = new ArticleList(); //Application.getInstance().m_loadedArticles;
|
||||
private Feed m_feed;
|
||||
|
||||
protected boolean m_topIdChanged = false;
|
||||
protected boolean m_firstIdChanged = false;
|
||||
protected int m_firstId = 0;
|
||||
|
||||
public HeadlinesRequest(Context context, OnlineActivity activity, final Feed feed, ArticleList articles) {
|
||||
super(context);
|
||||
@ -61,7 +61,10 @@ public class HeadlinesRequest extends ApiRequest {
|
||||
|
||||
//Log.d(TAG, "headerID:" + header.get("top_id_changed"));
|
||||
|
||||
m_topIdChanged = header.get("top_id_changed") != null;
|
||||
m_firstIdChanged = header.get("first_id_changed") != null;
|
||||
m_firstId = header.get("first_id").getAsInt();
|
||||
|
||||
Log.d(TAG, "firstID=" + m_firstId + " firstIdChanged=" + m_firstIdChanged);
|
||||
|
||||
Type listType = new TypeToken<List<Article>>() {}.getType();
|
||||
articles = new Gson().fromJson(content.get(1), listType);
|
||||
|
Loading…
Reference in New Issue
Block a user