use excerpt getheadlines field for faster rendering if using api 11

This commit is contained in:
Andrew Dolgov 2014-11-29 20:18:03 +03:00
parent 225458f60a
commit 0615634ce1
4 changed files with 22 additions and 9 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fox.ttrss" package="org.fox.ttrss"
android:versionCode="291" android:versionCode="292"
android:versionName="1.82" > android:versionName="1.83" >
<uses-sdk <uses-sdk
android:minSdkVersion="10" android:minSdkVersion="10"

View File

@ -222,6 +222,8 @@ public class ArticlePager extends Fragment {
put("op", "getHeadlines"); put("op", "getHeadlines");
put("sid", sessionId); put("sid", sessionId);
put("feed_id", String.valueOf(feed.id)); put("feed_id", String.valueOf(feed.id));
put("show_excerpt", "true");
put("excerpt_length", String.valueOf(CommonActivity.EXCERPT_MAX_LENGTH));
put("show_content", "true"); put("show_content", "true");
put("include_attachments", "true"); put("include_attachments", "true");
put("limit", String.valueOf(HeadlinesFragment.HEADLINES_REQUEST_SIZE)); put("limit", String.valueOf(HeadlinesFragment.HEADLINES_REQUEST_SIZE));

View File

@ -539,7 +539,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
Log.d(TAG, "allowForceUpdate=" + allowForceUpdate + " userInitiated=" + userInitiated); Log.d(TAG, "allowForceUpdate=" + allowForceUpdate + " userInitiated=" + userInitiated);
req.setOffset(skip); req.setOffset(skip);
HashMap<String,String> map = new HashMap<String,String>() { HashMap<String,String> map = new HashMap<String,String>() {
@ -547,6 +546,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
put("op", "getHeadlines"); put("op", "getHeadlines");
put("sid", sessionId); put("sid", sessionId);
put("feed_id", String.valueOf(m_feed.id)); put("feed_id", String.valueOf(m_feed.id));
put("show_excerpt", "true");
put("excerpt_length", String.valueOf(CommonActivity.EXCERPT_MAX_LENGTH));
put("show_content", "true"); put("show_content", "true");
put("include_attachments", "true"); put("include_attachments", "true");
put("view_mode", m_activity.getViewMode()); put("view_mode", m_activity.getViewMode());
@ -838,8 +839,15 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
if (holder.excerptView != null) { if (holder.excerptView != null) {
if (!m_prefs.getBoolean("headlines_show_content", true)) { if (!m_prefs.getBoolean("headlines_show_content", true)) {
holder.excerptView.setVisibility(View.GONE); holder.excerptView.setVisibility(View.GONE);
} else if (articleDoc != null) { } else {
String excerpt = articleDoc.text(); String excerpt;
if (m_activity.getApiLevel() >= 11) {
excerpt = article.excerpt != null ? article.excerpt : "";
excerpt = excerpt.replace("&hellip;", "");
} else {
excerpt = articleDoc.text();
}
if (excerpt.length() > CommonActivity.EXCERPT_MAX_LENGTH) if (excerpt.length() > CommonActivity.EXCERPT_MAX_LENGTH)
excerpt = excerpt.substring(0, CommonActivity.EXCERPT_MAX_LENGTH) + ""; excerpt = excerpt.substring(0, CommonActivity.EXCERPT_MAX_LENGTH) + "";

View File

@ -1,11 +1,11 @@
package org.fox.ttrss.types; package org.fox.ttrss.types;
import java.util.ArrayList;
import java.util.List;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import java.util.ArrayList;
import java.util.List;
// TODO: serialize Labels // TODO: serialize Labels
public class Article implements Parcelable { public class Article implements Parcelable {
public int id; public int id;
@ -21,6 +21,7 @@ public class Article implements Parcelable {
public List<String> tags; public List<String> tags;
public List<Attachment> attachments; public List<Attachment> attachments;
public String content; public String content;
public String excerpt;
public List<List<String>> labels; public List<List<String>> labels;
public String feed_title; public String feed_title;
public int comments_count; public int comments_count;
@ -63,6 +64,7 @@ public class Article implements Parcelable {
out.writeInt(feed_id); out.writeInt(feed_id);
out.writeStringList(tags); out.writeStringList(tags);
out.writeString(content); out.writeString(content);
out.writeString(excerpt);
out.writeList(attachments); out.writeList(attachments);
out.writeString(feed_title); out.writeString(feed_title);
out.writeInt(comments_count); out.writeInt(comments_count);
@ -88,6 +90,7 @@ public class Article implements Parcelable {
in.readStringList(tags); in.readStringList(tags);
content = in.readString(); content = in.readString();
excerpt = in.readString();
attachments = new ArrayList<Attachment>(); attachments = new ArrayList<Attachment>();
in.readList(attachments, Attachment.class.getClassLoader()); in.readList(attachments, Attachment.class.getClassLoader());