Commit 217deceb063efad389cd00f3f190fe1ed3a9f20b

Authored by 陶汉栋
2 parents 96a294c3 59f55e6b

no message

app/build.gradle
... ... @@ -28,4 +28,5 @@ dependencies {
28 28 androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
29 29 implementation project(':mvpsdk')
30 30 implementation project(':roundedimageview-2.2.1')
  31 +
31 32 }
... ...
app/src/main/java/com/shunzhi/parent/adapter/ChildAdapter.java
1 1 package com.shunzhi.parent.adapter;
2 2  
  3 +import android.content.Context;
  4 +import android.view.LayoutInflater;
  5 +import android.view.View;
  6 +import android.view.ViewGroup;
  7 +import android.widget.TextView;
  8 +
  9 +import com.share.mvpsdk.base.adapter.BaseRecyclerViewAdapter;
  10 +import com.share.mvpsdk.base.adapter.BaseRecyclerViewHolder;
  11 +import com.shunzhi.parent.R;
  12 +import com.shunzhi.parent.bean.ChildBean;
  13 +
3 14 /**
4 15 * Created by Administrator on 2018/3/9 0009.
5 16 */
6 17  
7   -public class ChildAdapter {
  18 +public class ChildAdapter extends BaseRecyclerViewAdapter<ChildBean>{
  19 + Context context;
  20 + public ChildAdapter(Context context){
  21 + this.context=context;
  22 + }
  23 +
  24 +
  25 + @Override
  26 + public BaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  27 + View view= LayoutInflater.from(context).inflate(R.layout.item_childlist,null);
  28 + return new MyViewHolder(view);
  29 + }
  30 +
  31 + private class MyViewHolder extends BaseRecyclerViewHolder<ChildBean>{
  32 +
  33 + TextView textView;
  34 +
  35 +
  36 + public MyViewHolder(View view) {
  37 + super(view);
  38 + textView=view.findViewById(R.id.test);
  39 + }
8 40  
  41 + @Override
  42 + public void onBindViewHolder(ChildBean object, int position) {
  43 + textView.setText("1234");
  44 + }
9 45  
  46 + }
10 47 }
... ...
app/src/main/java/com/shunzhi/parent/contract/mine/MyChildContract.java
... ... @@ -14,6 +14,7 @@ import java.util.List;
14 14 public interface MyChildContract {
15 15  
16 16 abstract class MyChildPresenter extends BasePresenter<IMyChildModel,IMyChildView> {
  17 + public abstract void loadChildList();
17 18  
18 19 }
19 20  
... ...
app/src/main/java/com/shunzhi/parent/presenter/mine/MyChildPresenter.java
1 1 package com.shunzhi.parent.presenter.mine;
2 2  
  3 +import com.shunzhi.parent.bean.ChildBean;
3 4 import com.shunzhi.parent.contract.mine.MyChildContract;
4 5 import com.shunzhi.parent.model.mine.MyChildModel;
5 6  
  7 +import java.util.ArrayList;
  8 +import java.util.List;
  9 +
6 10 /**
7 11 * Created by Administrator on 2018/3/8 0008.
8 12 */
... ... @@ -18,4 +22,16 @@ public class MyChildPresenter extends MyChildContract.MyChildPresenter {
18 22 public void onStart() {
19 23  
20 24 }
  25 +
  26 + @Override
  27 + public void loadChildList() {
  28 + ChildBean c=new ChildBean();
  29 + List<ChildBean> l=new ArrayList<>();
  30 + l.add(c);
  31 + l.add(c);
  32 + l.add(c);
  33 + l.add(c);
  34 + l.add(c);
  35 + mIView.updateChilsList(l);
  36 + }
21 37 }
... ...
app/src/main/java/com/shunzhi/parent/ui/activity/MyChildActivity.java
... ... @@ -11,6 +11,7 @@ import android.widget.TextView;
11 11 import com.share.mvpsdk.base.BasePresenter;
12 12 import com.share.mvpsdk.base.activity.BaseMVPCompatActivity;
13 13 import com.shunzhi.parent.R;
  14 +import com.shunzhi.parent.adapter.ChildAdapter;
14 15 import com.shunzhi.parent.bean.ChildBean;
15 16 import com.shunzhi.parent.contract.mine.MyChildContract;
16 17 import com.shunzhi.parent.presenter.mine.MyChildPresenter;
... ... @@ -25,7 +26,7 @@ public class MyChildActivity extends BaseMVPCompatActivity&lt;MyChildContract.MyChi
25 26 implements MyChildContract.IMyChildView, View.OnClickListener {
26 27 RecyclerView child_recycle;
27 28 TextView back;
28   -
  29 + ChildAdapter childAdapter;
29 30  
30 31 @NonNull
31 32 @Override
... ... @@ -45,6 +46,7 @@ public class MyChildActivity extends BaseMVPCompatActivity&lt;MyChildContract.MyChi
45 46  
46 47 private void initRecyclerView() {
47 48 child_recycle.setLayoutManager(new LinearLayoutManager(this));
  49 + mPresenter.loadChildList();
48 50 }
49 51  
50 52 @Override
... ... @@ -59,6 +61,9 @@ public class MyChildActivity extends BaseMVPCompatActivity&lt;MyChildContract.MyChi
59 61  
60 62 @Override
61 63 public void updateChilsList(List<ChildBean> list) {
  64 + childAdapter=new ChildAdapter(this);
  65 + childAdapter.addAll(list);
  66 + child_recycle.setAdapter(childAdapter);
62 67  
63 68 }
64 69 }
... ...
app/src/main/res/layout/item_childlist.xml 0 → 100644
... ... @@ -0,0 +1,51 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="wrap_content">
  5 +
  6 + <LinearLayout
  7 + android:layout_margin="10dp"
  8 + android:layout_width="match_parent"
  9 + android:layout_height="wrap_content">
  10 +
  11 + <LinearLayout
  12 + android:layout_width="wrap_content"
  13 + android:layout_height="wrap_content"
  14 + android:layout_weight="1"
  15 + android:orientation="vertical">
  16 +
  17 + <TextView
  18 + android:id="@+id/txt_childname"
  19 + android:layout_width="wrap_content"
  20 + android:layout_height="wrap_content"
  21 + android:textSize="@dimen/txtsize_title"
  22 + android:text="李小明" />
  23 +
  24 + <TextView
  25 + android:id="@+id/txt_childclass"
  26 + android:layout_width="wrap_content"
  27 + android:layout_height="wrap_content"
  28 + android:text="顺治中学 初一(3)班" />
  29 +
  30 + </LinearLayout>
  31 +
  32 +
  33 +
  34 + <TextView
  35 + android:id="@+id/go_buy"
  36 + android:layout_width="wrap_content"
  37 + android:layout_height="wrap_content"
  38 + android:paddingTop="5dp"
  39 + android:paddingBottom="5dp"
  40 + android:paddingLeft="10dp"
  41 + android:paddingRight="10dp"
  42 + android:layout_gravity="center_vertical"
  43 + android:gravity="center"
  44 + android:textSize="@dimen/sp_18"
  45 + android:textColor="@color/textBlue"
  46 + android:background="@drawable/rudiobtn2"
  47 + android:text="去订购" />
  48 +
  49 + </LinearLayout>
  50 +
  51 +</LinearLayout>
... ...
app/src/main/res/values/colors.xml
... ... @@ -10,6 +10,7 @@
10 10 <color name="bg_main">#F0EFF5</color>
11 11 <color name="textRed">#FC5B6A</color>
12 12 <color name="back_top">#C6DAFF</color>
  13 + <color name="textBlue">#ACC9FC</color>
13 14 <color name="titleColor">#C6DAFF</color>
14 15 <color name="bgColor">#F0EFF5</color>
15 16 <color name="textColor">#494947</color>
... ...
mvpsdk/build.gradle
... ... @@ -49,6 +49,9 @@ dependencies {
49 49 compile "com.android.support:design:$rootProject.supportLibraryVersion"
50 50 compile "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
51 51  
  52 + //delete
  53 + compile 'com.yanzhenjie:recyclerview-swipe:1.1.4'
  54 +
52 55 // Retrofit
53 56 compile "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
54 57 compile "com.squareup.retrofit2:converter-gson:$rootProject.retrofitVersion"
... ...