Explorar el Código

Merge branch 'MoneyNote3.0' of http://git.quyaqu.com/xieshengqi/MoneyMoreMoreNote into MoneyNote3.0

e %!s(int64=6) %!d(string=hace) años
padre
commit
d9c34d767d

+ 62 - 48
MoneyNote_Sqlite/src/main/java/com/kuxuan/sqlite/dao/CategoryDBDao.java

29
         public final static Property Demo = new Property(2, String.class, "demo", false, "DEMO");
29
         public final static Property Demo = new Property(2, String.class, "demo", false, "DEMO");
30
         public final static Property Name = new Property(3, String.class, "name", false, "NAME");
30
         public final static Property Name = new Property(3, String.class, "name", false, "NAME");
31
         public final static Property Type = new Property(4, int.class, "type", false, "TYPE");
31
         public final static Property Type = new Property(4, int.class, "type", false, "TYPE");
32
-        public final static Property Account = new Property(5, long.class, "account", false, "ACCOUNT");
33
-        public final static Property Category_id = new Property(6, int.class, "category_id", false, "CATEGORY_ID");
34
-        public final static Property Year = new Property(7, int.class, "year", false, "YEAR");
35
-        public final static Property Month = new Property(8, int.class, "month", false, "MONTH");
36
-        public final static Property Day = new Property(9, int.class, "day", false, "DAY");
37
-        public final static Property CreateTime = new Property(10, long.class, "createTime", false, "CREATE_TIME");
38
-        public final static Property UpdateTime = new Property(11, long.class, "updateTime", false, "UPDATE_TIME");
39
-        public final static Property User_id = new Property(12, int.class, "user_id", false, "USER_ID");
32
+        public final static Property Image_path = new Property(5, String.class, "image_path", false, "IMAGE_PATH");
33
+        public final static Property Account = new Property(6, long.class, "account", false, "ACCOUNT");
34
+        public final static Property Category_id = new Property(7, int.class, "category_id", false, "CATEGORY_ID");
35
+        public final static Property Year = new Property(8, int.class, "year", false, "YEAR");
36
+        public final static Property Month = new Property(9, int.class, "month", false, "MONTH");
37
+        public final static Property Day = new Property(10, int.class, "day", false, "DAY");
38
+        public final static Property CreateTime = new Property(11, long.class, "createTime", false, "CREATE_TIME");
39
+        public final static Property UpdateTime = new Property(12, long.class, "updateTime", false, "UPDATE_TIME");
40
+        public final static Property User_id = new Property(13, int.class, "user_id", false, "USER_ID");
40
     }
41
     }
41
 
42
 
42
 
43
 
57
                 "\"DEMO\" TEXT," + // 2: demo
58
                 "\"DEMO\" TEXT," + // 2: demo
58
                 "\"NAME\" TEXT," + // 3: name
59
                 "\"NAME\" TEXT," + // 3: name
59
                 "\"TYPE\" INTEGER NOT NULL ," + // 4: type
60
                 "\"TYPE\" INTEGER NOT NULL ," + // 4: type
60
-                "\"ACCOUNT\" INTEGER NOT NULL ," + // 5: account
61
-                "\"CATEGORY_ID\" INTEGER NOT NULL ," + // 6: category_id
62
-                "\"YEAR\" INTEGER NOT NULL ," + // 7: year
63
-                "\"MONTH\" INTEGER NOT NULL ," + // 8: month
64
-                "\"DAY\" INTEGER NOT NULL ," + // 9: day
65
-                "\"CREATE_TIME\" INTEGER NOT NULL ," + // 10: createTime
66
-                "\"UPDATE_TIME\" INTEGER NOT NULL ," + // 11: updateTime
67
-                "\"USER_ID\" INTEGER NOT NULL );"); // 12: user_id
61
+                "\"IMAGE_PATH\" TEXT," + // 5: image_path
62
+                "\"ACCOUNT\" INTEGER NOT NULL ," + // 6: account
63
+                "\"CATEGORY_ID\" INTEGER NOT NULL ," + // 7: category_id
64
+                "\"YEAR\" INTEGER NOT NULL ," + // 8: year
65
+                "\"MONTH\" INTEGER NOT NULL ," + // 9: month
66
+                "\"DAY\" INTEGER NOT NULL ," + // 10: day
67
+                "\"CREATE_TIME\" INTEGER NOT NULL ," + // 11: createTime
68
+                "\"UPDATE_TIME\" INTEGER NOT NULL ," + // 12: updateTime
69
+                "\"USER_ID\" INTEGER NOT NULL );"); // 13: user_id
68
     }
70
     }
69
 
71
 
70
     /** Drops the underlying database table. */
72
     /** Drops the underlying database table. */
97
             stmt.bindString(4, name);
99
             stmt.bindString(4, name);
98
         }
100
         }
99
         stmt.bindLong(5, entity.getType());
101
         stmt.bindLong(5, entity.getType());
100
-        stmt.bindLong(6, entity.getAccount());
101
-        stmt.bindLong(7, entity.getCategory_id());
102
-        stmt.bindLong(8, entity.getYear());
103
-        stmt.bindLong(9, entity.getMonth());
104
-        stmt.bindLong(10, entity.getDay());
105
-        stmt.bindLong(11, entity.getCreateTime());
106
-        stmt.bindLong(12, entity.getUpdateTime());
107
-        stmt.bindLong(13, entity.getUser_id());
102
+ 
103
+        String image_path = entity.getImage_path();
104
+        if (image_path != null) {
105
+            stmt.bindString(6, image_path);
106
+        }
107
+        stmt.bindLong(7, entity.getAccount());
108
+        stmt.bindLong(8, entity.getCategory_id());
109
+        stmt.bindLong(9, entity.getYear());
110
+        stmt.bindLong(10, entity.getMonth());
111
+        stmt.bindLong(11, entity.getDay());
112
+        stmt.bindLong(12, entity.getCreateTime());
113
+        stmt.bindLong(13, entity.getUpdateTime());
114
+        stmt.bindLong(14, entity.getUser_id());
108
     }
115
     }
109
 
116
 
110
     @Override
117
     @Override
131
             stmt.bindString(4, name);
138
             stmt.bindString(4, name);
132
         }
139
         }
133
         stmt.bindLong(5, entity.getType());
140
         stmt.bindLong(5, entity.getType());
134
-        stmt.bindLong(6, entity.getAccount());
135
-        stmt.bindLong(7, entity.getCategory_id());
136
-        stmt.bindLong(8, entity.getYear());
137
-        stmt.bindLong(9, entity.getMonth());
138
-        stmt.bindLong(10, entity.getDay());
139
-        stmt.bindLong(11, entity.getCreateTime());
140
-        stmt.bindLong(12, entity.getUpdateTime());
141
-        stmt.bindLong(13, entity.getUser_id());
141
+ 
142
+        String image_path = entity.getImage_path();
143
+        if (image_path != null) {
144
+            stmt.bindString(6, image_path);
145
+        }
146
+        stmt.bindLong(7, entity.getAccount());
147
+        stmt.bindLong(8, entity.getCategory_id());
148
+        stmt.bindLong(9, entity.getYear());
149
+        stmt.bindLong(10, entity.getMonth());
150
+        stmt.bindLong(11, entity.getDay());
151
+        stmt.bindLong(12, entity.getCreateTime());
152
+        stmt.bindLong(13, entity.getUpdateTime());
153
+        stmt.bindLong(14, entity.getUser_id());
142
     }
154
     }
143
 
155
 
144
     @Override
156
     @Override
154
             cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // demo
166
             cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // demo
155
             cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // name
167
             cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // name
156
             cursor.getInt(offset + 4), // type
168
             cursor.getInt(offset + 4), // type
157
-            cursor.getLong(offset + 5), // account
158
-            cursor.getInt(offset + 6), // category_id
159
-            cursor.getInt(offset + 7), // year
160
-            cursor.getInt(offset + 8), // month
161
-            cursor.getInt(offset + 9), // day
162
-            cursor.getLong(offset + 10), // createTime
163
-            cursor.getLong(offset + 11), // updateTime
164
-            cursor.getInt(offset + 12) // user_id
169
+            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // image_path
170
+            cursor.getLong(offset + 6), // account
171
+            cursor.getInt(offset + 7), // category_id
172
+            cursor.getInt(offset + 8), // year
173
+            cursor.getInt(offset + 9), // month
174
+            cursor.getInt(offset + 10), // day
175
+            cursor.getLong(offset + 11), // createTime
176
+            cursor.getLong(offset + 12), // updateTime
177
+            cursor.getInt(offset + 13) // user_id
165
         );
178
         );
166
         return entity;
179
         return entity;
167
     }
180
     }
173
         entity.setDemo(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
186
         entity.setDemo(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
174
         entity.setName(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
187
         entity.setName(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
175
         entity.setType(cursor.getInt(offset + 4));
188
         entity.setType(cursor.getInt(offset + 4));
176
-        entity.setAccount(cursor.getLong(offset + 5));
177
-        entity.setCategory_id(cursor.getInt(offset + 6));
178
-        entity.setYear(cursor.getInt(offset + 7));
179
-        entity.setMonth(cursor.getInt(offset + 8));
180
-        entity.setDay(cursor.getInt(offset + 9));
181
-        entity.setCreateTime(cursor.getLong(offset + 10));
182
-        entity.setUpdateTime(cursor.getLong(offset + 11));
183
-        entity.setUser_id(cursor.getInt(offset + 12));
189
+        entity.setImage_path(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
190
+        entity.setAccount(cursor.getLong(offset + 6));
191
+        entity.setCategory_id(cursor.getInt(offset + 7));
192
+        entity.setYear(cursor.getInt(offset + 8));
193
+        entity.setMonth(cursor.getInt(offset + 9));
194
+        entity.setDay(cursor.getInt(offset + 10));
195
+        entity.setCreateTime(cursor.getLong(offset + 11));
196
+        entity.setUpdateTime(cursor.getLong(offset + 12));
197
+        entity.setUser_id(cursor.getInt(offset + 13));
184
      }
198
      }
185
     
199
     
186
     @Override
200
     @Override

+ 20 - 3
MoneyNote_Sqlite/src/main/java/com/kuxuan/sqlite/db/CategoryDB.java

56
     private int type;
56
     private int type;
57
 
57
 
58
     /**
58
     /**
59
+     * 类别图片
60
+     */
61
+    private String image_path;
62
+    /**
59
      * 账单金额
63
      * 账单金额
60
      */
64
      */
61
     private long account;
65
     private long account;
98
 
102
 
99
 
103
 
100
 
104
 
101
-    @Generated(hash = 1281442951)
105
+    @Generated(hash = 708261383)
102
     public CategoryDB(Long id, String bill_id, String demo, String name, int type,
106
     public CategoryDB(Long id, String bill_id, String demo, String name, int type,
103
-            long account, int category_id, int year, int month, int day,
104
-            long createTime, long updateTime, int user_id) {
107
+            String image_path, long account, int category_id, int year, int month,
108
+            int day, long createTime, long updateTime, int user_id) {
105
         this.id = id;
109
         this.id = id;
106
         this.bill_id = bill_id;
110
         this.bill_id = bill_id;
107
         this.demo = demo;
111
         this.demo = demo;
108
         this.name = name;
112
         this.name = name;
109
         this.type = type;
113
         this.type = type;
114
+        this.image_path = image_path;
110
         this.account = account;
115
         this.account = account;
111
         this.category_id = category_id;
116
         this.category_id = category_id;
112
         this.year = year;
117
         this.year = year;
279
         this.user_id = user_id;
284
         this.user_id = user_id;
280
     }
285
     }
281
 
286
 
287
+
288
+
289
+    public String getImage_path() {
290
+        return this.image_path;
291
+    }
292
+
293
+
294
+
295
+    public void setImage_path(String image_path) {
296
+        this.image_path = image_path;
297
+    }
298
+
282
 }
299
 }

+ 13 - 0
app/src/main/java/com/kuxuan/moneynote/db/CategoryDBbean.java

30
      */
30
      */
31
     private int type;
31
     private int type;
32
 
32
 
33
+
34
+    /**
35
+     * 类型图片路径
36
+     */
37
+    private String type_imagepath;
33
     /**
38
     /**
34
      * 账单金额
39
      * 账单金额
35
      */
40
      */
63
     private long updateTime;
68
     private long updateTime;
64
 
69
 
65
 
70
 
71
+    public String getType_imagepath() {
72
+        return type_imagepath;
73
+    }
74
+
75
+    public void setType_imagepath(String type_imagepath) {
76
+        this.type_imagepath = type_imagepath;
77
+    }
78
+
66
     public long getUpdateTime() {
79
     public long getUpdateTime() {
67
         return updateTime;
80
         return updateTime;
68
     }
81
     }

+ 18 - 15
app/src/main/java/com/kuxuan/moneynote/db/CategoryDaoOperator.java

2
 
2
 
3
 import com.kuxuan.moneynote.MyApplication;
3
 import com.kuxuan.moneynote.MyApplication;
4
 import com.kuxuan.moneynote.common.Constant;
4
 import com.kuxuan.moneynote.common.Constant;
5
+import com.kuxuan.moneynote.json.TimeJson;
5
 import com.kuxuan.moneynote.utils.SPUtil;
6
 import com.kuxuan.moneynote.utils.SPUtil;
6
 import com.kuxuan.moneynote.utils.TimeUtlis;
7
 import com.kuxuan.moneynote.utils.TimeUtlis;
7
 import com.kuxuan.sqlite.dao.CategoryDBDao;
8
 import com.kuxuan.sqlite.dao.CategoryDBDao;
57
      * 插入数据
58
      * 插入数据
58
      *
59
      *
59
      * @param categoryDBbean
60
      * @param categoryDBbean
61
+     * @param isSync         是不是网络同步
60
      * @return
62
      * @return
61
      */
63
      */
62
-    public synchronized boolean insert(CategoryDBbean categoryDBbean) {
64
+    public synchronized boolean insert(CategoryDBbean categoryDBbean, boolean isSync) {
63
         start();
65
         start();
64
         boolean isSuccess = false;
66
         boolean isSuccess = false;
65
         CategoryDBDao categoryDBDao = DbManager.getInstance().getmDaoSession().getCategoryDBDao();
67
         CategoryDBDao categoryDBDao = DbManager.getInstance().getmDaoSession().getCategoryDBDao();
75
         }
77
         }
76
         SPUtil.putAndApply(MyApplication.getInstance(), Constant.DbInfo.DB_ID_COUNT, count);
78
         SPUtil.putAndApply(MyApplication.getInstance(), Constant.DbInfo.DB_ID_COUNT, count);
77
         String bill_id = null;
79
         String bill_id = null;
78
-        StringBuilder stringBuilder = new StringBuilder();
79
-        long createTime = categoryDBbean.getCreateTime();
80
-        if (String.valueOf(createTime).length() < 13) {
81
-            createTime = createTime * 1000;
80
+        if (isSync) {
81
+            bill_id = categoryDBbean.getBill_id() + "";
82
+        } else {
83
+            StringBuilder stringBuilder = new StringBuilder();
84
+            TimeJson currentTime = TimeUtlis.getCurrentTimeForhhmmss();
85
+            long createTime = currentTime.getCurrentTime();
86
+            if (String.valueOf(createTime).length() < 13) {
87
+                createTime = createTime * 1000;
88
+            }
89
+            String s = String.valueOf(createTime);
90
+            //毫秒4位数
91
+            String ms = s.substring(s.length() - 4, s.length());
92
+            stringBuilder.append(currentTime.getYear() + "" + currentTime.getMonth() + "" + currentTime.getDay() + currentTime.getHh() + "" + currentTime.getMm() + "" + currentTime.getSs() + ms + ((int) ((Math.random() * 9 + 1) * 1000)));
93
+            bill_id = stringBuilder.toString();
82
         }
94
         }
83
-        String hh_mm_dd = TimeUtlis.getHH_mm_dd(createTime + "");
84
-        String[] hh = hh_mm_dd.split(":");
85
-        String s = String.valueOf(createTime);
86
-        //毫秒4位数
87
-        String ms = s.substring(s.length() - 4, s.length());
88
-
89
-        stringBuilder.append(categoryDBbean.getYear() + "" + categoryDBbean.getMonth() + "" + categoryDBbean.getDay() + hh[0] + "" + hh[1] + "" + hh[2] + ms + ((int) ((Math.random() * 9 + 1) * 1000)));
90
-        bill_id =stringBuilder.toString();
91
-
92
         try {
95
         try {
93
-            CategoryDB categoryDB = new CategoryDB((long) count, bill_id, categoryDBbean.getDemo(), categoryDBbean.getName(), categoryDBbean.getType(), categoryDBbean.getAccount(), categoryDBbean.getCategory_id(), categoryDBbean.getYear(), categoryDBbean.getMonth(), categoryDBbean.getDay(), categoryDBbean.getCreateTime(), categoryDBbean.getUpdateTime(), categoryDBbean.getUser_id());
96
+            CategoryDB categoryDB = new CategoryDB((long) count, bill_id, categoryDBbean.getDemo(), categoryDBbean.getName(), categoryDBbean.getType(), categoryDBbean.getType_imagepath(), categoryDBbean.getAccount(), categoryDBbean.getCategory_id(), categoryDBbean.getYear(), categoryDBbean.getMonth(), categoryDBbean.getDay(), categoryDBbean.getCreateTime(), categoryDBbean.getUpdateTime(), categoryDBbean.getUser_id());
94
             long insert = categoryDBDao.insert(categoryDB);
97
             long insert = categoryDBDao.insert(categoryDB);
95
             isSuccess = true;
98
             isSuccess = true;
96
             onSuccess(insert);
99
             onSuccess(insert);

+ 48 - 0
app/src/main/java/com/kuxuan/moneynote/json/TimeJson.java

12
     private int year;
12
     private int year;
13
     private int month;
13
     private int month;
14
     private int day;
14
     private int day;
15
+    private String hh;
16
+    private String mm;
17
+    private String ss;
18
+    private long currentTime;
19
+
20
+
21
+    public long getCurrentTime() {
22
+        return currentTime;
23
+    }
24
+
25
+    public void setCurrentTime(long currentTime) {
26
+        this.currentTime = currentTime;
27
+    }
28
+
29
+    public TimeJson(int year, int month, int day, String hh, String mm, String ss, long currentTime) {
30
+        this.year = year;
31
+        this.month = month;
32
+        this.day = day;
33
+        this.currentTime = currentTime;
34
+        this.hh = hh;
35
+        this.mm = mm;
36
+        this.ss = ss;
37
+    }
15
 
38
 
16
     public TimeJson(int year, int month, int day) {
39
     public TimeJson(int year, int month, int day) {
17
         this.year = year;
40
         this.year = year;
19
         this.day = day;
42
         this.day = day;
20
     }
43
     }
21
 
44
 
45
+
46
+    public String getHh() {
47
+        return hh;
48
+    }
49
+
50
+    public void setHh(String hh) {
51
+        this.hh = hh;
52
+    }
53
+
54
+    public String getMm() {
55
+        return mm;
56
+    }
57
+
58
+    public void setMm(String mm) {
59
+        this.mm = mm;
60
+    }
61
+
62
+    public String getSs() {
63
+        return ss;
64
+    }
65
+
66
+    public void setSs(String ss) {
67
+        this.ss = ss;
68
+    }
69
+
22
     public int getYear() {
70
     public int getYear() {
23
         return year;
71
         return year;
24
     }
72
     }

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

196
             categoryDBbean.setCreateTime(System.currentTimeMillis());
196
             categoryDBbean.setCreateTime(System.currentTimeMillis());
197
             categoryDBbean.setUpdateTime(System.currentTimeMillis());
197
             categoryDBbean.setUpdateTime(System.currentTimeMillis());
198
             categoryDBbean.setUser_id(-1);
198
             categoryDBbean.setUser_id(-1);
199
-            categoryDaoOperator.insert(categoryDBbean);
199
+            categoryDaoOperator.insert(categoryDBbean,false);
200
         }
200
         }
201
 
201
 
202
         for (int i = 101; i < 150; i++) {
202
         for (int i = 101; i < 150; i++) {
216
             categoryDBbean.setCreateTime(System.currentTimeMillis());
216
             categoryDBbean.setCreateTime(System.currentTimeMillis());
217
             categoryDBbean.setUpdateTime(System.currentTimeMillis());
217
             categoryDBbean.setUpdateTime(System.currentTimeMillis());
218
             categoryDBbean.setUser_id(-1);
218
             categoryDBbean.setUser_id(-1);
219
-            categoryDaoOperator.insert(categoryDBbean);
219
+            categoryDaoOperator.insert(categoryDBbean,false);
220
         }
220
         }
221
 
221
 
222
     }
222
     }

+ 1 - 1
app/src/main/java/com/kuxuan/moneynote/ui/activitys/account/AccountModel.java

118
         Random random = new Random();
118
         Random random = new Random();
119
         int randNumber =random.nextInt(10000 - 1 + 1) + 1;
119
         int randNumber =random.nextInt(10000 - 1 + 1) + 1;
120
         categoryDBbean.setBill_id(1 +randNumber);
120
         categoryDBbean.setBill_id(1 +randNumber);
121
-        boolean insert = CategoryDaoOperator.newInstance().insert(categoryDBbean);
121
+        boolean insert = CategoryDaoOperator.newInstance().insert(categoryDBbean,false);
122
         if (insert) {
122
         if (insert) {
123
             listMVPListener.onSuccess(new Object());
123
             listMVPListener.onSuccess(new Object());
124
         } else {
124
         } else {

+ 12 - 0
app/src/main/java/com/kuxuan/moneynote/utils/TimeUtlis.java

125
     }
125
     }
126
 
126
 
127
 
127
 
128
+    public static TimeJson getCurrentTimeForhhmmss() {
129
+        long currentTimeMillis = System.currentTimeMillis();
130
+        Date date = new Date(currentTimeMillis);
131
+        SimpleDateFormat formatter = new SimpleDateFormat(TIME_FORMAT_FOUR);
132
+        String format = formatter.format(date);
133
+        String[] split = format.split(" ");
134
+        String yearMonthDay = split[0];
135
+        String hhmmss = split[1];
136
+        String[] split1 = yearMonthDay.split("-");
137
+        String[] split2 = hhmmss.split(":");
138
+        return new TimeJson(Integer.parseInt(split1[0]), Integer.parseInt(split1[1]), Integer.parseInt(split1[2]),split2[0],split2[1],split2[2],currentTimeMillis);
128
 
139
 
140
+    }
129
     /**
141
     /**
130
      * 时间戳变成日期
142
      * 时间戳变成日期
131
      * @param s
143
      * @param s