终极MVP二级购物车

所需要的依赖

1
2
3
4
5
6
7
8
compile 'com.android.support:appcompat-v7:24.2.1'
    testCompile 'junit:junit:4.12'
    compile 'com.squareup.okhttp3:okhttp:3.9.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.9.0'
    compile 'com.google.code.gson:gson:2.8.2'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    compile 'org.greenrobot:eventbus:3.1.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'

net下HttpUtils  GET请求

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
public class HttpUtils {
     private static volatile HttpUtils httpUtils;
     private final OkHttpClient client;
 
     private HttpUtils(){
         HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
         loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
         client = new OkHttpClient.Builder()
                 .addInterceptor(loggingInterceptor)
                 .build();
     }
     public static HttpUtils getHttpUtils(){
         if(httpUtils==null){
             synchronized (HttpUtils.class){
                 if (httpUtils==null){
                     httpUtils = new HttpUtils();
                 }
             }
         }
         return httpUtils;
     }
     /**
      * GET请求
      *
      * @param url
      * @param callback
      */
     public void doGet(String url, Callback callback){
         Request request = new Request.Builder().url(url).build();
         client.newCall(request).enqueue(callback);
     }
}

  OnNetListener接口回调

1
2
3
4
public interface OnNetListener< T > {
     public void onSuccess(T t);
     public void onFailure(Exception e);
}

  Api

1
2
3
public interface Api {
     public static final String url = "http://result.eolinker.com/iYXEPGn4e9c6dafce6e5cdd23287d2bb136ee7e9194d3e9?uri=evaluation";
}

  model层  MainModel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public class MainModel implements IMainModel{
     private Handler handler = new Handler(Looper.getMainLooper());
 
     public void getGoods(final OnNetListener< GoosBean > onNetListener){
         HttpUtils.getHttpUtils().doGet(Api.url, new Callback() {
             @Override
             public void onFailure(Call call, IOException e) {
 
             }
 
             @Override
             public void onResponse(Call call, Response response) throws IOException {
                 String string = response.body().string();
                 final GoosBean goosBean = new Gson().fromJson(string, GoosBean.class);
                 handler.post(new Runnable() {
                     @Override
                     public void run() {
                         onNetListener.onSuccess(goosBean);
                     }
                 });
             }
         });
     }
}

  IMainModel

1
2
3
public interface IMainModel {
     public void getGoods(OnNetListener< GoosBean > onNetListener);
}

  presenter层  MainPresenter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public class MainPresenter {
     private final IMainModel iMainModel;
     private final IMainActivity iMainActivity;
     public MainPresenter(IMainActivity iMainActivity) {
         this.iMainActivity = iMainActivity;
         iMainModel = new MainModel() ;
     }
 
     public void getGoods(){
 
         iMainModel.getGoods(new OnNetListener< GoosBean >() {
             @Override
             public void onSuccess(GoosBean goosBean) {
                 //List< GoosBean.DataBean > groupList, List< List <GoosBean.DataBean.DatasBean>> childList
                 List< GoosBean.DataBean > dataBean = goosBean.getData();
                 List< List <GoosBean.DataBean.DatasBean>> childList = new ArrayList< List <GoosBean.DataBean.DatasBean>>();
                 for (int i = 0; i <  dataBean.size (); i++) {
                     List<GoosBean.DataBean.DatasBean> datas = dataBean.get(i).getDatas();
                     childList.add(datas);
                 }
                 iMainActivity.showList(dataBean, childList);
             }
 
             @Override
             public void onFailure(Exception e) {
 
             }
         });
     }
 
}

  view层  MainActivity

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
public class MainActivity extends AppCompatActivity implements IMainActivity{
 
     private ExpandableListView mElv;
     private CheckBox mCheckbox2;
     /**
      * 0
      */
     private TextView mTvPrice;
     /**
      * 结算(0)
      */
     private TextView mTvNum;
     private MyAdapter adapter;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);
         initView();
         EventBus.getDefault().register(this);
         new MainPresenter(this).getGoods();
         mCheckbox2.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 adapter.changeAllListCbState(mCheckbox2.isChecked());
             }
         });
     }
 
     @Override
     protected void onDestroy() {
         super.onDestroy();
         EventBus.getDefault().unregister(this);
     }
 
     private void initView() {
         mElv = (ExpandableListView) findViewById(R.id.elv);
         mCheckbox2 = (CheckBox) findViewById(R.id.checkbox2);
         mTvPrice = (TextView) findViewById(R.id.tv_price);
         mTvNum = (TextView) findViewById(R.id.tv_num);
     }
 
     @Override
     public void showList(List< GoosBean.DataBean > groupList, List< List <GoosBean.DataBean.DatasBean>> childList) {
         adapter = new MyAdapter(this, groupList, childList);
         mElv.setAdapter(adapter);
         mElv.setGroupIndicator(null);
         //默认让其全部展开
         for (int i = 0; i < groupList.size(); i++) {
             mElv.expandGroup(i);
         }
     }
     @Subscribe
     public void onMessageEvent(MessageEvent event){
         mCheckbox2.setChecked(event.isChecked());
 
     }
     @Subscribe
     public void onMessageEvent(PriceAndCountEvent event){
 
         mTvNum.setText("结算(" + event.getCount() + ")");
         mTvPrice.setText(event.getPrice()+"");
     }
 
}

  IMainActivity

1
2
3
public interface IMainActivity {
     public void showList(List< GoosBean.DataBean > groupList, List< List <GoosBean.DataBean.DatasBean>> childList);
}

  adapter下 MyAdapter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
public class MyAdapter extends BaseExpandableListAdapter {
     private Context context;
     private List< GoosBean.DataBean > groupList;
     private List< List <GoosBean.DataBean.DatasBean>> childList;
     private final LayoutInflater inflater;
 
     public MyAdapter(Context context, List< GoosBean.DataBean > groupList, List< List <GoosBean.DataBean.DatasBean>> childList) {
         this.context = context;
         this.groupList = groupList;
         this.childList = childList;
         inflater = LayoutInflater.from(context);
 
     }
 
     @Override
     public int getGroupCount() {
         return groupList.size();
     }
 
     @Override
     public int getChildrenCount(int groupPosition) {
         return childList.get(groupPosition).size();
     }
 
     @Override
     public Object getGroup(int groupPosition) {
         return groupList.get(groupPosition);
     }
 
     @Override
     public Object getChild(int groupPosition, int childPosition) {
         return childList.get(groupPosition).get(childPosition);
     }
 
     @Override
     public long getGroupId(int groupPosition) {
         return groupPosition;
     }
 
     @Override
     public long getChildId(int groupPosition, int childPosition) {
         return childPosition;
     }
 
     @Override
     public boolean hasStableIds() {
         return false;
     }
 
     @Override
     public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
         View view;
         final GroupViewHolder holder;
         if (convertView == null) {
             holder = new GroupViewHolder();
             view = inflater.inflate(R.layout.item_parent_market, null);
             holder.cbGroup = (CheckBox) view.findViewById(R.id.cb_parent);
             holder.tv_number = (TextView) view.findViewById(R.id.tv_number);
             view.setTag(holder);
         } else {
             view = convertView;
             holder = (GroupViewHolder) view.getTag();
         }
         final GoosBean.DataBean dataBean = groupList.get(groupPosition);
         holder.cbGroup.setChecked(dataBean.isChecked());
         holder.tv_number.setText(dataBean.getTitle());
         //一级checkbox
         holder.cbGroup.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 dataBean.setChecked(holder.cbGroup.isChecked());
                 changeChildCbState(groupPosition, holder.cbGroup.isChecked());
                 EventBus.getDefault().post(compute());
                 changeAllCbState(isAllGroupCbSelected());
                 notifyDataSetChanged();
             }
         });
         return view;
     }
 
     @Override
     public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
         View view;
         final ChildViewHolder holder;
         if (convertView == null) {
             holder = new ChildViewHolder();
             view = inflater.inflate(R.layout.item_child_market, null);
             holder.cbChild = (CheckBox) view.findViewById(R.id.cb_child);
             holder.tv_tel = (TextView) view.findViewById(R.id.tv_tel);
             holder.tv_content = (TextView) view.findViewById(R.id.tv_content);
             holder.tv_time = (TextView) view.findViewById(R.id.tv_time);
             holder.tv_del = (TextView) view.findViewById(R.id.tv_del);
             holder.iv_add = (ImageView) view.findViewById(R.id.iv_add);
             holder.iv_del = (ImageView) view.findViewById(R.id.iv_del);
             holder.tv_price = (TextView) view.findViewById(R.id.tv_pri);
             holder.tv_num = (TextView) view.findViewById(R.id.tv_num);
             view.setTag(holder);
         } else {
             view = convertView;
             holder = (ChildViewHolder) view.getTag();
         }
         final GoosBean.DataBean.DatasBean datasBean = childList.get(groupPosition).get(childPosition);
         holder.cbChild.setChecked(datasBean.isChecked());
         holder.tv_tel.setText(datasBean.getType_name());
         holder.tv_content.setText(datasBean.getMsg());
         holder.tv_time.setText(datasBean.getAdd_time());
         holder.tv_price.setText(datasBean.getPrice() + "");
         holder.tv_num.setText(datasBean.getNum() + "");
 
 
         //二级checkbox
         holder.cbChild.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 //设置该条目对象里的checked属性值
                 datasBean.setChecked(holder.cbChild.isChecked());
                 PriceAndCountEvent priceAndCountEvent = compute();
                 EventBus.getDefault().post(priceAndCountEvent);
 
                 if (holder.cbChild.isChecked()) {
                     //当前checkbox是选中状态
                     if (isAllChildCbSelected(groupPosition)) {
                         changGroupCbState(groupPosition, true);
                         changeAllCbState(isAllGroupCbSelected());
                     }
                 } else {
                     changGroupCbState(groupPosition, false);
                     changeAllCbState(isAllGroupCbSelected());
                 }
                 notifyDataSetChanged();
             }
         });
 
         //加号
         holder.iv_add.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 int num = datasBean.getNum();
                 holder.tv_num.setText(++num + "");
                 datasBean.setNum(num);
                 if (holder.cbChild.isChecked()) {
                     PriceAndCountEvent priceAndCountEvent = compute();
                     EventBus.getDefault().post(priceAndCountEvent);
                 }
             }
         });
 
         //减号
         holder.iv_del.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 int num = datasBean.getNum();
                 if (num == 1) {
                     return;
                 }
                 holder.tv_num.setText(--num + "");
                 datasBean.setNum(num);
                 if (holder.cbChild.isChecked()) {
                     PriceAndCountEvent priceAndCountEvent = compute();
                     EventBus.getDefault().post(priceAndCountEvent);
                 }
             }
         });
         //二级checkbox
         holder.tv_del.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 //设置该条目对象里的checked属性值
                 datasBean.setChecked(holder.cbChild.isChecked());
                 PriceAndCountEvent priceAndCountEvent = compute();
                 EventBus.getDefault().post(priceAndCountEvent);
 
                 if (holder.cbChild.isChecked()) {
                     //当前checkbox是选中状态
                     if (isAllChildCbSelected(groupPosition)) {
                         changGroupCbState(groupPosition, true);
                         changeAllCbState(isAllGroupCbSelected());
                     }
                 } else {
                     changGroupCbState(groupPosition, false);
                     changeAllCbState(isAllGroupCbSelected());
                 }
                 notifyDataSetChanged();
 
             }
         });
         //删除
         holder.tv_del.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 List< GoosBean.DataBean.DatasBean > datasBeen = childList.get(groupPosition);
                 GoosBean.DataBean.DatasBean remove = datasBeen.remove(childPosition);
                 if (datasBeen.size() == 0) {
                     childList.remove(groupPosition);
                     groupList.remove(groupPosition);
                 }
                 EventBus.getDefault().post(compute());
                 notifyDataSetChanged();
             }
         });
         return view;
     }
 
     @Override
     public boolean isChildSelectable(int groupPosition, int childPosition) {
         return true;
     }
 
     class GroupViewHolder {
         CheckBox cbGroup;
         TextView tv_number;
     }
 
     class ChildViewHolder {
         CheckBox cbChild;
         TextView tv_tel;
         TextView tv_content;
         TextView tv_time;
         TextView tv_price;
         TextView tv_del;
         ImageView iv_del;
         ImageView iv_add;
         TextView tv_num;
     }
 
     /**
      * 改变全选的状态
      *
      * @param flag
      */
     private void changeAllCbState(boolean flag) {
         MessageEvent messageEvent = new MessageEvent();
         messageEvent.setChecked(flag);
         EventBus.getDefault().post(messageEvent);
     }
 
     /**
      * 改变一级列表checkbox状态
      *
      * @param groupPosition
      */
     private void changGroupCbState(int groupPosition, boolean flag) {
         GoosBean.DataBean dataBean = groupList.get(groupPosition);
         dataBean.setChecked(flag);
     }
 
 
 
     /**
      * 改变二级列表checkbox状态
      *
      * @param groupPosition
      * @param flag
      */
     private void changeChildCbState(int groupPosition, boolean flag) {
         List< GoosBean.DataBean.DatasBean > datasBeen = childList.get(groupPosition);
         for (int i = 0; i <  datasBeen.size (); i++) {
             GoosBean.DataBean.DatasBean datasBean = datasBeen.get(i);
             datasBean.setChecked(flag);
         }
     }
 
     /**
      * 判断一级列表是否全部选中
      *
      * @return
      */
     private boolean isAllGroupCbSelected() {
         for (int i = 0; i < groupList.size(); i++) {
             GoosBean.DataBean dataBean = groupList.get(i);
             if (!dataBean.isChecked()) {
                 return false;
             }
         }
         return true;
     }
 
     /**
      * 判断二级列表是否全部选中
      *
      * @param groupPosition
      * @return
      */
     private boolean isAllChildCbSelected(int groupPosition) {
         List<GoosBean.DataBean.DatasBean> datasBeen = childList.get(groupPosition);
         for (int i = 0; i <  datasBeen.size (); i++) {
             GoosBean.DataBean.DatasBean datasBean = datasBeen.get(i);
             if (!datasBean.isChecked()) {
                 return false;
             }
         }
         return true;
     }
 
     /**
      * 计算列表中,选中的钱和数量
      */
     private PriceAndCountEvent compute() {
         int count = 0;
         int price = 0;
         for (int i = 0; i < childList.size(); i++) {
             List<GoosBean.DataBean.DatasBean> datasBeen = childList.get(i);
             for (int j = 0; j < datasBeen.size(); j++) {
                 GoosBean.DataBean.DatasBean datasBean = datasBeen.get(j);
                 if (datasBean.isChecked()) {
                     price += datasBean.getNum() * datasBean.getPrice();
                     count += datasBean.getNum();
                 }
             }
         }
         PriceAndCountEvent priceAndCountEvent = new PriceAndCountEvent();
         priceAndCountEvent.setCount(count);
         priceAndCountEvent.setPrice(price);
         return priceAndCountEvent;
     }
 
 
     /**
      * 设置全选、反选
      *
      * @param flag
      */
     public void changeAllListCbState(boolean flag) {
         for (int i = 0; i < groupList.size(); i++) {
             changGroupCbState(i, flag);
             changeChildCbState(i, flag);
         }
         EventBus.getDefault().post(compute());
         notifyDataSetChanged();
     }
}

  evenBusevent下  MessageEvent

1
2
3
4
5
6
7
8
9
10
11
public class MessageEvent {
     private boolean checked;
 
     public boolean isChecked() {
         return checked;
     }
 
     public void setChecked(boolean checked) {
         this.checked = checked;
     }
}

  priceAndCountEvent

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class PriceAndCountEvent {
     private int price;
     private int count;
 
     public int getPrice() {
         return price;
     }
 
     public void setPrice(int price) {
         this.price = price;
     }
 
     public int getCount() {
         return count;
     }
 
     public void setCount(int count) {
         this.count = count;
     }
}

  GoosBean

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
public class GoosBean {
 
     /**
      * code : 200
      * data : [{"datas":[{"add_time":"2016-12-10 14:54:58","cart_id":"445162","house_id":"1","msg":"购买渠道:大陆国行","price":500,"type_name":"苹果 iPhone 6(白金色)","type_sn_id":"ggh"},{"add_time":"2016-12-10 14:55:18","cart_id":"445163","house_id":"1","msg":"购买渠道:水货无锁","price":1000,"type_name":"苹果 iPhone 7 (亮黑色)","type_sn_id":"tgg"}],"title":"苹果","title_id":"59280"},{"datas":[{"add_time":"2016-12-10 14:54:58","cart_id":"445162","house_id":"1","msg":"边框背板:全新未使用","price":50,"type_name":"小米4s (白金色)","type_sn_id":"ggh"},{"add_time":"2016-12-10 14:55:18","cart_id":"445163","house_id":"1","msg":"屏幕性能:色差/亮点/轻微发黄","price":100,"type_name":"小米5s (亮黑色)","type_sn_id":"tgg"}],"title":"小米","title_id":"59279"},{"datas":[{"add_time":"2016-12-10 14:54:58","cart_id":"445162","house_id":"1","msg":"边框背板:全新未使用","price":50,"type_name":"三星 (白金色)","type_sn_id":"ggh"},{"add_time":"2016-12-10 14:55:18","cart_id":"445163","house_id":"1","msg":"屏幕性能:色差/亮点/轻微发黄","price":100,"type_name":"三星 (亮黑色)","type_sn_id":"tgg"}],"title":"三星","title_id":"59279"},{"datas":[{"add_time":"2016-12-10 14:54:58","cart_id":"445162","house_id":"1","msg":"边框背板:全新未使用","price":50,"type_name":"华为 (白金色)","type_sn_id":"ggh"},{"add_time":"2016-12-10 14:55:18","cart_id":"445163","house_id":"1","msg":"屏幕性能:色差/亮点/轻微发黄","price":100,"type_name":"华为 (亮黑色)","type_sn_id":"tgg"},{"add_time":"2016-12-10 4:55:28","cart_id":"445164","house_id":"1","msg":"屏幕性能:色差/亮点/轻微发黄","price":150,"type_name":"华为 (纯黑色)","type_sn_id":"hgg"}],"title":"华为","title_id":"59279"}]
      * flag : Success
      * msg : 描述
      */
 
     private String code;
     private String flag;
     private String msg;
     private List< DataBean > data;
 
     public String getCode() {
         return code;
     }
 
     public void setCode(String code) {
         this.code = code;
     }
 
     public String getFlag() {
         return flag;
     }
 
     public void setFlag(String flag) {
         this.flag = flag;
     }
 
     public String getMsg() {
         return msg;
     }
 
     public void setMsg(String msg) {
         this.msg = msg;
     }
 
     public List< DataBean > getData() {
         return data;
     }
 
     public void setData(List< DataBean > data) {
         this.data = data;
     }
 
     public static class DataBean {
         /**
          * datas : [{"add_time":"2016-12-10 14:54:58","cart_id":"445162","house_id":"1","msg":"购买渠道:大陆国行","price":500,"type_name":"苹果 iPhone 6(白金色)","type_sn_id":"ggh"},{"add_time":"2016-12-10 14:55:18","cart_id":"445163","house_id":"1","msg":"购买渠道:水货无锁","price":1000,"type_name":"苹果 iPhone 7 (亮黑色)","type_sn_id":"tgg"}]
          * title : 苹果
          * title_id : 59280
          */
         private boolean checked;
         private String title;
         private String title_id;
         private List< DatasBean > datas;
 
         public boolean isChecked() {
             return checked;
         }
 
         public void setChecked(boolean checked) {
             this.checked = checked;
         }
 
         public String getTitle() {
             return title;
         }
 
         public void setTitle(String title) {
             this.title = title;
         }
 
         public String getTitle_id() {
             return title_id;
         }
 
         public void setTitle_id(String title_id) {
             this.title_id = title_id;
         }
 
         public List< DatasBean > getDatas() {
             return datas;
         }
 
         public void setDatas(List< DatasBean > datas) {
             this.datas = datas;
         }
 
         public static class DatasBean {
             /**
              * add_time : 2016-12-10 14:54:58
              * cart_id : 445162
              * house_id : 1
              * msg : 购买渠道:大陆国行
              * price : 500
              * type_name : 苹果 iPhone 6(白金色)
              * type_sn_id : ggh
              */
             private boolean checked;
             private int num = 1;
             private String add_time;
             private String cart_id;
             private String house_id;
             private String msg;
             private int price;
             private String type_name;
             private String type_sn_id;
 
             public int getNum() {
                 return num;
             }
 
             public void setNum(int num) {
                 this.num = num;
             }
 
             public boolean isChecked() {
                 return checked;
             }
 
             public void setChecked(boolean checked) {
                 this.checked = checked;
             }
 
             public String getAdd_time() {
                 return add_time;
             }
 
             public void setAdd_time(String add_time) {
                 this.add_time = add_time;
             }
 
             public String getCart_id() {
                 return cart_id;
             }
 
             public void setCart_id(String cart_id) {
                 this.cart_id = cart_id;
             }
 
             public String getHouse_id() {
                 return house_id;
             }
 
             public void setHouse_id(String house_id) {
                 this.house_id = house_id;
             }
 
             public String getMsg() {
                 return msg;
             }
 
             public void setMsg(String msg) {
                 this.msg = msg;
             }
 
             public int getPrice() {
                 return price;
             }
 
             public void setPrice(int price) {
                 this.price = price;
             }
 
             public String getType_name() {
                 return type_name;
             }
 
             public void setType_name(String type_name) {
                 this.type_name = type_name;
             }
 
             public String getType_sn_id() {
                 return type_sn_id;
             }
 
             public void setType_sn_id(String type_sn_id) {
                 this.type_sn_id = type_sn_id;
             }
         }
     }
}

 布局  activity_main.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<? xml  version="1.0" encoding="utf-8"?>
< LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical"
     >
 
     < TextView
         android:layout_width="match_parent"
         android:layout_height="40dp"
         android:background="#990000ff"
         android:gravity="center"
         android:text="购物车"
         android:textColor="#ff3660"
         android:textSize="25sp" />
 
     < ExpandableListView
         android:id="@+id/elv"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_weight="1" />
 
     < RelativeLayout
         android:layout_width="match_parent"
         android:layout_height="50dp"
         android:layout_alignParentBottom="true"
         android:background="@android:color/white"
         android:gravity="center_vertical">
 
         < CheckBox
             android:id="@+id/checkbox2"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_centerVertical="true"
             android:layout_marginLeft="10dp"
             android:focusable="false" />
 
         < TextView
             android:layout_width="wrap_content"
             android:layout_height="50dp"
             android:layout_centerVertical="true"
             android:layout_marginLeft="10dp"
             android:layout_toRightOf="@+id/checkbox2"
             android:gravity="center_vertical"
             android:text="全选"
             android:textSize="20sp" />
 
         < LinearLayout
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_alignParentRight="true"
             android:orientation="horizontal">
 
             < TextView
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginLeft="10dp"
                 android:text="合计 :" />
 
 
             < TextView
                 android:id="@+id/tv_price"
                 android:layout_width="wrap_content"
                 android:layout_height="50dp"
                 android:layout_marginLeft="10dp"
                 android:paddingRight="10dp"
                 android:text="0"
                 android:textColor="@android:color/holo_red_light" />
 
 
             < TextView
                 android:id="@+id/tv_num"
                 android:layout_width="wrap_content"
                 android:layout_height="50dp"
                 android:background="@android:color/holo_red_dark"
                 android:gravity="center"
                 android:padding="10dp"
                 android:text="结算(0)"
                 android:textColor="@android:color/white" />
         </ LinearLayout >
     </ RelativeLayout >
</ LinearLayout >

  itm_child_market.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<? xml  version="1.0" encoding="utf-8"?>
< LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="@android:color/darker_gray"
     android:gravity="center_vertical"
     android:orientation="horizontal">
 
     < CheckBox
 
         android:id="@+id/cb_child"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginBottom="30dp"
         android:layout_marginLeft="40dp"
         android:layout_marginTop="30dp"
         android:focusable="false" />
 
     < LinearLayout
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:orientation="vertical">
 
         < TextView
             android:id="@+id/tv_tel"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginLeft="20dp"
             android:text="iphone6" />
 
         < TextView
             android:id="@+id/tv_content"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginLeft="20dp"
             android:text="什么手机" />
 
         < TextView
             android:id="@+id/tv_time"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginLeft="20dp"
             android:text="2016-12-10" />
     </ LinearLayout >
 
     < LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_weight="1"
         android:orientation="vertical">
 
         < TextView
             android:id="@+id/tv_pri"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
 
             android:text="¥3000.00" />
 
         < LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:gravity="center_vertical">
 
             < ImageView
                 android:id="@+id/iv_del"
                 android:layout_width="20dp"
                 android:layout_height="20dp"
                 android:src="@drawable/shopcart_minus_grey" />
 
             < TextView
                 android:id="@+id/tv_num"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginLeft="5dp"
                 android:background="@drawable/shopcart_add_btn"
                 android:paddingBottom="2dp"
                 android:paddingLeft="20dp"
                 android:paddingRight="20dp"
                 android:paddingTop="2dp"
                 android:text="1" />
 
             < ImageView
                 android:id="@+id/iv_add"
                 android:layout_width="20dp"
                 android:layout_height="20dp"
                 android:layout_marginLeft="5dp"
                 android:src="@drawable/shopcart_add_red" />
 
         </ LinearLayout >
 
     </ LinearLayout >
 
     < TextView
         android:id="@+id/tv_del"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="删除" />
</ LinearLayout >

 item_parent_market.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<? xml  version="1.0" encoding="utf-8"?>
< LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="100dp"
     android:gravity="center_vertical"
     android:orientation="horizontal">
 
     < CheckBox
         android:id="@+id/cb_parent"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginBottom="30dp"
         android:layout_marginLeft="20dp"
         android:layout_marginTop="30dp"
         android:focusable="false" />
 
     < TextView
         android:id="@+id/tv_sign"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginLeft="20dp"
         android:text="标记" />
 
     < TextView
         android:id="@+id/tv_number"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginLeft="20dp"
         android:text="12345678" />
 
</ LinearLayout >
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
智慧校园整体解决方案是响应国家教育信息化政策,结合教育改革和技术创新的产物。该方案以物联网、大数据、人工智能和移动互联技术为基础,旨在打造一个安全、高效、互动且环保的教育环境。方案强调从数字化校园向智慧校园的转变,通过自动数据采集、智能分析和按需服务,实现校园业务的智能化管理。 方案的总体设计原则包括应用至上、分层设计和互联互通,确保系统能够满足不同用户角色的需求,并实现数据和资源的整合与共享。框架设计涵盖了校园安全、管理、教学、环境等多个方面,构建了一个全面的校园应用生态系统。这包括智慧安全系统、校园身份识别、智能排课及选课系统、智慧学习系统、精品录播教室方案等,以支持个性化学习和教学评估。 建设内容突出了智慧安全和智慧管理的重要性。智慧安全管理通过分布式录播系统和紧急预案一键启动功能,增强校园安全预警和事件响应能力。智慧管理系统则利用物联网技术,实现人员和设备的智能管理,提高校园运营效率。 智慧教学部分,方案提供了智慧学习系统和精品录播教室方案,支持专业级学习硬件和智能化网络管理,促进个性化学习和教学资源的高效利用。同时,教学质量评估中心和资源应用平台的建设,旨在提升教学评估的科学性和教育资源的共享性。 智慧环境建设则侧重于基于物联网的设备管理,通过智慧教室管理系统实现教室环境的智能控制和能效管理,打造绿色、节能的校园环境。电子班牌和校园信息发布系统的建设,将作为智慧校园的核心和入口,提供教务、一卡通、图书馆等系统的集成信息。 总体而言,智慧校园整体解决方案通过集成先进技术,不仅提升了校园的信息化水平,而且优化了教学和管理流程,为学生、教师和家长提供了更加便捷、个性化的教育体验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值