Commit e80f77fb6f35deff9f5e1409f1e8195f6382510d
Exists in
yxb_dev
and in
2 other branches
Merge branch 'yxb_dev' of http://git.shunzhi.net/taohd/parentwork into developer
Showing
2 changed files
with
46 additions
and
17 deletions
Show diff stats
app/src/main/java/com/shunzhi/parent/adapter/ContextAdapter.java
@@ -4,7 +4,9 @@ import android.content.Context; | @@ -4,7 +4,9 @@ import android.content.Context; | ||
4 | import android.view.LayoutInflater; | 4 | import android.view.LayoutInflater; |
5 | import android.view.View; | 5 | import android.view.View; |
6 | import android.view.ViewGroup; | 6 | import android.view.ViewGroup; |
7 | +import android.widget.FrameLayout; | ||
7 | import android.widget.ImageView; | 8 | import android.widget.ImageView; |
9 | +import android.widget.LinearLayout; | ||
8 | import android.widget.TextView; | 10 | import android.widget.TextView; |
9 | 11 | ||
10 | import com.bumptech.glide.Glide; | 12 | import com.bumptech.glide.Glide; |
@@ -17,7 +19,7 @@ import com.shunzhi.parent.bean.channel.ChannelContextBean; | @@ -17,7 +19,7 @@ import com.shunzhi.parent.bean.channel.ChannelContextBean; | ||
17 | * Created by lenovo on 2018/3/18. | 19 | * Created by lenovo on 2018/3/18. |
18 | */ | 20 | */ |
19 | 21 | ||
20 | -public class ContextAdapter extends BaseRecyclerViewAdapter<ChannelContextBean>{ | 22 | +public class ContextAdapter extends BaseRecyclerViewAdapter<ChannelContextBean> { |
21 | Context context; | 23 | Context context; |
22 | 24 | ||
23 | public ContextAdapter(Context context) { | 25 | public ContextAdapter(Context context) { |
@@ -32,29 +34,40 @@ public class ContextAdapter extends BaseRecyclerViewAdapter<ChannelContextBean> | @@ -32,29 +34,40 @@ public class ContextAdapter extends BaseRecyclerViewAdapter<ChannelContextBean> | ||
32 | } | 34 | } |
33 | 35 | ||
34 | private class MyViewHolder extends BaseRecyclerViewHolder<ChannelContextBean> { | 36 | private class MyViewHolder extends BaseRecyclerViewHolder<ChannelContextBean> { |
35 | - TextView tvConsultTitle,tvConsultContent,tvPingLunNums,tvZhuanFaNums; | ||
36 | - ImageView iv_consult; | 37 | + TextView tvConsultTitle, tvConsultContent, tvPingLunNums, tvZhuanFaNums; |
38 | + ImageView iv_consult, image_ad; | ||
39 | + FrameLayout frame_ad; | ||
40 | + LinearLayout normal_content; | ||
37 | 41 | ||
38 | 42 | ||
39 | public MyViewHolder(View view) { | 43 | public MyViewHolder(View view) { |
40 | super(view); | 44 | super(view); |
41 | - tvConsultContent=view.findViewById(R.id.tvConsultContent); | ||
42 | - tvConsultTitle=view.findViewById(R.id.tvConsultTitle); | ||
43 | - tvPingLunNums=view.findViewById(R.id.tvPingLunNums); | ||
44 | - tvZhuanFaNums=view.findViewById(R.id.tvZhuanFaNums); | ||
45 | - iv_consult=view.findViewById(R.id.iv_consult); | 45 | + tvConsultContent = view.findViewById(R.id.tvConsultContent); |
46 | + tvConsultTitle = view.findViewById(R.id.tvConsultTitle); | ||
47 | + tvPingLunNums = view.findViewById(R.id.tvPingLunNums); | ||
48 | + tvZhuanFaNums = view.findViewById(R.id.tvZhuanFaNums); | ||
49 | + iv_consult = view.findViewById(R.id.iv_consult); | ||
50 | + frame_ad = view.findViewById(R.id.frame_ad); | ||
51 | + image_ad = view.findViewById(R.id.image_ad); | ||
52 | + normal_content = view.findViewById(R.id.normal_content); | ||
46 | 53 | ||
47 | } | 54 | } |
48 | 55 | ||
49 | @Override | 56 | @Override |
50 | public void onBindViewHolder(final ChannelContextBean object, int position) { | 57 | public void onBindViewHolder(final ChannelContextBean object, int position) { |
51 | - tvConsultTitle.setText(object.getTitle()); | ||
52 | - tvConsultContent.setText(object.getContent()); | ||
53 | - Glide.with(context).load(object.getImage()).placeholder(R.color.xueqing_blue) | ||
54 | - .into(iv_consult); | ||
55 | - | ||
56 | - | ||
57 | - | 58 | + if (object.getIsAds() == 1) { |
59 | + frame_ad.setVisibility(View.VISIBLE); | ||
60 | + normal_content.setVisibility(View.GONE); | ||
61 | + Glide.with(context).load(object.getImage()).placeholder(R.color.xueqing_blue) | ||
62 | + .into(iv_consult); | ||
63 | + } else { | ||
64 | + frame_ad.setVisibility(View.GONE); | ||
65 | + normal_content.setVisibility(View.VISIBLE); | ||
66 | + tvConsultTitle.setText(object.getTitle()); | ||
67 | + tvConsultContent.setText(object.getContent()); | ||
68 | + Glide.with(context).load(object.getImage()).placeholder(R.color.xueqing_blue) | ||
69 | + .into(iv_consult); | ||
70 | + } | ||
58 | 71 | ||
59 | 72 | ||
60 | } | 73 | } |
@@ -62,5 +75,4 @@ public class ContextAdapter extends BaseRecyclerViewAdapter<ChannelContextBean> | @@ -62,5 +75,4 @@ public class ContextAdapter extends BaseRecyclerViewAdapter<ChannelContextBean> | ||
62 | } | 75 | } |
63 | 76 | ||
64 | 77 | ||
65 | - | ||
66 | } | 78 | } |
app/src/main/res/layout/layout_consult_content.xml
@@ -2,9 +2,11 @@ | @@ -2,9 +2,11 @@ | ||
2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
4 | android:layout_height="wrap_content" | 4 | android:layout_height="wrap_content" |
5 | - android:layout_marginBottom="@dimen/size_dp_10"> | 5 | + android:layout_marginBottom="@dimen/size_dp_10" |
6 | + android:orientation="vertical"> | ||
6 | 7 | ||
7 | <LinearLayout | 8 | <LinearLayout |
9 | + android:id="@+id/normal_content" | ||
8 | android:layout_width="match_parent" | 10 | android:layout_width="match_parent" |
9 | android:layout_height="match_parent" | 11 | android:layout_height="match_parent" |
10 | android:background="@drawable/report_white"> | 12 | android:background="@drawable/report_white"> |
@@ -77,4 +79,19 @@ | @@ -77,4 +79,19 @@ | ||
77 | android:layout_weight="2" | 79 | android:layout_weight="2" |
78 | android:src="@color/xueqing_blue" /> | 80 | android:src="@color/xueqing_blue" /> |
79 | </LinearLayout> | 81 | </LinearLayout> |
82 | + | ||
83 | + <FrameLayout | ||
84 | + android:id="@+id/frame_ad" | ||
85 | + android:layout_width="match_parent" | ||
86 | + android:layout_height="match_parent" | ||
87 | + android:visibility="gone" | ||
88 | + > | ||
89 | + | ||
90 | + <ImageView | ||
91 | + android:id="@+id/image_ad" | ||
92 | + android:layout_width="match_parent" | ||
93 | + android:layout_height="match_parent" | ||
94 | + android:src="@drawable/backgroud_top" /> | ||
95 | + | ||
96 | + </FrameLayout> | ||
80 | </LinearLayout> | 97 | </LinearLayout> |
81 | \ No newline at end of file | 98 | \ No newline at end of file |