Merge pull request #67 from wallabag/dev

Bringing changes to legacy branch
This commit is contained in:
Thomas Citharel
2015-01-12 23:26:07 +01:00
@@ -207,7 +207,7 @@ public class Poche extends Activity implements FeedUpdaterInterface {
if (pref.getInt("update_checker", 0) < 9) {
// Wipe Database, because we now save HTML content instead of plain text
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(this);
database = helper.getReadableDatabase();
getDatabase();
helper.truncateTables(database);
showToast("Update: Wiped Database. Please synchronize.");
}
@@ -229,6 +229,13 @@ public class Poche extends Activity implements FeedUpdaterInterface {
apiToken = settings.getString("APIToken", "");
}
private void getDatabase() {
if (database == null) {
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(this);
database = helper.getReadableDatabase();
}
}
@Override
protected void onResume() {
super.onResume();
@@ -258,7 +265,7 @@ public class Poche extends Activity implements FeedUpdaterInterface {
runOnUiThread(new Runnable() {
public void run() {
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(getApplicationContext());
database = helper.getReadableDatabase();
getDatabase();
int news = database.query(ARTICLE_TABLE, null, ARCHIVE + "=0", null, null, null, null).getCount();
btnGetPost.setText(String.format(getString(R.string.btnGetPost), news));
}
@@ -301,4 +308,4 @@ public class Poche extends Activity implements FeedUpdaterInterface {
updateUnread();
findViewById(R.id.progressBar1).setVisibility(View.GONE);
}
}
}