parent
5672fac09c
commit
6c130f9265
@ -1,102 +0,0 @@ |
||||
package com.unionmed.unionmedtv.adapter; |
||||
|
||||
import android.text.TextUtils; |
||||
import android.view.View; |
||||
import android.widget.ImageView; |
||||
import android.widget.TextView; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
import androidx.recyclerview.widget.RecyclerView; |
||||
|
||||
|
||||
import com.bumptech.glide.Glide; |
||||
import com.bumptech.glide.request.RequestOptions; |
||||
import com.chad.library.adapter.base.BaseQuickAdapter; |
||||
import com.chad.library.adapter.base.viewholder.BaseViewHolder; |
||||
import com.unionmed.unionmedtv.R; |
||||
import com.unionmed.unionmedtv.api.GetNearDoctorApi; |
||||
import com.unionmed.unionmedtv.presenter.TypeDoctorPresenter; |
||||
import com.unionmed.unionmedtv.utils.OnChildClickListener; |
||||
|
||||
|
||||
import org.jetbrains.annotations.NotNull; |
||||
|
||||
import java.util.List; |
||||
|
||||
public class HospitalDetailAdapter extends BaseQuickAdapter<GetNearDoctorApi.DoctorInfo.MemberBean,BaseViewHolder>{ |
||||
private OnChildClickListener onChildClickListener; |
||||
public HospitalDetailAdapter(int layoutResId, @Nullable List<GetNearDoctorApi.DoctorInfo.MemberBean> data, OnChildClickListener onChildClickListener) { |
||||
super(layoutResId, data); |
||||
this.onChildClickListener=onChildClickListener; |
||||
} |
||||
|
||||
@Override |
||||
protected void convert(@NotNull BaseViewHolder vh, GetNearDoctorApi.DoctorInfo.MemberBean memberBean) { |
||||
TextView tv_online_status=vh.getView(R.id.tv_online_status); |
||||
int drawable; |
||||
if (memberBean.getOnline().equals("1")) { |
||||
tv_online_status.setText("在线"); |
||||
tv_online_status.setBackground(getContext().getResources().getDrawable(R.drawable.shape_corner15_color_0bbac6)); |
||||
drawable = R.mipmap.icon_default_online; |
||||
} else { |
||||
tv_online_status.setText("离线"); |
||||
drawable = R.mipmap.icon_default_offline; |
||||
tv_online_status.setBackground(getContext().getResources().getDrawable(R.drawable.shape_corner15_color_9a9a9a)); |
||||
} |
||||
ImageView iv_photo=vh.getView(R.id.iv_photo); |
||||
Glide.with(getContext()) |
||||
.load(memberBean.getPhoto()) |
||||
.apply(new RequestOptions() |
||||
.circleCrop() |
||||
.placeholder(drawable) |
||||
.circleCrop()) |
||||
.into(iv_photo); |
||||
TextView tv_name=vh.getView(R.id.tv_name); |
||||
tv_name.setText(memberBean.getName()); |
||||
TextView tv_dept=vh.getView(R.id.tv_dept); |
||||
if (!memberBean.getPersoninfo().isEmpty()) { |
||||
if (!TextUtils.isEmpty(memberBean.getPersoninfo().get(0).getDepartment()) |
||||
&& !TextUtils.isEmpty(memberBean.getPersoninfo().get(0).getZc())) {//部门职称都不为null
|
||||
tv_dept.setText(memberBean.getPersoninfo().get(0).getDepartment() |
||||
+ " | " + memberBean.getPersoninfo().get(0).getZc()); |
||||
} else if (TextUtils.isEmpty(memberBean.getPersoninfo().get(0).getDepartment()) |
||||
&& TextUtils.isEmpty(memberBean.getPersoninfo().get(0).getZc())) {//部门职称都为null
|
||||
tv_dept.setText("- -"); |
||||
} else if (!TextUtils.isEmpty(memberBean.getPersoninfo().get(0).getDepartment()) |
||||
&& TextUtils.isEmpty(memberBean.getPersoninfo().get(0).getZc())) {//部门不为null,职称为null
|
||||
tv_dept.setText(memberBean.getPersoninfo().get(0).getDepartment()); |
||||
} else if (TextUtils.isEmpty(memberBean.getPersoninfo().get(0).getDepartment()) |
||||
&& !TextUtils.isEmpty(memberBean.getPersoninfo().get(0).getZc())) {//部门为null,职称不为null
|
||||
tv_dept.setText(memberBean.getPersoninfo().get(0).getZc()); |
||||
} |
||||
|
||||
|
||||
} else { |
||||
tv_dept.setText("- -"); |
||||
tv_dept.setText("- -"); |
||||
} |
||||
TextView tv_hospital=vh.getView(R.id.tv_hospital); |
||||
tv_hospital.setText(memberBean.getPersoninfo().get(0).getChosname()); |
||||
ImageView iv_sex=vh.getView(R.id.iv_sex); |
||||
if (memberBean.getSex().equals("男")) { |
||||
iv_sex.setImageDrawable(getContext().getResources().getDrawable(R.drawable.icon_sex_boy)); |
||||
} else { |
||||
iv_sex.setImageDrawable(getContext().getResources().getDrawable(R.drawable.icon_sex_girl)); |
||||
} |
||||
TextView tv_distance=vh.getView(R.id.tv_distance); |
||||
if (TextUtils.isEmpty(memberBean.getDistance())) { |
||||
tv_distance.setVisibility(View.GONE); |
||||
}else { |
||||
tv_distance.setVisibility(View.VISIBLE); |
||||
tv_distance.setText(memberBean.getDistance()); |
||||
} |
||||
vh.itemView.setOnClickListener(new View.OnClickListener() { |
||||
@Override |
||||
public void onClick(View view) { |
||||
onChildClickListener.onChildClick(view,vh.getLayoutPosition(),memberBean); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue