Commit 12229e0df3462a830fe65e44ad1e32611c470339
1 parent
e78e2e1d
Exists in
yxb_dev
and in
2 other branches
no message
Showing
8 changed files
with
120 additions
and
54 deletions
Show diff stats
app/src/main/java/com/shunzhi/parent/AppConfig.java
... | ... | @@ -25,6 +25,7 @@ public class AppConfig { |
25 | 25 | public static String NIM_CONFIG_VIBRATE = "nim_config_vibrate";//收到通知震动 |
26 | 26 | public static String NIM_CONFIG_SOUND = "nim_config_sound";//收到通知响铃 |
27 | 27 | public static String ISBINDING="isbinding"; |
28 | + public static String CURRCHILDJSONSTR=""; | |
28 | 29 | |
29 | 30 | |
30 | 31 | public static boolean ISLOGIN = false; | ... | ... |
app/src/main/java/com/shunzhi/parent/db/ChildInfoDao.java
... | ... | @@ -3,6 +3,7 @@ package com.shunzhi.parent.db; |
3 | 3 | import android.content.Context; |
4 | 4 | |
5 | 5 | import com.j256.ormlite.dao.Dao; |
6 | +import com.j256.ormlite.stmt.DeleteBuilder; | |
6 | 7 | import com.j256.ormlite.stmt.QueryBuilder; |
7 | 8 | import com.shunzhi.parent.bean.ChildBean; |
8 | 9 | import com.shunzhi.parent.util.DatabaseHelper; |
... | ... | @@ -30,6 +31,16 @@ public class ChildInfoDao { |
30 | 31 | } |
31 | 32 | } |
32 | 33 | |
34 | + public boolean createOrUpdate(ChildBean childBean){ | |
35 | + try { | |
36 | + return dao.createOrUpdate(childBean).getNumLinesChanged() > 0; | |
37 | + } catch (SQLException e) { | |
38 | + e.printStackTrace(); | |
39 | + return false; | |
40 | + } | |
41 | + } | |
42 | + | |
43 | + | |
33 | 44 | public boolean onCreate(ChildBean childBean) { |
34 | 45 | try { |
35 | 46 | return dao.create(childBean) > 0; |
... | ... | @@ -39,7 +50,15 @@ public class ChildInfoDao { |
39 | 50 | } |
40 | 51 | } |
41 | 52 | |
42 | - | |
53 | + public boolean deleteAll(){ | |
54 | + try { | |
55 | + DeleteBuilder builder = dao.deleteBuilder(); | |
56 | + return dao.delete(builder.prepare())>0; | |
57 | + } catch (SQLException e) { | |
58 | + e.printStackTrace(); | |
59 | + return false; | |
60 | + } | |
61 | + } | |
43 | 62 | public synchronized List<ChildBean> getAllChildren() { |
44 | 63 | List<ChildBean> children = null; |
45 | 64 | try { | ... | ... |
app/src/main/java/com/shunzhi/parent/presenter/mine/MyChildPresenter.java
... | ... | @@ -59,7 +59,6 @@ public class MyChildPresenter extends MyChildContract.MyChildPresenter { |
59 | 59 | } catch (Exception e1) { |
60 | 60 | e1.printStackTrace(); |
61 | 61 | } |
62 | - | |
63 | 62 | } |
64 | 63 | })); |
65 | 64 | |
... | ... | @@ -111,7 +110,6 @@ public class MyChildPresenter extends MyChildContract.MyChildPresenter { |
111 | 110 | mRxManager.register(mIModel.unBinnding(parentId, studentId).subscribe(new Consumer<JsonObject>() { |
112 | 111 | @Override |
113 | 112 | public void accept(JsonObject jsonObject) throws Exception { |
114 | - ToastUtils.showToast(jsonObject.toString()); | |
115 | 113 | mIView.showError("123"); |
116 | 114 | } |
117 | 115 | }, new Consumer<Throwable>() { | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/activity/ChildDetialActivity.java
... | ... | @@ -15,11 +15,14 @@ import android.widget.TextView; |
15 | 15 | import com.google.gson.Gson; |
16 | 16 | import com.share.mvpsdk.base.BasePresenter; |
17 | 17 | import com.share.mvpsdk.base.activity.BaseMVPCompatActivity; |
18 | +import com.shunzhi.parent.AppConfig; | |
19 | +import com.shunzhi.parent.AppContext; | |
18 | 20 | import com.shunzhi.parent.R; |
19 | 21 | import com.shunzhi.parent.bean.ChildBean; |
20 | 22 | import com.shunzhi.parent.bean.ChildClass; |
21 | 23 | import com.shunzhi.parent.bean.CurrentBean; |
22 | 24 | import com.shunzhi.parent.contract.mine.MyChildContract; |
25 | +import com.shunzhi.parent.presenter.mine.MyChildPresenter; | |
23 | 26 | |
24 | 27 | import java.util.List; |
25 | 28 | |
... | ... | @@ -34,6 +37,7 @@ public class ChildDetialActivity extends BaseMVPCompatActivity<MyChildContract.M |
34 | 37 | String childName, cardNumber; |
35 | 38 | int studentId; |
36 | 39 | int isactivation = 0; |
40 | + ChildBean childBean; | |
37 | 41 | |
38 | 42 | @Override |
39 | 43 | protected void initView(Bundle savedInstanceState) { |
... | ... | @@ -63,7 +67,7 @@ public class ChildDetialActivity extends BaseMVPCompatActivity<MyChildContract.M |
63 | 67 | |
64 | 68 | private void initChild(String childJson) { |
65 | 69 | Gson g = new Gson(); |
66 | - ChildBean childBean = g.fromJson(childJson, ChildBean.class); | |
70 | + childBean = g.fromJson(childJson, ChildBean.class); | |
67 | 71 | if (!TextUtils.isEmpty(childBean.getCardNumber())) { |
68 | 72 | cardNumber = childBean.getCardNumber(); |
69 | 73 | isactivation = 1; |
... | ... | @@ -97,7 +101,7 @@ public class ChildDetialActivity extends BaseMVPCompatActivity<MyChildContract.M |
97 | 101 | @NonNull |
98 | 102 | @Override |
99 | 103 | public BasePresenter initPresenter() { |
100 | - return null; | |
104 | + return new MyChildPresenter(); | |
101 | 105 | } |
102 | 106 | |
103 | 107 | @Override |
... | ... | @@ -117,7 +121,9 @@ public class ChildDetialActivity extends BaseMVPCompatActivity<MyChildContract.M |
117 | 121 | |
118 | 122 | @Override |
119 | 123 | public void showError(String error) { |
120 | - | |
124 | + if (error.equals("解绑成功")) ; | |
125 | + mPresenter.loadChildList(AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.LOGIN_NAME), 0, ""); | |
126 | + finish(); | |
121 | 127 | } |
122 | 128 | |
123 | 129 | public void delectChild() { |
... | ... | @@ -143,6 +149,7 @@ public class ChildDetialActivity extends BaseMVPCompatActivity<MyChildContract.M |
143 | 149 | public void onClick(View v) { |
144 | 150 | popupWindow.dismiss(); |
145 | 151 | backgroundAlpha(1f); |
152 | + mPresenter.unBinndingResult(childBean.getParentId(), childBean.getStudentId()); | |
146 | 153 | |
147 | 154 | } |
148 | 155 | }); | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/activity/MyChildActivity.java
... | ... | @@ -69,41 +69,12 @@ public class MyChildActivity extends BaseMVPCompatActivity<MyChildContract.MyChi |
69 | 69 | |
70 | 70 | private void initRecyclerView() { |
71 | 71 | child_recycle.setLayoutManager(new LinearLayoutManager(this)); |
72 | -// child_recycle.smoothOpenRightMenu(0); | |
73 | -// child_recycle.setSwipeMenuCreator(swipeMenuCreator); | |
74 | -// child_recycle.setSwipeMenuItemClickListener(new SwipeMenuItemClickListener() { | |
75 | -// @Override | |
76 | -// public void onItemClick(final SwipeMenuBridge menuBridge) { | |
77 | -// final PopupWindow popupWindow = new PopupWindow(); | |
78 | -// popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); | |
79 | -// popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); | |
80 | -// backgroundAlpha(0.5f); | |
81 | -// View view = LayoutInflater.from(MyChildActivity.this).inflate(R.layout.dialog_view, null); | |
82 | -// TextView tv = view.findViewById(R.id.dialog_info); | |
83 | -// tv.setText("是否解除绑定?"); | |
84 | -// TextView btn_cancel = view.findViewById(R.id.cancel_btn); | |
85 | -// btn_cancel.setOnClickListener(new View.OnClickListener() { | |
86 | -// @Override | |
87 | -// public void onClick(View v) { | |
88 | -// popupWindow.dismiss(); | |
89 | -// backgroundAlpha(1f); | |
90 | -// } | |
91 | -// }); | |
92 | -// TextView btn_right = view.findViewById(R.id.right_btn); | |
93 | -// btn_right.setOnClickListener(new View.OnClickListener() { | |
94 | -// @Override | |
95 | -// public void onClick(View v) { | |
96 | -// popupWindow.dismiss(); | |
97 | -// backgroundAlpha(1f); | |
98 | -// mPresenter.unBinndingResult(Integer.parseInt(AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.PARENT_ID)) | |
99 | -// , currlist.get(menuBridge.getAdapterPosition()).getStudentId()); | |
100 | -// } | |
101 | -// }); | |
102 | -// popupWindow.setContentView(view); | |
103 | -// popupWindow.showAtLocation(child_recycle, Gravity.CENTER, 0, 0); | |
104 | -// | |
105 | -// } | |
106 | -// }); | |
72 | + | |
73 | + } | |
74 | + | |
75 | + @Override | |
76 | + protected void onResume() { | |
77 | + super.onResume(); | |
107 | 78 | mPresenter.loadChildList(AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.LOGIN_NAME), 0, ""); |
108 | 79 | } |
109 | 80 | |
... | ... | @@ -131,6 +102,7 @@ public class MyChildActivity extends BaseMVPCompatActivity<MyChildContract.MyChi |
131 | 102 | @Override |
132 | 103 | public void updateChildList(CurrentBean currentBean) { |
133 | 104 | currlist.clear(); |
105 | + DBControl.childInfoDao.deleteAll(); | |
134 | 106 | List<ChildBean> list = currentBean.getStudentClass(); |
135 | 107 | for(int i=0;i<list.size();i++){ |
136 | 108 | DBControl.childInfoDao.onCreate(list.get(i)); |
... | ... | @@ -157,8 +129,7 @@ public class MyChildActivity extends BaseMVPCompatActivity<MyChildContract.MyChi |
157 | 129 | |
158 | 130 | @Override |
159 | 131 | public void showError(String error) { |
160 | - if (error.equals("解绑成功")) ; | |
161 | - mPresenter.loadChildList(AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.LOGIN_NAME), 0, ""); | |
132 | + | |
162 | 133 | } |
163 | 134 | |
164 | 135 | private SwipeMenuCreator swipeMenuCreator = new SwipeMenuCreator() { | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/fragment/ActivationFragment.java
... | ... | @@ -3,6 +3,7 @@ package com.shunzhi.parent.ui.fragment; |
3 | 3 | import android.os.Bundle; |
4 | 4 | import android.support.annotation.NonNull; |
5 | 5 | import android.support.annotation.Nullable; |
6 | +import android.text.TextUtils; | |
6 | 7 | import android.view.View; |
7 | 8 | import android.widget.EditText; |
8 | 9 | import android.widget.ImageView; |
... | ... | @@ -14,33 +15,34 @@ import com.share.mvpsdk.utils.ToastUtils; |
14 | 15 | import com.shunzhi.parent.R; |
15 | 16 | import com.shunzhi.parent.contract.apply.ApplyReplaceCardContract; |
16 | 17 | import com.shunzhi.parent.presenter.apply.ApplyReplaceCardPresenter; |
18 | +import com.shunzhi.parent.views.ReplaceCardDialog; | |
17 | 19 | |
18 | 20 | /** |
19 | 21 | * Created by Administrator on 2018/4/19 0019. |
20 | 22 | */ |
21 | 23 | |
22 | 24 | public class ActivationFragment extends BaseMVPCompatFragment<ApplyReplaceCardContract.ApplyReplaceCardPreenter, ApplyReplaceCardContract.IApplyReplaceCardModel> |
23 | - implements View.OnClickListener { | |
25 | + implements View.OnClickListener, ApplyReplaceCardContract.IApplyReplaceCardView { | |
24 | 26 | |
25 | 27 | |
26 | 28 | TextView center_title, tv_name, tv_submit; |
27 | 29 | EditText et_cardnum; |
28 | 30 | ImageView iv_back; |
29 | - | |
30 | - String cardNum = "",childName=""; | |
31 | + ReplaceCardDialog replaceCardDialog = null; | |
32 | + String cardNum = "", childName = ""; | |
31 | 33 | int studentId; |
32 | 34 | |
33 | 35 | @Override |
34 | 36 | public void onClick(View v) { |
35 | 37 | if (v == tv_submit) { |
36 | 38 | |
37 | - if (et_cardnum.getText().toString() != null) { | |
38 | - cardNum=et_cardnum.getText().toString(); | |
39 | + if (!TextUtils.isEmpty(et_cardnum.getText().toString())) { | |
40 | + cardNum = et_cardnum.getText().toString(); | |
39 | 41 | mPresenter.ReplaceCardDetail(studentId, cardNum); |
40 | 42 | } else { |
41 | 43 | ToastUtils.showToast("请输入卡号"); |
42 | 44 | } |
43 | - }else if(v==iv_back){ | |
45 | + } else if (v == iv_back) { | |
44 | 46 | getActivity().finish(); |
45 | 47 | } |
46 | 48 | |
... | ... | @@ -61,6 +63,7 @@ public class ActivationFragment extends BaseMVPCompatFragment<ApplyReplaceCardCo |
61 | 63 | public void initUI(View view, @Nullable Bundle savedInstanceState) { |
62 | 64 | center_title = view.findViewById(R.id.center_title); |
63 | 65 | iv_back = view.findViewById(R.id.back_top); |
66 | + iv_back.setOnClickListener(this); | |
64 | 67 | center_title.setText("校卡激活"); |
65 | 68 | tv_name = view.findViewById(R.id.tv_name); |
66 | 69 | |
... | ... | @@ -83,4 +86,19 @@ public class ActivationFragment extends BaseMVPCompatFragment<ApplyReplaceCardCo |
83 | 86 | } |
84 | 87 | |
85 | 88 | } |
89 | + | |
90 | + @Override | |
91 | + public void showTipsDialog(String msg) { | |
92 | + if (msg.equals("true")) { | |
93 | + if (replaceCardDialog == null) { | |
94 | + replaceCardDialog = new ReplaceCardDialog(getActivity()); | |
95 | + } | |
96 | + replaceCardDialog.setTitle("激活卡提示"); | |
97 | + replaceCardDialog.setText("卡号:" + cardNum + "\n\n" + "已成功激活!"); | |
98 | + replaceCardDialog.show(); | |
99 | + | |
100 | + } else { | |
101 | + ToastUtils.showToast("激活卡失败!"); | |
102 | + } | |
103 | + } | |
86 | 104 | } | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/fragment/ReportFragment.java
... | ... | @@ -10,20 +10,30 @@ import android.support.v4.app.Fragment; |
10 | 10 | import android.support.v4.app.FragmentManager; |
11 | 11 | import android.support.v4.app.FragmentPagerAdapter; |
12 | 12 | import android.support.v4.view.ViewPager; |
13 | +import android.support.v7.widget.PopupMenu; | |
14 | +import android.text.TextUtils; | |
15 | +import android.view.Menu; | |
16 | +import android.view.MenuItem; | |
13 | 17 | import android.view.View; |
14 | 18 | import android.widget.TextView; |
15 | 19 | |
20 | +import com.google.gson.Gson; | |
16 | 21 | import com.share.mvpsdk.base.fragment.BaseCompatFragment; |
22 | +import com.shunzhi.parent.AppConfig; | |
23 | +import com.shunzhi.parent.AppContext; | |
17 | 24 | import com.shunzhi.parent.R; |
25 | +import com.shunzhi.parent.bean.ChildBean; | |
26 | +import com.shunzhi.parent.db.DBControl; | |
18 | 27 | import com.shunzhi.parent.popu.ShaiXuanPop; |
19 | 28 | import com.shunzhi.parent.ui.fragment.report.ChengZhangFragment; |
20 | 29 | |
30 | +import java.util.ArrayList; | |
21 | 31 | import java.util.List; |
22 | 32 | |
23 | 33 | public class ReportFragment extends BaseCompatFragment implements View.OnClickListener { |
24 | 34 | ViewPager viewPager; |
25 | 35 | |
26 | - TextView tvDate, tvShaiXuan, tvNoData; | |
36 | + TextView tvDate, tvShaiXuan, tvNoData, tvName; | |
27 | 37 | |
28 | 38 | MyFragmentAdapter myFragmentAdapter = null; |
29 | 39 | |
... | ... | @@ -32,6 +42,10 @@ public class ReportFragment extends BaseCompatFragment implements View.OnClickLi |
32 | 42 | ChengZhangFragment chengZhangFragment1 = null, chengZhangFragment2 = null;//成长、报告页面 |
33 | 43 | |
34 | 44 | ShaiXuanPop shaiXuanPop = null; |
45 | + List<ChildBean> childlist = new ArrayList<>(); | |
46 | + | |
47 | + String jsonStr = ""; | |
48 | + Gson g = new Gson(); | |
35 | 49 | |
36 | 50 | @Override |
37 | 51 | public int getLayoutId() { |
... | ... | @@ -42,17 +56,28 @@ public class ReportFragment extends BaseCompatFragment implements View.OnClickLi |
42 | 56 | public void initUI(View view, @Nullable Bundle savedInstanceState) { |
43 | 57 | viewPager = view.findViewById(R.id.viewPager); |
44 | 58 | tvDate = view.findViewById(R.id.tvDate); |
59 | + tvName = view.findViewById(R.id.tvName); | |
45 | 60 | tvShaiXuan = view.findViewById(R.id.tvShaiXuan); |
46 | 61 | tvNoData = view.findViewById(R.id.tvNoData); |
47 | 62 | tabLayout = view.findViewById(R.id.tabLayout); |
63 | + tvName.setOnClickListener(this); | |
64 | + registerForContextMenu(tvName); | |
48 | 65 | |
49 | - | |
50 | - | |
51 | - tvNoData.setOnClickListener(this); | |
52 | 66 | tvShaiXuan.setOnClickListener(this); |
53 | 67 | |
54 | 68 | myFragmentAdapter = new MyFragmentAdapter(getChildFragmentManager()); |
55 | 69 | |
70 | + childlist = DBControl.childInfoDao.getAllChildren(); | |
71 | + createSchoolMenu(); | |
72 | + String currChildStr = AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.CURRCHILDJSONSTR); | |
73 | + if (TextUtils.isEmpty(currChildStr)) { | |
74 | + tvName.setText(childlist.get(0).getStudentName()); | |
75 | + jsonStr = g.toJson(childlist.get(0), ChildBean.class); | |
76 | + } else { | |
77 | + ChildBean childBean = g.fromJson(currChildStr, ChildBean.class); | |
78 | + tvName.setText(childBean.getStudentName()); | |
79 | + jsonStr = currChildStr; | |
80 | + } | |
56 | 81 | viewPager.setAdapter(myFragmentAdapter); |
57 | 82 | tabLayout.setupWithViewPager(viewPager); |
58 | 83 | tabLayout.removeAllTabs(); |
... | ... | @@ -85,6 +110,33 @@ public class ReportFragment extends BaseCompatFragment implements View.OnClickLi |
85 | 110 | if (null == shaiXuanPop) shaiXuanPop = new ShaiXuanPop(getActivity()); |
86 | 111 | chengZhangFragment2.showShaixuan(handler); |
87 | 112 | break; |
113 | + case R.id.tvName: | |
114 | + showChildName(); | |
115 | + break; | |
116 | + } | |
117 | + } | |
118 | + | |
119 | + private void showChildName() { | |
120 | + schoolMenu.show(); | |
121 | + } | |
122 | + | |
123 | + private PopupMenu schoolMenu = null; | |
124 | + | |
125 | + private void createSchoolMenu() { | |
126 | + if (schoolMenu != null) return; | |
127 | + schoolMenu = new PopupMenu(getActivity(), tvName); | |
128 | + Menu menu = schoolMenu.getMenu(); | |
129 | + for (int i = 0; i < childlist.size(); i++) { | |
130 | + final int finalI = i; | |
131 | + menu.add(0, i, 10, childlist.get(i).getStudentName()).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { | |
132 | + @Override | |
133 | + public boolean onMenuItemClick(MenuItem item) { | |
134 | + tvName.setText(item.getTitle()); | |
135 | + jsonStr = g.toJson(childlist.get(finalI), ChildBean.class); | |
136 | + AppConfig.getAppConfig(AppContext.getInstance()).set(AppConfig.CURRCHILDJSONSTR, jsonStr); | |
137 | + return false; | |
138 | + } | |
139 | + }); | |
88 | 140 | } |
89 | 141 | } |
90 | 142 | ... | ... |
app/src/main/res/layout/item_school.xml
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | 3 | android:layout_width="match_parent" |
4 | - android:layout_height="match_parent" | |
4 | + android:layout_height="wrap_content" | |
5 | 5 | android:orientation="vertical"> |
6 | 6 | <LinearLayout |
7 | 7 | android:layout_width="fill_parent" | ... | ... |