From d7c38a8602251b8111089caca96fa976bf4691e0 Mon Sep 17 00:00:00 2001
From: xuxiuxi <xuxiuxi@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期二, 11 七月 2017 11:44:05 +0800
Subject: [PATCH] 

---
 VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/SurveillanceMng.java                  |  272 ++++------------------
 VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/RegisterFragment.java                |    2 
 VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/AppApi.java                              |    2 
 VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/NativeImg.java                           |    1 
 VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/SurveillanceQueryItemUtil.java           |  236 +++++++++++++++++++
 VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/DeviceMng.java                        |    5 
 VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/discern/query/item/SurveillanceQueryItem.java |   10 
 VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/base/MainActivity.java                        |  108 +-------
 VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/dialog/SurveillancePhotoDialog.java           |    3 
 VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/discern/common/CommonVariables.java           |    2 
 VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/RtspFaceNative.java                      |   35 ++
 VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/FileUtil.java                            |    3 
 12 files changed, 355 insertions(+), 324 deletions(-)

diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/base/MainActivity.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/base/MainActivity.java
index 3427a76..2f84b6d 100644
--- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/base/MainActivity.java
+++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/base/MainActivity.java
@@ -7,6 +7,7 @@
 import android.content.pm.ActivityInfo;
 import android.content.res.Configuration;
 import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
 import android.graphics.Canvas;
 import android.graphics.Color;
 import android.graphics.Paint;
@@ -256,7 +257,7 @@
     public Preview mPreview;
     public ProcessImageAndDrawResults mDraw;
     private final String database = "Memory50.dat";
-    private final String help_text = "Luxand Face Recognition\n\nJust tap any detected face and name it. The app will recognize this face further. For best results, hold the device at arm's length. You may slowly rotate the head for the app to memorize you at multiple views. The app can memorize several persons. If a face is not recognized, tap and name it again.\n\nThe SDK is available for mobile developers: www.luxand.com/facesdk";
+    private final String help_text = "help";
 
     public static float sDensity = 1.0f;
 
@@ -266,21 +267,13 @@
         if (CommonVariables.FACE_SERVER) {
             sDensity = getResources().getDisplayMetrics().scaledDensity;
 
-            int res = FSDK.ActivateLibrary("bSB3NdbTnv/0eW/uhypSe6hDMtjZ76Sisw5NwcN+0sfahxOtoUW22el54e/M6cSG5/xsdVIorPgugbTIfoIIn7ltyw1QMSleNebVx/Xe8aRA8bP+aVDybjoWdW/0rDP9Pv7yqBzNXyuwjgsVhPB53VGP8oTirTSUP7PTzSwOEe0=");
+            int res = 0;
             if (res != FSDK.FSDKE_OK) {
                 mIsFailed = true;
-                showErrorAndClose("FaceSDK activation failed", res);
+                showErrorAndClose("failed", res);
             } else {
                 FSDK.Initialize();
-
-                // Hide the window title (it is done in manifest too)
                 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
-//z                requestWindowFeature(Window.FEATURE_NO_TITLE);
-
-                // Lock orientation
-                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
-
-                // Camera layer and drawing layer
                 mDraw = new ProcessImageAndDrawResults(this);
                 mPreview = new Preview(this, mDraw);
                 mDraw.mTracker = new FSDK.HTracker();
@@ -291,22 +284,7 @@
                         showErrorAndClose("Error creating tracker", res);
                     }
                 }
-
                 resetTrackerParameters();
-
-                //this.getWindow().setBackgroundDrawable(new ColorDrawable()); //black background
-
-                //setContentView(mPreview); //creates MainActivity contents
-                //addContentView(mDraw, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
-
-
-                // Menu
-//                LayoutInflater inflater = (LayoutInflater)this.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
-//                View buttons = inflater.inflate(R.layout.bottom_menu, null );
-//                buttons.findViewById(R.id.helpButton).setOnClickListener(this);
-//                buttons.findViewById(R.id.clearButton).setOnClickListener(this);
-//                addContentView(buttons, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
-
             }
         }
     }
@@ -331,7 +309,7 @@
                             @Override public void onClick(DialogInterface dialogInterface, int j) {
                             }
                         })
-                        .setCancelable(false) // cancel with button only
+                        .setCancelable(false)
                         .show();
             }
         }
@@ -377,7 +355,7 @@
                     public void onClick(DialogInterface dialogInterface, int i) {
                     }
                 })
-                .setCancelable(false) // cancel with button only
+                .setCancelable(false)
                 .show();
     }
 
@@ -392,7 +370,6 @@
     private void pauseProcessingFrames() {
         mDraw.mStopping = 1;
 
-        // It is essential to limit wait time, because mStopped will not be set to 0, if no frames are feeded to mDraw
         for (int i=0; i<100; ++i) {
             if (mDraw.mStopped != 0) break;
             try { Thread.sleep(10); }
@@ -412,7 +389,6 @@
     public int x1, y1, x2, y2;
 }
 
-// Draw graphics on top of the video
 class ProcessImageAndDrawResults extends View {
     public FSDK.HTracker mTracker;
 
@@ -485,7 +461,6 @@
         mPaintBlueTransparent.setColor(Color.BLUE);
         mPaintBlueTransparent.setTextSize(25);
 
-        //mBitmap = null;
         mYUVData = null;
         mRGBData = null;
 
@@ -502,16 +477,13 @@
 
         if (mYUVData == null || mTouchedIndex != -1) {
             super.onDraw(canvas);
-            return; //nothing to process or name is being entered now
+            return;
         }
 
         int canvasWidth = canvas.getWidth();
-        //int canvasHeight = canvas.getHeight();
 
-        // Convert from YUV to RGB
         decodeYUV420SP(mRGBData, mYUVData, mImageWidth, mImageHeight);
 
-        // Load image to FaceSDK
         FSDK.HImage Image = new FSDK.HImage();
         FSDK.FSDK_IMAGEMODE imagemode = new FSDK.FSDK_IMAGEMODE();
         imagemode.mode = FSDK.FSDK_IMAGEMODE.FSDK_IMAGE_COLOR_24BIT;
@@ -520,34 +492,19 @@
         FSDK.HImage RotatedImage = new FSDK.HImage();
         FSDK.CreateEmptyImage(RotatedImage);
 
-//        FSDK.SaveImageToFile(Image, MainActivity.getInstance().getFilesDir().getAbsolutePath()+System.currentTimeMillis()+".jpg");
-
-        //it is necessary to work with local variables (onDraw called not the time when mImageWidth,... being reassigned, so swapping mImageWidth and mImageHeight may be not safe)
         int ImageWidth = mImageWidth;
-        //int ImageHeight = mImageHeight;
         if (rotated) {
             ImageWidth = mImageHeight;
-            //ImageHeight = mImageWidth;
             FSDK.RotateImage90(Image, -1, RotatedImage);
         } else {
             FSDK.CopyImage(Image, RotatedImage);
         }
         FSDK.FreeImage(Image);
 
-        // Save first frame to gallery to debug (e.g. rotation angle)
-		/*
-		if (!first_frame_saved) {
-			first_frame_saved = true;
-			String galleryPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath();
-			FSDK.SaveImageToFile(RotatedImage, galleryPath + "/first_frame.jpg"); //frame is rotated!
-		}
-		*/
-
         long IDs[] = new long[MAX_FACES];
         long face_count[] = new long[1];
 
         FSDK.FeedFrame(mTracker, 0, RotatedImage, face_count, IDs);
-//        FSDK.FreeImage(RotatedImage);
 
         faceLock.lock();
 
@@ -602,13 +559,20 @@
                 nativeImg.size = nativeImg.image.length;
                 SurveillanceQueryItem surveillanceQueryItem = new SurveillanceQueryItem();
                 surveillanceQueryItem.setNativeImg(nativeImg);
-                //surveillanceQueryItem.setBitmap(bitmap);
+                nativeImg.st_track_id = 1;
+                surveillanceQueryItem.setStTrackId(nativeImg.st_track_id);
+                BitmapFactory.Options options = new BitmapFactory.Options();
+                options.inMutable = true;
+                Bitmap bmp = BitmapFactory.decodeByteArray(nativeImg.image, 0, nativeImg.image.length, options);
+                Canvas canvas1 = new Canvas(bmp);
+
+                surveillanceQueryItem.setBitmap(bmp);
                 surveillanceQueryItem.setWidth("100");
                 surveillanceQueryItem.setHeight("100");
                 bitmapList.add(surveillanceQueryItem);
 
 
-                SurveillanceMng.getInstance().addBitmap(bitmapList, nativeImg.image, 0, CommonVariables.Camera.IN+"");
+                SurveillanceMng.getInstance().addBitmap(bitmapList, nativeImg.image, 0, CommonVariables.Camera.IN+"", nativeImg.image);
             }
 
         }
@@ -617,7 +581,6 @@
 
         int shift = (int)(22 * MainActivity.sDensity);
 
-        // Mark and name faces
         for (int i=0; i<face_count[0]; ++i) {
             canvas.drawRect(mFacePositions[i].x1, mFacePositions[i].y1, mFacePositions[i].x2, mFacePositions[i].y2, mPaintBlueTransparent);
 
@@ -636,7 +599,7 @@
         }
 
         super.onDraw(canvas);
-    } // end onDraw method
+    }
 
 
     @Override
@@ -665,7 +628,6 @@
 
                         mTouchedIndex = i;
 
-                        // requesting name on tapping the face
                         final EditText input = new EditText(mContext);
                         AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
                         builder.setMessage("Enter person's name" )
@@ -683,7 +645,7 @@
                                         mTouchedIndex = -1;
                                     }
                                 })
-                                .setCancelable(false) // cancel with button only
+                                .setCancelable(false)
                                 .show();
 
                         break;
@@ -720,12 +682,8 @@
             }
         }
     }
-} // end of ProcessImageAndDrawResults class
+}
 
-
-
-
-// Show video from camera and pass frames to ProcessImageAndDraw class
 class Preview extends SurfaceView implements SurfaceHolder.Callback {
     Context mContext;
     SurfaceHolder mHolder;
@@ -738,23 +696,19 @@
         mContext = context;
         mDraw = draw;
 
-        //Install a SurfaceHolder.Callback so we get notified when the underlying surface is created and destroyed.
         mHolder = getHolder();
         mHolder.addCallback(this);
         mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
     }
 
-    //SurfaceView callback
     public void surfaceCreated(SurfaceHolder holder) {
         mFinished = false;
 
-        // Find the ID of the camera
         int cameraId = 0;
         boolean frontCameraFound = false;
         Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
         for (int i = 0; i < Camera.getNumberOfCameras(); i++) {
             Camera.getCameraInfo(i, cameraInfo);
-            //if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK)
             if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
                 cameraId = i;
                 frontCameraFound = true;
@@ -770,14 +724,12 @@
         try {
             mCamera.setPreviewDisplay(holder);
 
-            // Preview callback used whenever new viewfinder frame is available
             mCamera.setPreviewCallback(new Camera.PreviewCallback() {
                 public void onPreviewFrame(byte[] data, Camera camera) {
                     if ( (mDraw == null) || mFinished )
                         return;
 
                     if (mDraw.mYUVData == null) {
-                        // Initialize the draw-on-top companion
                         Camera.Parameters params = camera.getParameters();
                         mDraw.mImageWidth = params.getPreviewSize().width;
                         mDraw.mImageHeight = params.getPreviewSize().height;
@@ -785,7 +737,6 @@
                         mDraw.mYUVData = new byte[data.length];
                     }
 
-                    // Pass YUV data to draw-on-top companion
                     System.arraycopy(data, 0, mDraw.mYUVData, 0, data.length);
                     mDraw.invalidate();
                 }
@@ -808,11 +759,7 @@
         }
     }
 
-    //SurfaceView callback
     public void surfaceDestroyed(SurfaceHolder holder) {
-        // Surface will be destroyed when we return, so stop the preview.
-        // Because the CameraDevice object is not a shared resource, it's very
-        // important to release it when the activity is paused.
         mFinished = true;
         if (mCamera != null) {
             mCamera.setPreviewCallback(null);
@@ -822,28 +769,19 @@
         }
     }
 
-    //SurfaceView callback, configuring camera
     public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
         if (mCamera == null) return;
 
-        // Now that the size is known, set up the camera parameters and begin
-        // the preview.
         Camera.Parameters parameters = mCamera.getParameters();
 
-        //Keep uncommented to work correctly on phones:
-        //This is an undocumented although widely known feature
-		/**/
         if (this.getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) {
             parameters.set("orientation", "portrait");
-            mCamera.setDisplayOrientation(90); // For Android 2.2 and above
+            mCamera.setDisplayOrientation(90);
             mDraw.rotated = true;
         } else {
             parameters.set("orientation", "landscape");
-            mCamera.setDisplayOrientation(0); // For Android 2.2 and above
+            mCamera.setDisplayOrientation(0);
         }
-		/**/
-
-        // choose preview size closer to 640x480 for optimal performance
         List<Camera.Size> supportedSizes = parameters.getSupportedPreviewSizes();
         int width = 0;
         int height = 0;
@@ -855,12 +793,10 @@
             }
         }
 
-        //try to set preferred parameters
         try {
             if (width*height > 0) {
                 parameters.setPreviewSize(width, height);
             }
-            //parameters.setPreviewFrameRate(10);
             parameters.setSceneMode(Camera.Parameters.SCENE_MODE_PORTRAIT);
             parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
             mCamera.setParameters(parameters);
@@ -884,5 +820,5 @@
             this.invalidate();
         }
     }
-} // end of Preview class
+}
 
diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/dialog/SurveillancePhotoDialog.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/dialog/SurveillancePhotoDialog.java
index 3566ff2..f3a92ae 100644
--- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/dialog/SurveillancePhotoDialog.java
+++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/dialog/SurveillancePhotoDialog.java
@@ -31,6 +31,7 @@
 import cn.com.basic.face.service.SurveillanceMng;
 import cn.com.basic.face.util.Constant;
 import cn.com.basic.face.util.OkClickedListener;
+import cn.com.basic.face.util.SurveillanceQueryItemUtil;
 import cn.com.basic.face.widget.surveilance.SurveillancePhotoSelectListView;
 
 public class SurveillancePhotoDialog extends PopupWindow {
@@ -63,7 +64,7 @@
         View view = LayoutInflater.from(MainActivity.getInstance()).inflate(R.layout.dialog_surveillance_photo_select,null);
         ViewUtils.inject(this, view);
 
-        dialog_surveillance_photo_select_list_view.show(SurveillanceMng.getInstance().getSurveillancePhotoList(selectedId));
+        dialog_surveillance_photo_select_list_view.show(SurveillanceQueryItemUtil.getInstance().getAllUnregisterTwoRowsForSelect(selectedId));
 
         setTitleAndList(type);
         WheelView.WheelViewStyle style = new WheelView.WheelViewStyle();
diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/discern/common/CommonVariables.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/discern/common/CommonVariables.java
index fd210b1..a80bfab 100644
--- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/discern/common/CommonVariables.java
+++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/discern/common/CommonVariables.java
@@ -107,6 +107,6 @@
         public static final String CAMERA2 = "camera2";
     }
 
-    public static boolean FACE_SERVER = false;
+    public static boolean FACE_SERVER = true;
 
 }
diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/discern/query/item/SurveillanceQueryItem.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/discern/query/item/SurveillanceQueryItem.java
index 4b9ac90..a893576 100644
--- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/discern/query/item/SurveillanceQueryItem.java
+++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/discern/query/item/SurveillanceQueryItem.java
@@ -55,6 +55,8 @@
 
 	private String surveillancePhoto;
 
+	private int stTrackId;
+
     public SurveillanceQueryItem() {
         if (initialSelectId > 10000) {
             initialSelectId = 1;
@@ -270,4 +272,12 @@
 	public void setSurveillancePhoto(String surveillancePhoto) {
 		this.surveillancePhoto = surveillancePhoto;
 	}
+
+	public int getStTrackId() {
+		return stTrackId;
+	}
+
+	public void setStTrackId(int stTrackId) {
+		this.stTrackId = stTrackId;
+	}
 }
diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/RegisterFragment.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/RegisterFragment.java
index be628d5..e5466e4 100644
--- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/RegisterFragment.java
+++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/RegisterFragment.java
@@ -301,7 +301,7 @@
                 bitmapList.add(item);
                 bitmapList.add(item);
 
-                SurveillanceMng.getInstance().addBitmap(bitmapList, null, 0, CommonVariables.Camera.IN);
+                //SurveillanceMng.getInstance().addBitmap(bitmapList, null, 0, CommonVariables.Camera.IN);
 
             } catch (Exception e) {
                 e.printStackTrace();
diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/DeviceMng.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/DeviceMng.java
index ebb95a2..8141823 100644
--- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/DeviceMng.java
+++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/DeviceMng.java
@@ -191,8 +191,7 @@
 
 //        return "rtsp://"+username+":"+password+"@"+ip+":"+port+"/h264/ch1/sub/av_stream";
 //        return "rtsp://Admin:1234@192.168.1.22/h264";
-        return "rtsp://admin:a1234567@192.168.1.68:554/h264/ch1/main/av_stream";
-
+        return "rtsp://admin:a1234567@192.168.1.68:554/h264/ch1/sub/av_stream";
     }
 
     public String getCamera2Address() {
@@ -218,7 +217,7 @@
 
         //return "rtsp://"+username+":"+password+"@"+ip+":"+port+"/h264/ch1/sub/av_stream";
 //        return "rtsp://admin:a1234567@192.168.1.68:554/h264/ch1/main/av_stream";
-        return "rtsp://admin:a1234567@192.168.1.69:554/h264/ch1/main/av_stream";
+        return "rtsp://admin:a1234567@192.168.1.69:554/h264/ch1/sub/av_stream";
     }
 
 }
diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/SurveillanceMng.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/SurveillanceMng.java
index d4af223..6b36aad 100644
--- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/SurveillanceMng.java
+++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/SurveillanceMng.java
@@ -2,6 +2,7 @@
 
 import android.os.AsyncTask;
 import android.util.Base64;
+import android.widget.Toast;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
@@ -9,6 +10,8 @@
 import org.xutils.http.RequestParams;
 import org.xutils.x;
 
+import java.io.File;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Date;
@@ -21,11 +24,15 @@
 import cn.com.basic.face.discern.common.BaseCommonCallBack;
 import cn.com.basic.face.discern.common.CommonVariables;
 import cn.com.basic.face.discern.common.ResultBean;
+import cn.com.basic.face.discern.entity.Device;
 import cn.com.basic.face.discern.query.item.SurveillanceQueryItem;
+import cn.com.basic.face.fragment.RegisterFragment;
 import cn.com.basic.face.fragment.SurveillanceFragment;
 import cn.com.basic.face.util.AppApi;
 import cn.com.basic.face.util.Constant;
+import cn.com.basic.face.util.FileUtil;
 import cn.com.basic.face.util.PostData;
+import cn.com.basic.face.util.SurveillanceQueryItemUtil;
 import cn.com.basic.face.util.Uploader;
 
 public class SurveillanceMng {
@@ -44,9 +51,7 @@
                     MainActivity.getInstance().runOnUiThread(new Runnable() {
                         @Override
                         public void run() {
-                            List prevList = SurveillanceMng.getInstance().removeTimeoutItem(null);
-                            SurveillanceMng.getInstance().registerTopAndCheckInBottom(prevList);
-                            SurveillanceFragment.getInstance().get_fragment_supervisory_bottom_visitor_list_view().show(prevList);
+                            SurveillanceQueryItemUtil.getInstance().removeTimeoutItemAndShow();
                         }
                     });
                     Thread.sleep(1000*60*5);
@@ -57,236 +62,55 @@
         }
     }
 
-    private List<SurveillanceQueryItem> removeTimeoutItem(List<SurveillanceQueryItem> prevList) {
-        if (prevList == null) {
-            prevList = SurveillanceFragment.getInstance().get_fragment_supervisory_bottom_visitor_list_view().getPrevList();
-        }
-        List<SurveillanceQueryItem> newPrevList = new ArrayList();
-        for (SurveillanceQueryItem item : prevList) {
-            if (item.getRegisterOrCheckIn() == CommonVariables.Surveillance.VISIT_REGISTER_ITEM_TYPE) {
-                Date now = new Date();
-                Date createTime = item.getCreateTime();
-                double minutes = (now.getTime() - createTime.getTime())*1.0 / 1000 / 60;
-                if (minutes >= 5) {
-                    continue;
-                }
-                newPrevList.add(item);
-            }
-        }
-        return newPrevList;
-    }
+    int fileIndex = 1;
 
-    public void addBitmap(final List<SurveillanceQueryItem> bitmapList, final byte[] byteArray, int len, final String cameraInOrOut) {
+    public void addBitmap(final List<SurveillanceQueryItem> bitmapList, final byte[] byteArray, int len, final String cameraInOrOut, byte[] surveillancePhotoBytes) {
         if (!BaseApplication.deviceAvailable) {
             return;
         }
-        class ConnectionTask extends AsyncTask<String, Void, String> {
-            private String json = "";
-            @Override
-            protected String doInBackground(String... urls) {
-                try {
-                    PostData pd = new PostData();
-                    pd.addValue("deviceCompanyId", BaseApplication.getInstance().getAndroidDevice().getCompanyId());
-                    pd.addValue("InOrOutCamera", cameraInOrOut + "");
-                    pd.addValue("deviceId", BaseApplication.getInstance().getAndroidDevice().getDeviceId());
-                    pd.addData("surveillancePhoto", "application/octet-stream", byteArray);
-                    Uploader uploader = new Uploader("", AppApi.BASE_URL + AppApi.SURVEILLANCE_UPLOAD);
-                    json = uploader.upload("face/Surveillance/o_upload.do", pd);
-                    return json;
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
-                return null;
+        try {
+            if (fileIndex > 30) {
+                fileIndex = 1;
+            }
+            fileIndex++;
+            RequestParams params = new RequestParams();
+            File rawSurveillancePhotoFile = FileUtil.writeToFile("rawSurveillancePhotoFile_"+fileIndex, byteArray);
+            File surveillancePhotoFile = FileUtil.writeToFile("surveillancePhotoFile_"+fileIndex, surveillancePhotoBytes);
+
+            params.addBodyParameter("deviceCompanyId", BaseApplication.getInstance().getAndroidDevice().getCompanyId());
+            params.addBodyParameter("InOrOutCamera", cameraInOrOut + "");
+            params.addBodyParameter("deviceId", BaseApplication.getInstance().getAndroidDevice().getDeviceId());
+            params.addBodyParameter("rawSurveillancePhoto", rawSurveillancePhotoFile);
+            params.addBodyParameter("surveillancePhoto", surveillancePhotoFile);
+
+            File path = BaseApplication.getInstance().getFilesDir();
+            if (!rawSurveillancePhotoFile.exists()) {
+                rawSurveillancePhotoFile.createNewFile();
+            }
+            File f0 = new File(path, "f0");
+            if (!f0.exists()) {
+                f0.createNewFile();
             }
 
-            @Override
-            protected void onPostExecute(String result) {
-                try {
-
-                    System.out.println("json="+result);
-                    ResultBean resultBean = JSON.parseObject(result, ResultBean.class);
-                    if (resultBean == null) {
-                        System.out.println("resultBean="+resultBean);
-                        return;
+            FileWriter fw0 = new FileWriter(f0);
+            fw0.write("test1");
+            fw0.close();
+            params.setUri(AppApi.BASE_URL + AppApi.SURVEILLANCE_UPLOAD);
+            params.addBodyParameter("f0", f0);
+            params.addBodyParameter("rawSurveillancePhoto", rawSurveillancePhotoFile);
+            x.http().post(params, new BaseCommonCallBack() {
+                @Override
+                public void success() {
+                    try {
+                        SurveillanceQueryItemUtil.getInstance().addItems(resultBean.getListBeanOfType(SurveillanceQueryItem.class), bitmapList);
+                    } catch(Exception e) {
+                        e.printStackTrace();
                     }
-                    Object data = resultBean.getData();
-                    if (data instanceof JSONArray) {
-                        JSONArray jsonArray = (JSONArray) data;
-                        List<SurveillanceQueryItem> items =  JSON.parseArray(jsonArray.toJSONString(), SurveillanceQueryItem.class);
-
-                        List prevVisitorList = SurveillanceFragment.getInstance().get_fragment_supervisory_bottom_visitor_list_view().getPrevList();
-                        List prevAttendanceList = SurveillanceFragment.getInstance().get_fragment_supervisory_bottom_attendance_list_view().getPrevList();
-
-                        List newVisitorList = new ArrayList();
-
-                        List newAttendanceList = new ArrayList();
-
-                        for (int i = 0; items != null && i < items.size(); i++) {
-                            SurveillanceQueryItem item = items.get(i);
-                            int type = item.getRegisterOrCheckIn();
-                            if (type == CommonVariables.Surveillance.VISIT_REGISTER_ITEM_TYPE
-                                    || type == CommonVariables.Surveillance.VISIT_CHECK_IN_ITEM_TYPE
-                                    ) {
-                                item.setCreateTime(new Date());
-                                newVisitorList.add(0, item);
-                                if (i < bitmapList.size()) {
-                                    SurveillanceQueryItem surveillanceQueryItem = bitmapList.get(i);
-                                    item.setBitmap(surveillanceQueryItem.getBitmap());
-                                    item.setBase64Image(surveillanceQueryItem.getBase64Image());
-                                    item.setNativeImg(surveillanceQueryItem.getNativeImg());
-                                    item.setWidth(surveillanceQueryItem.getWidth());
-                                    item.setHeight(surveillanceQueryItem.getHeight());
-                                }
-                            }
-                            if (type ==  CommonVariables.Surveillance.VISIT_ATTENDANCE_ITEM_TYPE) {
-                                newAttendanceList.add(item);
-                                if (i < bitmapList.size()) {
-                                    SurveillanceQueryItem surveillanceQueryItem = bitmapList.get(i);
-                                    item.setBitmap(surveillanceQueryItem.getBitmap());
-                                    item.setBase64Image(surveillanceQueryItem.getBase64Image());
-                                    item.setNativeImg(surveillanceQueryItem.getNativeImg());
-                                    item.setWidth(surveillanceQueryItem.getWidth());
-                                    item.setHeight(surveillanceQueryItem.getHeight());
-                                }
-                            }
-                            System.out.println("inOutCamera="+item.getInOrOutCamera());
-                        }
-
-                        if (newVisitorList.size() > 0) {
-                            prevVisitorList.addAll(0, newVisitorList);
-                            registerTopAndCheckInBottom(prevVisitorList);
-                            SurveillanceFragment.getInstance().get_fragment_supervisory_bottom_visitor_list_view().show(prevVisitorList);
-                        }
-
-                        if (newAttendanceList.size() > 0) {
-                            prevAttendanceList.addAll(0, newAttendanceList);
-                            if (prevAttendanceList.size() > 20) {
-                                prevAttendanceList = prevAttendanceList.subList(0, 20);
-                            }
-                            SurveillanceFragment.getInstance().get_fragment_supervisory_bottom_attendance_list_view().show(prevAttendanceList);
-                        }
-                    }
-                } catch(Exception e) {
-                    e.printStackTrace();
                 }
-            }
-
+            });
+        }catch(Exception e) {
+            e.printStackTrace();
         }
-        ConnectionTask task = new ConnectionTask();
-        String[] params = new String[2];
-        task.execute(params);
-    }
-
-    public List getSurveillancePhotoList(long selectedId) {
-        List<SurveillanceQueryItem> prevVisitorList = SurveillanceFragment.getInstance().get_fragment_supervisory_bottom_visitor_list_view().getPrevList();
-        List<SurveillanceQueryItem> registerList = new ArrayList();
-        int countPerRow = 9;
-        for (SurveillanceQueryItem surveillanceQueryItem : prevVisitorList) {
-            if (surveillanceQueryItem.getRegisterOrCheckIn() == CommonVariables.Surveillance.VISIT_REGISTER_ITEM_TYPE) {
-                if (registerList.size() > countPerRow*2) {
-                    break;
-                }
-                if (surveillanceQueryItem.getIdForSelect() == selectedId) {
-                    surveillanceQueryItem.setSurveillancePhotoSelected(true);
-                } else {
-                    surveillanceQueryItem.setSurveillancePhotoSelected(false);
-                }
-                registerList.add(surveillanceQueryItem);
-            }
-        }
-        SurveillanceQueryItem item;
-        List items = new ArrayList();
-        int m = 0, n = 0;
-        for (int i = 0; i < countPerRow*2; i++) {
-            if (i % 2 == 0) {
-                if (m < registerList.size()) {
-                    item = registerList.get(m);
-                    m++;
-                } else {
-                    item = getBlankItem();
-                }
-            } else {
-                if (n < registerList.size() - countPerRow) {
-                    item = registerList.get(countPerRow+n);
-                    n++;
-                } else {
-                    item = getBlankItem();
-                }
-            }
-            items.add(item);
-        }
-        return items;
-    }
-
-    private void registerTopAndCheckInBottom(List<SurveillanceQueryItem> list) {
-        List<SurveillanceQueryItem> registerList = new ArrayList<SurveillanceQueryItem>();
-        List<SurveillanceQueryItem> checkInList = new ArrayList<SurveillanceQueryItem>();
-        removeDuplicateCheckIn(list);
-        int i1 = 0, j = 0;
-        int maxRegister = 50;
-        int maxCheckIn = 50;
-        for (SurveillanceQueryItem item : list) {
-            if (item.getRegisterOrCheckIn() == Constant.Surveillance.VISIT_REGISTER_ITEM_TYPE) {
-                if (i1 < maxRegister) {
-                    registerList.add(item);
-                    i1++;
-                }
-            }
-            if (item.getRegisterOrCheckIn() == Constant.Surveillance.VISIT_CHECK_IN_ITEM_TYPE) {
-                if (j < maxCheckIn) {
-                    checkInList.add(item);
-                    j++;
-                }
-            }
-        }
-
-        int max = registerList.size() > checkInList.size() ? registerList.size() : checkInList.size();
-
-        List tempList = new ArrayList();
-
-        int m = 0, n = 0;
-        for (int i = 0; i < max * 2; i++) {
-            SurveillanceQueryItem item;
-            if (i % 2 == 0) {
-                if (m < registerList.size()) {
-                    item = registerList.get(m);
-                } else {
-                    item = getBlankItem();
-                }
-                m++;
-            } else {
-                if (n < checkInList.size()) {
-                    item = checkInList.get(n);
-                } else {
-                    item = getBlankItem();
-                }
-                n++;
-            }
-            tempList.add(item);
-        }
-        list.clear();
-        list.addAll(tempList);
-    }
-
-    private void removeDuplicateCheckIn(List<SurveillanceQueryItem> list) {
-        List itemsToRemove = new ArrayList();
-        Set<String> registerIds = new HashSet<>();
-        for (SurveillanceQueryItem item : list) {
-            if (item.getRegisterOrCheckIn() == Constant.Surveillance.VISIT_CHECK_IN_ITEM_TYPE) {
-                if (registerIds.contains(item.getRegisterId()+"_"+item.getInOrOutCamera())) {
-                    itemsToRemove.add(item);
-                } else {
-                    registerIds.add(item.getRegisterId()+"_"+item.getInOrOutCamera());
-                }
-            }
-        }
-        list.removeAll(itemsToRemove);
-    }
-
-    private SurveillanceQueryItem getBlankItem() {
-        SurveillanceQueryItem blankItem = new SurveillanceQueryItem();
-        blankItem.setRegisterOrCheckIn(Constant.Surveillance.VISIT_BLANK_ITEM_TYPE);
-        return blankItem;
     }
 
 }
diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/AppApi.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/AppApi.java
index c808aa3..7aa8d4b 100644
--- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/AppApi.java
+++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/AppApi.java
@@ -7,7 +7,7 @@
 	public final static String IMAGE_URL_BASE = "http://192.168.1.49:8888/";
 	//public final static String BASE_URL = "http://192.168.1.51/face/";
 //	public final static String BASE_URL = "http://192.168.1.4:8333/face/";
-	public final static String BASE_URL = "http://192.168.1.14:8080/face/";
+	public final static String BASE_URL = "http://192.168.1.77:8080/face/";
 
 	//娉ㄥ唽娣诲姞
 	public static final String REGISTER_ADD = "Register/o_add.do";
diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/FileUtil.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/FileUtil.java
index 73f5fca..9977e56 100644
--- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/FileUtil.java
+++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/FileUtil.java
@@ -13,6 +13,9 @@
 
     public static File writeToFile(String fileName, byte[] fileBytes) {
         try {
+            if (fileBytes == null) {
+                fileBytes = new byte[]{};
+            }
             String dir = MainActivity.getInstance().getFilesDir().getAbsolutePath();
 
             File file = new File(dir, fileName);
diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/NativeImg.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/NativeImg.java
index 1bf70be..fdd73b7 100644
--- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/NativeImg.java
+++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/NativeImg.java
@@ -6,6 +6,7 @@
 
 public class NativeImg  {
 
+    public int st_track_id;
     public int size;
     public int type;
     public int width;
diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/RtspFaceNative.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/RtspFaceNative.java
index 6326e94..fa3c18a 100644
--- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/RtspFaceNative.java
+++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/RtspFaceNative.java
@@ -1,22 +1,29 @@
 package cn.com.basic.face.util;
 
-import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
 import android.util.Log;
 import android.view.Surface;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
+import android.view.SurfaceHolder;
+import android.widget.ImageButton;
+import android.graphics.Bitmap;
+import android.widget.ImageView;
 import java.util.List;
 
 import cn.com.basic.face.base.BaseApplication;
 import cn.com.basic.face.discern.query.item.SurveillanceQueryItem;
 import cn.com.basic.face.service.SurveillanceMng;
 
+import java.nio.ByteBuffer;
+
+import java.util.ArrayList;
+
 /**
  * Created by houxiao on 2017/3/21 0021.
  */
 
 class NativeImgIdx {
+    public int st_track_id;
     public int offset;
     public int size;
     public int type;
@@ -37,7 +44,7 @@
 
     public static native void init();
     public static native void setLocalIP(String ipaddr);
-    public static native void setSurface(int cameraIdx, Surface surface);
+    public static native void setSurface(int cameraIdx, Surface surfaceRender);
     public static native boolean createPlayer(int cameraIdx, String uri);
     public static native void shutdown(int cameraIdx);
     // typedef void (* Java_com_example_nativecodec_NativeCodec_FaceCallback_func)(int cameraIdx, int count);
@@ -52,11 +59,21 @@
     public static native String dbgGetLog();
     public static native void dbgSetStfaceLicense(String lic);
 
+    //public static native void dbgReadTexture();
+
+    public static native void setCaptureSurface(Surface surfaceCapture);
+    public static native void startCapturePlayer(String uri);
+    public static native void stopCapturePlayer();
+    public static native ArrayList<NativeImg> getCaptureImages();
+    public static native void teleCall(String phoneNumber);
+    public static native void teleHang();
+
+    public static native void setFaceLabel(int cameraIdx, int stTrackId, String label);
+
     public static int COMPANY_ID = 1001;
 
     public static void faceCallBack(int cameraIdx, int count)
     {
-        System.out.println("cameraIdex="+cameraIdx+", count="+count);
         Log.i("@@@", "RtspFaceNative.faceCallBack, cameraIdx=" + cameraIdx + ", count=" + count);
 
         // something else
@@ -67,11 +84,13 @@
 
         RefByteArray faceListPb = new RefByteArray();
 
+
         try {
             COMPANY_ID = Integer.parseInt(BaseApplication.getInstance().getAndroidDevice().getCompanyId());
         } catch (Exception e) {
             COMPANY_ID = 0;
         }
+
 
         int s = getFaceList(cameraIdx, COMPANY_ID, faceListPb);
         Log.i("@@@", "RtspFaceNative.faceCallBack, getFaceList, cameraIdx=" + cameraIdx + ", size=" + s);
@@ -93,6 +112,7 @@
         {
             Log.i("@@@", "cameraIdx=" + cameraIdx +
                     ", i=" + i +
+                    ", st_track_id=" + faceImages.get(i).st_track_id+
                     ", size=" + faceImages.get(i).size+
                     ", w=" + faceImages.get(i).width +
                     ", h=" + faceImages.get(i).height +
@@ -116,6 +136,7 @@
             for (int i = 0; i < faceImages.size(); i++) {
                 NativeImg item = faceImages.get(i);
                 SurveillanceQueryItem surveillanceQueryItem = new SurveillanceQueryItem();
+                surveillanceQueryItem.setStTrackId(item.st_track_id);
                 int offset = 0;
                 int size = item.size;
                 Bitmap bitmap = Bitmap.createBitmap(item.width,item.height, Bitmap.Config.RGB_565);
@@ -132,7 +153,7 @@
                 surveillanceQueryItem.setHeight(item.height+"");
                 bitmapList.add(surveillanceQueryItem);
             }
-            SurveillanceMng.getInstance().addBitmap(bitmapList, faceListPb.arr, s, cameraIdx+"");
+            SurveillanceMng.getInstance().addBitmap(bitmapList, faceListPb.arr, s, cameraIdx+"", new byte[]{});
 
         }catch(Exception e){
             e.printStackTrace();
diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/SurveillanceQueryItemUtil.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/SurveillanceQueryItemUtil.java
new file mode 100644
index 0000000..c52e764
--- /dev/null
+++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/util/SurveillanceQueryItemUtil.java
@@ -0,0 +1,236 @@
+package cn.com.basic.face.util;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import cn.com.basic.face.discern.common.CommonVariables;
+import cn.com.basic.face.discern.query.item.SurveillanceQueryItem;
+import cn.com.basic.face.fragment.SurveillanceFragment;
+
+public class SurveillanceQueryItemUtil {
+
+    private static SurveillanceQueryItemUtil instance = new SurveillanceQueryItemUtil();
+
+    public static SurveillanceQueryItemUtil getInstance() {
+        return instance;
+    }
+
+    //鎵�鏈夌洃鎺у浘鐗�
+    private static List<SurveillanceQueryItem> allItems = new ArrayList<>();
+    //璁垮閫夐」鍗$殑鍒嗙被锛堟湭娉ㄥ唽/浜哄憳绫诲瀷銆佹潵璁跨姸鎬併�佹爣绛剧姸鎬侊級
+    //鑰冨嫟閫夐」鍗★紙鑰冨嫟浜哄憳绫诲瀷锛氭暀甯堛�佸鐢熴�佸憳宸ワ紝鏉ヨ鐘舵�侊細绛惧埌銆佺閫�锛�
+    //绗竴琛屾樉绀烘湭娉ㄥ唽锛岀浜岃鏄剧ず鏉ヨ
+    private static List<SurveillanceQueryItem> visitorTwoRows = new ArrayList<>();
+    //绗竴琛屾樉绀虹鍒帮紝绗簩琛屾樉绀虹閫�
+    private static List<SurveillanceQueryItem> attendanceTwoRows = new ArrayList<>();
+    //鏈敞鍐岀殑鍒楄〃, 閫夋嫨鏃剁敤
+    private static List<SurveillanceQueryItem> allUnregisterTwoRowsForSelect = new ArrayList();
+
+    public void addItems(List<SurveillanceQueryItem> returnItems, List<SurveillanceQueryItem> requestItems) {
+        for ( int i = 0; i < returnItems.size(); i++) {
+            SurveillanceQueryItem returnItem = returnItems.get(i);
+            SurveillanceQueryItem requestItem = requestItems.get(i);
+            addItem(returnItem, requestItem);
+        }
+        removeTimeoutItemAndShow();
+    }
+
+    public void addItem(SurveillanceQueryItem returnItem, SurveillanceQueryItem requestItem) {
+        returnItem.setCreateTime(new Date());
+        returnItem.setStTrackId(requestItem.getStTrackId());
+        returnItem.setBitmap(requestItem.getBitmap());
+        returnItem.setNativeImg(requestItem.getNativeImg());
+        returnItem.setWidth(requestItem.getWidth());
+        returnItem.setHeight(requestItem.getHeight());
+        allItems.add(0, returnItem);
+    }
+
+    public List getVisitorTwoRows() {
+        visitorTwoRows.clear();
+        for (SurveillanceQueryItem item : allItems) {
+            int type = item.getRegisterOrCheckIn();
+            if (type == CommonVariables.Surveillance.VISIT_REGISTER_ITEM_TYPE
+                    || type == CommonVariables.Surveillance.VISIT_CHECK_IN_ITEM_TYPE
+                    ) {
+                visitorTwoRows.add(item);
+            }
+        }
+        VisitorUtil.removeDuplicateCheckIn();
+        VisitorUtil.removeDuplicateUnregister();
+        VisitorUtil.sortByRow();
+        return visitorTwoRows;
+    }
+
+    public List getAttendanceTwoRows() {
+        attendanceTwoRows.clear();
+        for (SurveillanceQueryItem item : allItems) {
+            if (item.getRegisterOrCheckIn() ==  CommonVariables.Surveillance.VISIT_ATTENDANCE_ITEM_TYPE) {
+                attendanceTwoRows.add(item);
+            }
+        }
+        return attendanceTwoRows;
+    }
+
+    public List getAllUnregisterTwoRowsForSelect(long selectedId) {
+        allUnregisterTwoRowsForSelect.clear();
+        List<SurveillanceQueryItem> registerList = new ArrayList();
+        int countPerRow = 9;
+        for (SurveillanceQueryItem surveillanceQueryItem : allItems) {
+            if (surveillanceQueryItem.getRegisterOrCheckIn() == CommonVariables.Surveillance.VISIT_REGISTER_ITEM_TYPE) {
+                if (registerList.size() > countPerRow*2) {
+                    break;
+                }
+                if (surveillanceQueryItem.getIdForSelect() == selectedId) {
+                    surveillanceQueryItem.setSurveillancePhotoSelected(true);
+                } else {
+                    surveillanceQueryItem.setSurveillancePhotoSelected(false);
+                }
+                registerList.add(surveillanceQueryItem);
+            }
+        }
+
+        SurveillanceQueryItem item;
+        List items = new ArrayList();
+        int m = 0, n = 0;
+        for (int i = 0; i < countPerRow*2; i++) {
+            if (i % 2 == 0) {
+                if (m < registerList.size()) {
+                    item = registerList.get(m);
+                    m++;
+                } else {
+                    item = VisitorUtil.getBlankItem();
+                }
+            } else {
+                if (n < registerList.size() - countPerRow) {
+                    item = registerList.get(countPerRow+n);
+                    n++;
+                } else {
+                    item = VisitorUtil.getBlankItem();
+                }
+            }
+            items.add(item);
+        }
+        allUnregisterTwoRowsForSelect.addAll(items);
+        return allUnregisterTwoRowsForSelect;
+    }
+
+    public void removeTimeoutItemAndShow() {
+        List itemsToRemove = new ArrayList();
+        for (SurveillanceQueryItem item : allItems) {
+            if (item.getRegisterOrCheckIn() == CommonVariables.Surveillance.VISIT_REGISTER_ITEM_TYPE) {
+                Date now = new Date();
+                Date createTime = item.getCreateTime();
+                double minutes = (now.getTime() - createTime.getTime())*1.0 / 1000 / 60;
+                if (minutes >= 5) {
+                    itemsToRemove.add(item);
+                }
+            }
+        }
+        allItems.removeAll(itemsToRemove);
+        SurveillanceFragment.getInstance().get_fragment_supervisory_bottom_visitor_list_view().show(SurveillanceQueryItemUtil.getInstance().getVisitorTwoRows());
+        SurveillanceFragment.getInstance().get_fragment_supervisory_bottom_attendance_list_view().show(SurveillanceQueryItemUtil.getInstance().getAttendanceTwoRows());
+    }
+
+    static class VisitorUtil {
+
+        public static void removeDuplicateCheckIn() {
+            List itemsToRemove = new ArrayList();
+            Set<String> registerIds = new HashSet<>();
+            for (SurveillanceQueryItem item : visitorTwoRows) {
+                if (item.getRegisterOrCheckIn() == Constant.Surveillance.VISIT_CHECK_IN_ITEM_TYPE) {
+                    if (registerIds.contains(item.getRegisterId()+"_"+item.getInOrOutCamera())) {
+                        itemsToRemove.add(item);
+                    } else {
+                        registerIds.add(item.getRegisterId()+"_"+item.getInOrOutCamera());
+                    }
+                }
+            }
+            visitorTwoRows.removeAll(itemsToRemove);
+        }
+
+        public static void removeDuplicateUnregister() {
+            List<SurveillanceQueryItem> registerList = new ArrayList<SurveillanceQueryItem>();
+            List itemsToRemove = new ArrayList();
+            for (SurveillanceQueryItem item : visitorTwoRows) {
+                if (item.getRegisterOrCheckIn() == Constant.Surveillance.VISIT_REGISTER_ITEM_TYPE) {
+                    int trackId = item.getStTrackId();
+                    boolean trackIdExist = false;
+                    for (SurveillanceQueryItem registerItem : registerList) {
+                        if (registerItem.getStTrackId() == trackId) {
+                            itemsToRemove.add(item);
+                        }
+                    }
+                    if (!trackIdExist) {
+                        registerList.add(item);
+                    }
+                }
+            }
+            visitorTwoRows.removeAll(itemsToRemove);
+        }
+
+        public static void sortByRow() {
+            List<SurveillanceQueryItem> registerList = new ArrayList<SurveillanceQueryItem>();
+            List<SurveillanceQueryItem> checkInList = new ArrayList<SurveillanceQueryItem>();
+            int i1 = 0, j = 0;
+            int maxRegister = 50;
+            int maxCheckIn = 50;
+            for (SurveillanceQueryItem item : visitorTwoRows) {
+                if (item.getRegisterOrCheckIn() == Constant.Surveillance.VISIT_REGISTER_ITEM_TYPE) {
+                    if (i1 < maxRegister) {
+                        registerList.add(item);
+                        i1++;
+                    }
+                }
+                if (item.getRegisterOrCheckIn() == Constant.Surveillance.VISIT_CHECK_IN_ITEM_TYPE) {
+                    if (j < maxCheckIn) {
+                        checkInList.add(item);
+                        j++;
+                    }
+                }
+            }
+
+            int max = registerList.size() > checkInList.size() ? registerList.size() : checkInList.size();
+
+            List tempList = new ArrayList();
+
+            int m = 0, n = 0;
+            for (int i = 0; i < max * 2; i++) {
+                SurveillanceQueryItem item;
+                if (i % 2 == 0) {
+                    if (m < registerList.size()) {
+                        item = registerList.get(m);
+                    } else {
+                        item = getBlankItem();
+                    }
+                    m++;
+                } else {
+                    if (n < checkInList.size()) {
+                        item = checkInList.get(n);
+                    } else {
+                        item = getBlankItem();
+                    }
+                    n++;
+                }
+                tempList.add(item);
+            }
+            visitorTwoRows.clear();
+            visitorTwoRows.addAll(tempList);
+        }
+
+        public static SurveillanceQueryItem getBlankItem() {
+            SurveillanceQueryItem blankItem = new SurveillanceQueryItem();
+            blankItem.setRegisterOrCheckIn(Constant.Surveillance.VISIT_BLANK_ITEM_TYPE);
+            return blankItem;
+        }
+
+    }
+
+    static class AttendentUtil {
+
+    }
+
+}
+

--
Gitblit v1.8.0