make headlines listview a bit faster
This commit is contained in:
parent
104df9df30
commit
accfa1c672
@ -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="289"
|
android:versionCode="290"
|
||||||
android:versionName="1.80" >
|
android:versionName="1.81" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="10"
|
android:minSdkVersion="10"
|
||||||
|
@ -35,6 +35,7 @@ import com.viewpagerindicator.UnderlinePageIndicator;
|
|||||||
|
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
|
import org.jsoup.nodes.Element;
|
||||||
import org.jsoup.select.Elements;
|
import org.jsoup.select.Elements;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -241,15 +242,38 @@ public class ArticleImagesPagerActivity extends CommonActivity implements Gestur
|
|||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
m_title = getIntent().getStringExtra("title");
|
m_title = getIntent().getStringExtra("title");
|
||||||
m_urls = getIntent().getStringArrayListExtra("urls");
|
//m_urls = getIntent().getStringArrayListExtra("urls");
|
||||||
m_content = getIntent().getStringExtra("content");
|
m_content = getIntent().getStringExtra("content");
|
||||||
|
|
||||||
|
String imgSrcFirst = getIntent().getStringExtra("firstSrc");
|
||||||
|
|
||||||
|
m_urls = new ArrayList<String>();
|
||||||
|
|
||||||
|
Document doc = Jsoup.parse(m_content);
|
||||||
|
Elements imgs = doc.select("img");
|
||||||
|
|
||||||
|
boolean firstFound = false;
|
||||||
|
|
||||||
|
for (Element img : imgs) {
|
||||||
|
String imgSrc = img.attr("src");
|
||||||
|
|
||||||
|
if (imgSrcFirst.equals(imgSrc))
|
||||||
|
firstFound = true;
|
||||||
|
|
||||||
|
if (firstFound) {
|
||||||
|
if (imgSrc.indexOf("//") == 0)
|
||||||
|
imgSrc = "http:" + imgSrc;
|
||||||
|
|
||||||
|
m_urls.add(imgSrc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
m_urls = savedInstanceState.getStringArrayList("urls");
|
m_urls = savedInstanceState.getStringArrayList("urls");
|
||||||
m_title = savedInstanceState.getString("title");
|
m_title = savedInstanceState.getString("title");
|
||||||
m_content = savedInstanceState.getString("content");
|
m_content = savedInstanceState.getString("content");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (m_urls.size() > 1) {
|
if (m_urls.size() > 1) {
|
||||||
m_checkedUrls = new ArrayList<String>();
|
m_checkedUrls = new ArrayList<String>();
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ public class CommonActivity extends ActionBarActivity {
|
|||||||
public final static String THEME_DEFAULT = CommonActivity.THEME_LIGHT;
|
public final static String THEME_DEFAULT = CommonActivity.THEME_LIGHT;
|
||||||
|
|
||||||
public static final int EXCERPT_MAX_LENGTH = 256;
|
public static final int EXCERPT_MAX_LENGTH = 256;
|
||||||
|
public static final int EXCERPT_MAX_QUERY_LENGTH = 1024;
|
||||||
|
|
||||||
private SQLiteDatabase m_readableDb;
|
private SQLiteDatabase m_readableDb;
|
||||||
private SQLiteDatabase m_writableDb;
|
private SQLiteDatabase m_writableDb;
|
||||||
|
@ -828,16 +828,30 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean showFlavorImage = "HL_DEFAULT".equals(m_prefs.getString("headline_mode", "HL_DEFAULT"));
|
||||||
|
|
||||||
String articleContent = article.content != null ? article.content : "";
|
String articleContent = article.content != null ? article.content : "";
|
||||||
|
|
||||||
|
|
||||||
|
String articleContentReduced = articleContent.length() > CommonActivity.EXCERPT_MAX_QUERY_LENGTH ?
|
||||||
|
articleContent.substring(0, CommonActivity.EXCERPT_MAX_QUERY_LENGTH) : articleContent;
|
||||||
|
|
||||||
|
/* if (m_compactLayoutMode || !showFlavorImage) {
|
||||||
|
if (articleContent.length() > CommonActivity.EXCERPT_MAX_QUERY_LENGTH) {
|
||||||
|
articleContent = articleContent.substring(0, CommonActivity.EXCERPT_MAX_QUERY_LENGTH);
|
||||||
|
}
|
||||||
|
} */
|
||||||
|
|
||||||
|
Document articleDoc = Jsoup.parse(articleContentReduced);
|
||||||
|
|
||||||
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 {
|
} else if (articleDoc != null) {
|
||||||
String tmp = articleContent.length() > CommonActivity.EXCERPT_MAX_LENGTH ?
|
String excerpt = articleDoc.text();
|
||||||
articleContent.substring(0, CommonActivity.EXCERPT_MAX_LENGTH) + "…" : articleContent;
|
|
||||||
|
|
||||||
String excerpt = Jsoup.parse(tmp).text();
|
if (excerpt.length() > CommonActivity.EXCERPT_MAX_LENGTH)
|
||||||
|
excerpt = excerpt.substring(0, CommonActivity.EXCERPT_MAX_LENGTH) + "…";
|
||||||
|
|
||||||
holder.excerptView.setTextSize(TypedValue.COMPLEX_UNIT_SP, headlineFontSize);
|
holder.excerptView.setTextSize(TypedValue.COMPLEX_UNIT_SP, headlineFontSize);
|
||||||
holder.excerptView.setText(excerpt);
|
holder.excerptView.setText(excerpt);
|
||||||
@ -845,19 +859,18 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!m_compactLayoutMode) {
|
if (!m_compactLayoutMode) {
|
||||||
boolean showFlavorImage = "HL_DEFAULT".equals(m_prefs.getString("headline_mode", "HL_DEFAULT"));
|
|
||||||
|
|
||||||
if (holder.flavorImageView != null && showFlavorImage) {
|
if (holder.flavorImageView != null && showFlavorImage) {
|
||||||
holder.flavorImageArrow.setVisibility(View.GONE);
|
holder.flavorImageArrow.setVisibility(View.GONE);
|
||||||
|
|
||||||
Document doc = Jsoup.parse(articleContent);
|
//Document doc = Jsoup.parse(articleContent);
|
||||||
|
|
||||||
boolean loadableImageFound = false;
|
boolean loadableImageFound = false;
|
||||||
|
|
||||||
if (doc != null) {
|
if (articleDoc != null) {
|
||||||
//Element img = doc.select("img").first();
|
//Element img = doc.select("img").first();
|
||||||
|
|
||||||
final Elements imgs = doc.select("img");
|
final Elements imgs = articleDoc.select("img");
|
||||||
Element img = null;
|
Element img = null;
|
||||||
|
|
||||||
for (Element tmp : imgs) {
|
for (Element tmp : imgs) {
|
||||||
@ -876,6 +889,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
|
|
||||||
if (img != null) {
|
if (img != null) {
|
||||||
String imgSrc = img.attr("src");
|
String imgSrc = img.attr("src");
|
||||||
|
final String imgSrcFirst = imgSrc;
|
||||||
|
|
||||||
// retarded schema-less urls
|
// retarded schema-less urls
|
||||||
if (imgSrc.indexOf("//") == 0)
|
if (imgSrc.indexOf("//") == 0)
|
||||||
@ -890,19 +904,27 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
holder.flavorImageView.setOnClickListener(new OnClickListener() {
|
holder.flavorImageView.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
ArrayList<String> imgsList = new ArrayList<String>();
|
/* ArrayList<String> imgsList = new ArrayList<String>();
|
||||||
|
|
||||||
|
boolean firstFound = false;
|
||||||
|
|
||||||
for (Element img : imgs) {
|
for (Element img : imgs) {
|
||||||
String imgSrc = img.attr("src");
|
String imgSrc = img.attr("src");
|
||||||
|
|
||||||
|
if (imgSrcFirst.equals(imgSrc))
|
||||||
|
firstFound = true;
|
||||||
|
|
||||||
|
if (firstFound) {
|
||||||
if (imgSrc.indexOf("//") == 0)
|
if (imgSrc.indexOf("//") == 0)
|
||||||
imgSrc = "http:" + imgSrc;
|
imgSrc = "http:" + imgSrc;
|
||||||
|
|
||||||
imgsList.add(imgSrc);
|
imgsList.add(imgSrc);
|
||||||
}
|
}
|
||||||
|
} */
|
||||||
|
|
||||||
Intent intent = new Intent(m_activity, ArticleImagesPagerActivity.class);
|
Intent intent = new Intent(m_activity, ArticleImagesPagerActivity.class);
|
||||||
intent.putExtra("urls", imgsList);
|
//intent.putExtra("urls", imgsList);
|
||||||
|
intent.putExtra("firstSrc", imgSrcFirst);
|
||||||
intent.putExtra("title", article.title);
|
intent.putExtra("title", article.title);
|
||||||
intent.putExtra("content", article.content);
|
intent.putExtra("content", article.content);
|
||||||
|
|
||||||
|
@ -694,18 +694,19 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
String articleContent = article.getString(article.getColumnIndex("content"));
|
|
||||||
if (articleContent == null) articleContent = "";
|
|
||||||
|
|
||||||
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 {
|
} else {
|
||||||
String tmp = articleContent.length() > CommonActivity.EXCERPT_MAX_LENGTH ?
|
String articleContent = article.getString(article.getColumnIndex("content"));
|
||||||
articleContent.substring(0, CommonActivity.EXCERPT_MAX_LENGTH) + "…" : articleContent;
|
|
||||||
|
String tmp = articleContent.length() > CommonActivity.EXCERPT_MAX_QUERY_LENGTH ?
|
||||||
|
articleContent.substring(0, CommonActivity.EXCERPT_MAX_QUERY_LENGTH) : articleContent;
|
||||||
|
|
||||||
String excerpt = Jsoup.parse(tmp).text();
|
String excerpt = Jsoup.parse(tmp).text();
|
||||||
|
|
||||||
|
if (excerpt.length() > CommonActivity.EXCERPT_MAX_LENGTH) excerpt = excerpt.substring(0, CommonActivity.EXCERPT_MAX_LENGTH) + "…";
|
||||||
|
|
||||||
holder.excerptView.setTextSize(TypedValue.COMPLEX_UNIT_SP, headlineFontSize);
|
holder.excerptView.setTextSize(TypedValue.COMPLEX_UNIT_SP, headlineFontSize);
|
||||||
holder.excerptView.setText(excerpt);
|
holder.excerptView.setText(excerpt);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user