From 3bdb6e86afb68ccebe9aa7fe3126a3d9152d584b Mon Sep 17 00:00:00 2001 From: jan_bar Date: Wed, 24 Apr 2013 15:48:44 +0200 Subject: Support score in online and offline mode Bump database version Fixed bug in database drop order --- .../fox/ttrss/offline/OfflineDownloadService.java | 30 ++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/org/fox/ttrss/offline/OfflineDownloadService.java') diff --git a/src/org/fox/ttrss/offline/OfflineDownloadService.java b/src/org/fox/ttrss/offline/OfflineDownloadService.java index 2fe87570..78ae6693 100644 --- a/src/org/fox/ttrss/offline/OfflineDownloadService.java +++ b/src/org/fox/ttrss/offline/OfflineDownloadService.java @@ -367,8 +367,10 @@ public class OfflineDownloadService extends Service { m_articles = new Gson().fromJson(content, listType); SQLiteStatement stmtInsert = getWritableDb().compileStatement("INSERT INTO articles " + - "("+BaseColumns._ID+", unread, marked, published, updated, is_updated, title, link, feed_id, tags, content) " + - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"); + "(" + + BaseColumns._ID + + ", unread, marked, published, score, updated, is_updated, title, link, feed_id, tags, content) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"); for (Article article : m_articles) { @@ -380,17 +382,19 @@ public class OfflineDownloadService extends Service { tagsString = tagsString.replaceAll(", $", ""); - stmtInsert.bindLong(1, article.id); - stmtInsert.bindLong(2, article.unread ? 1 : 0); - stmtInsert.bindLong(3, article.marked ? 1 : 0); - stmtInsert.bindLong(4, article.published ? 1 : 0); - stmtInsert.bindLong(5, article.updated); - stmtInsert.bindLong(6, article.is_updated ? 1 : 0); - stmtInsert.bindString(7, article.title); - stmtInsert.bindString(8, article.link); - stmtInsert.bindLong(9, article.feed_id); - stmtInsert.bindString(10, tagsString); // comma-separated tags - stmtInsert.bindString(11, article.content); + int index = 1; + stmtInsert.bindLong(index++, article.id); + stmtInsert.bindLong(index++, article.unread ? 1 : 0); + stmtInsert.bindLong(index++, article.marked ? 1 : 0); + stmtInsert.bindLong(index++, article.published ? 1 : 0); + stmtInsert.bindLong(index++, article.score); + stmtInsert.bindLong(index++, article.updated); + stmtInsert.bindLong(index++, article.is_updated ? 1 : 0); + stmtInsert.bindString(index++, article.title); + stmtInsert.bindString(index++, article.link); + stmtInsert.bindLong(index++, article.feed_id); + stmtInsert.bindString(index++, tagsString); // comma-separated tags + stmtInsert.bindString(index++, article.content); if (m_downloadImages) { Document doc = Jsoup.parse(article.content); -- cgit v1.2.3-54-g00ecf From 08220587127d97ad9dcddab16df2a83f75b9ffef Mon Sep 17 00:00:00 2001 From: jan_bar Date: Wed, 24 Apr 2013 16:07:51 +0200 Subject: Show author in offline mode --- src/org/fox/ttrss/offline/OfflineArticleFragment.java | 6 +++++- src/org/fox/ttrss/offline/OfflineDownloadService.java | 7 +++---- src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java | 8 ++++++++ src/org/fox/ttrss/util/DatabaseHelper.java | 1 + 4 files changed, 17 insertions(+), 5 deletions(-) (limited to 'src/org/fox/ttrss/offline/OfflineDownloadService.java') diff --git a/src/org/fox/ttrss/offline/OfflineArticleFragment.java b/src/org/fox/ttrss/offline/OfflineArticleFragment.java index cdbbdc55..2c51f033 100644 --- a/src/org/fox/ttrss/offline/OfflineArticleFragment.java +++ b/src/org/fox/ttrss/offline/OfflineArticleFragment.java @@ -284,7 +284,11 @@ public class OfflineArticleFragment extends Fragment implements GestureDetector. TextView author = (TextView)view.findViewById(R.id.author); if (author != null) { - author.setVisibility(View.GONE); + int authorIndex = m_cursor.getColumnIndex("author"); + if(authorIndex >= 0) + author.setText(m_cursor.getString(authorIndex)); + else + author.setVisibility(View.GONE); } } diff --git a/src/org/fox/ttrss/offline/OfflineDownloadService.java b/src/org/fox/ttrss/offline/OfflineDownloadService.java index 78ae6693..410c339a 100644 --- a/src/org/fox/ttrss/offline/OfflineDownloadService.java +++ b/src/org/fox/ttrss/offline/OfflineDownloadService.java @@ -367,10 +367,8 @@ public class OfflineDownloadService extends Service { m_articles = new Gson().fromJson(content, listType); SQLiteStatement stmtInsert = getWritableDb().compileStatement("INSERT INTO articles " + - "(" + - BaseColumns._ID + - ", unread, marked, published, score, updated, is_updated, title, link, feed_id, tags, content) " + - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"); + "("+BaseColumns._ID+", unread, marked, published, score, updated, is_updated, title, link, feed_id, tags, content, author) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"); for (Article article : m_articles) { @@ -395,6 +393,7 @@ public class OfflineDownloadService extends Service { stmtInsert.bindLong(index++, article.feed_id); stmtInsert.bindString(index++, tagsString); // comma-separated tags stmtInsert.bindString(index++, article.content); + stmtInsert.bindString(index++, article.author); if (m_downloadImages) { Document doc = Jsoup.parse(article.content); diff --git a/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java b/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java index 41297a8a..8c9d41c1 100644 --- a/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java +++ b/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java @@ -532,6 +532,14 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis te.setText(excerpt); } + TextView ta = (TextView)v.findViewById(R.id.author); + + if (ta != null) { + int authorIndex = article.getColumnIndex("author"); + if(authorIndex >= 0) + ta.setText(article.getString(authorIndex)); + } + /* ImageView separator = (ImageView)v.findViewById(R.id.headlines_separator); if (separator != null && m_offlineServices.isSmallScreen()) { diff --git a/src/org/fox/ttrss/util/DatabaseHelper.java b/src/org/fox/ttrss/util/DatabaseHelper.java index 3d64a820..572ff62e 100644 --- a/src/org/fox/ttrss/util/DatabaseHelper.java +++ b/src/org/fox/ttrss/util/DatabaseHelper.java @@ -51,6 +51,7 @@ public class DatabaseHelper extends SQLiteOpenHelper { "feed_id INTEGER, " + "tags TEXT, " + "content TEXT, " + + "author TEXT, " + "selected BOOLEAN, " + "modified BOOLEAN" + ");"); -- cgit v1.2.3-54-g00ecf