package com.bsk.zhangbo.demoforbsk.adapter; import android.content.Context; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import com.bsk.zhangbo.demoforbsk.R; import com.bsk.zhangbo.demoforbsk.util.Constant; import com.camnter.easyrecyclerview.adapter.EasyRecyclerViewAdapter; import com.camnter.easyrecyclerview.holder.EasyRecyclerViewHolder; import java.util.List; /** * Created by Sinoe on 2017/2/23. */ public class VisitorRecyclerViewAdapter extends EasyRecyclerViewAdapter { private Context mContext; private int type, mTypeColor; private List list; private TextView mTvName, mTvDepartment; public static final int TYPE_NAME = 10000; public static final int TYPE_DEPARTMENT = 10001; public VisitorRecyclerViewAdapter(Context mContext, int type) { this.mContext = mContext; this.type = type; } @Override public int[] getItemLayouts() { return new int[]{R.layout.item_visitor_from, R.layout.item_visitor_to}; } @Override public void onBindRecycleViewHolder(EasyRecyclerViewHolder viewHolder, int position) { switch (type) { case Constant.VISITOR_FROM: VisitorFromViewHolder(viewHolder, position); break; case Constant.VISITOR_TO: VisitorToViewHolder(viewHolder, position); break; } } @Override public int getRecycleViewItemType(int position) { switch (type) { case Constant.VISITOR_FROM: return 0; case Constant.VISITOR_TO: return 1; default: return 1; } } /** * 来访人Holder * * @param holder * @param posistion */ private void VisitorFromViewHolder(EasyRecyclerViewHolder holder, int posistion) { LinearLayout mLayout = holder.findViewById(R.id.item_visitor_from_base); ViewGroup.LayoutParams layoutParams = mLayout.getLayoutParams(); mLayout.setLayoutParams(layoutParams); } /** * 被访问Holder * * @param holder * @param posistion */ private void VisitorToViewHolder(EasyRecyclerViewHolder holder, int posistion) { mTvName = holder.findViewById(R.id.item_visitor_to_name); mTvDepartment = holder.findViewById(R.id.item_visitor_to_department); if (mTypeColor == TYPE_DEPARTMENT) { mTvName.setTextColor(mContext.getResources().getColor(R.color.colorText_b)); mTvDepartment.setTextColor(mContext.getResources().getColor(R.color.colorText_5)); } else { mTvName.setTextColor(mContext.getResources().getColor(R.color.colorText_5)); mTvDepartment.setTextColor(mContext.getResources().getColor(R.color.colorText_b)); } } public void setVisitorToColor(int type) { this.mTypeColor = type; } // public void setVisitorToTextColor(int type){ // switch (type){ // case TYPE_DEPARTMENT: // mTvName.setTextColor(mContext.getResources().getColor(R.color.colorText_b)); // mTvDepartment.setTextColor(mContext.getResources().getColor(R.color.colorText_5)); // notifyDataSetChanged(); // break; // case TYPE_NAME: // mTvName.setTextColor(mContext.getResources().getColor(R.color.colorText_5)); // mTvDepartment.setTextColor(mContext.getResources().getColor(R.color.colorText_b)); // notifyDataSetChanged(); // break; // } // } }