Commit b8d5d4716911a028988d340500ba747f371a41b9
1 parent
75be5d9a
Exists in
yxb_dev
and in
2 other branches
no message
Showing
9 changed files
with
154 additions
and
67 deletions
Show diff stats
app/src/main/java/com/shunzhi/parent/adapter/MyConsultAdapter.java
0 → 100644
... | ... | @@ -0,0 +1,65 @@ |
1 | +package com.shunzhi.parent.adapter; | |
2 | + | |
3 | +import android.content.Context; | |
4 | +import android.support.v7.widget.LinearLayoutManager; | |
5 | +import android.support.v7.widget.RecyclerView; | |
6 | +import android.view.LayoutInflater; | |
7 | +import android.view.View; | |
8 | +import android.view.ViewGroup; | |
9 | +import android.widget.ImageView; | |
10 | +import android.widget.TextView; | |
11 | + | |
12 | +import com.share.mvpsdk.base.adapter.BaseRecyclerViewAdapter; | |
13 | +import com.share.mvpsdk.base.adapter.BaseRecyclerViewHolder; | |
14 | +import com.shunzhi.parent.R; | |
15 | +import com.shunzhi.parent.bean.MyConsultBean; | |
16 | +import com.shunzhi.parent.ui.activity.consult.ConsultTwoLevelActivity; | |
17 | + | |
18 | +/** | |
19 | + * Created by ToaHanDong on 2018/3/14. | |
20 | + */ | |
21 | + | |
22 | +public class MyConsultAdapter extends BaseRecyclerViewAdapter<MyConsultBean> { | |
23 | + | |
24 | + private Context mContext=null; | |
25 | + | |
26 | + public MyConsultAdapter(Context context){ | |
27 | + mContext=context; | |
28 | + } | |
29 | + | |
30 | + @Override | |
31 | + public void onAttachedToRecyclerView(RecyclerView recyclerView) { | |
32 | + super.onAttachedToRecyclerView(recyclerView); | |
33 | + LinearLayoutManager layoutManager=new LinearLayoutManager(mContext); | |
34 | + layoutManager.setOrientation(LinearLayoutManager.VERTICAL); | |
35 | + recyclerView.setLayoutManager(layoutManager); | |
36 | + } | |
37 | + | |
38 | + @Override | |
39 | + public BaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |
40 | + View view = LayoutInflater.from(mContext).inflate(R.layout.layout_consult_content, parent, false); | |
41 | + return new MyConsultViewHolder(view); | |
42 | + } | |
43 | + | |
44 | + private class MyConsultViewHolder extends BaseRecyclerViewHolder<MyConsultBean>{ | |
45 | + | |
46 | + TextView tvConsultTitle, tvConsultContent, tvPingLunNums, tvZhuanFaNums; | |
47 | + ImageView iv_consult; | |
48 | + public MyConsultViewHolder(View itemView) { | |
49 | + super(itemView); | |
50 | + tvConsultTitle = itemView.findViewById(R.id.tvConsultTitle); | |
51 | + tvConsultContent = itemView.findViewById(R.id.tvConsultContent); | |
52 | + tvPingLunNums = itemView.findViewById(R.id.tvPingLunNums); | |
53 | + tvZhuanFaNums = itemView.findViewById(R.id.tvZhuanFaNums); | |
54 | + iv_consult = itemView.findViewById(R.id.iv_consult); | |
55 | + } | |
56 | + | |
57 | + @Override | |
58 | + public void onBindViewHolder(MyConsultBean object, int position) { | |
59 | + tvConsultContent.setText(object.consultContent); | |
60 | + tvConsultTitle.setText(object.consultTitle); | |
61 | + tvPingLunNums.setText(object.consultCounts); | |
62 | + tvZhuanFaNums.setText(object.consultZhuanfaCounts); | |
63 | + } | |
64 | + } | |
65 | +} | ... | ... |
app/src/main/java/com/shunzhi/parent/presenter/ceping/CePingPresenter.java
... | ... | @@ -9,6 +9,7 @@ import com.shunzhi.parent.R; |
9 | 9 | import com.shunzhi.parent.bean.ToolBean; |
10 | 10 | import com.shunzhi.parent.contract.ceping.CepingContract; |
11 | 11 | import com.shunzhi.parent.model.CePingModel; |
12 | +import com.shunzhi.parent.util.AttrsUtils; | |
12 | 13 | import com.shunzhi.parent.views.TextAndImgShowView; |
13 | 14 | |
14 | 15 | import java.util.ArrayList; |
... | ... | @@ -38,11 +39,7 @@ public class CePingPresenter extends CepingContract.CePingPresenter { |
38 | 39 | textAndImgShowView.setImgs(R.drawable.play, Integer.parseInt(toolBeanList.get(i).toolImg)); |
39 | 40 | textAndImgShowView.setSelect(true); |
40 | 41 | textAndImgShowView.setWidth(mIView.getBindActivity(),layout_control); |
41 | - TypedValue typedValue=new TypedValue(); | |
42 | - mIView.getBindActivity().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,typedValue,true); | |
43 | - int[] sttrides=new int[]{android.R.attr.selectableItemBackground}; | |
44 | - TypedArray typedArray=mIView.getBindActivity().getTheme().obtainStyledAttributes(sttrides); | |
45 | - textAndImgShowView.setBackground(typedArray.getDrawable(0)); | |
42 | + textAndImgShowView.setBackground(AttrsUtils.getAttrs(mIView.getBindActivity()).getDrawable(0)); | |
46 | 43 | textAndImgShowView.setOnClickListener(new View.OnClickListener() { |
47 | 44 | @Override |
48 | 45 | public void onClick(View view) { | ... | ... |
app/src/main/java/com/shunzhi/parent/presenter/consult/ConsultPresenter.java
... | ... | @@ -10,6 +10,7 @@ import com.shunzhi.parent.bean.ToolBean; |
10 | 10 | import com.shunzhi.parent.contract.consult.ConsultContract; |
11 | 11 | import com.shunzhi.parent.model.consult.ConsultModel; |
12 | 12 | import com.shunzhi.parent.ui.activity.consult.ConsultOneLevelActivity; |
13 | +import com.shunzhi.parent.util.AttrsUtils; | |
13 | 14 | import com.shunzhi.parent.views.TextAndImgShowView; |
14 | 15 | |
15 | 16 | import java.util.ArrayList; |
... | ... | @@ -34,11 +35,7 @@ public class ConsultPresenter extends ConsultContract.ConsultPresenter { |
34 | 35 | textAndImgShowView.setImgs(R.drawable.play, Integer.parseInt(toolBeanList.get(i).toolImg)); |
35 | 36 | textAndImgShowView.setSelect(true); |
36 | 37 | textAndImgShowView.setWidth(mIView.getBindActivity(),layout_control); |
37 | - TypedValue typedValue=new TypedValue(); | |
38 | - mIView.getBindActivity().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,typedValue,true); | |
39 | - int[] sttrides=new int[]{android.R.attr.selectableItemBackground}; | |
40 | - TypedArray typedArray=mIView.getBindActivity().getTheme().obtainStyledAttributes(sttrides); | |
41 | - textAndImgShowView.setBackground(typedArray.getDrawable(0)); | |
38 | + textAndImgShowView.setBackground(AttrsUtils.getAttrs(mIView.getBindActivity()).getDrawable(0)); | |
42 | 39 | textAndImgShowView.setOnClickListener(new View.OnClickListener() { |
43 | 40 | @Override |
44 | 41 | public void onClick(View view) { | ... | ... |
app/src/main/java/com/shunzhi/parent/presenter/consult/consultone/ConsultOnePresenter.java
1 | 1 | package com.shunzhi.parent.presenter.consult.consultone; |
2 | 2 | |
3 | +import android.view.View; | |
3 | 4 | import android.widget.LinearLayout; |
4 | 5 | |
5 | 6 | import com.shunzhi.parent.R; |
6 | 7 | import com.shunzhi.parent.bean.ToolBean; |
7 | 8 | import com.shunzhi.parent.contract.consult.consultone.ConsultOneContract; |
8 | 9 | import com.shunzhi.parent.model.consult.consultone.ConsultOneModel; |
10 | +import com.shunzhi.parent.ui.activity.consult.ConsultTwoLevelActivity; | |
11 | +import com.shunzhi.parent.util.AttrsUtils; | |
9 | 12 | import com.shunzhi.parent.views.TextAndImgShowView; |
10 | 13 | |
11 | 14 | import java.util.ArrayList; |
... | ... | @@ -31,7 +34,14 @@ public class ConsultOnePresenter extends ConsultOneContract.ConsultOnePresenter{ |
31 | 34 | textAndImgShowView.setImgs(R.drawable.play, Integer.parseInt(toolBeanList.get(i).toolImg)); |
32 | 35 | textAndImgShowView.setSelect(true); |
33 | 36 | textAndImgShowView.setWidth(mIView.getBindActivity(),layout_control); |
37 | + textAndImgShowView.setBackground(AttrsUtils.getAttrs(mIView.getBindActivity()).getDrawable(0)); | |
34 | 38 | layout_control.addView(textAndImgShowView); |
39 | + textAndImgShowView.setOnClickListener(new View.OnClickListener() { | |
40 | + @Override | |
41 | + public void onClick(View view) { | |
42 | + ConsultTwoLevelActivity.getInstance(mIView.getBindActivity()); | |
43 | + } | |
44 | + }); | |
35 | 45 | } |
36 | 46 | mIView.showTools(); |
37 | 47 | } | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/activity/consult/ConsultTwoLevelActivity.java
1 | 1 | package com.shunzhi.parent.ui.activity.consult; |
2 | 2 | |
3 | +import android.content.Context; | |
4 | +import android.content.Intent; | |
3 | 5 | import android.support.annotation.NonNull; |
4 | -import android.support.annotation.Nullable; | |
5 | 6 | import android.os.Bundle; |
6 | -import android.support.v7.widget.LinearLayoutManager; | |
7 | 7 | import android.support.v7.widget.RecyclerView; |
8 | -import android.view.LayoutInflater; | |
9 | 8 | import android.view.View; |
10 | -import android.view.ViewGroup; | |
11 | 9 | import android.widget.EditText; |
12 | 10 | import android.widget.ImageView; |
13 | 11 | import android.widget.TextView; |
14 | 12 | |
15 | 13 | import com.share.mvpsdk.base.BasePresenter; |
16 | 14 | import com.share.mvpsdk.base.activity.BaseMVPCompatActivity; |
17 | -import com.share.mvpsdk.base.adapter.BaseRecyclerViewAdapter; | |
18 | -import com.share.mvpsdk.base.adapter.BaseRecyclerViewHolder; | |
19 | -import com.share.mvpsdk.base.fragment.BaseMVPCompatFragment; | |
20 | 15 | import com.shunzhi.parent.R; |
16 | +import com.shunzhi.parent.adapter.MyConsultAdapter; | |
21 | 17 | import com.shunzhi.parent.bean.MyConsultBean; |
22 | 18 | |
23 | 19 | import java.util.ArrayList; |
... | ... | @@ -25,6 +21,11 @@ import java.util.List; |
25 | 21 | |
26 | 22 | public class ConsultTwoLevelActivity extends BaseMVPCompatActivity implements View.OnClickListener { |
27 | 23 | |
24 | + public static void getInstance(Context context){ | |
25 | + Intent intent=new Intent(context,ConsultTwoLevelActivity.class); | |
26 | + context.startActivity(intent); | |
27 | + } | |
28 | + | |
28 | 29 | ImageView ivBack, ivSearch; |
29 | 30 | |
30 | 31 | EditText et_search; |
... | ... | @@ -33,7 +34,7 @@ public class ConsultTwoLevelActivity extends BaseMVPCompatActivity implements Vi |
33 | 34 | |
34 | 35 | RecyclerView recyclerView; |
35 | 36 | |
36 | - MyTwoLevelAdapter myTwoLevelAdapter = null; | |
37 | + MyConsultAdapter myConsultAdapter = null; | |
37 | 38 | |
38 | 39 | List<MyConsultBean> myConsultBeanList = new ArrayList<>(); |
39 | 40 | |
... | ... | @@ -68,7 +69,7 @@ public class ConsultTwoLevelActivity extends BaseMVPCompatActivity implements Vi |
68 | 69 | |
69 | 70 | private void initRecyclerView() { |
70 | 71 | |
71 | - if (null == myTwoLevelAdapter) myTwoLevelAdapter = new MyTwoLevelAdapter(); | |
72 | + if (null == myConsultAdapter) myConsultAdapter = new MyConsultAdapter(this); | |
72 | 73 | for (int i = 0; i < 12; i++) { |
73 | 74 | MyConsultBean myConsultBean = new MyConsultBean(); |
74 | 75 | myConsultBean.consultCounts = i + ""; |
... | ... | @@ -77,8 +78,8 @@ public class ConsultTwoLevelActivity extends BaseMVPCompatActivity implements Vi |
77 | 78 | myConsultBean.consultZhuanfaCounts = "转发:" + i; |
78 | 79 | myConsultBeanList.add(myConsultBean); |
79 | 80 | } |
80 | - myTwoLevelAdapter.addAll(myConsultBeanList); | |
81 | - recyclerView.setAdapter(myTwoLevelAdapter); | |
81 | + myConsultAdapter.addAll(myConsultBeanList); | |
82 | + recyclerView.setAdapter(myConsultAdapter); | |
82 | 83 | } |
83 | 84 | |
84 | 85 | @NonNull |
... | ... | @@ -100,44 +101,5 @@ public class ConsultTwoLevelActivity extends BaseMVPCompatActivity implements Vi |
100 | 101 | } |
101 | 102 | |
102 | 103 | |
103 | - private class MyTwoLevelAdapter extends BaseRecyclerViewAdapter { | |
104 | - | |
105 | - @Override | |
106 | - public void onAttachedToRecyclerView(RecyclerView recyclerView) { | |
107 | - super.onAttachedToRecyclerView(recyclerView); | |
108 | - LinearLayoutManager layoutManager = new LinearLayoutManager(ConsultTwoLevelActivity.this); | |
109 | - recyclerView.setLayoutManager(layoutManager); | |
110 | - } | |
111 | - | |
112 | - @Override | |
113 | - public BaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |
114 | - View view = LayoutInflater.from(ConsultTwoLevelActivity.this).inflate(R.layout.layout_consult_content, parent, false); | |
115 | - return new MyTwoLevelViewHolder(view); | |
116 | - } | |
117 | - | |
118 | - private class MyTwoLevelViewHolder extends BaseRecyclerViewHolder { | |
119 | - | |
120 | - TextView tvConsultTitle, tvConsultContent, tvPingLunNums, tvZhuanFaNums; | |
121 | - ImageView iv_consult; | |
122 | - | |
123 | - public MyTwoLevelViewHolder(View itemView) { | |
124 | - super(itemView); | |
125 | - | |
126 | - tvConsultTitle = itemView.findViewById(R.id.tvConsultTitle); | |
127 | - tvConsultContent = itemView.findViewById(R.id.tvConsultContent); | |
128 | - tvPingLunNums = itemView.findViewById(R.id.tvPingLunNums); | |
129 | - tvZhuanFaNums = itemView.findViewById(R.id.tvZhuanFaNums); | |
130 | - iv_consult = itemView.findViewById(R.id.iv_consult); | |
131 | - | |
132 | - } | |
133 | - | |
134 | - @Override | |
135 | - public void onBindViewHolder(Object object, int position) { | |
136 | - | |
137 | - } | |
138 | - } | |
139 | - | |
140 | - | |
141 | - } | |
142 | 104 | |
143 | 105 | } | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/fragment/consult/ConsultOneLevelFragment.java
... | ... | @@ -13,6 +13,7 @@ import android.util.Log; |
13 | 13 | import android.view.LayoutInflater; |
14 | 14 | import android.view.View; |
15 | 15 | import android.view.ViewGroup; |
16 | +import android.widget.FrameLayout; | |
16 | 17 | import android.widget.ImageView; |
17 | 18 | import android.widget.LinearLayout; |
18 | 19 | import android.widget.TextView; |
... | ... | @@ -26,7 +27,9 @@ import com.share.mvpsdk.utils.DisplayUtils; |
26 | 27 | import com.share.mvpsdk.utils.ToastUtils; |
27 | 28 | import com.shunzhi.parent.AppContext; |
28 | 29 | import com.shunzhi.parent.R; |
30 | +import com.shunzhi.parent.adapter.MyConsultAdapter; | |
29 | 31 | import com.shunzhi.parent.bean.GrallyBean; |
32 | +import com.shunzhi.parent.bean.MyConsultBean; | |
30 | 33 | import com.shunzhi.parent.contract.consult.ConsultContract; |
31 | 34 | import com.shunzhi.parent.contract.consult.consultone.ConsultOneContract; |
32 | 35 | import com.shunzhi.parent.presenter.consult.consultone.ConsultOnePresenter; |
... | ... | @@ -39,18 +42,22 @@ import java.io.InputStream; |
39 | 42 | import java.util.ArrayList; |
40 | 43 | import java.util.List; |
41 | 44 | |
42 | -public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneContract.ConsultOnePresenter,ConsultOneContract.IConsultOneModel> | |
43 | - implements View.OnClickListener,ConsultOneContract.IConsultOneView { | |
45 | +public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneContract.ConsultOnePresenter, ConsultOneContract.IConsultOneModel> | |
46 | + implements View.OnClickListener, ConsultOneContract.IConsultOneView { | |
44 | 47 | |
45 | 48 | |
46 | - RecyclerView recyclerViewGrally; | |
49 | + RecyclerView recyclerViewGrally, recyclerViewConsultOne; | |
47 | 50 | |
48 | 51 | MyGrallyAdapter myGrallyAdapter = null; |
49 | 52 | |
53 | + MyConsultAdapter myConsultAdapter = null; | |
54 | + | |
50 | 55 | List<GrallyBean> grallyBeanList = new ArrayList<>(); |
51 | 56 | |
52 | 57 | LinearLayout layout_control; |
53 | 58 | |
59 | + List<MyConsultBean> myConsultBeanList=null; | |
60 | + | |
54 | 61 | @Override |
55 | 62 | public int getLayoutId() { |
56 | 63 | return R.layout.fragment_consult_one_level; |
... | ... | @@ -62,7 +69,7 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
62 | 69 | initViews(view); |
63 | 70 | } catch (Exception e) { |
64 | 71 | e.printStackTrace(); |
65 | - Log.d("exception:",e.toString()); | |
72 | + Log.d("exception:", e.toString()); | |
66 | 73 | } |
67 | 74 | } |
68 | 75 | |
... | ... | @@ -73,16 +80,38 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
73 | 80 | if (null == myGrallyAdapter) myGrallyAdapter = new MyGrallyAdapter(); |
74 | 81 | myGrallyAdapter.addAll(grallyBeanList); |
75 | 82 | recyclerViewGrally.setAdapter(myGrallyAdapter); |
83 | + | |
84 | + | |
76 | 85 | } |
77 | 86 | |
78 | 87 | private void initViews(View view) { |
79 | 88 | |
80 | - layout_control=view.findViewById(R.id.layout_control); | |
81 | - layout_control.measure(0,0); | |
89 | + layout_control = view.findViewById(R.id.layout_control); | |
90 | + layout_control.measure(0, 0); | |
82 | 91 | mPresenter.getTools(layout_control); |
83 | 92 | recyclerViewGrally = view.findViewById(R.id.recyclerViewGrally); |
93 | + recyclerViewConsultOne = view.findViewById(R.id.recyclerViewConsultOne); | |
84 | 94 | |
85 | 95 | initRecyclerView(); |
96 | + | |
97 | + initRecyclerViewConsult(); | |
98 | + } | |
99 | + | |
100 | + private void initRecyclerViewConsult() { | |
101 | + if (null == myConsultAdapter) myConsultAdapter = new MyConsultAdapter(getActivity()); | |
102 | + if (null==myConsultBeanList)myConsultBeanList=new ArrayList<>(); | |
103 | + else myConsultBeanList.clear(); | |
104 | + for (int i = 0; i < 12; i++) { | |
105 | + MyConsultBean myConsultBean = new MyConsultBean(); | |
106 | + myConsultBean.consultCounts = i + ""; | |
107 | + myConsultBean.consultContent = "咨询内容" + i; | |
108 | + myConsultBean.consultTitle = "咨询标题" + i; | |
109 | + myConsultBean.consultZhuanfaCounts = "转发:" + i; | |
110 | + myConsultBeanList.add(myConsultBean); | |
111 | + } | |
112 | + myConsultAdapter.addAll(myConsultBeanList); | |
113 | + recyclerViewConsultOne.setAdapter(myConsultAdapter); | |
114 | + | |
86 | 115 | } |
87 | 116 | |
88 | 117 | @NonNull |
... | ... | @@ -121,11 +150,16 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
121 | 150 | |
122 | 151 | ImageView iv_grally; |
123 | 152 | TextView tv_grally_title; |
153 | + FrameLayout frame_root; | |
124 | 154 | |
125 | 155 | public MyGrallyViewHolder(View itemView) { |
126 | 156 | super(itemView); |
127 | 157 | iv_grally = itemView.findViewById(R.id.iv_grally); |
128 | 158 | tv_grally_title = itemView.findViewById(R.id.tv_grally_title); |
159 | + frame_root = itemView.findViewById(R.id.frame_root); | |
160 | + FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(-1, -1); | |
161 | + params.width = DisplayUtils.getScreenWidthPixels(getActivity()) - 40; | |
162 | + frame_root.setLayoutParams(params); | |
129 | 163 | } |
130 | 164 | |
131 | 165 | @Override | ... | ... |
app/src/main/java/com/shunzhi/parent/util/AttrsUtils.java
0 → 100644
... | ... | @@ -0,0 +1,21 @@ |
1 | +package com.shunzhi.parent.util; | |
2 | + | |
3 | +import android.app.Activity; | |
4 | +import android.content.res.TypedArray; | |
5 | +import android.util.TypedValue; | |
6 | + | |
7 | +/** | |
8 | + * Created by ToaHanDong on 2018/3/14. | |
9 | + */ | |
10 | + | |
11 | +public class AttrsUtils { | |
12 | + | |
13 | + public static TypedArray getAttrs(Activity activity){ | |
14 | + TypedValue typedValue=new TypedValue(); | |
15 | + activity.getTheme().resolveAttribute(android.R.attr.selectableItemBackground,typedValue,true); | |
16 | + int[] sttrides=new int[]{android.R.attr.selectableItemBackground}; | |
17 | + TypedArray typedArray=activity.getTheme().obtainStyledAttributes(sttrides); | |
18 | + return typedArray; | |
19 | + } | |
20 | + | |
21 | +} | ... | ... |
app/src/main/res/layout/fragment_consult_one_level.xml
... | ... | @@ -24,7 +24,7 @@ |
24 | 24 | android:layout_width="match_parent" |
25 | 25 | android:layout_height="0dp" |
26 | 26 | android:layout_weight="3" |
27 | - android:background="@color/white" | |
27 | + android:id="@+id/recyclerViewConsultOne" | |
28 | 28 | ></android.support.v7.widget.RecyclerView> |
29 | 29 | |
30 | 30 | </LinearLayout> | ... | ... |
app/src/main/res/layout/item_grally.xml