xuxiuxi
2017-04-18 4dcad62f9276d34d13ff6e35bd8b0a910a1df3f1
VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/adapter/SurveillanceFragment.java
@@ -8,13 +8,16 @@
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.alibaba.fastjson.JSON;
import com.bsk.zhangbo.demoforbsk.R;
import com.camnter.easyrecyclerview.adapter.EasyRecyclerViewAdapter;
import com.camnter.easyrecyclerview.holder.EasyRecyclerViewHolder;
import cn.com.basic.face.base.MainActivity;
import cn.com.basic.face.discern.query.item.CheckInQueryItem;
import cn.com.basic.face.discern.query.item.FacePhotoItem;
import cn.com.basic.face.discern.query.item.SupervisoryQueryItem;
import cn.com.basic.face.discern.query.item.SurveillanceQueryItem;
import cn.com.basic.face.fragment.*;
import cn.com.basic.face.util.AppApi;
import cn.com.basic.face.util.Constant;
import cn.com.basic.face.util.WindowsUtil;
@@ -34,11 +37,11 @@
        @Override
        public void onBindRecycleViewHolder(EasyRecyclerViewHolder viewHolder, int position) {
            switch (((SupervisoryQueryItem)getList().get(position)).getType()){
                case Constant.Supervisory.VISIT_REGISTER_ITEM_TYPE:
            switch (((SurveillanceQueryItem)getList().get(position)).getType()){
                case Constant.Surveillance.VISIT_REGISTER_ITEM_TYPE:
                    RegisterCellViewFillData(viewHolder,position);
                    break;
                case Constant.Supervisory.VISIT_CHECK_IN_ITEM_TYPE:
                case Constant.Surveillance.VISIT_CHECK_IN_ITEM_TYPE:
                    checkInCellViewFillData(viewHolder,position);
                    break;
            }
@@ -46,41 +49,49 @@
        @Override
        public int getRecycleViewItemType(int position) {
            switch (((SupervisoryQueryItem)getList().get(position)).getType()) {
                case Constant.Supervisory.VISIT_REGISTER_ITEM_TYPE:
                    return Constant.Supervisory.REGISTER_CELL_VIEW_INDEX;
                case Constant.Supervisory.VISIT_CHECK_IN_ITEM_TYPE:
                    return Constant.Supervisory.CHECK_IN_CELL_VIEW_INDEX;
                case Constant.Supervisory.VISIT_BLANK_ITEM_TYPE:
                    return Constant.Supervisory.VISIT_BLANK_CELL_VIEW_INDEX;
            switch (((SurveillanceQueryItem)getList().get(position)).getType()) {
                case Constant.Surveillance.VISIT_REGISTER_ITEM_TYPE:
                    return Constant.Surveillance.REGISTER_CELL_VIEW_INDEX;
                case Constant.Surveillance.VISIT_CHECK_IN_ITEM_TYPE:
                    return Constant.Surveillance.CHECK_IN_CELL_VIEW_INDEX;
                case Constant.Surveillance.VISIT_BLANK_ITEM_TYPE:
                    return Constant.Surveillance.VISIT_BLANK_CELL_VIEW_INDEX;
            }
            return Constant.Supervisory.VISIT_BLANK_CELL_VIEW_INDEX;
            return Constant.Surveillance.VISIT_BLANK_CELL_VIEW_INDEX;
        }
        /**
         * 访客->人员注册
         */
        private void RegisterCellViewFillData(EasyRecyclerViewHolder holder, int posistion){
        private void RegisterCellViewFillData(EasyRecyclerViewHolder holder, int position){
            RelativeLayout mLayout = holder.findViewById(R.id.fragment_home_bottom_register_cell_relative_layout);
            ViewGroup.LayoutParams layoutParams = mLayout.getLayoutParams();
            layoutParams.height = WindowsUtil.dip2px(context, 127);
            layoutParams.width = WindowsUtil.dip2px(context, 104);
//            layoutParams.height = WindowsUtil.px2dip(context, 480);
//            layoutParams.width = WindowsUtil.px2dip(context, 640);
            mLayout.setLayoutParams(layoutParams);
            final Object data = this.getItem(posistion);
            final Object data = this.getItem(position);
            ImageView fragment_home_bottom_register_cell_photo = holder.findViewById(R.id.fragment_home_bottom_register_cell_photo);
            TextView fragment_home_bottom_register_cell_to_register = holder.findViewById(R.id.fragment_home_bottom_register_cell_to_register);
            if (data instanceof SupervisoryQueryItem) {
                final SupervisoryQueryItem item = (SupervisoryQueryItem)data;
                fragment_home_bottom_register_cell_photo.setImageURI(Uri.parse(AppApi.IMAGEURL_BASE +item.getImagePath()));
            if (data instanceof SurveillanceQueryItem) {
                final SurveillanceQueryItem item = (SurveillanceQueryItem)data;
                if (item.getImagePath() != null && !item.getImagePath().equals("")) {
                    fragment_home_bottom_register_cell_photo.setImageURI(Uri.parse(AppApi.IMAGE_URL_BASE +item.getImagePath()));
                } else {
                    fragment_home_bottom_register_cell_photo.setImageResource(R.drawable.u45);
                }
                fragment_home_bottom_register_cell_to_register.setOnClickListener(new View.OnClickListener(){
                    @Override
                    public void onClick(View view) {
                        MainActivity.selectPage(1);
                        //RegisterFragment.getInstance().setRegisterInfo(item);
                        RegisterFragment.getInstance().setRegisterInfo(getVo(item));
                    }
                });
            }
@@ -89,21 +100,22 @@
        /**
         * 访客->来访登记
         */
        private void checkInCellViewFillData(EasyRecyclerViewHolder holder, int posistion){
        private void checkInCellViewFillData(EasyRecyclerViewHolder holder, int position){
            RelativeLayout mLayout = holder.findViewById(R.id.fragment_supervisory_bottom_visitor_cell_relative_layout);
            ViewGroup.LayoutParams layoutParams = mLayout.getLayoutParams();
            layoutParams.height = WindowsUtil.dip2px(context, 127);
            layoutParams.width = WindowsUtil.dip2px(context, 104);
//            layoutParams.height = WindowsUtil.px2dip(context, 480);
//            layoutParams.width = WindowsUtil.px2dip(context, 640);
            mLayout.setLayoutParams(layoutParams);
            ImageView fragment_home_bottom_visitor_cell_photo = (ImageView) mLayout.findViewById(R.id.fragment_home_bottom_visitor_cell_photo);
            TextView fragment_home_bottom_visitor_cell_warning = (TextView) mLayout.findViewById(R.id.fragment_home_bottom_visitor_cell_warning);
            TextView fragment_home_bottom_visitor_cell_name = (TextView) mLayout.findViewById(R.id.fragment_home_bottom_visitor_cell_name);
            TextView fragment_home_bottom_visitor_cell_status = (TextView) mLayout.findViewById(R.id.fragment_home_bottom_visitor_cell_status);
            //statusTv.setText("");
            Object data = this.getItem(posistion);
            Object data = this.getItem(position);
            if (data instanceof FacePhotoItem) {
                final FacePhotoItem item = (FacePhotoItem) data;
@@ -135,10 +147,15 @@
            }
            fragment_home_bottom_visitor_cell_name.setText("");
            if (data instanceof SupervisoryQueryItem) {
                final SupervisoryQueryItem item = (SupervisoryQueryItem)data;
                fragment_home_bottom_visitor_cell_name.setText(item.getName());
                fragment_home_bottom_visitor_cell_photo.setImageURI(Uri.parse(AppApi.IMAGEURL_BASE +item.getImagePath()));
            if (data instanceof SurveillanceQueryItem) {
                final SurveillanceQueryItem item = (SurveillanceQueryItem)data;
                fragment_home_bottom_visitor_cell_name.setText(item.getUsername());
                if (item.getImagePath() != null && !item.getImagePath().equals("")) {
                    fragment_home_bottom_visitor_cell_photo.setImageURI(Uri.parse(AppApi.IMAGE_URL_BASE +item.getImagePath()));
                } else {
                    fragment_home_bottom_visitor_cell_photo.setImageResource(R.drawable.u45);
                }
                if (1==1) {
                    fragment_home_bottom_visitor_cell_status.setBackground(context.getDrawable(R.drawable.rectangle_textview));
@@ -146,9 +163,10 @@
                    fragment_home_bottom_visitor_cell_status.setOnClickListener(new View.OnClickListener(){
                        @Override
                        public void onClick(View view) {
                            MainActivity.selectPage(2);
                            //CheckInFragment.getInstance().checkInFromHomePage(item);
                            //CheckInFragment.getInstance().getFragment_check_in_right_visitor_cell().setVisitorInfo(item);
                            MainActivity.selectPage(Constant.TabType.CHECK_IN);
                            cn.com.basic.face.fragment.CheckInFragment.getInstance().
                                    getFragment_check_in_right_visitor_cell()
                                    .setVisitorInfo(getVo(item));
                        }
                    });
                }
@@ -156,6 +174,10 @@
        }
        private CheckInQueryItem getVo(SurveillanceQueryItem item) {
            return JSON.parseObject(JSON.toJSONString(item), CheckInQueryItem.class);
        }
        public void setRowType(int i) {
        }