[go: nahoru, domu]

Skip to content

Commit

Permalink
Merge pull request #21 from wordpress-mobile/issue/custom-wellsql-ver…
Browse files Browse the repository at this point in the history
…sion

Use our custom WellSQL Version
  • Loading branch information
aforcier committed Mar 14, 2016
2 parents 7946f32 + daabba0 commit 37a2a84
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 28 deletions.
7 changes: 4 additions & 3 deletions WordPressStores/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ dependencies {
exclude group: "com.mcxiaoke.volley";
}

// Custom WellSql version
compile 'org.wordpress:wellsql:1.0.6'
apt 'org.wordpress:wellsql-processor:1.0.6'

// External libs
compile 'com.squareup:otto:1.3.8'
compile 'com.squareup.okhttp:okhttp:2.6.0'
Expand All @@ -60,8 +64,6 @@ dependencies {
compile 'com.google.dagger:dagger:2.0.2'
apt 'com.google.dagger:dagger-compiler:2.0.2'
provided 'org.glassfish:javax.annotation:10.0-b28'
compile 'com.yarolegovich:wellsql:1.0.5'
apt 'com.yarolegovich:wellsql-processor:1.0.5'
}

signing {
Expand Down Expand Up @@ -119,4 +121,3 @@ uploadArchives {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,12 @@
import com.yarolegovich.wellsql.mapper.InsertMapper;
import com.yarolegovich.wellsql.mapper.SQLiteMapper;

import org.wordpress.android.util.AppLog;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class UpdateAllExceptId<T> implements InsertMapper<T> {
@Override
public ContentValues toCv(T item) {
try {
// Reflection equivalent for: SQLiteMapper<T> mapper = WellSql.mapperFor((Class<T>) item.getClass());
// This will be useless once the new wellsql version (1.0.6) is deployed
Method mapperFor = WellSql.class.getDeclaredMethod("mapperFor", Class.class);
mapperFor.setAccessible(true); // if security settings allow this
SQLiteMapper<T> mapper = (SQLiteMapper<T>) mapperFor.invoke(null, (Class<T>) item.getClass());
ContentValues cv = mapper.toCv(item);
cv.remove("_id");
return cv;
} catch (IllegalAccessException e) {
AppLog.e(AppLog.T.API, "can't invoke WellSql.mapperFor", e);
return null;
} catch (InvocationTargetException e) {
AppLog.e(AppLog.T.API, "can't invoke WellSql.mapperFor", e);
return null;
} catch (NoSuchMethodException e) {
AppLog.e(AppLog.T.API, "can't invoke WellSql.mapperFor", e);
return null;
}
SQLiteMapper<T> mapper = WellSql.mapperFor((Class<T>) item.getClass());
ContentValues cv = mapper.toCv(item);
cv.remove("_id");
return cv;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public int getSitesCount() {

public boolean hasSelfHostedSite() {
return WellSql.select(SiteModel.class)
.where().equals(SiteModelTable.IS_WPCOM, 0).endWhere()
.where().equals(SiteModelTable.IS_WPCOM, false).endWhere()
.getAsCursor().getCount() != 0;
}

Expand Down

0 comments on commit 37a2a84

Please sign in to comment.