Parcourir la Source

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

e il y a 6 ans
Parent
commit
77438d418a
36 fichiers modifiés avec 713 ajouts et 262 suppressions
  1. 1 0
      MoneyNote_Sqlite/proguard-rules.pro
  2. 20 0
      MoneyNote_Sqlite/src/main/java/com/kuxuan/sqlite/dao/TestActivity.java
  3. 10 1
      app/proguard-rules.pro
  4. 1 1
      app/src/main/assets/categore.txt
  5. 3 2
      app/src/main/java/com/kuxuan/moneynote/common/Constant.java
  6. 59 31
      app/src/main/java/com/kuxuan/moneynote/db/CategoryDaoOperator.java
  7. 15 5
      app/src/main/java/com/kuxuan/moneynote/db/UpDataOperator.java
  8. 72 0
      app/src/main/java/com/kuxuan/moneynote/json/BillTypeJson.java
  9. 9 9
      app/src/main/java/com/kuxuan/moneynote/json/ReportJson.java
  10. 3 3
      app/src/main/java/com/kuxuan/moneynote/json/TimeDataJson.java
  11. 20 1
      app/src/main/java/com/kuxuan/moneynote/json/UpJson.java
  12. 14 4
      app/src/main/java/com/kuxuan/moneynote/servier/DownLoadService.java
  13. 28 21
      app/src/main/java/com/kuxuan/moneynote/ui/activitys/LunchActivity.java
  14. 12 4
      app/src/main/java/com/kuxuan/moneynote/ui/activitys/MainActivity.java
  15. 1 0
      app/src/main/java/com/kuxuan/moneynote/ui/activitys/account/AccountActivity.java
  16. 17 0
      app/src/main/java/com/kuxuan/moneynote/ui/activitys/account/AccountPresenter.java
  17. 8 1
      app/src/main/java/com/kuxuan/moneynote/ui/activitys/edit/EditBillActivity.java
  18. 15 2
      app/src/main/java/com/kuxuan/moneynote/ui/activitys/login/LoginActivity.java
  19. 14 5
      app/src/main/java/com/kuxuan/moneynote/ui/activitys/login/PhoneLoginActivity.java
  20. 7 0
      app/src/main/java/com/kuxuan/moneynote/ui/activitys/person/PersonActivity.java
  21. 2 3
      app/src/main/java/com/kuxuan/moneynote/ui/adapter/DetialAdapter.java
  22. 26 25
      app/src/main/java/com/kuxuan/moneynote/ui/adapter/ReportAdapter.java
  23. 2 2
      app/src/main/java/com/kuxuan/moneynote/ui/fragments/details/DetialDBOpertor.java
  24. 48 14
      app/src/main/java/com/kuxuan/moneynote/ui/fragments/details/DetialPresent.java
  25. 3 3
      app/src/main/java/com/kuxuan/moneynote/ui/fragments/reportsingle/ReportSingleDBOpertor.java
  26. 1 0
      app/src/main/java/com/kuxuan/moneynote/ui/fragments/reportsingle/ReportSingleFragment.java
  27. 90 29
      app/src/main/java/com/kuxuan/moneynote/ui/fragments/reportsingle/ReportSingleModel.java
  28. 72 18
      app/src/main/java/com/kuxuan/moneynote/ui/fragments/reportsingle/ReportSinglePresent.java
  29. 14 8
      app/src/main/java/com/kuxuan/moneynote/ui/weight/ChartPop.java
  30. 19 7
      app/src/main/java/com/kuxuan/moneynote/ui/weight/MoneyChoosePop.java
  31. 90 52
      app/src/main/java/com/kuxuan/moneynote/utils/CalanderUtil.java
  32. 11 7
      app/src/main/java/com/kuxuan/moneynote/utils/JavaFormatUtils.java
  33. 1 1
      app/src/main/java/com/kuxuan/moneynote/utils/TimeUtlis.java
  34. 2 0
      app/src/main/java/com/kuxuan/moneynote/utils/Tools.java
  35. 1 1
      app/src/main/res/layout/pop_chart_layout.xml
  36. 2 2
      build.gradle

+ 1 - 0
MoneyNote_Sqlite/proguard-rules.pro

@@ -19,3 +19,4 @@
19 19
 # If you keep the line number information, uncomment this to
20 20
 # hide the original source file name.
21 21
 #-renamesourcefileattribute SourceFile
22
+

+ 20 - 0
MoneyNote_Sqlite/src/main/java/com/kuxuan/sqlite/dao/TestActivity.java

@@ -0,0 +1,20 @@
1
+package com.kuxuan.sqlite.dao;
2
+
3
+import android.os.Bundle;
4
+import android.support.annotation.Nullable;
5
+import android.support.v7.app.AppCompatActivity;
6
+
7
+import com.kuxuan.sqlite.R;
8
+
9
+/**
10
+ * Created by xieshengqi on 2018/4/13.
11
+ */
12
+
13
+public class TestActivity extends AppCompatActivity {
14
+
15
+
16
+    @Override
17
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
18
+        super.onCreate(savedInstanceState);
19
+    }
20
+}

+ 10 - 1
app/proguard-rules.pro

@@ -291,7 +291,8 @@ public static final int *;
291 291
 -keep public class * extends com.kuxuan.moneynote.base.mvpbase.MvpFragmentActivity
292 292
 -keep public class * extends com.kuxuan.moneynote.base.BaseViewHolder
293 293
 
294
--keep class com.kuxuan.monrynote.base.**{*;}
294
+-keep class com.kuxuan.moneynote.base.**{*;}
295
+-keep class com.kuxuan.moneynote.db.**{*;}
295 296
 
296 297
 
297 298
 -dontshrink
@@ -386,6 +387,14 @@ public static final int *;
386 387
 -keepattributes Signature
387 388
 #greendao3.2.0,此是针对3.2.0,如果是之前的,可能需要更换下包名
388 389
 -keep class org.greenrobot.greendao.**{*;}
390
+
391
+-keep public class * extends org.greenrobot.greendao.AbstractDao
392
+
389 393
 -keepclassmembers class * extends org.greenrobot.greendao.AbstractDao {
390 394
 public static java.lang.String TABLENAME;
391 395
 }
396
+
397
+-keep class **$Properties
398
+
399
+-keepclassmembers class **$Properties {*;}
400
+

Fichier diff supprimé car celui-ci est trop grand
+ 1 - 1
app/src/main/assets/categore.txt


+ 3 - 2
app/src/main/java/com/kuxuan/moneynote/common/Constant.java

@@ -9,9 +9,10 @@ public class Constant {
9 9
     //手机号正则,11位手机号
10 10
     public static final String REGEX_MOBILE = "[1][3,4,5,7,8][0-9]{9}$";
11 11
     //测试接口
12
-    public static final String BASE_URL = "http://bill.quyaqu.com/api/";
12
+//    public static final String BASE_URL = "http://bill.quyaqu.com/api/";
13
+//    public static final String BASE_URL = "http://web6.money.726p.com/api/";
13 14
     //正式
14
-//    public static final String BASE_URL = "https://apimoney.726p.com/api/";
15
+    public static final String BASE_URL = "https://apimoney.726p.com/api/";
15 16
     //    public static final String BASE_URL = "http://api.money.quyaqu.com/api/";
16 17
     public static final String MD5 = "b4b80c2676828f1df375684100f56d48";
17 18
 

+ 59 - 31
app/src/main/java/com/kuxuan/moneynote/db/CategoryDaoOperator.java

@@ -96,7 +96,21 @@ public class CategoryDaoOperator {
96 96
             String s = String.valueOf(createTime);
97 97
             //毫秒4位数
98 98
             String ms = s.substring(s.length() - 4, s.length());
99
-            stringBuilder.append(currentTime.getYear() + "" + currentTime.getMonth() + "" + currentTime.getDay() + currentTime.getHh() + "" + currentTime.getMm() + "" + currentTime.getSs() + ms + ((int) ((Math.random() * 9 + 1) * 1000)));
99
+            int month = currentTime.getMonth();
100
+            int day = currentTime.getDay();
101
+            String stringMonth = null;
102
+            String stringDay = null;
103
+            if (month < 10) {
104
+                stringMonth = "0" + month;
105
+            } else {
106
+                stringMonth = month + "";
107
+            }
108
+            if (day < 10) {
109
+                stringDay = "0" + day;
110
+            } else {
111
+                stringDay = day + "";
112
+            }
113
+            stringBuilder.append(currentTime.getYear() + "" + stringMonth + "" + stringDay + currentTime.getHh() + "" + currentTime.getMm() + "" + currentTime.getSs() + ms + ((int) ((Math.random() * 9 + 1) * 1000)));
100 114
             bill_id = stringBuilder.toString();
101 115
         }
102 116
         try {
@@ -199,8 +213,7 @@ public class CategoryDaoOperator {
199 213
         category.setDay(categoryDBbean.getDay());
200 214
         category.setMonth(categoryDBbean.getMonth());
201 215
         category.setYear(categoryDBbean.getYear());
202
-        category.setCreateTime(categoryDBbean.getCreateTime());
203
-        category.setUpdateTime(categoryDBbean.getCreateTime());
216
+        category.setUpdateTime(categoryDBbean.getUpdateTime());
204 217
         categoryDBDao.update(category);
205 218
         onSuccess(SUCCESS);
206 219
     }
@@ -219,6 +232,18 @@ public class CategoryDaoOperator {
219 232
     }
220 233
 
221 234
     /**
235
+     * 设置数据库数据需要同步
236
+     *
237
+     * @param bill_id
238
+     */
239
+    public synchronized void updataNeedSynce(String bill_id) {
240
+        CategoryDB category = getCategory(bill_id);
241
+        category.setIsNeedSync(true);
242
+        category.setUser_id(LoginStatusUtil.getLoginUserId());
243
+        DbManager.getInstance().getmDaoSession().getCategoryDBDao().update(category);
244
+    }
245
+
246
+    /**
222 247
      * 设置此项是否为删除项
223 248
      *
224 249
      * @param bill_id
@@ -240,7 +265,10 @@ public class CategoryDaoOperator {
240 265
      */
241 266
     public synchronized void deleteData(String bill_id) {
242 267
         start();
243
-        DbManager.getInstance().getmDaoSession().getCategoryDBDao().delete(getCategory(bill_id));
268
+        try {
269
+            DbManager.getInstance().getmDaoSession().getCategoryDBDao().delete(getCategory(bill_id));
270
+        } catch (Exception e) {
271
+        }
244 272
         onSuccess(SUCCESS);
245 273
     }
246 274
 
@@ -276,48 +304,47 @@ public class CategoryDaoOperator {
276 304
         int endDay = 1;
277 305
         if (startYear == endYear) {
278 306
             List<CategoryDB> monthLists = null;
279
-            if(category_id!=-1){
280
-
281
-             monthLists = getQuilder().where(CategoryDBDao.Properties.Year.eq(startYear), CategoryDBDao.Properties.Category_id.eq(category_id)).orderAsc(CategoryDBDao.Properties.Month).list();
282
-            }else{
283
-             monthLists = getQuilder().where(CategoryDBDao.Properties.Year.eq(startYear)).orderAsc(CategoryDBDao.Properties.Month).list();
307
+            if (category_id != -1) {
308
+                monthLists = getQuilder().where(CategoryDBDao.Properties.Type.eq(type),CategoryDBDao.Properties.Year.eq(startYear), CategoryDBDao.Properties.Category_id.eq(category_id)).orderAsc(CategoryDBDao.Properties.Month).list();
309
+            } else {
310
+                monthLists = getQuilder().where(CategoryDBDao.Properties.Type.eq(type),CategoryDBDao.Properties.Year.eq(startYear)).orderAsc(CategoryDBDao.Properties.Month).list();
284 311
             }
285 312
             startMonth = monthLists.get(0).getMonth();
286 313
             endMonth = monthLists.get(monthLists.size() - 1).getMonth();
287 314
         } else {
288 315
             List<CategoryDB> monthLists1 = null;
289
-            if(category_id!=-1){
290
-                monthLists1 = getQuilder().where(CategoryDBDao.Properties.Year.eq(startYear),CategoryDBDao.Properties.Category_id.eq(category_id)).orderAsc(CategoryDBDao.Properties.Month).list();
316
+            if (category_id != -1) {
317
+                monthLists1 = getQuilder().where(CategoryDBDao.Properties.Type.eq(type),CategoryDBDao.Properties.Year.eq(startYear), CategoryDBDao.Properties.Category_id.eq(category_id)).orderAsc(CategoryDBDao.Properties.Month).list();
291 318
 
292
-            }else{
293
-                monthLists1 = getQuilder().where(CategoryDBDao.Properties.Year.eq(startYear)).orderAsc(CategoryDBDao.Properties.Month).list();
319
+            } else {
320
+                monthLists1 = getQuilder().where(CategoryDBDao.Properties.Type.eq(type),CategoryDBDao.Properties.Year.eq(startYear)).orderAsc(CategoryDBDao.Properties.Month).list();
294 321
 
295 322
             }
296 323
             startMonth = monthLists1.get(0).getMonth();
297 324
             List<CategoryDB> monthLists2 = null;
298
-            if(category_id!=-1){
299
-                monthLists2 = getQuilder().where(CategoryDBDao.Properties.Year.eq(endYear),CategoryDBDao.Properties.Category_id.eq(category_id)).orderAsc(CategoryDBDao.Properties.Month).list();
325
+            if (category_id != -1) {
326
+                monthLists2 = getQuilder().where(CategoryDBDao.Properties.Type.eq(type),CategoryDBDao.Properties.Year.eq(endYear), CategoryDBDao.Properties.Category_id.eq(category_id)).orderAsc(CategoryDBDao.Properties.Month).list();
300 327
 
301
-            }else{
302
-                monthLists2 = getQuilder().where(CategoryDBDao.Properties.Year.eq(endYear)).orderAsc(CategoryDBDao.Properties.Month).list();
328
+            } else {
329
+                monthLists2 = getQuilder().where(CategoryDBDao.Properties.Type.eq(type),CategoryDBDao.Properties.Year.eq(endYear)).orderAsc(CategoryDBDao.Properties.Month).list();
303 330
 
304 331
             }
305 332
             endMonth = monthLists2.get(monthLists2.size() - 1).getMonth();
306 333
         }
307 334
         //查找开始日期和结束日期
308 335
         List<CategoryDB> daylist1 = null;
309
-        if(category_id!=-1){
310
-         daylist1 = getQuilder().where(CategoryDBDao.Properties.Year.eq(startYear), CategoryDBDao.Properties.Month.eq(startMonth),CategoryDBDao.Properties.Category_id.eq(category_id)).orderAsc(CategoryDBDao.Properties.Day).list();
311
-        }else{
312
-      daylist1 = getQuilder().where(CategoryDBDao.Properties.Year.eq(startYear), CategoryDBDao.Properties.Month.eq(startMonth)).orderAsc(CategoryDBDao.Properties.Day).list();
336
+        if (category_id != -1) {
337
+            daylist1 = getQuilder().where(CategoryDBDao.Properties.Type.eq(type),CategoryDBDao.Properties.Year.eq(startYear), CategoryDBDao.Properties.Month.eq(startMonth), CategoryDBDao.Properties.Category_id.eq(category_id)).orderAsc(CategoryDBDao.Properties.Day).list();
338
+        } else {
339
+            daylist1 = getQuilder().where(CategoryDBDao.Properties.Type.eq(type),CategoryDBDao.Properties.Year.eq(startYear), CategoryDBDao.Properties.Month.eq(startMonth)).orderAsc(CategoryDBDao.Properties.Day).list();
313 340
 
314 341
         }
315 342
         startDay = daylist1.get(0).getDay();
316 343
         List<CategoryDB> daylist2 = null;
317
-        if(category_id!=-1){
318
-        daylist2 = getQuilder().where(CategoryDBDao.Properties.Year.eq(endYear), CategoryDBDao.Properties.Month.eq(endMonth),CategoryDBDao.Properties.Category_id.eq(category_id)).orderAsc(CategoryDBDao.Properties.Day).list();
319
-        }else{
320
-        daylist2 = getQuilder().where(CategoryDBDao.Properties.Year.eq(endYear), CategoryDBDao.Properties.Month.eq(endMonth)).orderAsc(CategoryDBDao.Properties.Day).list();
344
+        if (category_id != -1) {
345
+            daylist2 = getQuilder().where(CategoryDBDao.Properties.Type.eq(type),CategoryDBDao.Properties.Year.eq(endYear), CategoryDBDao.Properties.Month.eq(endMonth), CategoryDBDao.Properties.Category_id.eq(category_id)).orderAsc(CategoryDBDao.Properties.Day).list();
346
+        } else {
347
+            daylist2 = getQuilder().where(CategoryDBDao.Properties.Type.eq(type),CategoryDBDao.Properties.Year.eq(endYear), CategoryDBDao.Properties.Month.eq(endMonth)).orderAsc(CategoryDBDao.Properties.Day).list();
321 348
 
322 349
         }
323 350
         endDay = daylist2.get(daylist2.size() - 1).getDay();
@@ -357,19 +384,19 @@ public class CategoryDaoOperator {
357 384
         int startDay = 1;
358 385
         int endDay = 1;
359 386
         if (startYear == endYear) {
360
-            List<CategoryDB> monthLists = categoryDBDao.queryBuilder().where(CategoryDBDao.Properties.Year.eq(startYear)).orderAsc(CategoryDBDao.Properties.Month).list();
387
+            List<CategoryDB> monthLists = getQuilder().where(CategoryDBDao.Properties.Year.eq(startYear)).orderAsc(CategoryDBDao.Properties.Month).list();
361 388
             startMonth = monthLists.get(0).getMonth();
362 389
             endMonth = monthLists.get(monthLists.size() - 1).getMonth();
363 390
         } else {
364
-            List<CategoryDB> monthLists1 = categoryDBDao.queryBuilder().where(CategoryDBDao.Properties.Year.eq(startYear)).orderAsc(CategoryDBDao.Properties.Month).list();
391
+            List<CategoryDB> monthLists1 = getQuilder().where(CategoryDBDao.Properties.Year.eq(startYear)).orderAsc(CategoryDBDao.Properties.Month).list();
365 392
             startMonth = monthLists1.get(0).getMonth();
366
-            List<CategoryDB> monthLists2 = categoryDBDao.queryBuilder().where(CategoryDBDao.Properties.Year.eq(endYear)).orderAsc(CategoryDBDao.Properties.Month).list();
393
+            List<CategoryDB> monthLists2 = getQuilder().where(CategoryDBDao.Properties.Year.eq(endYear)).orderAsc(CategoryDBDao.Properties.Month).list();
367 394
             endMonth = monthLists2.get(monthLists2.size() - 1).getMonth();
368 395
         }
369 396
         //查找开始日期和结束日期
370
-        List<CategoryDB> daylist1 = categoryDBDao.queryBuilder().where(CategoryDBDao.Properties.Year.eq(startYear), CategoryDBDao.Properties.Month.eq(startMonth)).orderAsc(CategoryDBDao.Properties.Day).list();
397
+        List<CategoryDB> daylist1 = getQuilder().where(CategoryDBDao.Properties.Year.eq(startYear), CategoryDBDao.Properties.Month.eq(startMonth)).orderAsc(CategoryDBDao.Properties.Day).list();
371 398
         startDay = daylist1.get(0).getDay();
372
-        List<CategoryDB> daylist2 = categoryDBDao.queryBuilder().where(CategoryDBDao.Properties.Year.eq(endYear), CategoryDBDao.Properties.Month.eq(endMonth)).orderAsc(CategoryDBDao.Properties.Day).list();
399
+        List<CategoryDB> daylist2 = getQuilder().where(CategoryDBDao.Properties.Year.eq(endYear), CategoryDBDao.Properties.Month.eq(endMonth)).orderAsc(CategoryDBDao.Properties.Day).list();
373 400
         endDay = daylist2.get(daylist2.size() - 1).getDay();
374 401
 
375 402
         map.put("startYear", startYear);
@@ -442,6 +469,7 @@ public class CategoryDaoOperator {
442 469
 
443 470
     /**
444 471
      * 我的界面获取某月数据
472
+     *
445 473
      * @param year
446 474
      * @param month
447 475
      * @return
@@ -539,7 +567,7 @@ public class CategoryDaoOperator {
539 567
      * @return
540 568
      */
541 569
     public ArrayList<CategoryDB> getCategoryForDay(int year, int monnth, int day) {
542
-        List<CategoryDB> list = getQuilder().where(CategoryDBDao.Properties.Year.eq(year), CategoryDBDao.Properties.Month.eq(monnth), CategoryDBDao.Properties.Day.eq(day)).list();
570
+        List<CategoryDB> list = getQuilder().where(CategoryDBDao.Properties.Year.eq(year), CategoryDBDao.Properties.Month.eq(monnth), CategoryDBDao.Properties.Day.eq(day)).orderAsc(CategoryDBDao.Properties.UpdateTime).list();
543 571
         return (ArrayList<CategoryDB>) list;
544 572
     }
545 573
 

+ 15 - 5
app/src/main/java/com/kuxuan/moneynote/db/UpDataOperator.java

@@ -49,11 +49,21 @@ public class UpDataOperator {
49 49
             uploadDbjson.setDemo(categoryDB.getDemo());
50 50
             uploadDbjson.setIdentification(categoryDB.getBill_id());
51 51
             uploadDbjson.setStatus(categoryDB.getStatus() + "");
52
-            String times = categoryDB.getCreateTime()+"";
53
-            if(times.length()>=13){
54
-            uploadDbjson.setTime(categoryDB.getCreateTime()/1000+"");
55
-            }else{
56
-            uploadDbjson.setTime(categoryDB.getCreateTime()+"");
52
+            String createTime = categoryDB.getCreateTime() + "";
53
+            String updateTime = categoryDB.getUpdateTime() + "";
54
+            if (createTime.length() >= 13) {
55
+                uploadDbjson.setTime(categoryDB.getCreateTime() / 1000 + "");
56
+                uploadDbjson.setCreated_at(categoryDB.getCreateTime() / 1000 + "");
57
+            } else {
58
+                uploadDbjson.setTime(categoryDB.getCreateTime() + "");
59
+                uploadDbjson.setCreated_at(categoryDB.getCreateTime() + "");
60
+            }
61
+            if (updateTime.length() >= 13) {
62
+                uploadDbjson.setUpdated_at(categoryDB.getUpdateTime() / 1000 + "");
63
+                uploadDbjson.setTime(categoryDB.getUpdateTime() / 1000 + "");
64
+            } else {
65
+                uploadDbjson.setUpdated_at(categoryDB.getUpdateTime() + "");
66
+                uploadDbjson.setTime(categoryDB.getUpdateTime() + "");
57 67
             }
58 68
             uploadDbjson.setUser_id(LoginStatusUtil.getLoginUserId());
59 69
             uploadDbjson.setType(categoryDB.getType() + "");

+ 72 - 0
app/src/main/java/com/kuxuan/moneynote/json/BillTypeJson.java

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

+ 9 - 9
app/src/main/java/com/kuxuan/moneynote/json/ReportJson.java

@@ -14,11 +14,11 @@ public class ReportJson implements Serializable ,Comparable<ReportJson>{
14 14
 
15 15
     private String name;
16 16
     //收入
17
-    private long inmoney;
17
+    private double inmoney;
18 18
     //支出
19
-    private long outmoney;
19
+    private double outmoney;
20 20
 
21
-    private long allMoney;
21
+    private double allMoney;
22 22
     private String url;
23 23
     //收入还是支出
24 24
     private boolean isOut;
@@ -60,27 +60,27 @@ public class ReportJson implements Serializable ,Comparable<ReportJson>{
60 60
         this.name = name;
61 61
     }
62 62
 
63
-    public float getInmoney() {
63
+    public double getInmoney() {
64 64
         return inmoney;
65 65
     }
66 66
 
67
-    public void setInmoney(long inmoney) {
67
+    public void setInmoney(double inmoney) {
68 68
         this.inmoney = inmoney;
69 69
     }
70 70
 
71
-    public float getOutmoney() {
71
+    public double getOutmoney() {
72 72
         return outmoney;
73 73
     }
74 74
 
75
-    public void setOutmoney(long outmoney) {
75
+    public void setOutmoney(double outmoney) {
76 76
         this.outmoney = outmoney;
77 77
     }
78 78
 
79
-    public float getAllMoney() {
79
+    public double getAllMoney() {
80 80
         return allMoney;
81 81
     }
82 82
 
83
-    public void setAllMoney(long allMoney) {
83
+    public void setAllMoney(double allMoney) {
84 84
         this.allMoney = allMoney;
85 85
     }
86 86
 

+ 3 - 3
app/src/main/java/com/kuxuan/moneynote/json/TimeDataJson.java

@@ -15,7 +15,7 @@ public class TimeDataJson implements Serializable{
15 15
      * day : 2017-10-23
16 16
      */
17 17
 
18
-    private float account;
18
+    private double account;
19 19
     private String time;
20 20
     private ArrayList<PopCharData> data;
21 21
 
@@ -36,11 +36,11 @@ public class TimeDataJson implements Serializable{
36 36
         this.data = data;
37 37
     }
38 38
 
39
-    public float getAccount() {
39
+    public double getAccount() {
40 40
         return account;
41 41
     }
42 42
 
43
-    public void setAccount(int account) {
43
+    public void setAccount(double account) {
44 44
         this.account = account;
45 45
     }
46 46
 

+ 20 - 1
app/src/main/java/com/kuxuan/moneynote/json/UpJson.java

@@ -6,7 +6,7 @@ import java.io.Serializable;
6 6
  * Created by xieshengqi on 2018/4/8.
7 7
  */
8 8
 
9
-public class UpJson implements Serializable{
9
+public class UpJson implements Serializable {
10 10
 
11 11
 
12 12
     /**
@@ -30,6 +30,25 @@ public class UpJson implements Serializable{
30 30
     private String category_id;
31 31
     private String type;
32 32
     private int user_id;
33
+    private String created_at;
34
+    private String updated_at;
35
+
36
+
37
+    public String getCreated_at() {
38
+        return created_at;
39
+    }
40
+
41
+    public void setCreated_at(String created_at) {
42
+        this.created_at = created_at;
43
+    }
44
+
45
+    public String getUpdated_at() {
46
+        return updated_at;
47
+    }
48
+
49
+    public void setUpdated_at(String updated_at) {
50
+        this.updated_at = updated_at;
51
+    }
33 52
 
34 53
     public String getIdentification() {
35 54
         return identification;

+ 14 - 4
app/src/main/java/com/kuxuan/moneynote/servier/DownLoadService.java

@@ -62,8 +62,8 @@ public class DownLoadService extends Service {
62 62
 
63 63
     @Override
64 64
     public void onDestroy() {
65
-        if(alarmManager!=null)
66
-        alarmManager.cancel(pIntent);//关闭的服务的时候同时关闭广播注册者
65
+        if (alarmManager != null)
66
+            alarmManager.cancel(pIntent);//关闭的服务的时候同时关闭广播注册者
67 67
         super.onDestroy();
68 68
     }
69 69
 
@@ -131,8 +131,18 @@ public class DownLoadService extends Service {
131 131
             categoryDBbean.setCategory_id(uploadDbjson.getCategory_id());
132 132
             categoryDBbean.setDemo(uploadDbjson.getDemo());
133 133
             long time = uploadDbjson.getTime() * 1000;
134
-            categoryDBbean.setCreateTime(uploadDbjson.getTime());
135
-            categoryDBbean.setUpdateTime(uploadDbjson.getTime());
134
+            long create_time = uploadDbjson.getCreated_at() * 1000;
135
+            long updata_time = uploadDbjson.getUpdated_at() * 1000;
136
+            if (create_time == 0) {
137
+                categoryDBbean.setCreateTime(uploadDbjson.getTime());
138
+            } else {
139
+                categoryDBbean.setCreateTime(create_time);
140
+            }
141
+            if (updata_time == 0) {
142
+                categoryDBbean.setUpdateTime(time);
143
+            } else {
144
+                categoryDBbean.setUpdateTime(updata_time);
145
+            }
136 146
             String data = TimeUtlis.getData(time);
137 147
             String[] split = data.split("-");
138 148
             categoryDBbean.setYear(Integer.parseInt(split[0]));

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

@@ -7,20 +7,26 @@ import android.view.View;
7 7
 import android.view.WindowManager;
8 8
 
9 9
 import com.google.gson.Gson;
10
+import com.google.gson.reflect.TypeToken;
10 11
 import com.kuxuan.moneynote.R;
11 12
 import com.kuxuan.moneynote.common.Constant;
12 13
 import com.kuxuan.moneynote.db.BillCategoreDaoOperator;
13
-import com.kuxuan.moneynote.db.CategoryDBJson;
14
+import com.kuxuan.moneynote.json.BillTypeJson;
14 15
 import com.kuxuan.moneynote.ui.activitys.eventbus.LoginOutEvent;
15 16
 import com.kuxuan.moneynote.ui.activitys.login.LoginActivity;
16 17
 import com.kuxuan.moneynote.utils.LoginStatusUtil;
17 18
 import com.kuxuan.moneynote.utils.SPUtil;
18 19
 import com.kuxuan.moneynote.utils.Tools;
19 20
 import com.kuxuan.moneynote.utils.UIHelper;
21
+import com.kuxuan.sqlite.db.BillCategoreDB;
20 22
 import com.umeng.analytics.MobclickAgent;
21 23
 
22 24
 import org.greenrobot.eventbus.EventBus;
23 25
 
26
+import java.lang.reflect.Type;
27
+import java.util.ArrayList;
28
+import java.util.List;
29
+
24 30
 /**
25 31
  * Created by xieshengqi on 2017/10/30.
26 32
  */
@@ -77,9 +83,9 @@ public class LunchActivity extends Activity {
77 83
 
78 84
     private void goMain() {
79 85
 
80
-        boolean isInsert= (boolean) SPUtil.get(getApplicationContext(),Constant.CategoreyDBConstant.ISINSERT,false);
86
+        boolean isInsert = (boolean) SPUtil.get(getApplicationContext(), Constant.CategoreyDBConstant.ISINSERT, false);
81 87
 
82
-        if(!isInsert){
88
+        if (!isInsert) {
83 89
             initBillCategore();
84 90
 
85 91
         }
@@ -88,8 +94,8 @@ public class LunchActivity extends Activity {
88 94
 //            LoginStatusUtil.loginOut();
89 95
 //            EventBus.getDefault().post(new LoginOutEvent());
90 96
 //        }
91
-        SPUtil.remove(getApplicationContext(),Constant.IsFirstWEiChatLogin.ISWECHATNEWUSERFIRSTLOGIN);
92
-        if((Boolean) SPUtil.get(this, Constant.IsFirstWEiChatLogin.ISWEICHATLOGIN,false)&&(Boolean) SPUtil.get(this,Constant.IsFirstWEiChatLogin.IsLoginOut,false)){
97
+        SPUtil.remove(getApplicationContext(), Constant.IsFirstWEiChatLogin.ISWECHATNEWUSERFIRSTLOGIN);
98
+        if ((Boolean) SPUtil.get(this, Constant.IsFirstWEiChatLogin.ISWEICHATLOGIN, false) && (Boolean) SPUtil.get(this, Constant.IsFirstWEiChatLogin.IsLoginOut, false)) {
93 99
             LoginStatusUtil.loginOut();
94 100
             EventBus.getDefault().post(new LoginOutEvent());
95 101
         }
@@ -128,29 +134,30 @@ public class LunchActivity extends Activity {
128 134
 
129 135
 
130 136
     BillCategoreDaoOperator billCategoreDaoOperator;
137
+
131 138
     private void initBillCategore() {
132 139
 
133
-      billCategoreDaoOperator = BillCategoreDaoOperator.newInstance();
140
+        billCategoreDaoOperator = BillCategoreDaoOperator.newInstance();
134 141
 
135
-        String json = Tools.getJson("categore.txt",getApplicationContext());
142
+        String json = Tools.getJson("categore.txt", getApplicationContext());
136 143
 
137 144
         Gson gson = new Gson();
138
-
139
-        CategoryDBJson categoryDBJson = gson.fromJson(json, CategoryDBJson.class);
140
-
141
-        for(int i=0;i<=36;i++){
142
-
143
-            categoryDBJson.getSystem().get(i).setIcon("file:///android_asset/icon_"+i+".png");
144
-            categoryDBJson.getSystem().get(i).setSelected_icon("file:///android_asset/selected_icon_"+i+".png");
145
-            categoryDBJson.getSystem().get(i).setDetail_icon("file:///android_asset/detail_icon_"+i+".png");
146
-
145
+        Type tp = new TypeToken<List<BillTypeJson>>() {
146
+        }.getType();
147
+        List<BillTypeJson> categoryDBJson = gson.fromJson(json, tp);
148
+        List<BillCategoreDB> categoreDBS = new ArrayList<>();
149
+        if(categoreDBS!=null){
150
+        for (int i = 0; i < categoryDBJson.size(); i++) {
151
+            BillTypeJson billCategoreDB = categoryDBJson.get(i);
152
+            billCategoreDB.setIcon("file:///android_asset/icon_" + i + ".png");
153
+            billCategoreDB.setSelected_icon("file:///android_asset/selected_icon_" + i + ".png");
154
+            billCategoreDB.setDetail_icon("file:///android_asset/detail_icon_" + i + ".png");
155
+            categoreDBS.add(new BillCategoreDB(billCategoreDB.getId(),billCategoreDB.getCategory_type(),billCategoreDB.getIcon(),billCategoreDB.getSelected_icon(),billCategoreDB.getDetail_icon(),billCategoreDB.getName(),billCategoreDB.getType()));
147 156
         }
148
-
149
-        billCategoreDaoOperator.insertList(categoryDBJson.getSystem());
150
-
151
-        SPUtil.putAndApply(getApplicationContext(),Constant.CategoreyDBConstant.ISINSERT,true);
157
+        billCategoreDaoOperator.insertList(categoreDBS);
158
+        }
159
+        SPUtil.putAndApply(getApplicationContext(), Constant.CategoreyDBConstant.ISINSERT, true);
152 160
     }
153 161
 
154 162
 
155
-
156 163
 }

+ 12 - 4
app/src/main/java/com/kuxuan/moneynote/ui/activitys/MainActivity.java

@@ -45,6 +45,16 @@ public class MainActivity extends BaseFragmentActivity {
45 45
     @Override
46 46
     protected void onCreate(Bundle savedInstanceState) {
47 47
         super.onCreate(savedInstanceState);
48
+        //更新版本的时候判断这个值
49
+        if (LoginStatusUtil.isLoginin()) {
50
+            if (LoginStatusUtil.getLoginUserId() == -1) {
51
+                //退出登录,首次离线记账
52
+                LoginStatusUtil.loginOut();
53
+            } else {
54
+                ServiceUtil.startDownLoadData(this);
55
+                ServiceUtil.startUpData(this);
56
+            }
57
+        }
48 58
 //        getTitleView(0).setTitle(getResources().getString(R.string.app_name));
49 59
         navigationLayout.setListener(new NavigationLayout.OnItemClickListener() {
50 60
             @Override
@@ -69,10 +79,8 @@ public class MainActivity extends BaseFragmentActivity {
69 79
             }
70 80
         });
71 81
         initFragments();
72
-        //开启上传服务
73
-        if (LoginStatusUtil.isLoginin()) {
74
-            ServiceUtil.startUpData(this);
75
-        }
82
+        //开启上传服务(更新的时候)
83
+
76 84
     }
77 85
 
78 86
 

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

@@ -170,6 +170,7 @@ public class AccountActivity extends MVPFragmentActivity<AccountPresenter, Accou
170 170
                 showPop();
171 171
             }
172 172
         });
173
+        mPresenter.setmContext(this);
173 174
 
174 175
 
175 176
         if(onLine==0) {

+ 17 - 0
app/src/main/java/com/kuxuan/moneynote/ui/activitys/account/AccountPresenter.java

@@ -22,6 +22,7 @@ import com.kuxuan.moneynote.listener.MVPListener;
22 22
 import com.kuxuan.moneynote.ui.activitys.category.CategoryActivity;
23 23
 import com.kuxuan.moneynote.ui.adapter.AccountAdapter;
24 24
 import com.kuxuan.moneynote.utils.LoginStatusUtil;
25
+import com.kuxuan.moneynote.utils.NetWorkUtil;
25 26
 import com.kuxuan.moneynote.utils.UIHelper;
26 27
 import com.kuxuan.sqlite.db.CategoryDB;
27 28
 
@@ -43,6 +44,11 @@ public class AccountPresenter extends AccountContract.AccountPresent {
43 44
     int a[] = new int[]{Integer.MAX_VALUE, Integer.MAX_VALUE};
44 45
     private static final String TAG = "AccountPresenter";
45 46
 
47
+
48
+    public void setmContext(Context mContext) {
49
+        this.mContext = mContext;
50
+    }
51
+
46 52
     @Override
47 53
     protected void initRecyclerView(final Context context, final RecyclerView recyclerView, int type, final ClickListener mClickListener) {
48 54
         mContext = context;
@@ -124,6 +130,7 @@ public class AccountPresenter extends AccountContract.AccountPresent {
124 130
 
125 131
                 if (LoginStatusUtil.isLoginin()) {
126 132
                     //同步一下
133
+
127 134
                     syncForAdd();
128 135
                 } else {
129 136
                     view.hideProgress();
@@ -141,6 +148,11 @@ public class AccountPresenter extends AccountContract.AccountPresent {
141 148
 
142 149
     private void syncForUpdata(final BillBody billBody) {
143 150
         if (LoginStatusUtil.isLoginin()) {
151
+            if (!NetWorkUtil.isNetworkAvailable(mContext.getApplicationContext())) {
152
+                view.hideProgress();
153
+                view.setResultData(billBody);
154
+                return;
155
+            }
144 156
             final CategoryDaoOperator categoryDaoOperator = CategoryDaoOperator.newInstance();
145 157
             final ArrayList<CategoryDB> needUpdataJson = categoryDaoOperator.getNeedUpdataJson();
146 158
             String json = UpDataOperator.getInstance().getJson(needUpdataJson);
@@ -170,6 +182,11 @@ public class AccountPresenter extends AccountContract.AccountPresent {
170 182
 
171 183
     private void syncForAdd() {
172 184
         if (LoginStatusUtil.isLoginin()) {
185
+            if (!NetWorkUtil.isNetworkAvailable(mContext.getApplicationContext())) {
186
+                view.hideProgress();
187
+                view.finishActivity();
188
+                return;
189
+            }
173 190
             final CategoryDaoOperator categoryDaoOperator = CategoryDaoOperator.newInstance();
174 191
             final ArrayList<CategoryDB> needUpdataJson = categoryDaoOperator.getNeedUpdataJson();
175 192
             String json = UpDataOperator.getInstance().getJson(needUpdataJson);

+ 8 - 1
app/src/main/java/com/kuxuan/moneynote/ui/activitys/edit/EditBillActivity.java

@@ -23,6 +23,7 @@ import com.kuxuan.moneynote.ui.weight.CustormDialog;
23 23
 import com.kuxuan.moneynote.utils.CalanderUtil;
24 24
 import com.kuxuan.moneynote.utils.GlideUtil;
25 25
 import com.kuxuan.moneynote.utils.LoginStatusUtil;
26
+import com.kuxuan.moneynote.utils.NetWorkUtil;
26 27
 import com.kuxuan.moneynote.utils.TimeUtlis;
27 28
 import com.kuxuan.moneynote.utils.UIHelper;
28 29
 import com.kuxuan.sqlite.db.CategoryDB;
@@ -230,7 +231,13 @@ public class EditBillActivity extends BaseActivity {
230 231
         //在没登录的状态下是真删,否则是假删
231 232
         categoryDaoOperator.updataIsDelete(bill_db_id, true);
232 233
         if (LoginStatusUtil.isLoginin()) {
233
-            sync();
234
+            if (NetWorkUtil.isNetworkAvailable(this))
235
+                sync();
236
+            else{
237
+                EventBus.getDefault().post(new RefreshEvent());
238
+                closeProgressDialog();
239
+                finish();
240
+            }
234 241
         } else {
235 242
             categoryDaoOperator.deleteData(bill_db_id);
236 243
             EventBus.getDefault().post(new RefreshEvent());

+ 15 - 2
app/src/main/java/com/kuxuan/moneynote/ui/activitys/login/LoginActivity.java

@@ -19,6 +19,7 @@ import com.kuxuan.moneynote.common.Constant;
19 19
 import com.kuxuan.moneynote.db.BillCategoreDaoOperator;
20 20
 import com.kuxuan.moneynote.db.CategoryDBbean;
21 21
 import com.kuxuan.moneynote.db.CategoryDaoOperator;
22
+import com.kuxuan.moneynote.db.UserDBOperator;
22 23
 import com.kuxuan.moneynote.json.BaseJson;
23 24
 import com.kuxuan.moneynote.json.BeanNewJson;
24 25
 import com.kuxuan.moneynote.json.LoginJson;
@@ -276,6 +277,8 @@ public class LoginActivity extends BaseFragmentActivity {
276 277
 
277 278
     private void goToNext() {
278 279
 
280
+        LoginStatusUtil.loginIn();
281
+        UserDBOperator.getInstance().insertUserId(LoginStatusUtil.getLoginUserId());
279 282
         LoginEvent loginEvent = new LoginEvent(newUser);
280 283
         EventBus.getDefault().post(loginEvent);
281 284
         Bundle bundle = new Bundle();
@@ -346,8 +349,18 @@ public class LoginActivity extends BaseFragmentActivity {
346 349
             categoryDBbean.setCategory_id(uploadDbjson.getCategory_id());
347 350
             categoryDBbean.setDemo(uploadDbjson.getDemo());
348 351
             long time = uploadDbjson.getTime() * 1000;
349
-            categoryDBbean.setCreateTime(uploadDbjson.getTime());
350
-            categoryDBbean.setUpdateTime(uploadDbjson.getTime());
352
+            long create_time = uploadDbjson.getCreated_at() * 1000;
353
+            long updata_time = uploadDbjson.getUpdated_at() * 1000;
354
+            if (create_time == 0) {
355
+                categoryDBbean.setCreateTime(uploadDbjson.getTime());
356
+            } else {
357
+                categoryDBbean.setCreateTime(create_time);
358
+            }
359
+            if (updata_time == 0) {
360
+                categoryDBbean.setUpdateTime(time);
361
+            } else {
362
+                categoryDBbean.setUpdateTime(updata_time);
363
+            }
351 364
             String data = TimeUtlis.getData(time);
352 365
             String[] split = data.split("-");
353 366
             categoryDBbean.setYear(Integer.parseInt(split[0]));

+ 14 - 5
app/src/main/java/com/kuxuan/moneynote/ui/activitys/login/PhoneLoginActivity.java

@@ -305,9 +305,8 @@ public class PhoneLoginActivity extends BaseActivity {
305 305
                             Toast.makeText(getApplicationContext(), "微信登录成功", Toast.LENGTH_SHORT).show();
306 306
                         }
307 307
 
308
-                        goMain();
309 308
                         SPUtil.putAndApply(PhoneLoginActivity.this, Constant.IsFirstWEiChatLogin.ISWEICHATLOGIN, true);
310
-                        EventBus.getDefault().post(new RefreshEvent());
309
+                        syncData(0);
311 310
                     } else {
312 311
 
313 312
                     }
@@ -379,7 +378,7 @@ public class PhoneLoginActivity extends BaseActivity {
379 378
                     LoginStatusUtil.setToken(loginJsonBaseJson.getData().getToken(), loginJsonBaseJson.getData().getId());
380 379
                     SPUtil.putAndApply(PhoneLoginActivity.this, Constant.IsFirstWEiChatLogin.ISWEICHATLOGIN, false);
381 380
                     syncData(0);
382
-                    goMain();
381
+//                    goMain();
383 382
                 } else {
384 383
                     closeProgressDialog();
385 384
                     ToastUtil.show(PhoneLoginActivity.this, loginJsonBaseJson.getError().get(0));
@@ -463,8 +462,18 @@ public class PhoneLoginActivity extends BaseActivity {
463 462
             categoryDBbean.setCategory_id(uploadDbjson.getCategory_id());
464 463
             categoryDBbean.setDemo(uploadDbjson.getDemo());
465 464
             long time = uploadDbjson.getTime() * 1000;
466
-            categoryDBbean.setCreateTime(uploadDbjson.getTime());
467
-            categoryDBbean.setUpdateTime(uploadDbjson.getTime());
465
+            long create_time = uploadDbjson.getCreated_at() * 1000;
466
+            long updata_time = uploadDbjson.getUpdated_at() * 1000;
467
+            if (create_time == 0) {
468
+                categoryDBbean.setCreateTime(uploadDbjson.getTime());
469
+            } else {
470
+                categoryDBbean.setCreateTime(create_time);
471
+            }
472
+            if (updata_time == 0) {
473
+                categoryDBbean.setUpdateTime(time);
474
+            } else {
475
+                categoryDBbean.setUpdateTime(updata_time);
476
+            }
468 477
             String data = TimeUtlis.getData(time);
469 478
             String[] split = data.split("-");
470 479
             categoryDBbean.setYear(Integer.parseInt(split[0]));

+ 7 - 0
app/src/main/java/com/kuxuan/moneynote/ui/activitys/person/PersonActivity.java

@@ -266,6 +266,13 @@ public class PersonActivity extends MVPFragmentActivity<PersonPresenter, PersonM
266 266
             @Override
267 267
             public void onError(ExceptionHandle.ResponeThrowable e) {
268 268
                 closeProgressDialog();
269
+                for (CategoryDB categoryDB : needUpdataJson) {
270
+                    if (categoryDB.getStatus() == 1) {
271
+                        categoryDaoOperator.updataIsDelete(categoryDB.getBill_id(), true);
272
+                    } else {
273
+                        categoryDaoOperator.updataNeedSynce(categoryDB.getBill_id());
274
+                    }
275
+                }
269 276
                 LoginStatusUtil.loginOut();
270 277
                 EventBus.getDefault().post(new LoginOutEvent());
271 278
                 finish();

+ 2 - 3
app/src/main/java/com/kuxuan/moneynote/ui/adapter/DetialAdapter.java

@@ -71,9 +71,9 @@ public class DetialAdapter extends BaseQuickAdapter<TypeDataJson, DetialViewHold
71 71
             }
72 72
 
73 73
             if (item.getType() == 2) {
74
-                helper.mingxi_text.setText("-" + item.getAccount());
74
+                helper.mingxi_text.setText("-" + JavaFormatUtils.formatFloatNumber(Double.parseDouble(item.getAccount())));
75 75
             } else {
76
-                helper.mingxi_text.setText(item.getAccount()+ "");
76
+                helper.mingxi_text.setText(JavaFormatUtils.formatFloatNumber(Double.parseDouble(item.getAccount())));
77 77
             }
78 78
             GlideUtil.setImageWithNoCache(mContext, item.getSmall_icon(), helper.imageView);
79 79
         } else {
@@ -82,7 +82,6 @@ public class DetialAdapter extends BaseQuickAdapter<TypeDataJson, DetialViewHold
82 82
 
83 83
     }
84 84
 
85
-
86 85
     @Override
87 86
     public int getItemCount() {
88 87
         return getData().size();

+ 26 - 25
app/src/main/java/com/kuxuan/moneynote/ui/adapter/ReportAdapter.java

@@ -69,21 +69,23 @@ public class ReportAdapter extends BaseQuickAdapter<ReportJson, ReportViewHolder
69 69
             type = typeDataJson.getType();
70 70
             switch (type) {
71 71
                 case 2:
72
-                    item.setOutmoney((long) Float.parseFloat(typeDataJson.getAccount()));
73
-                    data = JavaFormatUtils.getData(item.getOutmoney() / item.getAllMoney() * 100);
74
-                    helper.money_text.setText(changeFloatData(Double.parseDouble(typeDataJson.getAccount()))+ "");
75
-                    helper.progressBar.setProgress(Math.round(item.getOutmoney() * 100 / item.getAllMoney()));
72
+                    double x= item.getAllMoney()*100;
73
+                   double fenzi =  item.getOutmoney()*100;
74
+                    data = JavaFormatUtils.getData((fenzi/x)*100);
75
+                    helper.money_text.setText(changeFloatData(Double.parseDouble(typeDataJson.getAccount())) + "");
76
+                    helper.progressBar.setProgress((int) Math.round(item.getOutmoney() * 100 / item.getAllMoney()));
76 77
                     break;
77 78
                 case 1:
78
-                    item.setInmoney((long) Float.parseFloat(typeDataJson.getAccount()));
79
-                    data = JavaFormatUtils.getData(item.getInmoney() / item.getAllMoney() * 100);
79
+                    double x1= item.getAllMoney()*100 ;
80
+                    double fenz = item.getInmoney()*100;
81
+                    data = JavaFormatUtils.getData((fenz/x1)*100);
80 82
 //                    JavaFormatUtils.formatFloatNumber(Float.parseFloat(typeDataJson.getAccount())
81
-                    helper.money_text.setText(changeFloatData(Double.parseDouble(typeDataJson.getAccount()))+ "");
82
-                    helper.progressBar.setProgress(Math.round(item.getInmoney() * 100 / item.getAllMoney()));
83
+                    helper.money_text.setText(changeFloatData(Double.parseDouble(typeDataJson.getAccount())) + "");
84
+                    helper.progressBar.setProgress((int) Math.round(item.getInmoney() * 100 / item.getAllMoney()));
83 85
                     break;
84 86
             }
85
-                helper.name_text.setText(typeDataJson.getName() + "  " + data + "%");
86
-            GlideUtil.setImageWithNoCache(mContext,typeDataJson.getSmall_icon(),helper.imageView);
87
+            helper.name_text.setText(typeDataJson.getName() + "  " + data + "%");
88
+            GlideUtil.setImageWithNoCache(mContext, typeDataJson.getSmall_icon(), helper.imageView);
87 89
         } else {
88 90
             helper.time_text.setVisibility(View.VISIBLE);
89 91
             String data = "";
@@ -91,41 +93,40 @@ public class ReportAdapter extends BaseQuickAdapter<ReportJson, ReportViewHolder
91 93
             type = typeDataJson.getType();
92 94
             switch (type) {
93 95
                 case 2:
94
-                    item.setOutmoney((long) Float.parseFloat(typeDataJson.getAccount()));
95
-                    float f = item.getOutmoney() / item.getAllMoney();
96
+                    double f = item.getOutmoney() / item.getAllMoney();
96 97
                     data = JavaFormatUtils.getData(f * 100);
97 98
                     helper.money_text.setText(changeFloatData(Double.parseDouble(typeDataJson.getAccount())) + "");
98
-                    helper.progressBar.setProgress(Math.round(item.getOutmoney() * 100 / item.getAllMoney()));
99
+                    helper.progressBar.setProgress((int) Math.round(item.getOutmoney() * 100 / item.getAllMoney()));
99 100
                     break;
100 101
                 case 1:
101
-                    item.setInmoney((long)Float.parseFloat(typeDataJson.getAccount()));
102 102
                     data = JavaFormatUtils.getData(item.getInmoney() / item.getAllMoney() * 100);
103
-                    helper.money_text.setText(changeFloatData(Double.parseDouble(typeDataJson.getAccount()))+ "");
104
-                    helper.progressBar.setProgress(Math.round(item.getInmoney() * 100 / item.getAllMoney()));
103
+                    helper.money_text.setText(changeFloatData(Double.parseDouble(typeDataJson.getAccount())) + "");
104
+                    helper.progressBar.setProgress((int) Math.round(item.getInmoney() * 100 / item.getAllMoney()));
105 105
                     break;
106 106
             }
107 107
             String day = typeDataJson.getDay();
108 108
             String[] split = day.split("-");
109
-            GlideUtil.setImageWithNoCache(mContext,typeDataJson.getSmall_icon(),helper.imageView);
110
-            helper.time_text.setText(split[0]+"年"+split[1]+"月"+split[2]+"日");
109
+            GlideUtil.setImageWithNoCache(mContext, typeDataJson.getSmall_icon(), helper.imageView);
110
+            helper.time_text.setText(split[0] + "年" + split[1] + "月" + split[2] + "日");
111 111
             String demo = typeDataJson.getDemo();
112
-            if(TextUtils.isEmpty(demo))
113
-            helper.name_text.setText(typeDataJson.getName() + "  " + data + "%");
112
+            if (TextUtils.isEmpty(demo))
113
+                helper.name_text.setText(typeDataJson.getName() + "  " + data + "%");
114 114
             else
115 115
                 helper.name_text.setText(demo + "  " + data + "%");
116 116
         }
117 117
 
118 118
         int layoutPosition = helper.getLayoutPosition();
119
-        if(layoutPosition==getData().size()-1){
119
+        if (layoutPosition == getData().size() - 1) {
120 120
             helper.line_View.setVisibility(View.GONE);
121
-        }else{
121
+        } else {
122 122
             helper.line_View.setVisibility(View.VISIBLE);
123 123
         }
124 124
     }
125 125
 
126 126
 
127
-    private String changeFloatData(double account){
128
-        java.text.DecimalFormat df = new java.text.DecimalFormat("########.00");
129
-        return df.format(account);
127
+    private String changeFloatData(double account) {
128
+        return String.format("%.2f", account);
129
+//        java.text.DecimalFormat df = new java.text.DecimalFormat("########.00");
130
+//        return df.format(account);
130 131
     }
131 132
 }

+ 2 - 2
app/src/main/java/com/kuxuan/moneynote/ui/fragments/details/DetialDBOpertor.java

@@ -149,8 +149,8 @@ public class DetialDBOpertor {
149 149
             typeDataJson.setType(list.get(i).getType());
150 150
             typeDataJson.setDetail_icon(list.get(i).getImage_path());
151 151
             typeDataJson.setSmall_icon(list.get(i).getImage_path());
152
-            java.text.DecimalFormat df = new java.text.DecimalFormat("########.00");
153
-            typeDataJson.setAccount( df.format(list.get(i).getAccount()) + "");
152
+//            java.text.DecimalFormat df = new java.text.DecimalFormat("########.00");
153
+            typeDataJson.setAccount(list.get(i).getAccount() + "");
154 154
             typeDataJson.setName(list.get(i).getName());
155 155
             typeDataJson.setDemo(list.get(i).getDemo());
156 156
             datas.add(typeDataJson);

+ 48 - 14
app/src/main/java/com/kuxuan/moneynote/ui/fragments/details/DetialPresent.java

@@ -31,6 +31,13 @@ import java.util.HashMap;
31 31
 import java.util.List;
32 32
 
33 33
 import cn.addapp.pickers.picker.DatePicker;
34
+import io.reactivex.Observable;
35
+import io.reactivex.ObservableEmitter;
36
+import io.reactivex.ObservableOnSubscribe;
37
+import io.reactivex.Observer;
38
+import io.reactivex.android.schedulers.AndroidSchedulers;
39
+import io.reactivex.disposables.Disposable;
40
+import io.reactivex.schedulers.Schedulers;
34 41
 
35 42
 /**
36 43
  * Created by xieshengqi on 2017/10/19.
@@ -226,17 +233,43 @@ public class DetialPresent extends DetialContract.DetialPresent implements View.
226 233
     }
227 234
 
228 235
     @Override
229
-    void getDataLists(String year, String month) {
230
-            db_maps = CategoryDaoOperator.newInstance().getMaxAndMinTimeForUserId(-1);
231
-        currentYear = Integer.parseInt(year);
232
-        currentMonth = Integer.parseInt(month);
233
-// TODO: 2018/4/3 需要做没有网络和有网络的处理
234
-//        if(NetWorkUtil.isNetworkAvailable(mContext)){
235
-//            //有网
236
-//        }else{
237
-//            //没网
238
-//        }
239
-        getDataForDB(year, month, db_maps);
236
+    void getDataLists(final String year, final String month) {
237
+        Observable.create(new ObservableOnSubscribe<HashMap<String, Integer>>() {
238
+            @Override
239
+            public void subscribe(ObservableEmitter<HashMap<String, Integer>> e) throws Exception {
240
+                db_maps = CategoryDaoOperator.newInstance().getMaxAndMinTimeForUserId(-1);
241
+                e.onNext(db_maps);
242
+                e.onComplete();
243
+            }
244
+        }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<HashMap<String, Integer>>() {
245
+            @Override
246
+            public void onSubscribe(Disposable d) {
247
+
248
+            }
249
+
250
+            @Override
251
+            public void onNext(HashMap<String, Integer> stringIntegerHashMap) {
252
+                currentYear = Integer.parseInt(year);
253
+                currentMonth = Integer.parseInt(month);
254
+                getDataForDB(year, month, stringIntegerHashMap);
255
+            }
256
+
257
+            @Override
258
+            public void onError(Throwable e) {
259
+                currentYear = Integer.parseInt(year);
260
+                currentMonth = Integer.parseInt(month);
261
+                getDataForDB(year, month, db_maps);
262
+            }
263
+
264
+            @Override
265
+            public void onComplete() {
266
+
267
+            }
268
+        });
269
+
270
+
271
+
272
+
240 273
 //        mModel.getDataLists(year, month, new MVPListener<UserAllBillJson>() {
241 274
 //            @Override
242 275
 //            public void onSuccess(UserAllBillJson content) {
@@ -271,6 +304,7 @@ public class DetialPresent extends DetialContract.DetialPresent implements View.
271 304
             @Override
272 305
             public void onFail(String msg) {
273 306
                 view.finishRefresh();
307
+                view.showContentLayout();
274 308
                 if (msg.equals("网络错误")) {
275 309
                     view.showError();
276 310
                 } else if (msg.equals("网络连接失败,请检测网络")) {
@@ -304,7 +338,7 @@ public class DetialPresent extends DetialContract.DetialPresent implements View.
304 338
             case R.id.fragment_detial_month:
305 339
                 //日期选择器
306 340
 //                if (isLogin)
307
-                    showYearAndMonth();
341
+                showYearAndMonth();
308 342
                 break;
309 343
         }
310 344
     }
@@ -334,8 +368,8 @@ public class DetialPresent extends DetialContract.DetialPresent implements View.
334 368
                     BillData billData = bill_data.get(i);
335 369
                     List<TypeDataJson> day_data = billData.getDay_data();
336 370
                     if (day_data != null) {
337
-                        for (int j = day_data.size()-1; j>=0; j--) {
338
-                            if (j == day_data.size()-1) {
371
+                        for (int j = day_data.size() - 1; j >= 0; j--) {
372
+                            if (j == day_data.size() - 1) {
339 373
                                 day_data.get(j).setFirst(true);
340 374
                             }
341 375
                             day_data.get(j).setDay_type(billData.getTime());

+ 3 - 3
app/src/main/java/com/kuxuan/moneynote/ui/fragments/reportsingle/ReportSingleDBOpertor.java

@@ -315,7 +315,7 @@ public class ReportSingleDBOpertor {
315 315
         }
316 316
         timeDataJson.setData(data);
317 317
         if (account > 0) {
318
-            timeDataJson.setAccount((int) account);
318
+            timeDataJson.setAccount( account);
319 319
             return timeDataJson;
320 320
         } else {
321 321
             return null;
@@ -350,7 +350,7 @@ public class ReportSingleDBOpertor {
350 350
         }
351 351
         timeDataJson.setData(data);
352 352
         if (account > 0) {
353
-            timeDataJson.setAccount((int) account);
353
+            timeDataJson.setAccount(account);
354 354
             return timeDataJson;
355 355
         } else {
356 356
             return null;
@@ -386,7 +386,7 @@ public class ReportSingleDBOpertor {
386 386
         }
387 387
         timeDataJson.setData(data);
388 388
         if (account > 0) {
389
-            timeDataJson.setAccount((int) account);
389
+            timeDataJson.setAccount( account);
390 390
             return timeDataJson;
391 391
         } else {
392 392
             return null;

+ 1 - 0
app/src/main/java/com/kuxuan/moneynote/ui/fragments/reportsingle/ReportSingleFragment.java

@@ -277,6 +277,7 @@ public class ReportSingleFragment extends MVPFragment<ReportSinglePresent, Repor
277 277
     private void showPop() {
278 278
         if (popupWindow == null) {
279 279
             popupWindow = new MoneyChoosePop(getActivity());
280
+            popupWindow.setType(mType);
280 281
             popupWindow.setOnPopClickListener(new MoneyChoosePop.OnPopClickListener() {
281 282
                 @Override
282 283
                 public void onClick(int type) {

+ 90 - 29
app/src/main/java/com/kuxuan/moneynote/ui/fragments/reportsingle/ReportSingleModel.java

@@ -16,7 +16,12 @@ import com.kuxuan.moneynote.listener.MVPListener;
16 16
 import java.util.ArrayList;
17 17
 import java.util.HashMap;
18 18
 
19
+import io.reactivex.Observable;
20
+import io.reactivex.ObservableEmitter;
21
+import io.reactivex.ObservableOnSubscribe;
22
+import io.reactivex.Observer;
19 23
 import io.reactivex.android.schedulers.AndroidSchedulers;
24
+import io.reactivex.disposables.Disposable;
20 25
 import io.reactivex.schedulers.Schedulers;
21 26
 
22 27
 /**
@@ -100,39 +105,95 @@ public class ReportSingleModel implements ReportSingleContract.RepModel {
100 105
     }
101 106
 
102 107
     @Override
103
-    public void getDataCatgoryForDB(int statistic_type, int type, int category_id, CategoryDaoOperator categoryDaoOperator, NewChartData newChartData, MVPListener<NewCategoryJson> listener) {
104
-        NewCategoryJson categoryJson;
105
-        if (statistic_type == 1) {
106
-            //周:
107
-            categoryJson = ReportSingleDBOpertor.getInstance().getWeekNewCategoryJson((ArrayList<String>) newChartData.getTime_range(), categoryDaoOperator, category_id, type);
108
-        } else if (statistic_type == 2) {
109
-            //月
110
-            categoryJson = ReportSingleDBOpertor.getInstance().getMonthNewCategoryJson(Integer.parseInt(newChartData.getYear()), Integer.parseInt(newChartData.getMonth()), categoryDaoOperator, type, category_id);
111
-        } else {
112
-            //年
113
-            categoryJson = ReportSingleDBOpertor.getInstance().getYearNewCategoryJson(Integer.parseInt(newChartData.getYear()), categoryDaoOperator, type, category_id);
114
-        }
115
-        listener.onSuccess(categoryJson);
108
+    public void getDataCatgoryForDB(final int statistic_type, final int type, final int category_id, final CategoryDaoOperator categoryDaoOperator, final NewChartData newChartData, final MVPListener<NewCategoryJson> listener) {
109
+        Observable<NewCategoryJson> observable = Observable.create(new ObservableOnSubscribe<NewCategoryJson>() {
110
+            @Override
111
+            public void subscribe(ObservableEmitter<NewCategoryJson> e) throws Exception {
112
+                NewCategoryJson categoryJson;
113
+                if (statistic_type == 1) {
114
+                    //周:
115
+                    categoryJson = ReportSingleDBOpertor.getInstance().getWeekNewCategoryJson((ArrayList<String>) newChartData.getTime_range(), categoryDaoOperator, category_id, type);
116
+                } else if (statistic_type == 2) {
117
+                    //月
118
+                    categoryJson = ReportSingleDBOpertor.getInstance().getMonthNewCategoryJson(Integer.parseInt(newChartData.getYear()), Integer.parseInt(newChartData.getMonth()), categoryDaoOperator, type, category_id);
119
+                } else {
120
+                    //年
121
+                    categoryJson = ReportSingleDBOpertor.getInstance().getYearNewCategoryJson(Integer.parseInt(newChartData.getYear()), categoryDaoOperator, type, category_id);
122
+                }
123
+                e.onNext(categoryJson);
124
+                e.onComplete();
125
+            }
126
+        });
127
+        observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<NewCategoryJson>() {
128
+            @Override
129
+            public void onSubscribe(Disposable d) {
130
+
131
+            }
132
+
133
+            @Override
134
+            public void onNext(NewCategoryJson newCategoryJson) {
135
+                listener.onSuccess(newCategoryJson);
136
+            }
137
+
138
+            @Override
139
+            public void onError(Throwable e) {
140
+
141
+            }
142
+
143
+            @Override
144
+            public void onComplete() {
145
+
146
+            }
147
+        });
148
+
116 149
 
117 150
     }
118 151
 
119 152
     @Override
120
-    public void getDataForDB(HashMap<String, Integer> db_maps, int statis_type, int type, MVPListener<ArrayList<NewChartData>> listener) {
121
-        ArrayList<NewChartData> weekTabDatas;
122
-        //周
123
-        if (statis_type == 1) {
124
-            weekTabDatas = ReportSingleDBOpertor.getInstance().getWeekTabData(db_maps, statis_type);
125
-        }//月
126
-        else if (statis_type == 2) {
127
-            weekTabDatas = ReportSingleDBOpertor.getInstance().getMonthTabData(db_maps, statis_type);
128
-        }
129
-        //年
130
-        else if (statis_type == 3) {
131
-            weekTabDatas = ReportSingleDBOpertor.getInstance().getYearTabData(db_maps, statis_type);
132
-        } else {
133
-            weekTabDatas = null;
134
-        }
135
-        listener.onSuccess(weekTabDatas);
153
+    public void getDataForDB(final HashMap<String, Integer> db_maps, final int statis_type, final int type, final MVPListener<ArrayList<NewChartData>> listener) {
154
+        Observable<ArrayList<NewChartData>> observable = Observable.create(new ObservableOnSubscribe<ArrayList<NewChartData>>() {
155
+            @Override
156
+            public void subscribe(ObservableEmitter<ArrayList<NewChartData>> e) throws Exception {
157
+                ArrayList<NewChartData> weekTabDatas;
158
+                //周
159
+                if (statis_type == 1) {
160
+                    weekTabDatas = ReportSingleDBOpertor.getInstance().getWeekTabData(db_maps, statis_type);
161
+                }//月
162
+                else if (statis_type == 2) {
163
+                    weekTabDatas = ReportSingleDBOpertor.getInstance().getMonthTabData(db_maps, statis_type);
164
+                }
165
+                //年
166
+                else if (statis_type == 3) {
167
+                    weekTabDatas = ReportSingleDBOpertor.getInstance().getYearTabData(db_maps, statis_type);
168
+                } else {
169
+                    weekTabDatas = null;
170
+                }
171
+                e.onNext(weekTabDatas);
172
+            }
173
+        });
174
+        observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<ArrayList<NewChartData>>() {
175
+            @Override
176
+            public void onSubscribe(Disposable d) {
177
+
178
+            }
179
+
180
+            @Override
181
+            public void onNext(ArrayList<NewChartData> newChartData) {
182
+                listener.onSuccess(newChartData);
183
+            }
184
+
185
+            @Override
186
+            public void onError(Throwable e) {
187
+
188
+            }
189
+
190
+            @Override
191
+            public void onComplete() {
192
+
193
+            }
194
+        });
195
+
196
+
136 197
     }
137 198
 
138 199
 

+ 72 - 18
app/src/main/java/com/kuxuan/moneynote/ui/fragments/reportsingle/ReportSinglePresent.java

@@ -39,6 +39,14 @@ import java.util.HashMap;
39 39
 import java.util.List;
40 40
 import java.util.WeakHashMap;
41 41
 
42
+import io.reactivex.Observable;
43
+import io.reactivex.ObservableEmitter;
44
+import io.reactivex.ObservableOnSubscribe;
45
+import io.reactivex.Observer;
46
+import io.reactivex.android.schedulers.AndroidSchedulers;
47
+import io.reactivex.disposables.Disposable;
48
+import io.reactivex.schedulers.Schedulers;
49
+
42 50
 import static com.kuxuan.moneynote.utils.CalanderUtil.getMonthDay;
43 51
 
44 52
 /**
@@ -303,7 +311,7 @@ public class ReportSinglePresent extends ReportSingleContract.RepPresent {
303 311
      *
304 312
      * @param statis_type
305 313
      */
306
-    private void getDataForDB(int statis_type, int type) {
314
+    private void getDataForDB(final int statis_type, final int type) {
307 315
         if (categoryDaoOperator == null) {
308 316
             categoryDaoOperator = CategoryDaoOperator.newInstance();
309 317
             categoryDaoOperator.setOnDBChangeListener(new CategoryDaoOperator.OnDBChangeListener() {
@@ -324,14 +332,61 @@ public class ReportSinglePresent extends ReportSingleContract.RepPresent {
324 332
             });
325 333
         }
326 334
 //        if (db_maps == null) {
327
-        db_maps = categoryDaoOperator.getMaxAndMinTime(moneyType, catrogy_id);
335
+//        db_maps = categoryDaoOperator.getMaxAndMinTime(moneyType, catrogy_id);
336
+////        }
337
+//        if (db_maps == null) {
338
+////            view.hideProgress();
339
+//            view.showNoDBdata();
340
+//            return;
328 341
 //        }
329
-        if (db_maps == null) {
330
-//            view.hideProgress();
331
-            view.showNoDBdata();
332
-            return;
333
-        }
334 342
 
343
+
344
+        Observable<HashMap<String, Integer>> observable = io.reactivex.Observable.create(new ObservableOnSubscribe<HashMap<String, Integer>>() {
345
+            @Override
346
+            public void subscribe(ObservableEmitter<HashMap<String, Integer>> e) throws Exception {
347
+                db_maps = categoryDaoOperator.getMaxAndMinTime(moneyType, catrogy_id);
348
+                if (db_maps != null) {
349
+                    e.onNext(db_maps);
350
+                    e.onComplete();
351
+                } else {
352
+                    e.onError(new Throwable());
353
+                }
354
+            }
355
+        });
356
+        observable.observeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<HashMap<String, Integer>>() {
357
+            @Override
358
+            public void onSubscribe(Disposable d) {
359
+
360
+            }
361
+
362
+            @Override
363
+            public void onNext(HashMap<String, Integer> stringIntegerHashMap) {
364
+                getRealDataForDB(statis_type, type);
365
+            }
366
+
367
+            @Override
368
+            public void onError(Throwable e) {
369
+                view.showContentLayout();
370
+                view.showNoDBdata();
371
+            }
372
+
373
+            @Override
374
+            public void onComplete() {
375
+
376
+            }
377
+        });
378
+
379
+
380
+    }
381
+
382
+
383
+    /**
384
+     * 获取数据
385
+     *
386
+     * @param statis_type
387
+     * @param type
388
+     */
389
+    private void getRealDataForDB(int statis_type, int type) {
335 390
         mModel.getDataForDB(db_maps, statis_type, type, new MVPListener<ArrayList<NewChartData>>() {
336 391
             @Override
337 392
             public void onSuccess(ArrayList<NewChartData> content) {
@@ -351,7 +406,6 @@ public class ReportSinglePresent extends ReportSingleContract.RepPresent {
351 406
         });
352 407
     }
353 408
 
354
-
355 409
     /**
356 410
      * 判断是否需要刷新网络
357 411
      *
@@ -835,12 +889,12 @@ public class ReportSinglePresent extends ReportSingleContract.RepPresent {
835 889
                     ReportJson reportJson = new ReportJson();
836 890
                     if (moneyType == 2) {
837 891
                         reportJson.setOut(true);
838
-                        reportJson.setOutmoney((long) Float.parseFloat(category_data.get(i).getAccount()));
892
+                        reportJson.setOutmoney(Double.parseDouble(category_data.get(i).getAccount()));
839 893
                     } else {
840 894
                         reportJson.setOut(false);
841
-                        reportJson.setInmoney((long) Float.parseFloat(category_data.get(i).getAccount()));
895
+                        reportJson.setInmoney(Double.parseDouble(category_data.get(i).getAccount()));
842 896
                     }
843
-                    reportJson.setAllMoney((long) Float.parseFloat(chartData.getAccount()));
897
+                    reportJson.setAllMoney(Double.parseDouble(chartData.getAccount()));
844 898
                     reportJson.setTag(category_data.get(i));
845 899
                     reportJsons.add(reportJson);
846 900
                 }
@@ -853,12 +907,12 @@ public class ReportSinglePresent extends ReportSingleContract.RepPresent {
853 907
                     ReportJson reportJson = new ReportJson();
854 908
                     if (moneyType == 2) {
855 909
                         reportJson.setOut(true);
856
-                        reportJson.setOutmoney((long) Float.parseFloat(category_data.get(i).getAccount()));
910
+                        reportJson.setOutmoney(Double.parseDouble(category_data.get(i).getAccount()));
857 911
                     } else {
858 912
                         reportJson.setOut(false);
859
-                        reportJson.setInmoney((long) Float.parseFloat(category_data.get(i).getAccount()));
913
+                        reportJson.setInmoney(Double.parseDouble(category_data.get(i).getAccount()));
860 914
                     }
861
-                    reportJson.setAllMoney((long) Float.parseFloat(chartData.getAccount()));
915
+                    reportJson.setAllMoney(Double.parseDouble(chartData.getAccount()));
862 916
                     reportJson.setTag(category_data.get(i));
863 917
                     reportJsons.add(reportJson);
864 918
                 }
@@ -866,7 +920,7 @@ public class ReportSinglePresent extends ReportSingleContract.RepPresent {
866 920
         }
867 921
 //        Log.e("List排序前的集合", reportJsons.toString());
868 922
 //        //排序
869
-//        Collections.sort(reportJsons);
923
+        Collections.sort(reportJsons);
870 924
 //        Log.e("List排序后的集合", reportJsons.toString());
871 925
         adapter.setNewData(reportJsons);
872 926
     }
@@ -1077,7 +1131,7 @@ public class ReportSinglePresent extends ReportSingleContract.RepPresent {
1077 1131
         }
1078 1132
         for (TimeDataJson dataJson : list) {
1079 1133
             if (key.equals(dataJson.getTime())) {
1080
-                y = dataJson.getAccount();
1134
+                y = (float) dataJson.getAccount();
1081 1135
                 break;
1082 1136
             }
1083 1137
         }
@@ -1093,7 +1147,7 @@ public class ReportSinglePresent extends ReportSingleContract.RepPresent {
1093 1147
      * @return
1094 1148
      */
1095 1149
     private float getYvalueForYear(String key, List<TimeDataJson> list) {
1096
-        float y = 0;
1150
+        double y = 0;
1097 1151
         if (list == null) {
1098 1152
             return 0;
1099 1153
         }
@@ -1102,6 +1156,6 @@ public class ReportSinglePresent extends ReportSingleContract.RepPresent {
1102 1156
                 y += dataJson.getAccount();
1103 1157
             }
1104 1158
         }
1105
-        return y;
1159
+        return (float) y;
1106 1160
     }
1107 1161
 }

+ 14 - 8
app/src/main/java/com/kuxuan/moneynote/ui/weight/ChartPop.java

@@ -17,6 +17,7 @@ import com.kuxuan.moneynote.R;
17 17
 import com.kuxuan.moneynote.json.PopCharData;
18 18
 import com.kuxuan.moneynote.utils.DisplayUtil;
19 19
 import com.kuxuan.moneynote.utils.GlideUtil;
20
+import com.kuxuan.moneynote.utils.JavaFormatUtils;
20 21
 
21 22
 import java.util.ArrayList;
22 23
 
@@ -99,7 +100,7 @@ public class ChartPop extends PopupWindow {
99 100
         // 设置SelectPicPopupWindow弹出窗体可点击
100 101
         this.setFocusable(true);
101 102
         // 实例化一个ColorDrawable颜色为半透明
102
-        final ColorDrawable dw = new ColorDrawable(Color.TRANSPARENT);
103
+        ColorDrawable dw = new ColorDrawable(Color.TRANSPARENT);
103 104
         // 设置SelectPicPopupWindow弹出窗体的背景
104 105
         this.setBackgroundDrawable(dw);
105 106
         this.setOutsideTouchable(true);
@@ -119,10 +120,12 @@ public class ChartPop extends PopupWindow {
119 120
             return false;
120 121
         }
121 122
         for (int i = 0; i < list.size(); i++) {
122
-            View view = getView(list.get(i));
123
-            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
124
-            view.setLayoutParams(params);
125
-            viewLayout.addView(view);
123
+            if (i < 3) {
124
+                View view = getView(list.get(i));
125
+                LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
126
+                view.setLayoutParams(params);
127
+                viewLayout.addView(view);
128
+            }
126 129
         }
127 130
         return true;
128 131
 
@@ -136,14 +139,17 @@ public class ChartPop extends PopupWindow {
136 139
         ImageView image = childView.findViewById(R.id.item_chartpop_image);
137 140
         if (type == 1) {
138 141
         }
139
-        time.setText(charData.getTime());
142
+        //格式为18/03/01之前格式为2018/03/01
143
+        String substring = charData.getTime().substring(2, charData.getTime().length());
144
+        time.setText(substring);
140 145
         name.setText(charData.getName());
141
-        count.setText(charData.getAccount());
146
+        count.setText(JavaFormatUtils.formatFloatNumber(Double.parseDouble(charData.getAccount())));
142 147
         GlideUtil.setImageWithNoCache(mContext, charData.getSmall_icon(), image);
143 148
         return childView;
144 149
     }
145 150
 
146 151
 
152
+
147 153
     /**
148 154
      * 设置位置
149 155
      *
@@ -152,7 +158,7 @@ public class ChartPop extends PopupWindow {
152 158
      * @param y
153 159
      */
154 160
     public void setParamsForLayout(int fixY, float x, float y) {
155
-        int allY = (int) (fixY  + y);
161
+        int allY = (int) (fixY + y);
156 162
         int leftMargin = -DisplayUtil.dip2px(4);
157 163
         int left;
158 164
         RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) linearLayout.getLayoutParams();

+ 19 - 7
app/src/main/java/com/kuxuan/moneynote/ui/weight/MoneyChoosePop.java

@@ -103,15 +103,27 @@ public class MoneyChoosePop extends PopupWindow {
103 103
             }
104 104
         });
105 105
 
106
-        bgView.setOnClickListener(new View.OnClickListener() {
107
-            @Override
108
-            public void onClick(View view) {
109
-                dismiss();
110
-            }
111
-        });
106
+            bgView.setOnClickListener(new View.OnClickListener() {
107
+                @Override
108
+                public void onClick(View view) {
109
+                    dismiss();
110
+                }
111
+            });
112
+        }
113
+
114
+
115
+    public void setType(int type) {
116
+        initImage();
117
+        this.type = type;
118
+        if (type == 1) {
119
+            this.type = SHOURU;
120
+            image_shouru.setVisibility(View.VISIBLE);
121
+        } else {
122
+            this.type = ZHICHU;
123
+            image_zhichu.setVisibility(View.VISIBLE);
124
+        }
112 125
     }
113 126
 
114
-
115 127
     @Override
116 128
     public void showAsDropDown(View anchor) {
117 129
         super.showAsDropDown(anchor);

+ 90 - 52
app/src/main/java/com/kuxuan/moneynote/utils/CalanderUtil.java

@@ -17,9 +17,9 @@ public class CalanderUtil {
17 17
 
18 18
 
19 19
     public static void main(String[] args) {
20
-//        ArrayList<String> weekTab = getWeekTab(2017, 5, 10, 2018, 3, 10);
20
+        ArrayList<String> weekTab = getWeekTab(2015, 12, 31, 2016, 1, 5);
21 21
 //        ArrayList<String> monthTab = getMonthTab(2017, 11, 2018, 3);
22
-//        System.out.println(monthTab.toString());
22
+        System.out.println(weekTab.toString());
23 23
 //        ArrayList<String> yearTab = getYearTab(2014, 2018);
24 24
 //        System.out.print(yearTab.toString());
25 25
 //        String[] weekAllDay = getWeekAllDay(2016, 53);
@@ -48,18 +48,37 @@ public class CalanderUtil {
48 48
      */
49 49
     public static int getWeek(String date) {
50 50
         Calendar cal = Calendar.getInstance();
51
+        cal.setFirstDayOfWeek(Calendar.MONDAY);
51 52
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
52 53
         try {
53 54
             cal.setTime(format.parse(date));
54 55
         } catch (ParseException e) {
55 56
             e.printStackTrace();
56 57
         }
57
-        cal.setFirstDayOfWeek(Calendar.MONDAY);
58 58
         int week = cal.get(Calendar.WEEK_OF_YEAR);
59 59
         return week;
60 60
     }
61 61
 
62 62
     /**
63
+     * 获取月
64
+     *
65
+     * @param date
66
+     * @return
67
+     */
68
+    public static int getMonth(String date) {
69
+        Calendar cal = Calendar.getInstance();
70
+        cal.setFirstDayOfWeek(Calendar.MONDAY);
71
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
72
+        try {
73
+            cal.setTime(format.parse(date));
74
+        } catch (ParseException e) {
75
+            e.printStackTrace();
76
+        }
77
+        int month = cal.get(Calendar.MONTH);
78
+        return month;
79
+    }
80
+
81
+    /**
63 82
      * 得到某一天是这周的第几天
64 83
      *
65 84
      * @param date
@@ -308,12 +327,37 @@ public class CalanderUtil {
308 327
         int month = startMonth;
309 328
         int day = getDayForWeek(data);
310 329
         //先添加一个最开始的数据
311
-        tabLists.add(getData(year, month, startDay));
330
+//        tabLists.add(getData(year, month, startDay));
312 331
         count = 0;
313 332
         int indexCount = 7 - day;
333
+        //从周一开始循环
334
+        allDayCount = allDayCount + day;
335
+//        day = startDay;
336
+        int index = day;
314 337
         day = startDay;
315
-        int c1 = 0;
316
-        while (count < allDayCount) {
338
+        for (int i = index; i > 1; i--) {
339
+            if (day == 1) {
340
+                if (month == 1) {
341
+                    month = 12;
342
+                    day = 31;
343
+                    year--;
344
+                } else {
345
+                    month--;
346
+                    day = getMonthDay(year, month);
347
+                }
348
+            } else {
349
+                day--;
350
+            }
351
+        }
352
+        int c1 = 6;
353
+        while (count < (allDayCount - 1)) {
354
+            if (c1 == 6) {
355
+                //算一个周期
356
+                c1 = 0;
357
+                tabLists.add(getData(year, month, day));
358
+            } else {
359
+                c1++;
360
+            }
317 361
             //获取一个月有多少天
318 362
             int monthDay = getMonthDay(year, month);
319 363
             if (day == monthDay) {
@@ -327,40 +371,19 @@ public class CalanderUtil {
327 371
             } else {
328 372
                 day++;
329 373
             }
330
-            if (count >= indexCount) {
331
-                if (c1 == 6) {
332
-                    //算一个周期
333
-                    c1 = 0;
334
-                    tabLists.add(getData(year, month, day));
335
-                } else {
336
-
337
-                    c1++;
338
-                }
339
-            }
340
-            count++;
341 374
             if (count == allDayCount - 1) {
342 375
                 //如果为最后一位
343 376
                 if (c1 > 0) {
344
-//                    int monthDay1 = getMonthDay(year, month);
345
-//                    if (day == monthDay1) {
346
-//                        day = 1;
347
-//                        if (month == 12) {
348
-//                            year++;
349
-//                            month = 1;
350
-//                        } else {
351
-//                            month++;
352
-//                        }
377
+//                    if (c1 >= 3) {
378
+                    tabLists.add(getData(year, month, day));
379
+
353 380
 //                    } else {
354
-//                        day++;
381
+//                        tabLists.add(getData(year, month, day, c1));
355 382
 //                    }
356
-                    if (c1 >= 3) {
357
-                        tabLists.add(getData(year, month, day));
358
-
359
-                    } else {
360
-                        tabLists.add(getData(year, month, day, c1));
361
-                    }
362 383
                 }
363 384
             }
385
+            count++;
386
+
364 387
         }
365 388
         return tabLists;
366 389
     }
@@ -445,31 +468,46 @@ public class CalanderUtil {
445 468
      * @return
446 469
      */
447 470
     private static String getData(int year, int month, int day) {
448
-        int week_day = getDayForWeek(year + "-" + month + "-" + day);
449
-        if (week_day > 3) {
450
-            for (int i = 3; i > 0; i--) {
451
-                if (day == 1) {
452
-                    if (month == 1) {
453
-                        month = 12;
454
-                        day = 31;
455
-                        year--;
456
-                    } else {
457
-                        month--;
458
-                        day = CalanderUtil.getMonthDay(year, month);
459
-                    }
460
-                } else {
461
-                    day--;
462
-                }
463
-            }
464
-        }
471
+        int startYear = year;
472
+//        int week_day = getDayForWeek(year + "-" + month + "-" + day);
473
+//        if (week_day == 7 && (day == 31 || day == 1) && (month == 12 || month == 10)) {
474
+//
475
+//        } else {
476
+//            if (week_day > 3) {
477
+//                for (int i = 3; i > 0; i--) {
478
+//                    if (day == 1) {
479
+//                        if (month == 1) {
480
+//                            month = 12;
481
+//                            day = 31;
482
+//                            year--;
483
+//                        } else {
484
+//                            month--;
485
+//                            day = CalanderUtil.getMonthDay(year, month);
486
+//                        }
487
+//                    } else {
488
+//                        day--;
489
+//                    }
490
+//                }
491
+//            }
492
+//        }
493
+
465 494
 
466 495
         int week = getWeek(year + "-" + String.format("%02d", month) + "-" + String.format("%02d", day));
467
-        if (month >= 11 && week <= 1) {
496
+        int mo = getMonth(year + "-" + String.format("%02d", month) + "-" + String.format("%02d", day));
497
+        if (mo >= 11 && week <= 1&&getDayForWeek(year+"-12"+"-31")==7) {
468 498
             week += 52;
499
+        }else if(month==12&&week==1&&getDayForWeek(year+"-12"+"-31")!=7){
500
+            year++;
469 501
         }
502
+//        if (month == 12 && week == 1) {
503
+//            year++;
504
+//        }
470 505
         if (isCurrentYear(year)) {
471 506
             return String.format("%02d", week) + "周";
472 507
         }
508
+//        if (month == 12 && week == 1) {
509
+//            return (year + 1) + "-" + String.format("%02d", week) + "周";
510
+//        }
473 511
         return year + "-" + String.format("%02d", week) + "周";
474 512
     }
475 513
 
@@ -482,7 +520,7 @@ public class CalanderUtil {
482 520
                     year--;
483 521
                 } else {
484 522
                     month--;
485
-                    day =CalanderUtil.getMonthDay(year,month);
523
+                    day = CalanderUtil.getMonthDay(year, month);
486 524
                 }
487 525
             } else {
488 526
                 day--;

+ 11 - 7
app/src/main/java/com/kuxuan/moneynote/utils/JavaFormatUtils.java

@@ -12,17 +12,21 @@ public class JavaFormatUtils  {
12 12
         DecimalFormat df = new DecimalFormat("0.00");
13 13
        return df.format(d);
14 14
     }
15
+    public static String getData(double d){
16
+        DecimalFormat df = new DecimalFormat("0.00");
17
+        return df.format(d);
18
+    }
15 19
     public static String getDataForTwo(float d){
16 20
         DecimalFormat df = new DecimalFormat("0.00");
17 21
         return df.format(d);
18 22
     }
19 23
     public static String formatFloatNumber(double value) {
20
-        if(value != 0.00){
21
-            java.text.DecimalFormat df = new java.text.DecimalFormat("########.00");
22
-            return df.format(value);
23
-        }else{
24
-            return "0.00";
25
-        }
26
-
24
+//        if(value != 0.00){
25
+//            java.text.DecimalFormat df = new java.text.DecimalFormat("########.00");
26
+//            return df.format(value);
27
+//        }else{
28
+//            return "0.00";
29
+//        }
30
+       return String.format("%.2f", value);
27 31
     }
28 32
 }

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

@@ -50,7 +50,7 @@ public class TimeUtlis {
50 50
     /**
51 51
      * yyyy-MM-dd HH:mm:ss
52 52
      */
53
-    public static final String TIME_FORMAT_FOUR = "yyyy-MM-dd hh:mm:ss";
53
+    public static final String TIME_FORMAT_FOUR = "yyyy-MM-dd HH:mm:ss";
54 54
     public static final String TIME_FORMAT_FOUR1 = "yyyy/MM/dd hh:mm:ss";
55 55
     /**
56 56
      * yyyy-MM-dd HH:mm:ss.SSSZ

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

@@ -2,6 +2,7 @@ package com.kuxuan.moneynote.utils;
2 2
 
3 3
 import android.content.Context;
4 4
 import android.content.res.AssetManager;
5
+import android.util.Log;
5 6
 
6 7
 import java.io.BufferedReader;
7 8
 import java.io.IOException;
@@ -28,6 +29,7 @@ public class Tools {
28 29
                 stringBuilder.append(line);
29 30
             }
30 31
         } catch (IOException e) {
32
+            Log.e("beginjson",e.toString());
31 33
             e.printStackTrace();
32 34
         }
33 35
         return stringBuilder.toString();

+ 1 - 1
app/src/main/res/layout/pop_chart_layout.xml

@@ -43,7 +43,7 @@
43 43
         android:id="@+id/pop_chart_image"
44 44
         android:layout_width="wrap_content"
45 45
         android:layout_height="wrap_content"
46
-
46
+        android:scaleType="fitXY"
47 47
         android:src="@mipmap/chart_marker_pointer_bg" />
48 48
 
49 49
 </RelativeLayout>

+ 2 - 2
build.gradle

@@ -25,8 +25,8 @@ task clean(type: Delete) {
25 25
     delete rootProject.buildDir
26 26
 }
27 27
 ext{
28
-    versionCode = 9
29
-    versionName = "1.4.2"
28
+    versionCode = 10
29
+    versionName = "1.5.0"
30 30
     minSdkVersion = 18
31 31
     targetSdkVersion = 22
32 32
     compileSdkVersion = 26