7 Commits 5bf601ad53 ... 52e45ba553

Autor SHA1 Nachricht Datum
  e 52e45ba553 数据库类别表 vor 6 Jahren
  e 5cf2a85d7e what vor 6 Jahren
  e acaa15798e 3.0 vor 6 Jahren
  e 8c7ebc208d 3.0 vor 6 Jahren
  e f2bc96782c 拉代码 vor 6 Jahren
  e b893dbdb06 3.0 vor 6 Jahren
  e 8969250655 3.0 vor 6 Jahren

+ 0 - 6
.idea/encodings.xml

@@ -1,6 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<project version="4">
3
-  <component name="Encoding">
4
-    <file url="PROJECT" charset="UTF-8" />
5
-  </component>
6
-</project>

+ 0 - 19
.idea/gradle.xml

@@ -1,19 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<project version="4">
3
-  <component name="GradleSettings">
4
-    <option name="linkedExternalProjectsSettings">
5
-      <GradleProjectSettings>
6
-        <option name="distributionType" value="DEFAULT_WRAPPED" />
7
-        <option name="externalProjectPath" value="$PROJECT_DIR$" />
8
-        <option name="modules">
9
-          <set>
10
-            <option value="$PROJECT_DIR$" />
11
-            <option value="$PROJECT_DIR$/MoneyNote_Sqlite" />
12
-            <option value="$PROJECT_DIR$/app" />
13
-          </set>
14
-        </option>
15
-        <option name="resolveModulePerSourceSet" value="false" />
16
-      </GradleProjectSettings>
17
-    </option>
18
-  </component>
19
-</project>

+ 0 - 30
.idea/misc.xml

@@ -1,30 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<project version="4">
3
-  <component name="NullableNotNullManager">
4
-    <option name="myDefaultNullable" value="android.support.annotation.Nullable" />
5
-    <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
6
-    <option name="myNullables">
7
-      <value>
8
-        <list size="4">
9
-          <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
10
-          <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
11
-          <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
12
-          <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
13
-        </list>
14
-      </value>
15
-    </option>
16
-    <option name="myNotNulls">
17
-      <value>
18
-        <list size="4">
19
-          <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
20
-          <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
21
-          <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
22
-          <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
23
-        </list>
24
-      </value>
25
-    </option>
26
-  </component>
27
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
28
-    <output url="file://$PROJECT_DIR$/build/classes" />
29
-  </component>
30
-</project>

+ 0 - 12
.idea/modules.xml

@@ -1,12 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<project version="4">
3
-  <component name="ProjectModuleManager">
4
-    <modules>
5
-      <module fileurl="file://$PROJECT_DIR$/MoneyMoreMoreNote.iml" filepath="$PROJECT_DIR$/MoneyMoreMoreNote.iml" />
6
-      <module fileurl="file://$PROJECT_DIR$/MoneyNote.iml" filepath="$PROJECT_DIR$/MoneyNote.iml" />
7
-      <module fileurl="file://$PROJECT_DIR$/MoneyNote_Sqlite/MoneyNote_Sqlite.iml" filepath="$PROJECT_DIR$/MoneyNote_Sqlite/MoneyNote_Sqlite.iml" />
8
-      <module fileurl="file://E:\moneymoremorenote\MoneyMoreMoreNote\MoneyNote_Sqlite\MoneyNote_Sqlite.iml" filepath="E:\moneymoremorenote\MoneyMoreMoreNote\MoneyNote_Sqlite\MoneyNote_Sqlite.iml" />
9
-      <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
10
-    </modules>
11
-  </component>
12
-</project>

+ 0 - 12
.idea/runConfigurations.xml

@@ -1,12 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<project version="4">
3
-  <component name="RunConfigurationProducerService">
4
-    <option name="ignoredProducers">
5
-      <set>
6
-        <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
7
-        <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
8
-        <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
9
-      </set>
10
-    </option>
11
-  </component>
12
-</project>

+ 0 - 6
.idea/vcs.xml

@@ -1,6 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<project version="4">
3
-  <component name="VcsDirectoryMappings">
4
-    <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
-  </component>
6
-</project>

+ 1 - 1
MoneyNote_Sqlite/.gitignore

@@ -1 +1 @@
1
-/build
1
+/build

+ 172 - 0
MoneyNote_Sqlite/src/main/java/com/kuxuan/sqlite/dao/BillCategoreDBDao.java

@@ -0,0 +1,172 @@
1
+package com.kuxuan.sqlite.dao;
2
+
3
+import android.database.Cursor;
4
+import android.database.sqlite.SQLiteStatement;
5
+
6
+import org.greenrobot.greendao.AbstractDao;
7
+import org.greenrobot.greendao.Property;
8
+import org.greenrobot.greendao.internal.DaoConfig;
9
+import org.greenrobot.greendao.database.Database;
10
+import org.greenrobot.greendao.database.DatabaseStatement;
11
+
12
+import com.kuxuan.sqlite.db.BillCategoreDB;
13
+
14
+// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
15
+/** 
16
+ * DAO for table "BILL_CATEGORE_DB".
17
+*/
18
+public class BillCategoreDBDao extends AbstractDao<BillCategoreDB, Void> {
19
+
20
+    public static final String TABLENAME = "BILL_CATEGORE_DB";
21
+
22
+    /**
23
+     * Properties of entity BillCategoreDB.<br/>
24
+     * Can be used for QueryBuilder and for referencing column names.
25
+     */
26
+    public static class Properties {
27
+        public final static Property Id = new Property(0, long.class, "id", false, "ID");
28
+        public final static Property Category_type = new Property(1, int.class, "category_type", false, "CATEGORY_TYPE");
29
+        public final static Property Icon = new Property(2, String.class, "icon", false, "ICON");
30
+        public final static Property Selected_icon = new Property(3, String.class, "selected_icon", false, "SELECTED_ICON");
31
+        public final static Property Detail_icon = new Property(4, String.class, "detail_icon", false, "DETAIL_ICON");
32
+        public final static Property Name = new Property(5, String.class, "name", false, "NAME");
33
+        public final static Property Type = new Property(6, int.class, "type", false, "TYPE");
34
+    }
35
+
36
+
37
+    public BillCategoreDBDao(DaoConfig config) {
38
+        super(config);
39
+    }
40
+    
41
+    public BillCategoreDBDao(DaoConfig config, DaoSession daoSession) {
42
+        super(config, daoSession);
43
+    }
44
+
45
+    /** Creates the underlying database table. */
46
+    public static void createTable(Database db, boolean ifNotExists) {
47
+        String constraint = ifNotExists? "IF NOT EXISTS ": "";
48
+        db.execSQL("CREATE TABLE " + constraint + "\"BILL_CATEGORE_DB\" (" + //
49
+                "\"ID\" INTEGER NOT NULL UNIQUE ," + // 0: id
50
+                "\"CATEGORY_TYPE\" INTEGER NOT NULL ," + // 1: category_type
51
+                "\"ICON\" TEXT," + // 2: icon
52
+                "\"SELECTED_ICON\" TEXT," + // 3: selected_icon
53
+                "\"DETAIL_ICON\" TEXT," + // 4: detail_icon
54
+                "\"NAME\" TEXT," + // 5: name
55
+                "\"TYPE\" INTEGER NOT NULL );"); // 6: type
56
+    }
57
+
58
+    /** Drops the underlying database table. */
59
+    public static void dropTable(Database db, boolean ifExists) {
60
+        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"BILL_CATEGORE_DB\"";
61
+        db.execSQL(sql);
62
+    }
63
+
64
+    @Override
65
+    protected final void bindValues(DatabaseStatement stmt, BillCategoreDB entity) {
66
+        stmt.clearBindings();
67
+        stmt.bindLong(1, entity.getId());
68
+        stmt.bindLong(2, entity.getCategory_type());
69
+ 
70
+        String icon = entity.getIcon();
71
+        if (icon != null) {
72
+            stmt.bindString(3, icon);
73
+        }
74
+ 
75
+        String selected_icon = entity.getSelected_icon();
76
+        if (selected_icon != null) {
77
+            stmt.bindString(4, selected_icon);
78
+        }
79
+ 
80
+        String detail_icon = entity.getDetail_icon();
81
+        if (detail_icon != null) {
82
+            stmt.bindString(5, detail_icon);
83
+        }
84
+ 
85
+        String name = entity.getName();
86
+        if (name != null) {
87
+            stmt.bindString(6, name);
88
+        }
89
+        stmt.bindLong(7, entity.getType());
90
+    }
91
+
92
+    @Override
93
+    protected final void bindValues(SQLiteStatement stmt, BillCategoreDB entity) {
94
+        stmt.clearBindings();
95
+        stmt.bindLong(1, entity.getId());
96
+        stmt.bindLong(2, entity.getCategory_type());
97
+ 
98
+        String icon = entity.getIcon();
99
+        if (icon != null) {
100
+            stmt.bindString(3, icon);
101
+        }
102
+ 
103
+        String selected_icon = entity.getSelected_icon();
104
+        if (selected_icon != null) {
105
+            stmt.bindString(4, selected_icon);
106
+        }
107
+ 
108
+        String detail_icon = entity.getDetail_icon();
109
+        if (detail_icon != null) {
110
+            stmt.bindString(5, detail_icon);
111
+        }
112
+ 
113
+        String name = entity.getName();
114
+        if (name != null) {
115
+            stmt.bindString(6, name);
116
+        }
117
+        stmt.bindLong(7, entity.getType());
118
+    }
119
+
120
+    @Override
121
+    public Void readKey(Cursor cursor, int offset) {
122
+        return null;
123
+    }    
124
+
125
+    @Override
126
+    public BillCategoreDB readEntity(Cursor cursor, int offset) {
127
+        BillCategoreDB entity = new BillCategoreDB( //
128
+            cursor.getLong(offset + 0), // id
129
+            cursor.getInt(offset + 1), // category_type
130
+            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // icon
131
+            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // selected_icon
132
+            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // detail_icon
133
+            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // name
134
+            cursor.getInt(offset + 6) // type
135
+        );
136
+        return entity;
137
+    }
138
+     
139
+    @Override
140
+    public void readEntity(Cursor cursor, BillCategoreDB entity, int offset) {
141
+        entity.setId(cursor.getLong(offset + 0));
142
+        entity.setCategory_type(cursor.getInt(offset + 1));
143
+        entity.setIcon(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
144
+        entity.setSelected_icon(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
145
+        entity.setDetail_icon(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
146
+        entity.setName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
147
+        entity.setType(cursor.getInt(offset + 6));
148
+     }
149
+    
150
+    @Override
151
+    protected final Void updateKeyAfterInsert(BillCategoreDB entity, long rowId) {
152
+        // Unsupported or missing PK type
153
+        return null;
154
+    }
155
+    
156
+    @Override
157
+    public Void getKey(BillCategoreDB entity) {
158
+        return null;
159
+    }
160
+
161
+    @Override
162
+    public boolean hasKey(BillCategoreDB entity) {
163
+        // TODO
164
+        return false;
165
+    }
166
+
167
+    @Override
168
+    protected final boolean isEntityUpdateable() {
169
+        return true;
170
+    }
171
+    
172
+}

+ 3 - 0
MoneyNote_Sqlite/src/main/java/com/kuxuan/sqlite/dao/DaoMaster.java

@@ -23,12 +23,14 @@ public class DaoMaster extends AbstractDaoMaster {
23 23
     public static void createAllTables(Database db, boolean ifNotExists) {
24 24
         CategoryDBDao.createTable(db, ifNotExists);
25 25
         TestDao.createTable(db, ifNotExists);
26
+        BillCategoreDBDao.createTable(db, ifNotExists);
26 27
     }
27 28
 
28 29
     /** Drops underlying database table using DAOs. */
29 30
     public static void dropAllTables(Database db, boolean ifExists) {
30 31
         CategoryDBDao.dropTable(db, ifExists);
31 32
         TestDao.dropTable(db, ifExists);
33
+        BillCategoreDBDao.dropTable(db, ifExists);
32 34
     }
33 35
 
34 36
     /**
@@ -49,6 +51,7 @@ public class DaoMaster extends AbstractDaoMaster {
49 51
         super(db, SCHEMA_VERSION);
50 52
         registerDaoClass(CategoryDBDao.class);
51 53
         registerDaoClass(TestDao.class);
54
+        registerDaoClass(BillCategoreDBDao.class);
52 55
     }
53 56
 
54 57
     public DaoSession newSession() {

+ 14 - 0
MoneyNote_Sqlite/src/main/java/com/kuxuan/sqlite/dao/DaoSession.java

@@ -10,9 +10,11 @@ import org.greenrobot.greendao.internal.DaoConfig;
10 10
 
11 11
 import com.kuxuan.sqlite.db.CategoryDB;
12 12
 import com.kuxuan.sqlite.db.Test;
13
+import com.kuxuan.sqlite.db.BillCategoreDB;
13 14
 
14 15
 import com.kuxuan.sqlite.dao.CategoryDBDao;
15 16
 import com.kuxuan.sqlite.dao.TestDao;
17
+import com.kuxuan.sqlite.dao.BillCategoreDBDao;
16 18
 
17 19
 // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
18 20
 
@@ -25,9 +27,11 @@ public class DaoSession extends AbstractDaoSession {
25 27
 
26 28
     private final DaoConfig categoryDBDaoConfig;
27 29
     private final DaoConfig testDaoConfig;
30
+    private final DaoConfig billCategoreDBDaoConfig;
28 31
 
29 32
     private final CategoryDBDao categoryDBDao;
30 33
     private final TestDao testDao;
34
+    private final BillCategoreDBDao billCategoreDBDao;
31 35
 
32 36
     public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
33 37
             daoConfigMap) {
@@ -39,16 +43,22 @@ public class DaoSession extends AbstractDaoSession {
39 43
         testDaoConfig = daoConfigMap.get(TestDao.class).clone();
40 44
         testDaoConfig.initIdentityScope(type);
41 45
 
46
+        billCategoreDBDaoConfig = daoConfigMap.get(BillCategoreDBDao.class).clone();
47
+        billCategoreDBDaoConfig.initIdentityScope(type);
48
+
42 49
         categoryDBDao = new CategoryDBDao(categoryDBDaoConfig, this);
43 50
         testDao = new TestDao(testDaoConfig, this);
51
+        billCategoreDBDao = new BillCategoreDBDao(billCategoreDBDaoConfig, this);
44 52
 
45 53
         registerDao(CategoryDB.class, categoryDBDao);
46 54
         registerDao(Test.class, testDao);
55
+        registerDao(BillCategoreDB.class, billCategoreDBDao);
47 56
     }
48 57
     
49 58
     public void clear() {
50 59
         categoryDBDaoConfig.clearIdentityScope();
51 60
         testDaoConfig.clearIdentityScope();
61
+        billCategoreDBDaoConfig.clearIdentityScope();
52 62
     }
53 63
 
54 64
     public CategoryDBDao getCategoryDBDao() {
@@ -59,4 +69,8 @@ public class DaoSession extends AbstractDaoSession {
59 69
         return testDao;
60 70
     }
61 71
 
72
+    public BillCategoreDBDao getBillCategoreDBDao() {
73
+        return billCategoreDBDao;
74
+    }
75
+
62 76
 }

+ 78 - 0
MoneyNote_Sqlite/src/main/java/com/kuxuan/sqlite/db/BillCategoreDB.java

@@ -0,0 +1,78 @@
1
+package com.kuxuan.sqlite.db;
2
+
3
+import org.greenrobot.greendao.annotation.Entity;
4
+import org.greenrobot.greendao.annotation.Unique;
5
+import org.greenrobot.greendao.annotation.Generated;
6
+
7
+/**
8
+ * Created by Allence on 2018/3/30 0030.
9
+ */
10
+@Entity
11
+public class BillCategoreDB {
12
+    @Unique
13
+    private long  id;
14
+    private int category_type;
15
+    private String icon;
16
+    private String selected_icon;
17
+    private String detail_icon;
18
+    private String name;
19
+    private int type;
20
+    @Generated(hash = 1251638153)
21
+    public BillCategoreDB(long id, int category_type, String icon,
22
+            String selected_icon, String detail_icon, String name, int type) {
23
+        this.id = id;
24
+        this.category_type = category_type;
25
+        this.icon = icon;
26
+        this.selected_icon = selected_icon;
27
+        this.detail_icon = detail_icon;
28
+        this.name = name;
29
+        this.type = type;
30
+    }
31
+    @Generated(hash = 10525810)
32
+    public BillCategoreDB() {
33
+    }
34
+    public long getId() {
35
+        return this.id;
36
+    }
37
+    public void setId(long id) {
38
+        this.id = id;
39
+    }
40
+    public int getCategory_type() {
41
+        return this.category_type;
42
+    }
43
+    public void setCategory_type(int category_type) {
44
+        this.category_type = category_type;
45
+    }
46
+    public String getIcon() {
47
+        return this.icon;
48
+    }
49
+    public void setIcon(String icon) {
50
+        this.icon = icon;
51
+    }
52
+    public String getSelected_icon() {
53
+        return this.selected_icon;
54
+    }
55
+    public void setSelected_icon(String selected_icon) {
56
+        this.selected_icon = selected_icon;
57
+    }
58
+    public String getDetail_icon() {
59
+        return this.detail_icon;
60
+    }
61
+    public void setDetail_icon(String detail_icon) {
62
+        this.detail_icon = detail_icon;
63
+    }
64
+    public String getName() {
65
+        return this.name;
66
+    }
67
+    public void setName(String name) {
68
+        this.name = name;
69
+    }
70
+    public int getType() {
71
+        return this.type;
72
+    }
73
+    public void setType(int type) {
74
+        this.type = type;
75
+    }
76
+
77
+
78
+}

+ 1 - 1
app/.gitignore

@@ -1,2 +1,2 @@
1 1
 /build
2
-/local.properties
2
+/local.properties

+ 0 - 12
app/local.properties

@@ -1,12 +0,0 @@
1
-## This file is automatically generated by Android Studio.
2
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3
-#
4
-# This file must *NOT* be checked into Version Control Systems,
5
-# as it contains information specific to your local configuration.
6
-#
7
-# Location of the SDK. This is only used by Gradle.
8
-# For customization when using a Version Control System, please read the
9
-# header note.
10
-#Thu Mar 15 14:17:07 CST 2018
11
-ndk.dir=/Users/xieshengqi/Library/Android/sdk/ndk-bundle
12
-sdk.dir=/Users/xieshengqi/Library/Android/sdk

+ 0 - 2
app/src/main/AndroidManifest.xml

@@ -27,7 +27,6 @@
27 27
             android:name=".ui.activitys.MainActivity"
28 28
             android:launchMode="singleTask"
29 29
             android:screenOrientation="portrait">
30
-
31 30
         </activity>
32 31
 
33 32
 
@@ -36,7 +35,6 @@
36 35
             android:screenOrientation="portrait"
37 36
             android:theme="@style/WelcomeStyle"
38 37
             >
39
-
40 38
             <intent-filter>
41 39
                 <action android:name="android.intent.action.MAIN" />
42 40
 

Datei-Diff unterdrückt, da er zu groß ist
+ 1 - 0
app/src/main/assets/categore.txt


+ 9 - 0
app/src/main/java/com/kuxuan/moneynote/common/Constant.java

@@ -47,6 +47,15 @@ public class Constant {
47 47
 
48 48
 
49 49
 
50
+    public static class CategoreyDBConstant{
51
+
52
+        public static final String ISINSERT = "isInsert";
53
+
54
+
55
+    }
56
+
57
+
58
+
50 59
     public static class Code_Request {
51 60
         public static final int SUCCESS_CODE = 0;
52 61
         /**

+ 88 - 0
app/src/main/java/com/kuxuan/moneynote/db/BillCategoreDaoOperator.java

@@ -0,0 +1,88 @@
1
+package com.kuxuan.moneynote.db;
2
+
3
+import com.kuxuan.sqlite.dao.BillCategoreDBDao;
4
+import com.kuxuan.sqlite.db.BillCategoreDB;
5
+
6
+import java.util.List;
7
+
8
+/**
9
+ * Created by Allence on 2018/3/30 0030.
10
+ */
11
+
12
+public class BillCategoreDaoOperator {
13
+
14
+
15
+    public static BillCategoreDaoOperator newInstance(){
16
+
17
+        return new BillCategoreDaoOperator();
18
+    }
19
+
20
+
21
+    /**
22
+     * 添加一条数据
23
+     * @param billCategoreDB
24
+     * @return
25
+     */
26
+    public synchronized boolean insert(BillCategoreDB billCategoreDB){
27
+
28
+        boolean isSuccess = false;
29
+        BillCategoreDBDao billCategoreDBDao = DbManager.getInstance().getmDaoSession().getBillCategoreDBDao();
30
+
31
+        try {
32
+            long insert = billCategoreDBDao.insertOrReplace(billCategoreDB);
33
+        } catch (Exception e) {
34
+
35
+        }
36
+        return isSuccess;
37
+
38
+    }
39
+
40
+
41
+    /**
42
+     * 添加一堆数据
43
+     * @param billCategoreDBList
44
+     * @return
45
+     */
46
+
47
+    public synchronized boolean insertList(List<BillCategoreDB> billCategoreDBList){
48
+
49
+        boolean isSuccess = false;
50
+        BillCategoreDBDao billCategoreDBDao = DbManager.getInstance().getmDaoSession().getBillCategoreDBDao();
51
+
52
+        try {
53
+            billCategoreDBDao.insertOrReplaceInTx(billCategoreDBList);
54
+            isSuccess = true;
55
+        } catch (Exception e) {
56
+
57
+        }
58
+
59
+        return isSuccess;
60
+    }
61
+
62
+
63
+    /**
64
+     * 根据id查询
65
+     * @return
66
+     */
67
+    public synchronized List<BillCategoreDB> getCategoreDataById(int id){
68
+
69
+        List<BillCategoreDB> billCategoreDBList=null;
70
+
71
+        try {
72
+            BillCategoreDBDao billCategoreDBDao = DbManager.getInstance().getmDaoSession().getBillCategoreDBDao();
73
+            billCategoreDBList = billCategoreDBDao.queryBuilder().where(BillCategoreDBDao.Properties.Id.eq(id)).list();
74
+        } catch (Exception e) {
75
+
76
+        }
77
+
78
+        return billCategoreDBList;
79
+    }
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+}

+ 22 - 0
app/src/main/java/com/kuxuan/moneynote/db/CategoryDBJson.java

@@ -0,0 +1,22 @@
1
+package com.kuxuan.moneynote.db;
2
+
3
+import com.kuxuan.sqlite.db.BillCategoreDB;
4
+
5
+import java.util.List;
6
+
7
+/**
8
+ * Created by Allence on 2018/4/2 0002.
9
+ */
10
+
11
+public class CategoryDBJson {
12
+
13
+    private List<BillCategoreDB> system;
14
+
15
+    public List<BillCategoreDB> getSystem() {
16
+        return system;
17
+    }
18
+
19
+    public void setSystem(List<BillCategoreDB> system) {
20
+        this.system = system;
21
+    }
22
+}

+ 34 - 4
app/src/main/java/com/kuxuan/moneynote/ui/activitys/LunchActivity.java

@@ -6,14 +6,18 @@ import android.os.Bundle;
6 6
 import android.view.View;
7 7
 import android.view.WindowManager;
8 8
 
9
+import com.google.gson.Gson;
9 10
 import com.kuxuan.moneynote.R;
10 11
 import com.kuxuan.moneynote.common.Constant;
12
+import com.kuxuan.moneynote.db.BillCategoreDaoOperator;
13
+import com.kuxuan.moneynote.db.CategoryDBJson;
11 14
 import com.kuxuan.moneynote.db.CategoryDBbean;
12 15
 import com.kuxuan.moneynote.db.CategoryDaoOperator;
13 16
 import com.kuxuan.moneynote.ui.activitys.eventbus.LoginOutEvent;
14 17
 import com.kuxuan.moneynote.ui.activitys.login.LoginActivity;
15 18
 import com.kuxuan.moneynote.utils.LoginStatusUtil;
16 19
 import com.kuxuan.moneynote.utils.SPUtil;
20
+import com.kuxuan.moneynote.utils.Tools;
17 21
 import com.kuxuan.moneynote.utils.UIHelper;
18 22
 import com.umeng.analytics.MobclickAgent;
19 23
 
@@ -76,17 +80,22 @@ public class LunchActivity extends Activity {
76 80
     private void goMain() {
77 81
         //测试用
78 82
         initCateDbOpeator();
83
+
84
+        boolean isInsert= (boolean) SPUtil.get(getApplicationContext(),Constant.CategoreyDBConstant.ISINSERT,false);
85
+
86
+        if(!isInsert){
87
+
88
+            initBillCategore();
89
+
90
+        }
91
+
79 92
 //        if ((Boolean) SPUtil.get(this, Constant.IsFirstWEiChatLogin.ISWEICHATLOGIN, false) && !(Boolean) SPUtil.get(this, Constant.IsFirstWEiChatLogin.ISFIRSTWEICHATLOGIN, false)) {
80 93
 //            LoginStatusUtil.loginOut();
81
-//            //TODO 刷新数据(重写)
82
-//            //        EventBus.getDefault().post(new RefreshEvent());
83 94
 //            EventBus.getDefault().post(new LoginOutEvent());
84 95
 //        }
85 96
 
86 97
         if((Boolean) SPUtil.get(this, Constant.IsFirstWEiChatLogin.ISWEICHATLOGIN,false)&&(Boolean) SPUtil.get(this,Constant.IsFirstWEiChatLogin.IsLoginOut,false)){
87 98
             LoginStatusUtil.loginOut();
88
-            //TODO 刷新数据(重写)
89
-            //        EventBus.getDefault().post(new RefreshEvent());
90 99
             EventBus.getDefault().post(new LoginOutEvent());
91 100
         }
92 101
 
@@ -123,6 +132,27 @@ public class LunchActivity extends Activity {
123 132
     }
124 133
 
125 134
 
135
+    BillCategoreDaoOperator billCategoreDaoOperator;
136
+    private void initBillCategore() {
137
+
138
+      billCategoreDaoOperator = BillCategoreDaoOperator.newInstance();
139
+
140
+        String json = Tools.getJson("categore.txt",getApplicationContext());
141
+
142
+        Gson gson = new Gson();
143
+
144
+        CategoryDBJson categoryDBJson = gson.fromJson(json, CategoryDBJson.class);
145
+
146
+        billCategoreDaoOperator.insertList(categoryDBJson.getSystem());
147
+
148
+        SPUtil.putAndApply(getApplicationContext(),Constant.CategoreyDBConstant.ISINSERT,true);
149
+
150
+    }
151
+
152
+
153
+
154
+
155
+
126 156
     CategoryDaoOperator categoryDaoOperator;
127 157
 
128 158
     private void initCateDbOpeator() {

+ 1 - 6
app/src/main/java/com/kuxuan/moneynote/ui/activitys/login/LoginActivity.java

@@ -126,9 +126,7 @@ public class LoginActivity extends BaseFragmentActivity {
126 126
             case R.id.activity_login_wchat_btn:
127 127
 //                UMShareAPI.get(LoginActivity.this).getPlatformInfo(LoginActivity.this, SHARE_MEDIA.WEIXIN, umAuthListener);
128 128
 //                UMShareAPI.get(this).doOauthVerify(LoginActivity.this, SHARE_MEDIA.WEIXIN, umAuthListener);
129
-
130
-                UMShareAPI.get(this).doOauthVerify(LoginActivity.this, SHARE_MEDIA.WEIXIN, mUMAuthListener);
131
-
129
+                  UMShareAPI.get(this).doOauthVerify(LoginActivity.this, SHARE_MEDIA.WEIXIN, mUMAuthListener);
132 130
                 break;
133 131
             case R.id.activity_login_more_text:
134 132
                 choose();
@@ -203,9 +201,6 @@ public class LoginActivity extends BaseFragmentActivity {
203 201
         @Override
204 202
         public void onComplete(SHARE_MEDIA platform, int action, Map<String, String> data) {
205 203
 
206
-
207
-
208
-
209 204
             String openid = data.get("openid");
210 205
             String unionid = data.get("uid");
211 206
             String gender = data.get("gender");

+ 37 - 0
app/src/main/java/com/kuxuan/moneynote/utils/Tools.java

@@ -0,0 +1,37 @@
1
+package com.kuxuan.moneynote.utils;
2
+
3
+import android.content.Context;
4
+import android.content.res.AssetManager;
5
+
6
+import java.io.BufferedReader;
7
+import java.io.IOException;
8
+import java.io.InputStreamReader;
9
+
10
+/**
11
+ * Created by Allence on 2018/4/2 0002.
12
+ */
13
+
14
+public class Tools {
15
+
16
+
17
+    public static String getJson(String fileName,Context context) {
18
+        //将json数据变成字符串
19
+        StringBuilder stringBuilder = new StringBuilder();
20
+        try {
21
+            //获取assets资源管理器
22
+            AssetManager assetManager = context.getAssets();
23
+            //通过管理器打开文件并读取
24
+            BufferedReader bf = new BufferedReader(new InputStreamReader(
25
+                    assetManager.open(fileName)));
26
+            String line;
27
+            while ((line = bf.readLine()) != null) {
28
+                stringBuilder.append(line);
29
+            }
30
+        } catch (IOException e) {
31
+            e.printStackTrace();
32
+        }
33
+        return stringBuilder.toString();
34
+    }
35
+
36
+
37
+}