summaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2012-09-20 09:56:02 +0400
committerAndrew Dolgov <[email protected]>2012-09-20 09:56:02 +0400
commitfa05b3fe0a5c30445ea2a026096a001f82854598 (patch)
tree4c263c3277f8295541dea8b4a14fab7f561a1fbc /src/org
parent282285ef78779159c3f9d714fe0c8dd6c6ff195a (diff)
offline not syncing fixes
Diffstat (limited to 'src/org')
-rw-r--r--src/org/fox/ttrss/offline/OfflineActivity.java20
-rw-r--r--src/org/fox/ttrss/offline/OfflineFeedsActivity.java6
-rw-r--r--src/org/fox/ttrss/offline/OfflineHeadlinesActivity.java2
-rw-r--r--src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java22
-rw-r--r--src/org/fox/ttrss/offline/OfflineUploadService.java24
5 files changed, 41 insertions, 33 deletions
diff --git a/src/org/fox/ttrss/offline/OfflineActivity.java b/src/org/fox/ttrss/offline/OfflineActivity.java
index 6444d88e..2c6309fa 100644
--- a/src/org/fox/ttrss/offline/OfflineActivity.java
+++ b/src/org/fox/ttrss/offline/OfflineActivity.java
@@ -259,10 +259,10 @@ public class OfflineActivity extends CommonActivity {
if (isCat) {
stmt = getWritableDb().compileStatement(
- "UPDATE articles SET unread = 0 WHERE feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?)");
+ "UPDATE articles SET modified = 1, unread = 0 WHERE feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?)");
} else {
stmt = getWritableDb().compileStatement(
- "UPDATE articles SET unread = 0 WHERE feed_id = ?");
+ "UPDATE articles SET modified = 1, unread = 0 WHERE feed_id = ?");
}
stmt.bindLong(1, feedId);
stmt.execute();
@@ -283,7 +283,7 @@ public class OfflineActivity extends CommonActivity {
int articleId = oap.getSelectedArticleId();
SQLiteStatement stmt = getWritableDb().compileStatement(
- "UPDATE articles SET marked = NOT marked WHERE "
+ "UPDATE articles SET modified = 1, marked = NOT marked WHERE "
+ BaseColumns._ID + " = ?");
stmt.bindLong(1, articleId);
stmt.execute();
@@ -299,7 +299,7 @@ public class OfflineActivity extends CommonActivity {
if (getSelectedArticleCount() > 0) {
SQLiteStatement stmt = getWritableDb()
.compileStatement(
- "UPDATE articles SET unread = NOT unread WHERE selected = 1");
+ "UPDATE articles SET modified = 1, unread = NOT unread WHERE selected = 1");
stmt.execute();
stmt.close();
@@ -310,7 +310,7 @@ public class OfflineActivity extends CommonActivity {
if (getSelectedArticleCount() > 0) {
SQLiteStatement stmt = getWritableDb()
.compileStatement(
- "UPDATE articles SET marked = NOT marked WHERE selected = 1");
+ "UPDATE articles SET modified = 1, marked = NOT marked WHERE selected = 1");
stmt.execute();
stmt.close();
@@ -321,7 +321,7 @@ public class OfflineActivity extends CommonActivity {
if (getSelectedArticleCount() > 0) {
SQLiteStatement stmt = getWritableDb()
.compileStatement(
- "UPDATE articles SET published = NOT published WHERE selected = 1");
+ "UPDATE articles SET modified = 1, published = NOT published WHERE selected = 1");
stmt.execute();
stmt.close();
@@ -333,7 +333,7 @@ public class OfflineActivity extends CommonActivity {
int articleId = oap.getSelectedArticleId();
SQLiteStatement stmt = getWritableDb().compileStatement(
- "UPDATE articles SET published = NOT published WHERE "
+ "UPDATE articles SET modified = 1, published = NOT published WHERE "
+ BaseColumns._ID + " = ?");
stmt.bindLong(1, articleId);
stmt.execute();
@@ -352,12 +352,12 @@ public class OfflineActivity extends CommonActivity {
if (isCat) {
stmt = getWritableDb().compileStatement(
- "UPDATE articles SET unread = 0 WHERE " +
+ "UPDATE articles SET modified = 1, unread = 0 WHERE " +
"updated >= (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " +
"AND feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?)");
} else {
stmt = getWritableDb().compileStatement(
- "UPDATE articles SET unread = 0 WHERE " +
+ "UPDATE articles SET modified = 1, unread = 0 WHERE " +
"updated >= (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " +
"AND feed_id = ?");
}
@@ -375,7 +375,7 @@ public class OfflineActivity extends CommonActivity {
int articleId = oap.getSelectedArticleId();
SQLiteStatement stmt = getWritableDb().compileStatement(
- "UPDATE articles SET unread = 1 WHERE "
+ "UPDATE articles SET modified = 1, unread = 1 WHERE "
+ BaseColumns._ID + " = ?");
stmt.bindLong(1, articleId);
stmt.execute();
diff --git a/src/org/fox/ttrss/offline/OfflineFeedsActivity.java b/src/org/fox/ttrss/offline/OfflineFeedsActivity.java
index 7813c807..5abf8b12 100644
--- a/src/org/fox/ttrss/offline/OfflineFeedsActivity.java
+++ b/src/org/fox/ttrss/offline/OfflineFeedsActivity.java
@@ -200,14 +200,14 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
public void catchupFeed(int feedId, boolean isCat) {
if (isCat) {
SQLiteStatement stmt = getWritableDb().compileStatement(
- "UPDATE articles SET unread = 0 WHERE feed_id IN (SELECT "+
+ "UPDATE articles SET modified = 1, unread = 0 WHERE feed_id IN (SELECT "+
BaseColumns._ID+" FROM feeds WHERE cat_id = ?)");
stmt.bindLong(1, feedId);
stmt.execute();
stmt.close();
} else {
SQLiteStatement stmt = getWritableDb().compileStatement(
- "UPDATE articles SET unread = 0 WHERE feed_id = ?");
+ "UPDATE articles SET modified = 1, unread = 0 WHERE feed_id = ?");
stmt.bindLong(1, feedId);
stmt.execute();
stmt.close();
@@ -219,7 +219,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
@Override
public void onArticleSelected(int articleId, boolean open) {
SQLiteStatement stmt = getWritableDb().compileStatement(
- "UPDATE articles SET unread = 0 " + "WHERE " + BaseColumns._ID
+ "UPDATE articles SET modified = 1, unread = 0 " + "WHERE " + BaseColumns._ID
+ " = ?");
stmt.bindLong(1, articleId);
diff --git a/src/org/fox/ttrss/offline/OfflineHeadlinesActivity.java b/src/org/fox/ttrss/offline/OfflineHeadlinesActivity.java
index d9053f27..a7a550a9 100644
--- a/src/org/fox/ttrss/offline/OfflineHeadlinesActivity.java
+++ b/src/org/fox/ttrss/offline/OfflineHeadlinesActivity.java
@@ -92,7 +92,7 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
@Override
public void onArticleSelected(int articleId, boolean open) {
SQLiteStatement stmt = getWritableDb().compileStatement(
- "UPDATE articles SET unread = 0 " + "WHERE " + BaseColumns._ID
+ "UPDATE articles SET modified = 1, unread = 0 " + "WHERE " + BaseColumns._ID
+ " = ?");
stmt.bindLong(1, articleId);
diff --git a/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java b/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java
index 158e36cd..31a1638b 100644
--- a/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java
+++ b/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java
@@ -118,14 +118,14 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
if (getSelectedArticleCount() > 0) {
SQLiteStatement stmt = m_activity.getWritableDb()
.compileStatement(
- "UPDATE articles SET marked = NOT marked WHERE selected = 1");
+ "UPDATE articles SET modified = 1, marked = NOT marked WHERE selected = 1");
stmt.execute();
stmt.close();
} else {
int articleId = getArticleIdAtPosition(info.position);
SQLiteStatement stmt = m_activity.getWritableDb().compileStatement(
- "UPDATE articles SET marked = NOT marked WHERE "
+ "UPDATE articles SET modified = 1, marked = NOT marked WHERE "
+ BaseColumns._ID + " = ?");
stmt.bindLong(1, articleId);
stmt.execute();
@@ -137,14 +137,14 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
if (getSelectedArticleCount() > 0) {
SQLiteStatement stmt = m_activity.getWritableDb()
.compileStatement(
- "UPDATE articles SET published = NOT published WHERE selected = 1");
+ "UPDATE articles SET modified = 1, published = NOT published WHERE selected = 1");
stmt.execute();
stmt.close();
} else {
int articleId = getArticleIdAtPosition(info.position);
SQLiteStatement stmt = m_activity.getWritableDb().compileStatement(
- "UPDATE articles SET published = NOT published WHERE "
+ "UPDATE articles SET modified = 1, published = NOT published WHERE "
+ BaseColumns._ID + " = ?");
stmt.bindLong(1, articleId);
stmt.execute();
@@ -156,14 +156,14 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
if (getSelectedArticleCount() > 0) {
SQLiteStatement stmt = m_activity.getWritableDb()
.compileStatement(
- "UPDATE articles SET unread = NOT unread WHERE selected = 1");
+ "UPDATE articles SET modified = 1, unread = NOT unread WHERE selected = 1");
stmt.execute();
stmt.close();
} else {
int articleId = getArticleIdAtPosition(info.position);
SQLiteStatement stmt = m_activity.getWritableDb().compileStatement(
- "UPDATE articles SET unread = NOT unread WHERE "
+ "UPDATE articles SET modified = 1, unread = NOT unread WHERE "
+ BaseColumns._ID + " = ?");
stmt.bindLong(1, articleId);
stmt.execute();
@@ -185,12 +185,12 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
if (m_feedIsCat) {
stmt = m_activity.getWritableDb().compileStatement(
- "UPDATE articles SET unread = 0 WHERE " +
+ "UPDATE articles SET modified = 1, unread = 0 WHERE " +
"updated >= (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " +
"AND feed_id IN (SELECT "+BaseColumns._ID+" FROM feeds WHERE cat_id = ?)");
} else {
stmt = m_activity.getWritableDb().compileStatement(
- "UPDATE articles SET unread = 0 WHERE " +
+ "UPDATE articles SET modified = 1, unread = 0 WHERE " +
"updated >= (SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) " +
"AND feed_id = ?");
}
@@ -344,7 +344,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
m_listener.onArticleSelected(articleId);
} else {
SQLiteStatement stmt = m_activity.getWritableDb().compileStatement(
- "UPDATE articles SET unread = 0 " + "WHERE " + BaseColumns._ID
+ "UPDATE articles SET modified = 1, unread = 0 " + "WHERE " + BaseColumns._ID
+ " = ?");
stmt.bindLong(1, articleId);
@@ -484,7 +484,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
@Override
public void onClick(View v) {
- SQLiteStatement stmtUpdate = m_activity.getWritableDb().compileStatement("UPDATE articles SET marked = NOT marked " +
+ SQLiteStatement stmtUpdate = m_activity.getWritableDb().compileStatement("UPDATE articles SET modified = 1, marked = NOT marked " +
"WHERE " + BaseColumns._ID + " = ?");
stmtUpdate.bindLong(1, articleId);
@@ -505,7 +505,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
@Override
public void onClick(View v) {
- SQLiteStatement stmtUpdate = m_activity.getWritableDb().compileStatement("UPDATE articles SET published = NOT published " +
+ SQLiteStatement stmtUpdate = m_activity.getWritableDb().compileStatement("UPDATE articles SET modified = 1, published = NOT published " +
"WHERE " + BaseColumns._ID + " = ?");
stmtUpdate.bindLong(1, articleId);
diff --git a/src/org/fox/ttrss/offline/OfflineUploadService.java b/src/org/fox/ttrss/offline/OfflineUploadService.java
index bacb1ede..70981e5b 100644
--- a/src/org/fox/ttrss/offline/OfflineUploadService.java
+++ b/src/org/fox/ttrss/offline/OfflineUploadService.java
@@ -251,14 +251,22 @@ public class OfflineUploadService extends IntentService {
@Override
protected void onHandleIntent(Intent intent) {
- m_sessionId = intent.getStringExtra("sessionId");
-
- if (!m_uploadInProgress) {
- m_uploadInProgress = true;
-
- updateNotification(R.string.notify_uploading_sending_data);
-
- uploadRead();
+ try {
+ if (getWritableDb().isDbLockedByCurrentThread() || getWritableDb().isDbLockedByOtherThreads()) {
+ return;
+ }
+
+ m_sessionId = intent.getStringExtra("sessionId");
+
+ if (!m_uploadInProgress) {
+ m_uploadInProgress = true;
+
+ updateNotification(R.string.notify_uploading_sending_data);
+
+ uploadRead();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
}
}