Procházet zdrojové kódy

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

e %!s(int64=6) %!d(string=před) roky
rodič
revize
dcf354bd86

+ 86 - 5
app/src/main/java/com/kuxuan/moneynote/ui/activitys/account/AccountPresenter.java

@@ -8,16 +8,29 @@ import android.view.View;
8 8
 
9 9
 import com.chad.library.adapter.base.BaseQuickAdapter;
10 10
 import com.kuxuan.moneynote.R;
11
+import com.kuxuan.moneynote.api.ExceptionHandle;
12
+import com.kuxuan.moneynote.api.MyObsever;
13
+import com.kuxuan.moneynote.api.RetrofitClient;
14
+import com.kuxuan.moneynote.db.CategoryDaoOperator;
15
+import com.kuxuan.moneynote.db.UpDataOperator;
16
+import com.kuxuan.moneynote.json.BeanNewJson;
11 17
 import com.kuxuan.moneynote.json.CategoryJson;
12 18
 import com.kuxuan.moneynote.json.CategoryList;
13 19
 import com.kuxuan.moneynote.json.netbody.BillBody;
20
+import com.kuxuan.moneynote.json.netbody.UpDataBody;
14 21
 import com.kuxuan.moneynote.listener.MVPListener;
15 22
 import com.kuxuan.moneynote.ui.activitys.category.CategoryActivity;
16 23
 import com.kuxuan.moneynote.ui.adapter.AccountAdapter;
24
+import com.kuxuan.moneynote.utils.LoginStatusUtil;
17 25
 import com.kuxuan.moneynote.utils.UIHelper;
26
+import com.kuxuan.sqlite.db.CategoryDB;
18 27
 
28
+import java.util.ArrayList;
19 29
 import java.util.List;
20 30
 
31
+import io.reactivex.android.schedulers.AndroidSchedulers;
32
+import io.reactivex.schedulers.Schedulers;
33
+
21 34
 /**
22 35
  * @author HFRX hfrx1314@qq.com
23 36
  * @version 1.0.0
@@ -108,18 +121,82 @@ public class AccountPresenter extends AccountContract.AccountPresent {
108 121
         mModel.addAccountForDB(new MVPListener<Object>() {
109 122
             @Override
110 123
             public void onSuccess(Object content) {
111
-                view.hideProgress();
112
-                view.finishActivity();
124
+
125
+                if (LoginStatusUtil.isLoginin()) {
126
+                    //同步一下
127
+                    syncForAdd();
128
+                } else {
129
+                    view.hideProgress();
130
+                    view.finishActivity();
131
+                }
113 132
             }
114 133
 
115 134
             @Override
116 135
             public void onFail(String msg) {
117
-                    view.hideProgress();
136
+                view.hideProgress();
118 137
                 view.showMsg(msg);
119 138
             }
120 139
         }, billBody, name);
121 140
     }
122 141
 
142
+    private void syncForUpdata(final BillBody billBody) {
143
+        if (LoginStatusUtil.isLoginin()) {
144
+            final CategoryDaoOperator categoryDaoOperator = CategoryDaoOperator.newInstance();
145
+            final ArrayList<CategoryDB> needUpdataJson = categoryDaoOperator.getNeedUpdataJson();
146
+            String json = UpDataOperator.getInstance().getJson(needUpdataJson);
147
+            RetrofitClient.getApiService().upData(new UpDataBody(0, json)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new MyObsever<BeanNewJson<Object>>() {
148
+                @Override
149
+                public void onError(ExceptionHandle.ResponeThrowable e) {
150
+                    view.hideProgress();
151
+                    view.setResultData(billBody);
152
+                }
153
+
154
+                @Override
155
+                public void onSuccess(BeanNewJson<Object> objectBeanNewJson) {
156
+                    //更新数据库
157
+                    for (CategoryDB categoryDB : needUpdataJson) {
158
+                        if (categoryDB.getStatus() == 1) {
159
+                            categoryDaoOperator.deleteData(categoryDB.getBill_id());
160
+                        } else {
161
+                            categoryDaoOperator.updataNoNeedSynce(categoryDB.getBill_id());
162
+                        }
163
+                    }
164
+                    view.hideProgress();
165
+                    view.setResultData(billBody);
166
+                }
167
+            });
168
+        }
169
+    }
170
+
171
+    private void syncForAdd() {
172
+        if (LoginStatusUtil.isLoginin()) {
173
+            final CategoryDaoOperator categoryDaoOperator = CategoryDaoOperator.newInstance();
174
+            final ArrayList<CategoryDB> needUpdataJson = categoryDaoOperator.getNeedUpdataJson();
175
+            String json = UpDataOperator.getInstance().getJson(needUpdataJson);
176
+            RetrofitClient.getApiService().upData(new UpDataBody(0, json)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new MyObsever<BeanNewJson<Object>>() {
177
+                @Override
178
+                public void onError(ExceptionHandle.ResponeThrowable e) {
179
+                    view.hideProgress();
180
+                    view.finishActivity();
181
+                }
182
+
183
+                @Override
184
+                public void onSuccess(BeanNewJson<Object> objectBeanNewJson) {
185
+                    //更新数据库
186
+                    for (CategoryDB categoryDB : needUpdataJson) {
187
+                        if (categoryDB.getStatus() == 1) {
188
+                            categoryDaoOperator.deleteData(categoryDB.getBill_id());
189
+                        } else {
190
+                            categoryDaoOperator.updataNoNeedSynce(categoryDB.getBill_id());
191
+                        }
192
+                    }
193
+                    view.hideProgress();
194
+                    view.finishActivity();
195
+                }
196
+            });
197
+        }
198
+    }
199
+
123 200
     @Override
124 201
     void uploadBill(final BillBody billBody, int online_OR_Offline, String name, String bill_id) {
125 202
 // TODO: 2018/4/3 需要做没有网络和有网络的处理
@@ -143,8 +220,12 @@ public class AccountPresenter extends AccountContract.AccountPresent {
143 220
         mModel.uploadBillForDB(new MVPListener<Object>() {
144 221
             @Override
145 222
             public void onSuccess(Object content) {
146
-                view.hideProgress();
147
-                view.setResultData(billBody);
223
+                if (LoginStatusUtil.isLoginin()) {
224
+                    syncForUpdata(billBody);
225
+                } else {
226
+                    view.hideProgress();
227
+                    view.setResultData(billBody);
228
+                }
148 229
             }
149 230
 
150 231
             @Override

+ 52 - 5
app/src/main/java/com/kuxuan/moneynote/ui/activitys/edit/EditBillActivity.java

@@ -7,10 +7,16 @@ import android.view.View;
7 7
 import android.widget.TextView;
8 8
 
9 9
 import com.kuxuan.moneynote.R;
10
+import com.kuxuan.moneynote.api.ExceptionHandle;
11
+import com.kuxuan.moneynote.api.MyObsever;
12
+import com.kuxuan.moneynote.api.RetrofitClient;
10 13
 import com.kuxuan.moneynote.base.BaseActivity;
11 14
 import com.kuxuan.moneynote.common.Constant;
12 15
 import com.kuxuan.moneynote.db.CategoryDaoOperator;
16
+import com.kuxuan.moneynote.db.UpDataOperator;
17
+import com.kuxuan.moneynote.json.BeanNewJson;
13 18
 import com.kuxuan.moneynote.json.TypeDataJson;
19
+import com.kuxuan.moneynote.json.netbody.UpDataBody;
14 20
 import com.kuxuan.moneynote.ui.activitys.account.AccountActivity;
15 21
 import com.kuxuan.moneynote.ui.activitys.eventbus.RefreshEvent;
16 22
 import com.kuxuan.moneynote.ui.weight.CustormDialog;
@@ -19,12 +25,17 @@ import com.kuxuan.moneynote.utils.GlideUtil;
19 25
 import com.kuxuan.moneynote.utils.LoginStatusUtil;
20 26
 import com.kuxuan.moneynote.utils.TimeUtlis;
21 27
 import com.kuxuan.moneynote.utils.UIHelper;
28
+import com.kuxuan.sqlite.db.CategoryDB;
22 29
 import com.umeng.analytics.MobclickAgent;
23 30
 
24 31
 import org.greenrobot.eventbus.EventBus;
25 32
 
33
+import java.util.ArrayList;
34
+
26 35
 import butterknife.Bind;
27 36
 import butterknife.OnClick;
37
+import io.reactivex.android.schedulers.AndroidSchedulers;
38
+import io.reactivex.schedulers.Schedulers;
28 39
 
29 40
 /**
30 41
  * 编辑类别
@@ -215,19 +226,55 @@ public class EditBillActivity extends BaseActivity {
215 226
 //            });
216 227
 //
217 228
 //        } else {
218
-        closeProgressDialog();
229
+
219 230
         //在没登录的状态下是真删,否则是假删
231
+        categoryDaoOperator.updataIsDelete(bill_db_id, true);
220 232
         if (LoginStatusUtil.isLoginin()) {
221
-            categoryDaoOperator.updataIsDelete(bill_db_id, true);
222
-
233
+            sync();
223 234
         } else {
224 235
             categoryDaoOperator.deleteData(bill_db_id);
236
+            EventBus.getDefault().post(new RefreshEvent());
237
+            closeProgressDialog();
238
+            finish();
225 239
         }
226
-        EventBus.getDefault().post(new RefreshEvent());
227
-        finish();
240
+
228 241
 //        }
229 242
     }
230 243
 
244
+    /**
245
+     * 同步数据
246
+     */
247
+    private void sync() {
248
+        if (LoginStatusUtil.isLoginin()) {
249
+            final CategoryDaoOperator categoryDaoOperator = CategoryDaoOperator.newInstance();
250
+            final ArrayList<CategoryDB> needUpdataJson = categoryDaoOperator.getNeedUpdataJson();
251
+            String json = UpDataOperator.getInstance().getJson(needUpdataJson);
252
+            RetrofitClient.getApiService().upData(new UpDataBody(0, json)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new MyObsever<BeanNewJson<Object>>() {
253
+                @Override
254
+                public void onError(ExceptionHandle.ResponeThrowable e) {
255
+                    categoryDaoOperator.updataIsDelete(bill_db_id, true);
256
+                    EventBus.getDefault().post(new RefreshEvent());
257
+                    closeProgressDialog();
258
+                    finish();
259
+                }
260
+
261
+                @Override
262
+                public void onSuccess(BeanNewJson<Object> objectBeanNewJson) {
263
+                    //更新数据库
264
+                    for (CategoryDB categoryDB : needUpdataJson) {
265
+                        if (categoryDB.getStatus() == 1) {
266
+                            categoryDaoOperator.deleteData(categoryDB.getBill_id());
267
+                        } else {
268
+                            categoryDaoOperator.updataNoNeedSynce(categoryDB.getBill_id());
269
+                        }
270
+                    }
271
+                    EventBus.getDefault().post(new RefreshEvent());
272
+                    closeProgressDialog();
273
+                    finish();
274
+                }
275
+            });
276
+        }
277
+    }
231 278
 
232 279
     @Override
233 280
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {

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

@@ -72,14 +72,14 @@ public class ReportAdapter extends BaseQuickAdapter<ReportJson, ReportViewHolder
72 72
                     item.setOutmoney((long) Float.parseFloat(typeDataJson.getAccount()));
73 73
                     data = JavaFormatUtils.getData(item.getOutmoney() / item.getAllMoney() * 100);
74 74
                     helper.money_text.setText(changeFloatData(Double.parseDouble(typeDataJson.getAccount()))+ "");
75
-                    helper.progressBar.setProgress((int) (item.getOutmoney() * 100 / item.getAllMoney()));
75
+                    helper.progressBar.setProgress(Math.round(item.getOutmoney() * 100 / item.getAllMoney()));
76 76
                     break;
77 77
                 case 1:
78 78
                     item.setInmoney((long) Float.parseFloat(typeDataJson.getAccount()));
79 79
                     data = JavaFormatUtils.getData(item.getInmoney() / item.getAllMoney() * 100);
80 80
 //                    JavaFormatUtils.formatFloatNumber(Float.parseFloat(typeDataJson.getAccount())
81 81
                     helper.money_text.setText(changeFloatData(Double.parseDouble(typeDataJson.getAccount()))+ "");
82
-                    helper.progressBar.setProgress((int) (item.getInmoney() * 100 / item.getAllMoney()));
82
+                    helper.progressBar.setProgress(Math.round(item.getInmoney() * 100 / item.getAllMoney()));
83 83
                     break;
84 84
             }
85 85
                 helper.name_text.setText(typeDataJson.getName() + "  " + data + "%");
@@ -95,13 +95,13 @@ public class ReportAdapter extends BaseQuickAdapter<ReportJson, ReportViewHolder
95 95
                     float f = item.getOutmoney() / item.getAllMoney();
96 96
                     data = JavaFormatUtils.getData(f * 100);
97 97
                     helper.money_text.setText(changeFloatData(Double.parseDouble(typeDataJson.getAccount())) + "");
98
-                    helper.progressBar.setProgress((int) (item.getOutmoney() * 100 / item.getAllMoney()));
98
+                    helper.progressBar.setProgress(Math.round(item.getOutmoney() * 100 / item.getAllMoney()));
99 99
                     break;
100 100
                 case 1:
101 101
                     item.setInmoney((long)Float.parseFloat(typeDataJson.getAccount()));
102 102
                     data = JavaFormatUtils.getData(item.getInmoney() / item.getAllMoney() * 100);
103 103
                     helper.money_text.setText(changeFloatData(Double.parseDouble(typeDataJson.getAccount()))+ "");
104
-                    helper.progressBar.setProgress((int) (item.getInmoney() * 100 / item.getAllMoney()));
104
+                    helper.progressBar.setProgress(Math.round(item.getInmoney() * 100 / item.getAllMoney()));
105 105
                     break;
106 106
             }
107 107
             String day = typeDataJson.getDay();

+ 0 - 1
app/src/main/java/com/kuxuan/moneynote/ui/fragments/details/DetialPresent.java

@@ -290,7 +290,6 @@ public class DetialPresent extends DetialContract.DetialPresent implements View.
290 290
         if (isLogin) {
291 291
             //获取数据
292 292
             view.showLogin();
293
-
294 293
         } else {
295 294
             view.showNoLogin();
296 295
         }

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

@@ -41,7 +41,7 @@ public class ReportSingleDBOpertor {
41 41
      * @return
42 42
      */
43 43
     public ArrayList<NewChartData> getWeekTabData(HashMap<String, Integer> maps, int type) {
44
-        if(maps==null){
44
+        if (maps == null) {
45 45
             return null;
46 46
         }
47 47
         int startYear = maps.get("startYear");
@@ -150,7 +150,7 @@ public class ReportSingleDBOpertor {
150 150
      * @param categoryDaoOperator
151 151
      * @return
152 152
      */
153
-    public NewCategoryJson getWeekNewCategoryJson(ArrayList<String> datasLists, CategoryDaoOperator categoryDaoOperator, int category_id,int type) {
153
+    public NewCategoryJson getWeekNewCategoryJson(ArrayList<String> datasLists, CategoryDaoOperator categoryDaoOperator, int category_id, int type) {
154 154
         NewCategoryJson newCategoryJson = new NewCategoryJson();
155 155
         ArrayList<TypeDataJson> typeDataJsonLists = new ArrayList<>();
156 156
         ArrayList<TimeDataJson> timeDataJsonsLists = new ArrayList<>();
@@ -161,7 +161,7 @@ public class ReportSingleDBOpertor {
161 161
             int year = Integer.parseInt(split[0]);
162 162
             int month = Integer.parseInt(split[1]);
163 163
             int day = Integer.parseInt(split[2]);
164
-            ArrayList<CategoryDB> weekData = categoryDaoOperator.getWeekData(year, month, day, type,category_id);
164
+            ArrayList<CategoryDB> weekData = categoryDaoOperator.getWeekData(year, month, day, type, category_id);
165 165
             if (category_id != -1) {
166 166
                 detialDataLists.addAll(changJson(weekData, category_id));
167 167
             } else {
@@ -179,7 +179,7 @@ public class ReportSingleDBOpertor {
179 179
                 account += Double.parseDouble(typeDataJson.getAccount());
180 180
             }
181 181
             newCategoryJson.setAccount(account + "");
182
-            newCategoryJson.setCategory(typeDataJsonLists);
182
+            newCategoryJson.setCategory(categLists);
183 183
         } else {
184 184
             double account = 0;
185 185
             for (TypeDataJson typeDataJson : detialDataLists) {
@@ -202,20 +202,20 @@ public class ReportSingleDBOpertor {
202 202
      * @param categoryDaoOperator
203 203
      * @return
204 204
      */
205
-    public NewCategoryJson getMonthNewCategoryJson(int year, int month, CategoryDaoOperator categoryDaoOperator,int type, int category_id) {
205
+    public NewCategoryJson getMonthNewCategoryJson(int year, int month, CategoryDaoOperator categoryDaoOperator, int type, int category_id) {
206 206
 
207 207
         NewCategoryJson newCategoryJson = new NewCategoryJson();
208 208
         ArrayList<TypeDataJson> typeDataJsonLists = new ArrayList<>();
209 209
         ArrayList<TimeDataJson> timeDataJsonsLists = new ArrayList<>();
210 210
         ArrayList<TypeDataJson> detialDataLists = new ArrayList<>();
211
-        ArrayList<CategoryDB> weekData = categoryDaoOperator.getMonthData(year, month, type,category_id);
211
+        ArrayList<CategoryDB> weekData = categoryDaoOperator.getMonthData(year, month, type, category_id);
212 212
         if (category_id == -1)
213 213
             typeDataJsonLists.addAll(changJson(weekData));
214 214
         else
215 215
             detialDataLists.addAll(changJson(weekData, category_id));
216 216
         int monthDay = CalanderUtil.getMonthDay(year, month);
217 217
         for (int i = 1; i <= monthDay; i++) {
218
-            TimeDataJson timeDataJson = getMonthTimeDataJson(year, month, i, categoryDaoOperator, category_id,type);
218
+            TimeDataJson timeDataJson = getMonthTimeDataJson(year, month, i, categoryDaoOperator, category_id, type);
219 219
             if (timeDataJson != null) {
220 220
                 timeDataJsonsLists.add(timeDataJson);
221 221
             }
@@ -227,7 +227,7 @@ public class ReportSingleDBOpertor {
227 227
                 account += Double.parseDouble(typeDataJson.getAccount());
228 228
             }
229 229
             newCategoryJson.setAccount(account + "");
230
-            newCategoryJson.setCategory(typeDataJsonLists);
230
+            newCategoryJson.setCategory(categLists);
231 231
         } else {
232 232
             double account = 0;
233 233
             for (TypeDataJson typeDataJson : detialDataLists) {
@@ -249,18 +249,18 @@ public class ReportSingleDBOpertor {
249 249
      * @param categoryDaoOperator
250 250
      * @return
251 251
      */
252
-    public NewCategoryJson getYearNewCategoryJson(int year, CategoryDaoOperator categoryDaoOperator,int type, int category_id) {
252
+    public NewCategoryJson getYearNewCategoryJson(int year, CategoryDaoOperator categoryDaoOperator, int type, int category_id) {
253 253
         NewCategoryJson newCategoryJson = new NewCategoryJson();
254 254
         ArrayList<TypeDataJson> typeDataJsonLists = new ArrayList<>();
255 255
         ArrayList<TypeDataJson> detialDataLists = new ArrayList<>();
256 256
         ArrayList<TimeDataJson> timeDataJsonsLists = new ArrayList<>();
257
-        ArrayList<CategoryDB> weekData = categoryDaoOperator.getYearData(year,type, category_id);
257
+        ArrayList<CategoryDB> weekData = categoryDaoOperator.getYearData(year, type, category_id);
258 258
         if (category_id == -1)
259 259
             typeDataJsonLists.addAll(changJson(weekData));
260 260
         else
261 261
             detialDataLists.addAll(changJson(weekData, category_id));
262 262
         for (int i = 1; i <= 12; i++) {
263
-            TimeDataJson timeDataJson = getYearTimeDataJson(year, i, categoryDaoOperator, type,category_id);
263
+            TimeDataJson timeDataJson = getYearTimeDataJson(year, i, categoryDaoOperator, type, category_id);
264 264
             if (timeDataJson != null) {
265 265
                 timeDataJsonsLists.add(timeDataJson);
266 266
             }
@@ -272,7 +272,7 @@ public class ReportSingleDBOpertor {
272 272
                 account += Double.parseDouble(typeDataJson.getAccount());
273 273
             }
274 274
             newCategoryJson.setAccount(account + "");
275
-            newCategoryJson.setCategory(typeDataJsonLists);
275
+            newCategoryJson.setCategory(categLists);
276 276
         } else {
277 277
             double account = 0;
278 278
             for (TypeDataJson typeDataJson : detialDataLists) {
@@ -330,11 +330,11 @@ public class ReportSingleDBOpertor {
330 330
      * @param day
331 331
      * @return
332 332
      */
333
-    private TimeDataJson getMonthTimeDataJson(int year, int month, int day, CategoryDaoOperator categoryDaoOperator, int category_id,int type) {
333
+    private TimeDataJson getMonthTimeDataJson(int year, int month, int day, CategoryDaoOperator categoryDaoOperator, int category_id, int type) {
334 334
         TimeDataJson timeDataJson = new TimeDataJson();
335 335
         timeDataJson.setDay(String.format("%02d", day) + "");
336 336
         ArrayList<PopCharData> data = new ArrayList<>();
337
-        ArrayList<CategoryDB> weekData = categoryDaoOperator.getWeekData(year, month, day, type,category_id);
337
+        ArrayList<CategoryDB> weekData = categoryDaoOperator.getWeekData(year, month, day, type, category_id);
338 338
         for (int i = 0; i < weekData.size(); i++) {
339 339
             PopCharData typeDataJson = new PopCharData();
340 340
             typeDataJson.setCategory_id(weekData.get(i).getCategory_id());
@@ -366,11 +366,11 @@ public class ReportSingleDBOpertor {
366 366
      * @param categoryDaoOperator
367 367
      * @return
368 368
      */
369
-    private TimeDataJson getYearTimeDataJson(int year, int month, CategoryDaoOperator categoryDaoOperator, int type,int category_id) {
369
+    private TimeDataJson getYearTimeDataJson(int year, int month, CategoryDaoOperator categoryDaoOperator, int type, int category_id) {
370 370
         TimeDataJson timeDataJson = new TimeDataJson();
371 371
         timeDataJson.setDay(String.format("%02d", month) + "");
372 372
         ArrayList<PopCharData> data = new ArrayList<>();
373
-        ArrayList<CategoryDB> monthData = categoryDaoOperator.getMonthData(year, month,type, category_id);
373
+        ArrayList<CategoryDB> monthData = categoryDaoOperator.getMonthData(year, month, type, category_id);
374 374
         for (int i = 0; i < monthData.size(); i++) {
375 375
             PopCharData typeDataJson = new PopCharData();
376 376
             typeDataJson.setCategory_id(monthData.get(i).getCategory_id());
@@ -416,6 +416,8 @@ public class ReportSingleDBOpertor {
416 416
                         t = new TypeDataJson();
417 417
                         t.setName(typeDataJson.getName());
418 418
                         t.setCategory_id(typeDataJson.getCategory_id());
419
+                        t.setDetail_icon(typeDataJson.getDetail_icon());
420
+                        t.setSmall_icon(typeDataJson.getSmall_icon());
419 421
                         t.setAccount(typeDataJson.getAccount());
420 422
                         t.setType(typeDataJson.getType());
421 423
                     } else {
@@ -453,6 +455,65 @@ public class ReportSingleDBOpertor {
453 455
     }
454 456
 
455 457
     /**
458
+     * 数据归类(最外层的数据)
459
+     *
460
+     * @param list
461
+     * @return
462
+     */
463
+    private ArrayList<TypeDataJson> changJsonNoDetial(ArrayList<CategoryDB> list) {
464
+        ArrayList<TypeDataJson> datas = new ArrayList<>();
465
+        ArrayList<String> idLists = new ArrayList<>();
466
+
467
+        for (int i = 0; i < list.size(); i++) {
468
+            if (!isInLists(list.get(i).getCategory_id() + "", idLists)) {
469
+                idLists.add(list.get(i).getCategory_id() + "");
470
+            }
471
+        }
472
+//        for (int i = 0; i < list.size(); i++) {
473
+//            TypeDataJson typeDataJson = new TypeDataJson();
474
+//            typeDataJson.setBill_id(list.get(i).getBill_id());
475
+//            typeDataJson.setCategory_id(list.get(i).getCategory_id());
476
+//            typeDataJson.setType(list.get(i).getType());
477
+//            typeDataJson.setDetail_icon(list.get(i).getImage_path());
478
+//            typeDataJson.setSmall_icon(list.get(i).getImage_path());
479
+//            typeDataJson.setName(list.get(i).getName());
480
+//            typeDataJson.setAccount(list.get(i).getAccount() + "");
481
+//            datas.add(typeDataJson);
482
+//        }
483
+
484
+        for (int i = 0; i < idLists.size(); i++) {
485
+            TypeDataJson typeDataJson = new TypeDataJson();
486
+            typeDataJson.setBill_id(list.get(i).getBill_id());
487
+            typeDataJson.setCategory_id(list.get(i).getCategory_id());
488
+            typeDataJson.setType(list.get(i).getType());
489
+            typeDataJson.setDetail_icon(list.get(i).getImage_path());
490
+            typeDataJson.setSmall_icon(list.get(i).getImage_path());
491
+            typeDataJson.setName(list.get(i).getName());
492
+            double account = 0;
493
+            for (CategoryDB categoryDB : list) {
494
+                if (String.valueOf(categoryDB.getCategory_id()).equals(idLists.get(i))) {
495
+                    account += categoryDB.getAccount();
496
+                }
497
+            }
498
+            typeDataJson.setAccount(account + "");
499
+        }
500
+        return datas;
501
+    }
502
+
503
+
504
+    private boolean isInLists(String id, ArrayList<String> lists) {
505
+        boolean isIn = false;
506
+        for (String i : lists) {
507
+            if (i.equals(id)) {
508
+                isIn = true;
509
+                break;
510
+            }
511
+        }
512
+        return isIn;
513
+    }
514
+
515
+
516
+    /**
456 517
      * 详情页本地数据转化
457 518
      *
458 519
      * @param list
@@ -463,7 +524,7 @@ public class ReportSingleDBOpertor {
463 524
         ArrayList<TypeDataJson> datas = new ArrayList<>();
464 525
         for (int i = 0; i < list.size(); i++) {
465 526
             TypeDataJson typeDataJson = new TypeDataJson();
466
-            typeDataJson.setBill_id( list.get(i).getBill_id());
527
+            typeDataJson.setBill_id(list.get(i).getBill_id());
467 528
             typeDataJson.setDetail_icon(list.get(i).getImage_path());
468 529
             typeDataJson.setSmall_icon(list.get(i).getImage_path());
469 530
             typeDataJson.setDay(list.get(i).getYear() + "-" + String.format("%02d", list.get(i).getMonth()) + "-" + String.format("%02d", list.get(i).getDay()));

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

@@ -156,6 +156,7 @@ public class CalanderUtil {
156 156
         ArrayList<String> data = new ArrayList<String>();
157 157
         Calendar cal = getCalendarFormYear(startYear);
158 158
         cal.set(Calendar.WEEK_OF_YEAR, week);
159
+        cal.setFirstDayOfWeek(Calendar.MONDAY);
159 160
         int year = cal.get(Calendar.YEAR);
160 161
         int month = (cal.get(Calendar.MONTH) + 1);
161 162
         int day = cal.get(Calendar.DAY_OF_MONTH);