xuxiuxi
2017-05-03 b7fd23fb1b9d04eb8fa0d97a5d9747e145605612
VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/adapter/SurveillanceFragment.java
@@ -18,14 +18,15 @@
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.BitmapUtil;
import cn.com.basic.face.util.Constant;
import cn.com.basic.face.util.WindowsUtil;
public class SurveillanceFragment {
    public static class SurveillanceBottomListViewAdapter extends EasyRecyclerViewAdapter {
    public static class SurveillanceBottomVisitorListViewAdapter extends EasyRecyclerViewAdapter {
        private Context context;
        public SurveillanceBottomListViewAdapter(Context context) {
        public SurveillanceBottomVisitorListViewAdapter(Context context) {
            this.context = context;
        }
@@ -66,8 +67,8 @@
            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 = (int)MainActivity.getInstance().getResources().getDimension(R.dimen.h127dp);//WindowsUtil.dip2px(context, 127);
            layoutParams.width = (int)MainActivity.getInstance().getResources().getDimension(R.dimen.h122dp);//WindowsUtil.dip2px(context, 122);
            mLayout.setLayoutParams(layoutParams);
            final Object data = this.getItem(position);
@@ -92,11 +93,11 @@
                    @Override
                    public void onClick(View view) {
                        MainActivity.selectPage(1);
                        RegisterFragment.getInstance().setRegisterInfo(getVo(item));
                        if(item.getBitmap() != null) {
                            RegisterFragment.getInstance().setChoosePhoto(item.getBitmap());
                            RegisterFragment.getInstance().setSurveillanceQueryItem(item);
                        }
                        //RegisterFragment.getInstance().setRegisterInfo(getVo(item));//java.lang.OutOfMemoryError: Failed to allocate a 25338980 byte allocation with 15827186 free bytes and 15MB until OOM
                        //if(item.getBitmap() != null) {
                        //    RegisterFragment.getInstance().setChoosePhoto(item.getBitmap());
                        //    RegisterFragment.getInstance().setSurveillanceQueryItem(item);
                        //}
                    }
                });
            }
@@ -110,7 +111,7 @@
            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.width = WindowsUtil.dip2px(context, 122);
            mLayout.setLayoutParams(layoutParams);
            ImageView fragment_home_bottom_visitor_cell_photo = (ImageView) mLayout.findViewById(R.id.fragment_home_bottom_visitor_cell_photo);
@@ -200,4 +201,56 @@
        }
    }
    public static class SurveillanceBottomAttendanceListViewAdapter extends EasyRecyclerViewAdapter {
        private Context context;
        public SurveillanceBottomAttendanceListViewAdapter(Context context) {
            this.context = context;
        }
        @Override
        public int[] getItemLayouts() {
            return new int[]{R.layout.fragment_surveillance_bottom_attendance_cell, R.layout.fragment_surveillance_bottom_attendance_blank_cell};
        }
        @Override
        public void onBindRecycleViewHolder(EasyRecyclerViewHolder viewHolder, int position) {
            RelativeLayout mLayout = viewHolder.findViewById(R.id.fragment_supervisory_bottom_attendance_cell_relative_layout);
            ViewGroup.LayoutParams layoutParams = mLayout.getLayoutParams();
            layoutParams.height = WindowsUtil.dip2px(context, 127);
            layoutParams.width = WindowsUtil.dip2px(context, 122);
            mLayout.setLayoutParams(layoutParams);
            ImageView fragment_home_bottom_attendance_cell_photo = (ImageView) mLayout.findViewById(R.id.fragment_home_bottom_attendance_cell_photo);
            TextView fragment_home_bottom_attendance_cell_name = (TextView) mLayout.findViewById(R.id.fragment_home_bottom_attendance_cell_name);
            TextView fragment_home_bottom_attendance_cell_status = (TextView) mLayout.findViewById(R.id.fragment_home_bottom_attendance_cell_status);
            Object data = this.getItem(position);
            fragment_home_bottom_attendance_cell_name.setText("");
            if (data instanceof SurveillanceQueryItem) {
                final SurveillanceQueryItem item = (SurveillanceQueryItem)data;
                fragment_home_bottom_attendance_cell_name.setText(item.getUsername());
                if (item.getImagePath() != null && !item.getImagePath().equals("")) {
                    fragment_home_bottom_attendance_cell_photo.setImageURI(Uri.parse(AppApi.IMAGE_URL_BASE +item.getImagePath()));
                } else {
                    if (item.getBitmap() != null) {
                        fragment_home_bottom_attendance_cell_photo.setImageBitmap(item.getBitmap());
                    } else {
                        fragment_home_bottom_attendance_cell_photo.setImageResource(R.drawable.u45);
                    }
                }
                fragment_home_bottom_attendance_cell_status.setText(item.getStatus());
            }
        }
        @Override
        public int getRecycleViewItemType(int position) {
            return 0;
        }
        private CheckInQueryItem getVo(SurveillanceQueryItem item) {
            return JSON.parseObject(JSON.toJSONString(item), CheckInQueryItem.class);
        }
    }
}