e 6 yıl önce
ebeveyn
işleme
38c3355a00

+ 9 - 0
app/src/main/java/com/kuxuan/moneynote/api/ApiService.java

@@ -407,6 +407,15 @@ public interface ApiService {
407 407
     @POST("upData")
408 408
     Observable<BaseJson<Object>> upData(@Body UpDataBody dataBody);
409 409
 
410
+
411
+    /**
412
+     * 设置预算
413
+     * @param month_budget
414
+     * @return
415
+     */
416
+    @POST("setMonthBudget")
417
+    Observable<BaseJson<Object>> setBudgetData(@Query("month_budget")String month_budget);
418
+
410 419
 }
411 420
 
412 421
 

+ 10 - 0
app/src/main/java/com/kuxuan/moneynote/json/MineJson.java

@@ -17,6 +17,16 @@ public class MineJson {
17 17
     private String nickname;
18 18
     private String headimgurl;
19 19
     private String android_share_url;
20
+    private String month_budget;
21
+
22
+
23
+    public String getMonth_budget() {
24
+        return month_budget;
25
+    }
26
+
27
+    public void setMonth_budget(String month_budget) {
28
+        this.month_budget = month_budget;
29
+    }
20 30
 
21 31
     public String getAndroid_share_url() {
22 32
         return android_share_url;

+ 54 - 4
app/src/main/java/com/kuxuan/moneynote/ui/activitys/budget/BudgetActivity.java

@@ -7,17 +7,28 @@ import android.widget.ImageView;
7 7
 import android.widget.RelativeLayout;
8 8
 import android.widget.TextView;
9 9
 
10
+import com.kuxuan.moneynote.MyApplication;
10 11
 import com.kuxuan.moneynote.R;
12
+import com.kuxuan.moneynote.api.ExceptionHandle;
13
+import com.kuxuan.moneynote.api.MyObsever;
14
+import com.kuxuan.moneynote.api.RetrofitClient;
11 15
 import com.kuxuan.moneynote.base.BaseActivity;
12 16
 import com.kuxuan.moneynote.common.Constant;
17
+import com.kuxuan.moneynote.json.BaseJson;
18
+import com.kuxuan.moneynote.json.MineJson;
13 19
 import com.kuxuan.moneynote.ui.activitys.eventbus.BugetEvent;
20
+import com.kuxuan.moneynote.utils.LoginStatusUtil;
21
+import com.kuxuan.moneynote.utils.NetWorkUtil;
14 22
 import com.kuxuan.moneynote.utils.SPUtil;
23
+import com.kuxuan.moneynote.utils.ToastUtil;
15 24
 
16 25
 import org.greenrobot.eventbus.EventBus;
17 26
 import org.greenrobot.eventbus.Subscribe;
18 27
 import org.greenrobot.eventbus.ThreadMode;
19 28
 
20 29
 import butterknife.Bind;
30
+import io.reactivex.android.schedulers.AndroidSchedulers;
31
+import io.reactivex.schedulers.Schedulers;
21 32
 
22 33
 /**
23 34
  * 预算设置
@@ -54,14 +65,18 @@ public class BudgetActivity extends BaseActivity {
54 65
         imageView.setOnClickListener(new View.OnClickListener() {
55 66
             @Override
56 67
             public void onClick(View view) {
68
+                if(!NetWorkUtil.isNetworkAvailable(BudgetActivity.this)){
69
+                    ToastUtil.show(BudgetActivity.this,getResources().getString(R.string.nonetwork));
70
+                   return;
71
+                }
57 72
                 boolean isOpne = (boolean) SPUtil.get(BudgetActivity.this, Constant.System.SWITCH, false);
58 73
                 if (isOpne) {
59
-                    SPUtil.putAndApply(BudgetActivity.this, Constant.System.SWITCH, false);
74
+                    setData("0", isOpne);
60 75
                 } else {
61
-                    SPUtil.putAndApply(BudgetActivity.this, Constant.System.SWITCH, true);
76
+                    int d = (int) SPUtil.get(BudgetActivity.this, Constant.System.BUGET_NUM, Constant.System.NORMAL_NUM);
77
+                    setData(d + "", isOpne);
62 78
                 }
63
-                EventBus.getDefault().post(new BugetEvent());
64
-                finish();
79
+
65 80
             }
66 81
         });
67 82
         activityBugetGotosettingLayout.setOnClickListener(new View.OnClickListener() {
@@ -105,4 +120,39 @@ public class BudgetActivity extends BaseActivity {
105 120
         setData();
106 121
     }
107 122
 
123
+
124
+    private void setData(final String data, final boolean isOpen) {
125
+        RetrofitClient.getApiService().setBudgetData(data).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new MyObsever<BaseJson<Object>>() {
126
+            @Override
127
+            public void onError(ExceptionHandle.ResponeThrowable e) {
128
+            }
129
+
130
+            @Override
131
+            public void onSuccess(BaseJson<Object> objectBaseJson) {
132
+                if (objectBaseJson != null) {
133
+                    if (objectBaseJson.getCode() == 0) {
134
+                        int i = Integer.parseInt(data);
135
+                        SPUtil.putAndApply(MyApplication.getInstance(), Constant.System.BUGET_NUM, i);
136
+                        MineJson userInfo = LoginStatusUtil.getUserInfo();
137
+                        if(userInfo!=null){
138
+                            userInfo.setMonth_budget(data);
139
+                            LoginStatusUtil.setUserInfo(userInfo);
140
+                        }
141
+                        if (isOpen) {
142
+                            SPUtil.putAndApply(BudgetActivity.this, Constant.System.SWITCH, false);
143
+
144
+
145
+                        } else {
146
+                            SPUtil.putAndApply(BudgetActivity.this, Constant.System.SWITCH, true);
147
+                        }
148
+                        EventBus.getDefault().post(new BugetEvent());
149
+                        finish();
150
+                    } else {
151
+                    }
152
+                } else {
153
+
154
+                }
155
+            }
156
+        });
157
+    }
108 158
 }

+ 58 - 8
app/src/main/java/com/kuxuan/moneynote/ui/activitys/budget/BudgetSettingActivity.java

@@ -7,17 +7,29 @@ import android.view.View;
7 7
 import android.widget.Button;
8 8
 import android.widget.EditText;
9 9
 
10
+import com.kuxuan.moneynote.MyApplication;
10 11
 import com.kuxuan.moneynote.R;
12
+import com.kuxuan.moneynote.api.ExceptionHandle;
13
+import com.kuxuan.moneynote.api.MyObsever;
14
+import com.kuxuan.moneynote.api.RetrofitClient;
11 15
 import com.kuxuan.moneynote.base.BaseActivity;
12 16
 import com.kuxuan.moneynote.common.Constant;
17
+import com.kuxuan.moneynote.json.BaseJson;
18
+import com.kuxuan.moneynote.json.MineJson;
13 19
 import com.kuxuan.moneynote.ui.activitys.eventbus.BugetEvent;
20
+import com.kuxuan.moneynote.utils.DrawableUtil;
14 21
 import com.kuxuan.moneynote.utils.JavaFormatUtils;
22
+import com.kuxuan.moneynote.utils.LoginStatusUtil;
23
+import com.kuxuan.moneynote.utils.NetWorkUtil;
15 24
 import com.kuxuan.moneynote.utils.SPUtil;
25
+import com.kuxuan.moneynote.utils.ToastUtil;
16 26
 
17 27
 import org.greenrobot.eventbus.EventBus;
18 28
 
19 29
 import butterknife.Bind;
20 30
 import butterknife.OnClick;
31
+import io.reactivex.android.schedulers.AndroidSchedulers;
32
+import io.reactivex.schedulers.Schedulers;
21 33
 
22 34
 /**
23 35
  * Created by xieshengqi on 2018/4/24.
@@ -47,6 +59,7 @@ public class BudgetSettingActivity extends BaseActivity {
47 59
         int num = (int) SPUtil.get(this, Constant.System.BUGET_NUM, Constant.System.NORMAL_NUM);
48 60
         numedit.setHint(JavaFormatUtils.formatFloatNumber(num));
49 61
         initEdit();
62
+
50 63
     }
51 64
 
52 65
     private void initEdit() {
@@ -64,12 +77,12 @@ public class BudgetSettingActivity extends BaseActivity {
64 77
             @Override
65 78
             public void afterTextChanged(Editable editable) {
66 79
                 if (editable.length() != 0 && numedit.getText().length() != 0) {
67
-                    completeBtn.setBackground(getResources().getDrawable(R.drawable.bg_orange_btn));
68
-                    completeBtn.setTextColor(getResources().getColor(R.color.black));
80
+                    completeBtn.setBackground(DrawableUtil.getShape(BudgetSettingActivity.this));
81
+                    completeBtn.setTextColor(getResources().getColor(R.color.white));
69 82
                     completeBtn.setEnabled(true);
70 83
                 } else {
71 84
                     completeBtn.setBackground(getResources().getDrawable(R.drawable.bg_gray_btn));
72
-                    completeBtn.setTextColor(getResources().getColor(R.color.gray_text));
85
+                    completeBtn.setTextColor(getResources().getColor(R.color.white));
73 86
                     completeBtn.setEnabled(false);
74 87
                 }
75 88
             }
@@ -78,11 +91,48 @@ public class BudgetSettingActivity extends BaseActivity {
78 91
 
79 92
     @OnClick(R.id.activity_bugetsetting_complete_btn)
80 93
     public void onViewClicked() {
81
-
82 94
         String string = numedit.getText().toString();
83
-        int i = Integer.parseInt(string);
84
-        SPUtil.putAndApply(this, Constant.System.BUGET_NUM, i);
85
-        EventBus.getDefault().post(new BugetEvent());
86
-        finish();
95
+        int da = Integer.parseInt(string);
96
+        if (da == 0) {
97
+            ToastUtil.show(this, "预算金额必须大于0");
98
+            return;
99
+        }
100
+        if (!NetWorkUtil.isNetworkAvailable(this)) {
101
+            ToastUtil.show(this, getResources().getString(R.string.nonetwork));
102
+            return;
103
+        }
104
+        setData(string);
105
+    }
106
+
107
+
108
+    private void setData(final String data) {
109
+        RetrofitClient.getApiService().setBudgetData(data).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new MyObsever<BaseJson<Object>>() {
110
+            @Override
111
+            public void onError(ExceptionHandle.ResponeThrowable e) {
112
+                ToastUtil.show(BudgetSettingActivity.this, "设置失败");
113
+            }
114
+
115
+            @Override
116
+            public void onSuccess(BaseJson<Object> objectBaseJson) {
117
+                if (objectBaseJson != null) {
118
+                    if (objectBaseJson.getCode() == 0) {
119
+                        int i = Integer.parseInt(data);
120
+                        MineJson userInfo = LoginStatusUtil.getUserInfo();
121
+                        if (userInfo != null) {
122
+                            userInfo.setMonth_budget(data);
123
+                            LoginStatusUtil.setUserInfo(userInfo);
124
+                        }
125
+                        if (i != 0)
126
+                            SPUtil.putAndApply(MyApplication.getInstance(), Constant.System.BUGET_NUM, i);
127
+                        EventBus.getDefault().post(new BugetEvent());
128
+                        finish();
129
+                    } else {
130
+                        ToastUtil.show(BudgetSettingActivity.this, objectBaseJson.getMessage().get(0));
131
+                    }
132
+                } else {
133
+                    ToastUtil.show(BudgetSettingActivity.this, "设置失败");
134
+                }
135
+            }
136
+        });
87 137
     }
88 138
 }

+ 1 - 1
app/src/main/java/com/kuxuan/moneynote/ui/activitys/category/CategoryPresent.java

@@ -84,7 +84,7 @@ public class CategoryPresent extends CategoryContract.CategoryPresent {
84 84
 
85 85
             @Override
86 86
             public void onFail(String msg) {
87
-
87
+view.hideProgress();
88 88
             }
89 89
         }, type);
90 90
     }

+ 5 - 4
app/src/main/java/com/kuxuan/moneynote/ui/fragments/details/DetialFragment.java

@@ -323,12 +323,13 @@ public class DetialFragment extends MVPFragment<DetialPresent, DetialModel> impl
323 323
         currentOutMoney = Double.parseDouble(outMoey);
324 324
         TextSetUtil.setTextForMoey(JavaFormatUtils.formatFloatNumber(currentInmoney), fragmentDetialMoneyin);
325 325
         TextSetUtil.setTextForMoey(JavaFormatUtils.formatFloatNumber(currentOutMoney), fragmentDetialMoneyout);
326
-        changeTypeData(currentInmoney, currentOutMoney);
326
+        boolean isOpen = (boolean) SPUtil.get(getActivity(), Constant.System.SWITCH, false);
327
+            changeTypeData(currentInmoney, currentOutMoney);
327 328
     }
328 329
 
329 330
     private void changeTypeData(Double inMoney, Double outMoney) {
330 331
         boolean isOpen = (boolean) SPUtil.get(getActivity(), Constant.System.SWITCH, false);
331
-        Integer date = (Integer) SPUtil.get(getActivity(), Constant.System.BUGET_NUM, Constant.System.NORMAL_NUM);
332
+        Integer date = (Integer) SPUtil.get(getActivity(), Constant.System.BUGET_NUM, 0);
332 333
         if (isOpen) {
333 334
             type_text.setText("预算结余");
334 335
             TextSetUtil.setTextForBigSize(JavaFormatUtils.formatFloatNumber(date - outMoney), allMoney_text);
@@ -598,8 +599,8 @@ public class DetialFragment extends MVPFragment<DetialPresent, DetialModel> impl
598 599
                     //选中的时候存储颜色
599 600
 //                    SPUtil.putAndApply(getContext(), Constant.Skin.COLOR_SELECT, "#FF4081" );
600 601
                     String color1 = item.getColor();
601
-                    color1 =  color1.substring(2,8);
602
-                    Log.e("字符数",color1.length()+"");
602
+                    color1 = color1.substring(2, 8);
603
+                    Log.e("字符数", color1.length() + "");
603 604
                     SPUtil.putAndApply(MyApplication.getInstance(), Constant.Skin.COLOR_SELECT, color1);
604 605
 
605 606
                     EventBus.getDefault().post(new SkinEvent(mskinBean.getCode()));

+ 21 - 4
app/src/main/java/com/kuxuan/moneynote/ui/fragments/mine/MineFragment.java

@@ -25,6 +25,7 @@ import com.kuxuan.moneynote.ui.activitys.bill.BillActivity;
25 25
 import com.kuxuan.moneynote.ui.activitys.bindphone.BindThirdActivity;
26 26
 import com.kuxuan.moneynote.ui.activitys.budget.BudgetActivity;
27 27
 import com.kuxuan.moneynote.ui.activitys.category.CategoryActivity;
28
+import com.kuxuan.moneynote.ui.activitys.eventbus.BugetEvent;
28 29
 import com.kuxuan.moneynote.ui.activitys.eventbus.LoginEvent;
29 30
 import com.kuxuan.moneynote.ui.activitys.eventbus.LoginOutEvent;
30 31
 import com.kuxuan.moneynote.ui.activitys.eventbus.NetworkEvent;
@@ -233,13 +234,12 @@ public class MineFragment extends MVPFragment<MinePresent, MineModel> implements
233 234
          }
234 235
 
235 236
 
236
-
237 237
         cal = Calendar.getInstance();
238 238
         activity = (BaseFragmentActivity) getActivity();
239 239
         mShareListener = new CustomShareListener(getActivity());
240 240
         month = cal.get(Calendar.MONTH) + 1 + "";
241 241
         year = cal.get(Calendar.YEAR) + "";
242
-        TextSetUtil.setTextForMonth(month+"月", monthTv, Color.BLACK);
242
+        TextSetUtil.setTextForMonth(month + "月", monthTv, Color.BLACK);
243 243
         if (LoginStatusUtil.isLoginin()) {
244 244
             MineJson userInfo = LoginStatusUtil.getUserInfo();
245 245
             if (userInfo == null) {
@@ -450,6 +450,7 @@ public class MineFragment extends MVPFragment<MinePresent, MineModel> implements
450 450
 
451 451
     @Bind(R.id.iv_mineskin)
452 452
     ImageView iv_mineskin;
453
+
453 454
     @Subscribe(threadMode = ThreadMode.MAIN)
454 455
     public void onMessageEvent5(SkinEvent skinBean){
455 456
         String fileheader = MyApplication.getInstance().getApplicationContext().getFilesDir().getPath()+"/"+"skin/";
@@ -463,8 +464,6 @@ public class MineFragment extends MVPFragment<MinePresent, MineModel> implements
463 464
             GlideUtil.setImageWithNoCache(getContext(),file,iv_mineskin);
464 465
         }
465 466
 
466
-
467
-
468 467
     }
469 468
 
470 469
 
@@ -547,6 +546,24 @@ public class MineFragment extends MVPFragment<MinePresent, MineModel> implements
547 546
         }
548 547
         aaaa = mineModel.getAndroid_share_url();
549 548
 
549
+
550
+        //预算设置
551
+        String month_budget = mineModel.getMonth_budget();
552
+        int budget = 0;
553
+        try {
554
+            budget = (int) Double.parseDouble(month_budget);
555
+
556
+        } catch (Exception e) {
557
+
558
+        }
559
+        if (budget == 0) {
560
+            SPUtil.putAndApply(MyApplication.getInstance(), Constant.System.SWITCH, false);
561
+            SPUtil.putAndApply(MyApplication.getInstance(), Constant.System.BUGET_NUM, Constant.System.NORMAL_NUM);
562
+        } else {
563
+            SPUtil.putAndApply(MyApplication.getInstance(), Constant.System.SWITCH, true);
564
+            SPUtil.putAndApply(MyApplication.getInstance(), Constant.System.BUGET_NUM, budget);
565
+        }
566
+        EventBus.getDefault().post(new BugetEvent());
550 567
     }
551 568
 
552 569
     @Override

+ 4 - 2
app/src/main/java/com/kuxuan/moneynote/utils/LoginStatusUtil.java

@@ -46,8 +46,10 @@ public class LoginStatusUtil {
46 46
         SPUtil.putAndApply(MyApplication.getInstance(), Constant.Time.TOKEN_FAIL, 0L);
47 47
         SPUtil.putAndApply(MyApplication.getInstance(), Constant.UserInfo.USER_ID, -1);
48 48
         SPUtil.putAndApply(MyApplication.getInstance(), Constant.UserInfo.USER_INFO, "");
49
-        //初始下载数据位
50
-        SPUtil.putAndApply(MyApplication.getInstance(), Constant.DbInfo.DB_DOWNLOAD_INDEX, 0);
49
+//预算初始化
50
+        SPUtil.putAndApply(MyApplication.getInstance(), Constant.System.SWITCH, false);
51
+        SPUtil.putAndApply(MyApplication.getInstance(), Constant.System.BUGET_NUM, Constant.System.NORMAL_NUM);
52
+
51 53
     }
52 54
 
53 55