package com.bsk.zhangbo.demoforbsk.ui.fragment; import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.view.LayoutInflater; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RadioGroup; import android.widget.TextView; import android.widget.Toast; import com.bsk.zhangbo.demoforbsk.R; import com.bsk.zhangbo.demoforbsk.adapter.VisitorRecyclerViewAdapter; import com.bsk.zhangbo.demoforbsk.base.MainUIBaseFragment; import com.bsk.zhangbo.demoforbsk.ui.activity.MainActivity; import com.bsk.zhangbo.demoforbsk.util.Constant; import com.bsk.zhangbo.demoforbsk.widget.VisitorView; import com.camnter.easyrecyclerview.widget.EasyRecyclerView; import com.lidroid.xutils.ViewUtils; import com.lidroid.xutils.view.annotation.event.OnClick; import java.util.ArrayList; import java.util.List; import cn.com.basic.face.discern.query.item.FacePhotoItem; import cn.com.basic.face.discern.query.item.IntervieweeQueryItem; import cn.com.basic.face.discern.query.item.VisitorQueryItem; /** * Created by Administrator on 2017/2/20 0020. */ public class VisitorRegisterFragment extends MainUIBaseFragment { private View mViewLeft,mViewRight; private RadioGroup mRGTop,mRGClass; private LinearLayout mLlRadioGroupClass; private VisitorView mVisitorTo,mVisitorFrom; private VisitorRecyclerViewAdapter mAdapter; private EasyRecyclerView mRecyclerView; private List mList; private static VisitorRegisterFragment instance = new VisitorRegisterFragment(); private TextView companyNameTv; private TextView identity; private ImageView visitorPhoto; private TextView fromPhone; private TextView mDepartmentTv; private TextView mDutyTv; private TextView mPhoneTv; private TextView mTelTv; private List visitPurposeList = new ArrayList(); public static VisitorRegisterFragment getInstance() { return instance; } @Override protected void initViews(View view, Bundle savedInstanceState) { super.initViews(view, savedInstanceState); } @Override protected void initListeners() { mRGTop.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup radioGroup, int i) { switch (radioGroup.getCheckedRadioButtonId()){ case R.id.visitor_register_rb_left: mLlRadioGroupClass.setVisibility(View.GONE); mAdapter = new VisitorRecyclerViewAdapter(getActivity(), Constant.VISITOR_FROM); mAdapter.setList(mList); mRecyclerView.setAdapter(mAdapter); break; case R.id.visitor_register_rb_right: mLlRadioGroupClass.setVisibility(View.VISIBLE); mAdapter = new VisitorRecyclerViewAdapter(getActivity(), Constant.VISITOR_TO); mAdapter.setVisitorToColor(VisitorRecyclerViewAdapter.TYPE_NAME); mAdapter.setList(mList); mRecyclerView.setAdapter(mAdapter); break; } } }); mRGClass.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup radioGroup, int i) { switch (radioGroup.getCheckedRadioButtonId()){ case R.id.visitor_register_check_name: // mAdapter.setVisitorToTextColor(VisitorRecyclerViewAdapter.TYPE_NAME); mAdapter.setVisitorToColor(VisitorRecyclerViewAdapter.TYPE_NAME); mAdapter.setList(mList); mRecyclerView.setAdapter(mAdapter); break; case R.id.visitor_register_check_department: // mAdapter.setVisitorToTextColor(VisitorRecyclerViewAdapter.TYPE_DEPARTMENT); mAdapter.setVisitorToColor(VisitorRecyclerViewAdapter.TYPE_DEPARTMENT); mAdapter.setList(mList); mRecyclerView.setAdapter(mAdapter); break; } } }); } @Override protected void initData() { mList = new ArrayList(); for (int i=0;i<25;i++){ //mList.add(""); VisitorQueryItem item = new VisitorQueryItem(); item.setName("李四"+i); item.setCompanyName("贝思科"+i); item.setIdentify("1001"+i); item.setImagePath("test.png"); item.setPhone("136913486"+i); mList.add(item); } mAdapter.setList(mList); mRecyclerView.setAdapter(mAdapter); } @Override public View addLeftLayout() { mViewLeft = LayoutInflater.from(getActivity()).inflate(R.layout.visitor_register_left,null); mRGTop = (RadioGroup) mViewLeft.findViewById(R.id.visitor_register_radio); mRGClass = (RadioGroup) mViewLeft.findViewById(R.id.visitor_register_check_class); mLlRadioGroupClass = (LinearLayout) mViewLeft.findViewById(R.id.visitor_register_check_class_ll); mRecyclerView = (EasyRecyclerView) mViewLeft.findViewById(R.id.visitor_register_recycler); LinearLayoutManager manager = new LinearLayoutManager(getActivity(),LinearLayoutManager.VERTICAL,false); mRecyclerView.setLayoutManager(manager); mAdapter = new VisitorRecyclerViewAdapter(getActivity(),Constant.VISITOR_FROM); ViewUtils.inject(this, mViewLeft); return mViewLeft; } @Override public View addRightLayout() { mViewRight = LayoutInflater.from(getActivity()).inflate(R.layout.visitor_register_right,null); mVisitorFrom = (VisitorView) mViewRight.findViewById(R.id.visitor_from); companyNameTv = (TextView)mVisitorFrom.findViewById(R.id.visitor_view_from_company_name); identity = (TextView)mVisitorFrom.findViewById(R.id.visitor_view_from_identity); fromPhone = (TextView)mVisitorFrom.findViewById(R.id.visitor_view_from_phone); visitorPhoto = (ImageView)mVisitorFrom.findViewById(R.id.visitor_view_from_photo); mVisitorTo = (VisitorView) mViewRight.findViewById(R.id.visitor_to); mDepartmentTv = (TextView)mVisitorTo.findViewById(R.id.view_visitor_to_deptartment); mDutyTv = (TextView)mVisitorTo.findViewById(R.id.view_visitor_to_duty); mPhoneTv = (TextView)mVisitorTo.findViewById(R.id.visitor_to_phone); mTelTv = (TextView)mVisitorTo.findViewById(R.id.visitor_to_tel); mVisitorFrom.setType(Constant.VISITOR_FROM); mVisitorTo.setType(Constant.VISITOR_TO); mVisitorFrom.setTitle("dasfasdfasdf"); mVisitorTo.setTitle("dasfasdfasdf"); ViewUtils.inject(this, mVisitorTo); return mViewRight; } @OnClick(R.id.visitor_register_back) public void back(View view) { MainActivity.selectPage(0); } public void visitorCheckIn(FacePhotoItem item) { mVisitorFrom.setTitle(item.getName()); } public void listChanged(List list, boolean isClear) { if (isClear) { mList.clear(); } mList.addAll(list); mAdapter.notifyDataSetChanged(); } public void setVisitorInfo(VisitorQueryItem item) { mVisitorFrom.setTitle(item.getName()); companyNameTv.setText(item.getCompanyName()); identity.setText(item.getIdentify()); fromPhone.setText(item.getPhone()); } public void setIntervieweeInfo(VisitorQueryItem item) { mVisitorTo.setTitle(item.getName()); mDepartmentTv.setText("部门"); mDutyTv.setText("财务"); mPhoneTv.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View view) { Toast.makeText(MainActivity.getInstance(), "正在呼叫手机", Toast.LENGTH_SHORT).show(); } }); mTelTv.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View view) { Toast.makeText(MainActivity.getInstance(), "正在呼叫座机", Toast.LENGTH_SHORT).show(); } }); } public void setVisitPurposeList(List visitPurposeList) { this.visitPurposeList = visitPurposeList; } }