Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yuweiguocn committed Jan 4, 2016
0 parents commit 3faaca7
Show file tree
Hide file tree
Showing 38 changed files with 1,097 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
28 changes: 28 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.github.yuweiguocn.demo.greendao"
minSdkVersion 8
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'de.greenrobot:greendao:2.0.0'
compile project(':library')
}
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in E:\android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.github.yuweiguocn.demo.greendao;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
20 changes: 20 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.github.yuweiguocn.demo.greendao"
xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.github.yuweiguocn.demo.greendao;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.github.yuweiguocn.demo.greendao.db.DaoMaster;

public class MainActivity extends AppCompatActivity {

private DaoMaster daoMaster;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "test",
null);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.github.yuweiguocn.demo.greendao.db;

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 com.github.yuweiguocn.library.greendao.MigrationHelper;

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 1): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 1;

/** Creates underlying database table using DAOs. */
public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) {
TestDataDao.createTable(db, ifNotExists);
}

/** Drops underlying database table using DAOs. */
public static void dropAllTables(SQLiteDatabase db, boolean ifExists) {
TestDataDao.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");
MigrationHelper.getInstance().migrate(db,TestDataDao.class);
}
}

public DaoMaster(SQLiteDatabase db) {
super(db, SCHEMA_VERSION);
registerDaoClass(TestDataDao.class);
}

public DaoSession newSession() {
return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
}

public DaoSession newSession(IdentityScopeType type) {
return new DaoSession(db, type, daoConfigMap);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.github.yuweiguocn.demo.greendao.db;

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 testDataDaoConfig;

private final TestDataDao testDataDao;

public DaoSession(SQLiteDatabase db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
daoConfigMap) {
super(db);

testDataDaoConfig = daoConfigMap.get(TestDataDao.class).clone();
testDataDaoConfig.initIdentityScope(type);

testDataDao = new TestDataDao(testDataDaoConfig, this);

registerDao(TestData.class, testDataDao);
}

public void clear() {
testDataDaoConfig.getIdentityScope().clear();
}

public TestDataDao getTestDataDao() {
return testDataDao;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.github.yuweiguocn.demo.greendao.db;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit.
/**
* Entity mapped to table "TEST_DATA".
*/
public class TestData {

private Long id;
private String testString;
private Long testLong;
private java.util.Date testDate;
private Integer testInt;
private Boolean testBoolean;

public TestData() {
}

public TestData(Long id) {
this.id = id;
}

public TestData(Long id, String testString, Long testLong, java.util.Date testDate, Integer testInt, Boolean testBoolean) {
this.id = id;
this.testString = testString;
this.testLong = testLong;
this.testDate = testDate;
this.testInt = testInt;
this.testBoolean = testBoolean;
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getTestString() {
return testString;
}

public void setTestString(String testString) {
this.testString = testString;
}

public Long getTestLong() {
return testLong;
}

public void setTestLong(Long testLong) {
this.testLong = testLong;
}

public java.util.Date getTestDate() {
return testDate;
}

public void setTestDate(java.util.Date testDate) {
this.testDate = testDate;
}

public Integer getTestInt() {
return testInt;
}

public void setTestInt(Integer testInt) {
this.testInt = testInt;
}

public Boolean getTestBoolean() {
return testBoolean;
}

public void setTestBoolean(Boolean testBoolean) {
this.testBoolean = testBoolean;
}

}
Loading

0 comments on commit 3faaca7

Please sign in to comment.