diff --git a/.idea/gradle.xml b/.idea/gradle.xml index fe865d3..442ba66 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -9,6 +9,7 @@ diff --git a/.idea/modules.xml b/.idea/modules.xml index 38300f0..b677426 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,6 +3,7 @@ + diff --git a/MyDaoGenerator/MyDaoGenerator.iml b/MyDaoGenerator/MyDaoGenerator.iml new file mode 100644 index 0000000..371e3c7 --- /dev/null +++ b/MyDaoGenerator/MyDaoGenerator.iml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MyDaoGenerator/build.gradle b/MyDaoGenerator/build.gradle new file mode 100644 index 0000000..9af8772 --- /dev/null +++ b/MyDaoGenerator/build.gradle @@ -0,0 +1,22 @@ +project(':MyDaoGenerator') { + apply plugin: 'application' + apply plugin: 'java' + + mainClassName = "pl.surecase.eu.MyDaoGenerator" + // edit output direction + outputDir = "../app/src/main/java-gen" + + dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile('de.greenrobot:DaoGenerator:1.3.0') + } + + task createDocs { + def docs = file(outputDir) + docs.mkdirs() + } + + run { + args outputDir + } +} \ No newline at end of file diff --git a/MyDaoGenerator/src/main/java/pl/surecase/eu/MyDaoGenerator.java b/MyDaoGenerator/src/main/java/pl/surecase/eu/MyDaoGenerator.java new file mode 100644 index 0000000..20df834 --- /dev/null +++ b/MyDaoGenerator/src/main/java/pl/surecase/eu/MyDaoGenerator.java @@ -0,0 +1,20 @@ +package pl.surecase.eu; + +import de.greenrobot.daogenerator.DaoGenerator; +import de.greenrobot.daogenerator.Entity; +import de.greenrobot.daogenerator.Schema; + +public class MyDaoGenerator { + + public static void main(String args[]) throws Exception { + Schema schema = new Schema(3, "greendao"); + Entity box = schema.addEntity("Match"); + box.addIdProperty(); + box.addStringProperty("t1"); + box.addStringProperty("t2"); + box.addStringProperty("t1c"); + box.addStringProperty("t2c"); + box.addStringProperty("ETA"); + new DaoGenerator().generateAll(schema, args[0]); + } +} diff --git a/app/app.iml b/app/app.iml index 6d12f56..5584a46 100644 --- a/app/app.iml +++ b/app/app.iml @@ -50,6 +50,7 @@ + @@ -84,6 +85,7 @@ + diff --git a/app/build.gradle b/app/build.gradle index 01825b3..8325f90 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -17,6 +17,13 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + sourceSets { + main { + manifest.srcFile 'src/main/AndroidManifest.xml' + java.srcDirs = ['src/main/java', 'src/main/java-gen'] + res.srcDirs = ['src/main/res'] + } + } } dependencies { @@ -28,5 +35,5 @@ dependencies { compile 'com.google.code.gson:gson:2.3.1' compile 'joda-time:joda-time:2.6' compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0' - + compile 'de.greenrobot:greendao:1.3.7' } diff --git a/app/src/main/java-gen/greendao/DaoMaster.java b/app/src/main/java-gen/greendao/DaoMaster.java new file mode 100644 index 0000000..15395b4 --- /dev/null +++ b/app/src/main/java-gen/greendao/DaoMaster.java @@ -0,0 +1,69 @@ +package greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.database.sqlite.SQLiteOpenHelper; +import android.util.Log; + +import de.greenrobot.dao.AbstractDaoMaster; +import de.greenrobot.dao.identityscope.IdentityScopeType; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 3): knows all DAOs. +*/ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 3; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) { + MatchDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(SQLiteDatabase db, boolean ifExists) { + MatchDao.dropTable(db, ifExists); + } + + public static abstract class OpenHelper extends SQLiteOpenHelper { + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(SQLiteDatabase db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + + public DaoMaster(SQLiteDatabase db) { + super(db, SCHEMA_VERSION); + registerDaoClass(MatchDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + +} diff --git a/app/src/main/java-gen/greendao/DaoSession.java b/app/src/main/java-gen/greendao/DaoSession.java new file mode 100644 index 0000000..9d371d8 --- /dev/null +++ b/app/src/main/java-gen/greendao/DaoSession.java @@ -0,0 +1,45 @@ +package greendao; + +import android.database.sqlite.SQLiteDatabase; + +import java.util.Map; + +import de.greenrobot.dao.AbstractDao; +import de.greenrobot.dao.AbstractDaoSession; +import de.greenrobot.dao.identityscope.IdentityScopeType; +import de.greenrobot.dao.internal.DaoConfig; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see de.greenrobot.dao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig matchDaoConfig; + + private final MatchDao matchDao; + + public DaoSession(SQLiteDatabase db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + matchDaoConfig = daoConfigMap.get(MatchDao.class).clone(); + matchDaoConfig.initIdentityScope(type); + + matchDao = new MatchDao(matchDaoConfig, this); + + registerDao(Match.class, matchDao); + } + + public void clear() { + matchDaoConfig.getIdentityScope().clear(); + } + + public MatchDao getMatchDao() { + return matchDao; + } + +} diff --git a/app/src/main/java-gen/greendao/Match.java b/app/src/main/java-gen/greendao/Match.java new file mode 100644 index 0000000..ae3b04d --- /dev/null +++ b/app/src/main/java-gen/greendao/Match.java @@ -0,0 +1,80 @@ +package greendao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. +/** + * Entity mapped to table MATCH. + */ +public class Match { + + private Long id; + private String t1; + private String t2; + private String t1c; + private String t2c; + private String ETA; + + public Match() { + } + + public Match(Long id) { + this.id = id; + } + + public Match(Long id, String t1, String t2, String t1c, String t2c, String ETA) { + this.id = id; + this.t1 = t1; + this.t2 = t2; + this.t1c = t1c; + this.t2c = t2c; + this.ETA = ETA; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getT1() { + return t1; + } + + public void setT1(String t1) { + this.t1 = t1; + } + + public String getT2() { + return t2; + } + + public void setT2(String t2) { + this.t2 = t2; + } + + public String getT1c() { + return t1c; + } + + public void setT1c(String t1c) { + this.t1c = t1c; + } + + public String getT2c() { + return t2c; + } + + public void setT2c(String t2c) { + this.t2c = t2c; + } + + public String getETA() { + return ETA; + } + + public void setETA(String ETA) { + this.ETA = ETA; + } + +} diff --git a/app/src/main/java-gen/greendao/MatchDao.java b/app/src/main/java-gen/greendao/MatchDao.java new file mode 100644 index 0000000..af2f4cb --- /dev/null +++ b/app/src/main/java-gen/greendao/MatchDao.java @@ -0,0 +1,149 @@ +package greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteStatement; + +import de.greenrobot.dao.AbstractDao; +import de.greenrobot.dao.Property; +import de.greenrobot.dao.internal.DaoConfig; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table MATCH. +*/ +public class MatchDao extends AbstractDao { + + public static final String TABLENAME = "MATCH"; + + /** + * Properties of entity Match.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property T1 = new Property(1, String.class, "t1", false, "T1"); + public final static Property T2 = new Property(2, String.class, "t2", false, "T2"); + public final static Property T1c = new Property(3, String.class, "t1c", false, "T1C"); + public final static Property T2c = new Property(4, String.class, "t2c", false, "T2C"); + public final static Property ETA = new Property(5, String.class, "ETA", false, "ETA"); + }; + + + public MatchDao(DaoConfig config) { + super(config); + } + + public MatchDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(SQLiteDatabase db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "'MATCH' (" + // + "'_id' INTEGER PRIMARY KEY ," + // 0: id + "'T1' TEXT," + // 1: t1 + "'T2' TEXT," + // 2: t2 + "'T1C' TEXT," + // 3: t1c + "'T2C' TEXT," + // 4: t2c + "'ETA' TEXT);"); // 5: ETA + } + + /** Drops the underlying database table. */ + public static void dropTable(SQLiteDatabase db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "'MATCH'"; + db.execSQL(sql); + } + + /** @inheritdoc */ + @Override + protected void bindValues(SQLiteStatement stmt, Match entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String t1 = entity.getT1(); + if (t1 != null) { + stmt.bindString(2, t1); + } + + String t2 = entity.getT2(); + if (t2 != null) { + stmt.bindString(3, t2); + } + + String t1c = entity.getT1c(); + if (t1c != null) { + stmt.bindString(4, t1c); + } + + String t2c = entity.getT2c(); + if (t2c != null) { + stmt.bindString(5, t2c); + } + + String ETA = entity.getETA(); + if (ETA != null) { + stmt.bindString(6, ETA); + } + } + + /** @inheritdoc */ + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + /** @inheritdoc */ + @Override + public Match readEntity(Cursor cursor, int offset) { + Match entity = new Match( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // t1 + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // t2 + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // t1c + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // t2c + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // ETA + ); + return entity; + } + + /** @inheritdoc */ + @Override + public void readEntity(Cursor cursor, Match entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setT1(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setT2(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setT1c(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setT2c(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setETA(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + } + + /** @inheritdoc */ + @Override + protected Long updateKeyAfterInsert(Match entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + /** @inheritdoc */ + @Override + public Long getKey(Match entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + /** @inheritdoc */ + @Override + protected boolean isEntityUpdateable() { + return true; + } + +} diff --git a/gradle.properties b/gradle.properties index 89e0d99..75c6495 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,3 +16,5 @@ # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true + +outputDir = '.' \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index e7b4def..551d53c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app' +include ':app',':MyDaoGenerator'