remove some db field remnants
This commit is contained in:
parent
5838b6f724
commit
cbc88f57e1
@ -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="349"
|
android:versionCode="350"
|
||||||
android:versionName="1.122" >
|
android:versionName="1.123" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="15"
|
android:minSdkVersion="15"
|
||||||
|
@ -52,8 +52,6 @@ public class OfflineDownloadService extends Service {
|
|||||||
private static final int OFFLINE_SYNC_SEQ = 50;
|
private static final int OFFLINE_SYNC_SEQ = 50;
|
||||||
private static final int OFFLINE_SYNC_MAX = OFFLINE_SYNC_SEQ * 10;
|
private static final int OFFLINE_SYNC_MAX = OFFLINE_SYNC_SEQ * 10;
|
||||||
|
|
||||||
private SQLiteDatabase m_writableDb;
|
|
||||||
private SQLiteDatabase m_readableDb;
|
|
||||||
private int m_articleOffset = 0;
|
private int m_articleOffset = 0;
|
||||||
private String m_sessionId;
|
private String m_sessionId;
|
||||||
private NotificationManager m_nmgr;
|
private NotificationManager m_nmgr;
|
||||||
@ -66,8 +64,9 @@ public class OfflineDownloadService extends Service {
|
|||||||
private boolean m_canProceed = true;
|
private boolean m_canProceed = true;
|
||||||
|
|
||||||
private final IBinder m_binder = new LocalBinder();
|
private final IBinder m_binder = new LocalBinder();
|
||||||
|
private DatabaseHelper m_databaseHelper;
|
||||||
public class LocalBinder extends Binder {
|
|
||||||
|
public class LocalBinder extends Binder {
|
||||||
OfflineDownloadService getService() {
|
OfflineDownloadService getService() {
|
||||||
return OfflineDownloadService.this;
|
return OfflineDownloadService.this;
|
||||||
}
|
}
|
||||||
@ -128,9 +127,6 @@ public class OfflineDownloadService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void downloadFailed() {
|
private void downloadFailed() {
|
||||||
m_readableDb.close();
|
|
||||||
m_writableDb.close();
|
|
||||||
|
|
||||||
m_nmgr.cancel(NOTIFY_DOWNLOADING);
|
m_nmgr.cancel(NOTIFY_DOWNLOADING);
|
||||||
|
|
||||||
// TODO send notification to activity?
|
// TODO send notification to activity?
|
||||||
@ -172,25 +168,20 @@ public class OfflineDownloadService extends Service {
|
|||||||
} else {
|
} else {
|
||||||
updateNotification(getString(R.string.notify_downloading_images, 0), 0, 0, true);
|
updateNotification(getString(R.string.notify_downloading_images, 0), 0, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_readableDb.close();
|
|
||||||
m_writableDb.close();
|
|
||||||
|
|
||||||
stopSelf();
|
stopSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initDatabase() {
|
private void initDatabase() {
|
||||||
DatabaseHelper dh = DatabaseHelper.getInstance(this);
|
m_databaseHelper = DatabaseHelper.getInstance(this);
|
||||||
m_writableDb = dh.getWritableDatabase();
|
|
||||||
m_readableDb = dh.getReadableDatabase();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* private synchronized SQLiteDatabase getReadableDb() {
|
/* private synchronized SQLiteDatabase getReadableDb() {
|
||||||
return m_readableDb;
|
return m_readableDb;
|
||||||
} */
|
} */
|
||||||
|
|
||||||
private synchronized SQLiteDatabase getWritableDb() {
|
private synchronized SQLiteDatabase getDatabase() {
|
||||||
return m_writableDb;
|
return m_databaseHelper.getWritableDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@ -221,7 +212,7 @@ public class OfflineDownloadService extends Service {
|
|||||||
|
|
||||||
updateNotification(R.string.notify_downloading_feeds, 0, 0, true);
|
updateNotification(R.string.notify_downloading_feeds, 0, 0, true);
|
||||||
|
|
||||||
getWritableDb().execSQL("DELETE FROM feeds;");
|
getDatabase().execSQL("DELETE FROM feeds;");
|
||||||
|
|
||||||
ApiRequest req = new ApiRequest(getApplicationContext()) {
|
ApiRequest req = new ApiRequest(getApplicationContext()) {
|
||||||
@Override
|
@Override
|
||||||
@ -234,9 +225,9 @@ public class OfflineDownloadService extends Service {
|
|||||||
Type listType = new TypeToken<List<Feed>>() {}.getType();
|
Type listType = new TypeToken<List<Feed>>() {}.getType();
|
||||||
List<Feed> feeds = new Gson().fromJson(content, listType);
|
List<Feed> feeds = new Gson().fromJson(content, listType);
|
||||||
|
|
||||||
SQLiteStatement stmtInsert = getWritableDb().compileStatement("INSERT INTO feeds " +
|
SQLiteStatement stmtInsert = getDatabase().compileStatement("INSERT INTO feeds " +
|
||||||
"("+BaseColumns._ID+", title, feed_url, has_icon, cat_id) " +
|
"(" + BaseColumns._ID + ", title, feed_url, has_icon, cat_id) " +
|
||||||
"VALUES (?, ?, ?, ?, ?);");
|
"VALUES (?, ?, ?, ?, ?);");
|
||||||
|
|
||||||
for (Feed feed : feeds) {
|
for (Feed feed : feeds) {
|
||||||
stmtInsert.bindLong(1, feed.id);
|
stmtInsert.bindLong(1, feed.id);
|
||||||
@ -254,7 +245,7 @@ public class OfflineDownloadService extends Service {
|
|||||||
|
|
||||||
m_articleOffset = 0;
|
m_articleOffset = 0;
|
||||||
|
|
||||||
getWritableDb().execSQL("DELETE FROM articles;");
|
getDatabase().execSQL("DELETE FROM articles;");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
updateNotification(R.string.offline_switch_error, 0, 0, false);
|
updateNotification(R.string.offline_switch_error, 0, 0, false);
|
||||||
@ -298,7 +289,7 @@ public class OfflineDownloadService extends Service {
|
|||||||
|
|
||||||
updateNotification(R.string.notify_downloading_categories, 0, 0, true);
|
updateNotification(R.string.notify_downloading_categories, 0, 0, true);
|
||||||
|
|
||||||
getWritableDb().execSQL("DELETE FROM categories;");
|
getDatabase().execSQL("DELETE FROM categories;");
|
||||||
|
|
||||||
ApiRequest req = new ApiRequest(getApplicationContext()) {
|
ApiRequest req = new ApiRequest(getApplicationContext()) {
|
||||||
protected JsonElement doInBackground(HashMap<String, String>... params) {
|
protected JsonElement doInBackground(HashMap<String, String>... params) {
|
||||||
@ -309,9 +300,9 @@ public class OfflineDownloadService extends Service {
|
|||||||
Type listType = new TypeToken<List<FeedCategory>>() {}.getType();
|
Type listType = new TypeToken<List<FeedCategory>>() {}.getType();
|
||||||
List<FeedCategory> cats = new Gson().fromJson(content, listType);
|
List<FeedCategory> cats = new Gson().fromJson(content, listType);
|
||||||
|
|
||||||
SQLiteStatement stmtInsert = getWritableDb().compileStatement("INSERT INTO categories " +
|
SQLiteStatement stmtInsert = getDatabase().compileStatement("INSERT INTO categories " +
|
||||||
"("+BaseColumns._ID+", title) " +
|
"(" + BaseColumns._ID + ", title) " +
|
||||||
"VALUES (?, ?);");
|
"VALUES (?, ?);");
|
||||||
|
|
||||||
for (FeedCategory cat : cats) {
|
for (FeedCategory cat : cats) {
|
||||||
stmtInsert.bindLong(1, cat.id);
|
stmtInsert.bindLong(1, cat.id);
|
||||||
@ -370,9 +361,7 @@ public class OfflineDownloadService extends Service {
|
|||||||
|
|
||||||
m_canProceed = false;
|
m_canProceed = false;
|
||||||
Log.d(TAG, "onDestroy");
|
Log.d(TAG, "onDestroy");
|
||||||
|
|
||||||
//m_readableDb.close();
|
|
||||||
//m_writableDb.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OfflineArticlesRequest extends ApiRequest {
|
public class OfflineArticlesRequest extends ApiRequest {
|
||||||
@ -392,9 +381,9 @@ public class OfflineDownloadService extends Service {
|
|||||||
Type listType = new TypeToken<List<Article>>() {}.getType();
|
Type listType = new TypeToken<List<Article>>() {}.getType();
|
||||||
m_articles = new Gson().fromJson(content, listType);
|
m_articles = new Gson().fromJson(content, listType);
|
||||||
|
|
||||||
SQLiteStatement stmtInsert = getWritableDb().compileStatement("INSERT INTO articles " +
|
SQLiteStatement stmtInsert = getDatabase().compileStatement("INSERT INTO articles " +
|
||||||
"("+BaseColumns._ID+", unread, marked, published, score, updated, is_updated, title, link, feed_id, tags, content, author) " +
|
"(" + BaseColumns._ID + ", unread, marked, published, score, updated, is_updated, title, link, feed_id, tags, content, author) " +
|
||||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||||
|
|
||||||
for (Article article : m_articles) {
|
for (Article article : m_articles) {
|
||||||
|
|
||||||
@ -494,7 +483,7 @@ public class OfflineDownloadService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public void onStart(Intent intent, int startId) {
|
public void onStart(Intent intent, int startId) {
|
||||||
try {
|
try {
|
||||||
if (getWritableDb().isDbLockedByCurrentThread() || getWritableDb().isDbLockedByOtherThreads()) {
|
if (getDatabase().isDbLockedByCurrentThread() || getDatabase().isDbLockedByOtherThreads()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,13 +29,12 @@ public class OfflineUploadService extends IntentService {
|
|||||||
public static final int NOTIFY_UPLOADING = 2;
|
public static final int NOTIFY_UPLOADING = 2;
|
||||||
public static final String INTENT_ACTION_SUCCESS = "org.fox.ttrss.intent.action.UploadComplete";
|
public static final String INTENT_ACTION_SUCCESS = "org.fox.ttrss.intent.action.UploadComplete";
|
||||||
|
|
||||||
private SQLiteDatabase m_writableDb;
|
|
||||||
private SQLiteDatabase m_readableDb;
|
|
||||||
private String m_sessionId;
|
private String m_sessionId;
|
||||||
private NotificationManager m_nmgr;
|
private NotificationManager m_nmgr;
|
||||||
private boolean m_uploadInProgress = false;
|
private boolean m_uploadInProgress = false;
|
||||||
private boolean m_batchMode = false;
|
private boolean m_batchMode = false;
|
||||||
|
private DatabaseHelper m_databaseHelper;
|
||||||
|
|
||||||
public OfflineUploadService() {
|
public OfflineUploadService() {
|
||||||
super("OfflineUploadService");
|
super("OfflineUploadService");
|
||||||
}
|
}
|
||||||
@ -89,17 +88,11 @@ public class OfflineUploadService extends IntentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initDatabase() {
|
private void initDatabase() {
|
||||||
DatabaseHelper dh = DatabaseHelper.getInstance(this);
|
m_databaseHelper = DatabaseHelper.getInstance(this);
|
||||||
m_writableDb = dh.getWritableDatabase();
|
|
||||||
m_readableDb = dh.getReadableDatabase();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized SQLiteDatabase getReadableDb() {
|
private synchronized SQLiteDatabase getDatabase() {
|
||||||
return m_readableDb;
|
return m_databaseHelper.getWritableDatabase();
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized SQLiteDatabase getWritableDb() {
|
|
||||||
return m_writableDb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void uploadRead() {
|
private void uploadRead() {
|
||||||
@ -157,7 +150,7 @@ public class OfflineUploadService extends IntentService {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cursor c = getReadableDb().query("articles", null,
|
Cursor c = getDatabase().query("articles", null,
|
||||||
"modified = 1 AND " + criteriaStr, null, null, null, null);
|
"modified = 1 AND " + criteriaStr, null, null, null, null);
|
||||||
|
|
||||||
String tmp = "";
|
String tmp = "";
|
||||||
@ -209,16 +202,13 @@ public class OfflineUploadService extends IntentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void uploadFailed() {
|
private void uploadFailed() {
|
||||||
m_readableDb.close();
|
|
||||||
m_writableDb.close();
|
|
||||||
|
|
||||||
// TODO send notification to activity?
|
// TODO send notification to activity?
|
||||||
|
|
||||||
m_uploadInProgress = false;
|
m_uploadInProgress = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void uploadSuccess() {
|
private void uploadSuccess() {
|
||||||
getWritableDb().execSQL("UPDATE articles SET modified = 0");
|
getDatabase().execSQL("UPDATE articles SET modified = 0");
|
||||||
|
|
||||||
if (m_batchMode) {
|
if (m_batchMode) {
|
||||||
|
|
||||||
@ -233,10 +223,7 @@ public class OfflineUploadService extends IntentService {
|
|||||||
intent.addCategory(Intent.CATEGORY_DEFAULT);
|
intent.addCategory(Intent.CATEGORY_DEFAULT);
|
||||||
sendBroadcast(intent);
|
sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_readableDb.close();
|
|
||||||
m_writableDb.close();
|
|
||||||
|
|
||||||
m_uploadInProgress = false;
|
m_uploadInProgress = false;
|
||||||
|
|
||||||
m_nmgr.cancel(NOTIFY_UPLOADING);
|
m_nmgr.cancel(NOTIFY_UPLOADING);
|
||||||
@ -281,7 +268,7 @@ public class OfflineUploadService extends IntentService {
|
|||||||
@Override
|
@Override
|
||||||
protected void onHandleIntent(Intent intent) {
|
protected void onHandleIntent(Intent intent) {
|
||||||
try {
|
try {
|
||||||
if (getWritableDb().isDbLockedByCurrentThread() || getWritableDb().isDbLockedByOtherThreads()) {
|
if (getDatabase().isDbLockedByCurrentThread() || getDatabase().isDbLockedByOtherThreads()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user