Skip to content

Commit

Permalink
Merge pull request #440 from wallabag/fixes
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
tcitworld authored Mar 2, 2017
2 parents 12e8746 + b8a1d88 commit c28f873
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 39 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ android {
}

greendao {
schemaVersion 100
schemaVersion 101
daoPackage 'fr.gaulupeau.apps.Poche.data.dao'
}

Expand All @@ -62,6 +62,6 @@ dependencies {
compile 'com.facebook.stetho:stetho:1.4.2'
compile 'com.facebook.stetho:stetho-okhttp3:1.4.2'
compile 'com.mikepenz:aboutlibraries:5.7.3'
compile 'com.github.di72nn.wallabag-api-wrapper:api-wrapper:0fd11d1'
compile 'com.github.di72nn.wallabag-api-wrapper:api-wrapper:12664b5'
compile 'org.slf4j:slf4j-android:1.7.23'
}
30 changes: 9 additions & 21 deletions app/src/main/java/fr/gaulupeau/apps/Poche/data/DbConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,46 +75,34 @@ public WallabagOpenHelper(Context context, String name, SQLiteDatabase.CursorFac
public void onUpgrade(Database db, int oldVersion, int newVersion) {
Log.i(TAG, "Upgrading schema from version " + oldVersion + " to " + newVersion);

boolean recreateTables = true;

List<String> offlineUrls = null;
if(oldVersion == 2) {
if(oldVersion >= 2) {
Cursor c = null;
try {
c = db.rawQuery("select url from offline_url order by _id", null);
c = db.rawQuery(oldVersion == 2
? "select url from offline_url order by _id"
: "select extra from QUEUE_ITEM where action = 1 order by _id", null);

offlineUrls = new ArrayList<>();
while(c.moveToNext()) {
if(!c.isNull(0)) offlineUrls.add(c.getString(0));
}
} catch(Exception e) {
Log.w(TAG, "Exception while migrating from version 2", e);
Log.w(TAG, "Exception while migrating from version " + oldVersion, e);
} finally {
if(c != null) {
c.close();
}
}
} else if(oldVersion == 5) {
db.beginTransaction();
try {
db.execSQL("ALTER TABLE ARTICLE ADD COLUMN images_downloaded INTEGER DEFAULT 0");

db.setTransactionSuccessful();

recreateTables = false;
} catch(Exception e) {
Log.w(TAG, "Exception while altering table ARTICLE", e);
} finally {
db.endTransaction();
}
}

if(!recreateTables) return;

DaoMaster.dropAllTables(db, true);
onCreate(db);

new Settings(context).setFirstSyncDone(false);
Settings settings = new Settings(context);
settings.setFirstSyncDone(false);
settings.setLatestUpdatedItemTimestamp(0);
settings.setLatestUpdateRunTimestamp(0);

if(offlineUrls != null && !offlineUrls.isEmpty()) {
boolean inserted = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,12 @@ public static void deleteArticle(Context context, int articleID) {

public static void wipeDB(Settings settings) {
DbConnection.getSession().getArticleDao().deleteAll();
DbConnection.getSession().getTagDao().deleteAll();
DbConnection.getSession().getArticleTagsJoinDao().deleteAll();
DbConnection.getSession().getQueueItemDao().deleteAll();

settings.setLatestUpdatedItemTimestamp(0);
settings.setLatestUpdateRunTimestamp(0);
settings.setFirstSyncDone(false);

EventHelper.notifyEverythingChanged();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public class Article {

private String content;

private String author;

private String title;

private String domain;
Expand Down Expand Up @@ -72,15 +70,14 @@ public Article(Long id) {
this.id = id;
}

@Generated(hash = 1312680328)
public Article(Long id, Integer articleId, String content, String author, String title,
String domain, String url, int estimatedReadingTime, String language,
String previewPictureURL, Boolean favorite, Boolean archive, Date creationDate,
Date updateDate, Double articleProgress, Boolean imagesDownloaded) {
@Generated(hash = 768349527)
public Article(Long id, Integer articleId, String content, String title, String domain, String url,
int estimatedReadingTime, String language, String previewPictureURL, Boolean favorite,
Boolean archive, Date creationDate, Date updateDate, Double articleProgress,
Boolean imagesDownloaded) {
this.id = id;
this.articleId = articleId;
this.content = content;
this.author = author;
this.title = title;
this.domain = domain;
this.url = url;
Expand Down Expand Up @@ -119,14 +116,6 @@ public void setContent(String content) {
this.content = content;
}

public String getAuthor() {
return author;
}

public void setAuthor(String author) {
this.author = author;
}

public String getTitle() {
return title;
}
Expand Down

0 comments on commit c28f873

Please sign in to comment.