瀏覽代碼

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

e 6 年之前
父節點
當前提交
dcf354bd86

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

8
 
8
 
9
 import com.chad.library.adapter.base.BaseQuickAdapter;
9
 import com.chad.library.adapter.base.BaseQuickAdapter;
10
 import com.kuxuan.moneynote.R;
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
 import com.kuxuan.moneynote.json.CategoryJson;
17
 import com.kuxuan.moneynote.json.CategoryJson;
12
 import com.kuxuan.moneynote.json.CategoryList;
18
 import com.kuxuan.moneynote.json.CategoryList;
13
 import com.kuxuan.moneynote.json.netbody.BillBody;
19
 import com.kuxuan.moneynote.json.netbody.BillBody;
20
+import com.kuxuan.moneynote.json.netbody.UpDataBody;
14
 import com.kuxuan.moneynote.listener.MVPListener;
21
 import com.kuxuan.moneynote.listener.MVPListener;
15
 import com.kuxuan.moneynote.ui.activitys.category.CategoryActivity;
22
 import com.kuxuan.moneynote.ui.activitys.category.CategoryActivity;
16
 import com.kuxuan.moneynote.ui.adapter.AccountAdapter;
23
 import com.kuxuan.moneynote.ui.adapter.AccountAdapter;
24
+import com.kuxuan.moneynote.utils.LoginStatusUtil;
17
 import com.kuxuan.moneynote.utils.UIHelper;
25
 import com.kuxuan.moneynote.utils.UIHelper;
26
+import com.kuxuan.sqlite.db.CategoryDB;
18
 
27
 
28
+import java.util.ArrayList;
19
 import java.util.List;
29
 import java.util.List;
20
 
30
 
31
+import io.reactivex.android.schedulers.AndroidSchedulers;
32
+import io.reactivex.schedulers.Schedulers;
33
+
21
 /**
34
 /**
22
  * @author HFRX hfrx1314@qq.com
35
  * @author HFRX hfrx1314@qq.com
23
  * @version 1.0.0
36
  * @version 1.0.0
108
         mModel.addAccountForDB(new MVPListener<Object>() {
121
         mModel.addAccountForDB(new MVPListener<Object>() {
109
             @Override
122
             @Override
110
             public void onSuccess(Object content) {
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
             @Override
134
             @Override
116
             public void onFail(String msg) {
135
             public void onFail(String msg) {
117
-                    view.hideProgress();
136
+                view.hideProgress();
118
                 view.showMsg(msg);
137
                 view.showMsg(msg);
119
             }
138
             }
120
         }, billBody, name);
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
     @Override
200
     @Override
124
     void uploadBill(final BillBody billBody, int online_OR_Offline, String name, String bill_id) {
201
     void uploadBill(final BillBody billBody, int online_OR_Offline, String name, String bill_id) {
125
 // TODO: 2018/4/3 需要做没有网络和有网络的处理
202
 // TODO: 2018/4/3 需要做没有网络和有网络的处理
143
         mModel.uploadBillForDB(new MVPListener<Object>() {
220
         mModel.uploadBillForDB(new MVPListener<Object>() {
144
             @Override
221
             @Override
145
             public void onSuccess(Object content) {
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
             @Override
231
             @Override

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

7
 import android.widget.TextView;
7
 import android.widget.TextView;
8
 
8
 
9
 import com.kuxuan.moneynote.R;
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
 import com.kuxuan.moneynote.base.BaseActivity;
13
 import com.kuxuan.moneynote.base.BaseActivity;
11
 import com.kuxuan.moneynote.common.Constant;
14
 import com.kuxuan.moneynote.common.Constant;
12
 import com.kuxuan.moneynote.db.CategoryDaoOperator;
15
 import com.kuxuan.moneynote.db.CategoryDaoOperator;
16
+import com.kuxuan.moneynote.db.UpDataOperator;
17
+import com.kuxuan.moneynote.json.BeanNewJson;
13
 import com.kuxuan.moneynote.json.TypeDataJson;
18
 import com.kuxuan.moneynote.json.TypeDataJson;
19
+import com.kuxuan.moneynote.json.netbody.UpDataBody;
14
 import com.kuxuan.moneynote.ui.activitys.account.AccountActivity;
20
 import com.kuxuan.moneynote.ui.activitys.account.AccountActivity;
15
 import com.kuxuan.moneynote.ui.activitys.eventbus.RefreshEvent;
21
 import com.kuxuan.moneynote.ui.activitys.eventbus.RefreshEvent;
16
 import com.kuxuan.moneynote.ui.weight.CustormDialog;
22
 import com.kuxuan.moneynote.ui.weight.CustormDialog;
19
 import com.kuxuan.moneynote.utils.LoginStatusUtil;
25
 import com.kuxuan.moneynote.utils.LoginStatusUtil;
20
 import com.kuxuan.moneynote.utils.TimeUtlis;
26
 import com.kuxuan.moneynote.utils.TimeUtlis;
21
 import com.kuxuan.moneynote.utils.UIHelper;
27
 import com.kuxuan.moneynote.utils.UIHelper;
28
+import com.kuxuan.sqlite.db.CategoryDB;
22
 import com.umeng.analytics.MobclickAgent;
29
 import com.umeng.analytics.MobclickAgent;
23
 
30
 
24
 import org.greenrobot.eventbus.EventBus;
31
 import org.greenrobot.eventbus.EventBus;
25
 
32
 
33
+import java.util.ArrayList;
34
+
26
 import butterknife.Bind;
35
 import butterknife.Bind;
27
 import butterknife.OnClick;
36
 import butterknife.OnClick;
37
+import io.reactivex.android.schedulers.AndroidSchedulers;
38
+import io.reactivex.schedulers.Schedulers;
28
 
39
 
29
 /**
40
 /**
30
  * 编辑类别
41
  * 编辑类别
215
 //            });
226
 //            });
216
 //
227
 //
217
 //        } else {
228
 //        } else {
218
-        closeProgressDialog();
229
+
219
         //在没登录的状态下是真删,否则是假删
230
         //在没登录的状态下是真删,否则是假删
231
+        categoryDaoOperator.updataIsDelete(bill_db_id, true);
220
         if (LoginStatusUtil.isLoginin()) {
232
         if (LoginStatusUtil.isLoginin()) {
221
-            categoryDaoOperator.updataIsDelete(bill_db_id, true);
222
-
233
+            sync();
223
         } else {
234
         } else {
224
             categoryDaoOperator.deleteData(bill_db_id);
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
     @Override
279
     @Override
233
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
280
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {

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

72
                     item.setOutmoney((long) Float.parseFloat(typeDataJson.getAccount()));
72
                     item.setOutmoney((long) Float.parseFloat(typeDataJson.getAccount()));
73
                     data = JavaFormatUtils.getData(item.getOutmoney() / item.getAllMoney() * 100);
73
                     data = JavaFormatUtils.getData(item.getOutmoney() / item.getAllMoney() * 100);
74
                     helper.money_text.setText(changeFloatData(Double.parseDouble(typeDataJson.getAccount()))+ "");
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
                     break;
76
                     break;
77
                 case 1:
77
                 case 1:
78
                     item.setInmoney((long) Float.parseFloat(typeDataJson.getAccount()));
78
                     item.setInmoney((long) Float.parseFloat(typeDataJson.getAccount()));
79
                     data = JavaFormatUtils.getData(item.getInmoney() / item.getAllMoney() * 100);
79
                     data = JavaFormatUtils.getData(item.getInmoney() / item.getAllMoney() * 100);
80
 //                    JavaFormatUtils.formatFloatNumber(Float.parseFloat(typeDataJson.getAccount())
80
 //                    JavaFormatUtils.formatFloatNumber(Float.parseFloat(typeDataJson.getAccount())
81
                     helper.money_text.setText(changeFloatData(Double.parseDouble(typeDataJson.getAccount()))+ "");
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
                     break;
83
                     break;
84
             }
84
             }
85
                 helper.name_text.setText(typeDataJson.getName() + "  " + data + "%");
85
                 helper.name_text.setText(typeDataJson.getName() + "  " + data + "%");
95
                     float f = item.getOutmoney() / item.getAllMoney();
95
                     float f = item.getOutmoney() / item.getAllMoney();
96
                     data = JavaFormatUtils.getData(f * 100);
96
                     data = JavaFormatUtils.getData(f * 100);
97
                     helper.money_text.setText(changeFloatData(Double.parseDouble(typeDataJson.getAccount())) + "");
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
                     break;
99
                     break;
100
                 case 1:
100
                 case 1:
101
                     item.setInmoney((long)Float.parseFloat(typeDataJson.getAccount()));
101
                     item.setInmoney((long)Float.parseFloat(typeDataJson.getAccount()));
102
                     data = JavaFormatUtils.getData(item.getInmoney() / item.getAllMoney() * 100);
102
                     data = JavaFormatUtils.getData(item.getInmoney() / item.getAllMoney() * 100);
103
                     helper.money_text.setText(changeFloatData(Double.parseDouble(typeDataJson.getAccount()))+ "");
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
                     break;
105
                     break;
106
             }
106
             }
107
             String day = typeDataJson.getDay();
107
             String day = typeDataJson.getDay();

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

290
         if (isLogin) {
290
         if (isLogin) {
291
             //获取数据
291
             //获取数据
292
             view.showLogin();
292
             view.showLogin();
293
-
294
         } else {
293
         } else {
295
             view.showNoLogin();
294
             view.showNoLogin();
296
         }
295
         }

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

41
      * @return
41
      * @return
42
      */
42
      */
43
     public ArrayList<NewChartData> getWeekTabData(HashMap<String, Integer> maps, int type) {
43
     public ArrayList<NewChartData> getWeekTabData(HashMap<String, Integer> maps, int type) {
44
-        if(maps==null){
44
+        if (maps == null) {
45
             return null;
45
             return null;
46
         }
46
         }
47
         int startYear = maps.get("startYear");
47
         int startYear = maps.get("startYear");
150
      * @param categoryDaoOperator
150
      * @param categoryDaoOperator
151
      * @return
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
         NewCategoryJson newCategoryJson = new NewCategoryJson();
154
         NewCategoryJson newCategoryJson = new NewCategoryJson();
155
         ArrayList<TypeDataJson> typeDataJsonLists = new ArrayList<>();
155
         ArrayList<TypeDataJson> typeDataJsonLists = new ArrayList<>();
156
         ArrayList<TimeDataJson> timeDataJsonsLists = new ArrayList<>();
156
         ArrayList<TimeDataJson> timeDataJsonsLists = new ArrayList<>();
161
             int year = Integer.parseInt(split[0]);
161
             int year = Integer.parseInt(split[0]);
162
             int month = Integer.parseInt(split[1]);
162
             int month = Integer.parseInt(split[1]);
163
             int day = Integer.parseInt(split[2]);
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
             if (category_id != -1) {
165
             if (category_id != -1) {
166
                 detialDataLists.addAll(changJson(weekData, category_id));
166
                 detialDataLists.addAll(changJson(weekData, category_id));
167
             } else {
167
             } else {
179
                 account += Double.parseDouble(typeDataJson.getAccount());
179
                 account += Double.parseDouble(typeDataJson.getAccount());
180
             }
180
             }
181
             newCategoryJson.setAccount(account + "");
181
             newCategoryJson.setAccount(account + "");
182
-            newCategoryJson.setCategory(typeDataJsonLists);
182
+            newCategoryJson.setCategory(categLists);
183
         } else {
183
         } else {
184
             double account = 0;
184
             double account = 0;
185
             for (TypeDataJson typeDataJson : detialDataLists) {
185
             for (TypeDataJson typeDataJson : detialDataLists) {
202
      * @param categoryDaoOperator
202
      * @param categoryDaoOperator
203
      * @return
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
         NewCategoryJson newCategoryJson = new NewCategoryJson();
207
         NewCategoryJson newCategoryJson = new NewCategoryJson();
208
         ArrayList<TypeDataJson> typeDataJsonLists = new ArrayList<>();
208
         ArrayList<TypeDataJson> typeDataJsonLists = new ArrayList<>();
209
         ArrayList<TimeDataJson> timeDataJsonsLists = new ArrayList<>();
209
         ArrayList<TimeDataJson> timeDataJsonsLists = new ArrayList<>();
210
         ArrayList<TypeDataJson> detialDataLists = new ArrayList<>();
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
         if (category_id == -1)
212
         if (category_id == -1)
213
             typeDataJsonLists.addAll(changJson(weekData));
213
             typeDataJsonLists.addAll(changJson(weekData));
214
         else
214
         else
215
             detialDataLists.addAll(changJson(weekData, category_id));
215
             detialDataLists.addAll(changJson(weekData, category_id));
216
         int monthDay = CalanderUtil.getMonthDay(year, month);
216
         int monthDay = CalanderUtil.getMonthDay(year, month);
217
         for (int i = 1; i <= monthDay; i++) {
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
             if (timeDataJson != null) {
219
             if (timeDataJson != null) {
220
                 timeDataJsonsLists.add(timeDataJson);
220
                 timeDataJsonsLists.add(timeDataJson);
221
             }
221
             }
227
                 account += Double.parseDouble(typeDataJson.getAccount());
227
                 account += Double.parseDouble(typeDataJson.getAccount());
228
             }
228
             }
229
             newCategoryJson.setAccount(account + "");
229
             newCategoryJson.setAccount(account + "");
230
-            newCategoryJson.setCategory(typeDataJsonLists);
230
+            newCategoryJson.setCategory(categLists);
231
         } else {
231
         } else {
232
             double account = 0;
232
             double account = 0;
233
             for (TypeDataJson typeDataJson : detialDataLists) {
233
             for (TypeDataJson typeDataJson : detialDataLists) {
249
      * @param categoryDaoOperator
249
      * @param categoryDaoOperator
250
      * @return
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
         NewCategoryJson newCategoryJson = new NewCategoryJson();
253
         NewCategoryJson newCategoryJson = new NewCategoryJson();
254
         ArrayList<TypeDataJson> typeDataJsonLists = new ArrayList<>();
254
         ArrayList<TypeDataJson> typeDataJsonLists = new ArrayList<>();
255
         ArrayList<TypeDataJson> detialDataLists = new ArrayList<>();
255
         ArrayList<TypeDataJson> detialDataLists = new ArrayList<>();
256
         ArrayList<TimeDataJson> timeDataJsonsLists = new ArrayList<>();
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
         if (category_id == -1)
258
         if (category_id == -1)
259
             typeDataJsonLists.addAll(changJson(weekData));
259
             typeDataJsonLists.addAll(changJson(weekData));
260
         else
260
         else
261
             detialDataLists.addAll(changJson(weekData, category_id));
261
             detialDataLists.addAll(changJson(weekData, category_id));
262
         for (int i = 1; i <= 12; i++) {
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
             if (timeDataJson != null) {
264
             if (timeDataJson != null) {
265
                 timeDataJsonsLists.add(timeDataJson);
265
                 timeDataJsonsLists.add(timeDataJson);
266
             }
266
             }
272
                 account += Double.parseDouble(typeDataJson.getAccount());
272
                 account += Double.parseDouble(typeDataJson.getAccount());
273
             }
273
             }
274
             newCategoryJson.setAccount(account + "");
274
             newCategoryJson.setAccount(account + "");
275
-            newCategoryJson.setCategory(typeDataJsonLists);
275
+            newCategoryJson.setCategory(categLists);
276
         } else {
276
         } else {
277
             double account = 0;
277
             double account = 0;
278
             for (TypeDataJson typeDataJson : detialDataLists) {
278
             for (TypeDataJson typeDataJson : detialDataLists) {
330
      * @param day
330
      * @param day
331
      * @return
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
         TimeDataJson timeDataJson = new TimeDataJson();
334
         TimeDataJson timeDataJson = new TimeDataJson();
335
         timeDataJson.setDay(String.format("%02d", day) + "");
335
         timeDataJson.setDay(String.format("%02d", day) + "");
336
         ArrayList<PopCharData> data = new ArrayList<>();
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
         for (int i = 0; i < weekData.size(); i++) {
338
         for (int i = 0; i < weekData.size(); i++) {
339
             PopCharData typeDataJson = new PopCharData();
339
             PopCharData typeDataJson = new PopCharData();
340
             typeDataJson.setCategory_id(weekData.get(i).getCategory_id());
340
             typeDataJson.setCategory_id(weekData.get(i).getCategory_id());
366
      * @param categoryDaoOperator
366
      * @param categoryDaoOperator
367
      * @return
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
         TimeDataJson timeDataJson = new TimeDataJson();
370
         TimeDataJson timeDataJson = new TimeDataJson();
371
         timeDataJson.setDay(String.format("%02d", month) + "");
371
         timeDataJson.setDay(String.format("%02d", month) + "");
372
         ArrayList<PopCharData> data = new ArrayList<>();
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
         for (int i = 0; i < monthData.size(); i++) {
374
         for (int i = 0; i < monthData.size(); i++) {
375
             PopCharData typeDataJson = new PopCharData();
375
             PopCharData typeDataJson = new PopCharData();
376
             typeDataJson.setCategory_id(monthData.get(i).getCategory_id());
376
             typeDataJson.setCategory_id(monthData.get(i).getCategory_id());
416
                         t = new TypeDataJson();
416
                         t = new TypeDataJson();
417
                         t.setName(typeDataJson.getName());
417
                         t.setName(typeDataJson.getName());
418
                         t.setCategory_id(typeDataJson.getCategory_id());
418
                         t.setCategory_id(typeDataJson.getCategory_id());
419
+                        t.setDetail_icon(typeDataJson.getDetail_icon());
420
+                        t.setSmall_icon(typeDataJson.getSmall_icon());
419
                         t.setAccount(typeDataJson.getAccount());
421
                         t.setAccount(typeDataJson.getAccount());
420
                         t.setType(typeDataJson.getType());
422
                         t.setType(typeDataJson.getType());
421
                     } else {
423
                     } else {
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
      * @param list
519
      * @param list
463
         ArrayList<TypeDataJson> datas = new ArrayList<>();
524
         ArrayList<TypeDataJson> datas = new ArrayList<>();
464
         for (int i = 0; i < list.size(); i++) {
525
         for (int i = 0; i < list.size(); i++) {
465
             TypeDataJson typeDataJson = new TypeDataJson();
526
             TypeDataJson typeDataJson = new TypeDataJson();
466
-            typeDataJson.setBill_id( list.get(i).getBill_id());
527
+            typeDataJson.setBill_id(list.get(i).getBill_id());
467
             typeDataJson.setDetail_icon(list.get(i).getImage_path());
528
             typeDataJson.setDetail_icon(list.get(i).getImage_path());
468
             typeDataJson.setSmall_icon(list.get(i).getImage_path());
529
             typeDataJson.setSmall_icon(list.get(i).getImage_path());
469
             typeDataJson.setDay(list.get(i).getYear() + "-" + String.format("%02d", list.get(i).getMonth()) + "-" + String.format("%02d", list.get(i).getDay()));
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
         ArrayList<String> data = new ArrayList<String>();
156
         ArrayList<String> data = new ArrayList<String>();
157
         Calendar cal = getCalendarFormYear(startYear);
157
         Calendar cal = getCalendarFormYear(startYear);
158
         cal.set(Calendar.WEEK_OF_YEAR, week);
158
         cal.set(Calendar.WEEK_OF_YEAR, week);
159
+        cal.setFirstDayOfWeek(Calendar.MONDAY);
159
         int year = cal.get(Calendar.YEAR);
160
         int year = cal.get(Calendar.YEAR);
160
         int month = (cal.get(Calendar.MONTH) + 1);
161
         int month = (cal.get(Calendar.MONTH) + 1);
161
         int day = cal.get(Calendar.DAY_OF_MONTH);
162
         int day = cal.get(Calendar.DAY_OF_MONTH);