use jsoup to create article excerpts

This commit is contained in:
Andrew Dolgov 2011-09-09 13:55:57 +04:00
parent 23e390d2cf
commit cf0c9b8c6c
3 changed files with 6 additions and 3 deletions

View File

@ -4,5 +4,6 @@
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="lib/gson-1.7.1.jar"/>
<classpathentry kind="lib" path="lib/jsoup-1.6.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

BIN
lib/jsoup-1.6.1.jar Normal file

Binary file not shown.

View File

@ -6,6 +6,8 @@ import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import org.jsoup.Jsoup;
import android.app.Activity;
import android.app.FragmentTransaction;
import android.content.Intent;
@ -255,10 +257,10 @@ public class MainActivity extends Activity {
Cursor c = db.query("articles", new String[] { BaseColumns._ID } , BaseColumns._ID + "=?",
new String[] { String.valueOf(article.id) }, null, null, null);
String excerpt = article.content.replaceAll("\\<[^>]*>","");
String excerpt = Jsoup.parse(article.content).text();
if (excerpt.length() > 120) {
excerpt = excerpt.substring(120) + "...";
if (excerpt.length() > 250) {
excerpt = excerpt.substring(250) + "...";
}
if (c.getCount() != 0) {