From 6d25cbae7fd9bd66ed79c6de7c77d78e309da6ed Mon Sep 17 00:00:00 2001 From: xuxiuxi <xuxiuxi@454eff88-639b-444f-9e54-f578c98de674> Date: 星期一, 15 五月 2017 11:24:16 +0800 Subject: [PATCH] --- VisitFace/DemoForBsk/app/src/main/res/layout/fragment_surveillance.xml | 15 +++++++ VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/SurveillanceFragment.java | 56 ++++++++++++++++++++++++---- 2 files changed, 62 insertions(+), 9 deletions(-) diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/SurveillanceFragment.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/SurveillanceFragment.java index 8b8fa40..3788dfa 100644 --- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/SurveillanceFragment.java +++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/SurveillanceFragment.java @@ -5,8 +5,10 @@ import android.os.Build; import android.os.Bundle; import android.text.format.Formatter; +import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; +import android.widget.ProgressBar; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.TextView; @@ -16,6 +18,7 @@ import cn.com.basic.face.base.BaseFragment; import cn.com.basic.face.base.MainActivity; +import cn.com.basic.face.discern.common.CommonVariables; import cn.com.basic.face.service.DeviceMng; import cn.com.basic.face.util.RtspFaceNative; @@ -50,13 +53,17 @@ @ViewInject(R.id.fragment_supervisory_bottom_attendance_list_view) private SurveillanceBottomAttendanceListView fragment_supervisory_bottom_attendance_list_view; @ViewInject(R.id.fragment_supervisory_enter_camera) - SurfaceView fragment_supervisory_enter_camera; + private SurfaceView fragment_supervisory_enter_camera; @ViewInject(R.id.fragment_supervisory_exit_camera) - SurfaceView fragment_supervisory_exit_camera; + private SurfaceView fragment_supervisory_exit_camera; @ViewInject(R.id.fragment_surveillance_enter_timer) private TextView fragment_surveillance_enter_timer; @ViewInject(R.id.fragment_surveillance_exit_timer) private TextView fragment_surveillance_exit_timer; + @ViewInject(R.id.fragment_supervisory_enter_progress_bar) + private ProgressBar fragment_supervisory_enter_progress_bar; + @ViewInject(R.id.fragment_supervisory_exit_progress_bar) + private ProgressBar fragment_supervisory_exit_progress_bar; static boolean useNative = false; @@ -116,6 +123,44 @@ @Override protected void initViews(View view, Bundle savedInstanceState) { + fragment_supervisory_enter_camera.getHolder().addCallback(new SurfaceHolder.Callback() { + @Override + public void surfaceCreated(SurfaceHolder holder) { + fragment_supervisory_enter_progress_bar.setVisibility(View.INVISIBLE); + RtspFaceNative.setSurface(Integer.parseInt(CommonVariables.Camera.IN), fragment_supervisory_enter_camera.getHolder().getSurface()); + RtspFaceNative.createPlayer(Integer.parseInt(CommonVariables.Camera.IN), DeviceMng.getInstance().getCamera1Address()); + RtspFaceNative.setFaceCallback(Integer.parseInt(CommonVariables.Camera.IN), "cn/com/basic/face/util/RtspFaceNative", "faceCallBack"); + } + + @Override + public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { + + } + + @Override + public void surfaceDestroyed(SurfaceHolder holder) { + //fragment_supervisory_enter_progress_bar.setVisibility(View.VISIBLE); + } + }); + fragment_supervisory_exit_camera.getHolder().addCallback(new SurfaceHolder.Callback() { + @Override + public void surfaceCreated(SurfaceHolder holder) { + fragment_supervisory_exit_progress_bar.setVisibility(View.INVISIBLE); + RtspFaceNative.setSurface(Integer.parseInt(CommonVariables.Camera.OUT), fragment_supervisory_exit_camera.getHolder().getSurface()); + RtspFaceNative.createPlayer(Integer.parseInt(CommonVariables.Camera.OUT), DeviceMng.getInstance().getCamera2Address()); + RtspFaceNative.setFaceCallback(Integer.parseInt(CommonVariables.Camera.OUT), "cn/com/basic/face/util/RtspFaceNative", "faceCallBack"); + } + + @Override + public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { + + } + + @Override + public void surfaceDestroyed(SurfaceHolder holder) { + //fragment_supervisory_exit_progress_bar.setVisibility(View.VISIBLE); + } + }); new Thread(new Runnable() { @Override public void run() { @@ -135,12 +180,7 @@ } catch (Exception e) { e.printStackTrace(); } - RtspFaceNative.setSurface(1, fragment_supervisory_enter_camera.getHolder().getSurface()); - RtspFaceNative.setSurface(2, fragment_supervisory_exit_camera.getHolder().getSurface()); - RtspFaceNative.createPlayer(1, DeviceMng.getInstance().getCamera1Address()); - RtspFaceNative.createPlayer(2, DeviceMng.getInstance().getCamera2Address()); - RtspFaceNative.setFaceCallback(1, "cn/com/basic/face/util/RtspFaceNative", "faceCallBack"); - RtspFaceNative.setFaceCallback(2, "cn/com/basic/face/util/RtspFaceNative", "faceCallBack"); + } public String convertStreamToString(InputStream is) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); diff --git a/VisitFace/DemoForBsk/app/src/main/res/layout/fragment_surveillance.xml b/VisitFace/DemoForBsk/app/src/main/res/layout/fragment_surveillance.xml index ac4d70f..089e33f 100644 --- a/VisitFace/DemoForBsk/app/src/main/res/layout/fragment_surveillance.xml +++ b/VisitFace/DemoForBsk/app/src/main/res/layout/fragment_surveillance.xml @@ -73,8 +73,14 @@ android:text="鎽勫儚鏈鸿繘" android:layout_marginRight="@dimen/w122dp"/> </RelativeLayout> + <ProgressBar + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerInParent="true" + android:visibility="invisible" + android:id="@+id/fragment_supervisory_enter_progress_bar" + /> </RelativeLayout> - <RelativeLayout android:layout_width="@dimen/view_size_0" android:layout_height="match_parent" @@ -115,6 +121,13 @@ android:text="鎽勫儚鏈哄嚭" android:layout_marginRight="@dimen/w12dp"/> </RelativeLayout> + <ProgressBar + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerInParent="true" + android:visibility="invisible" + android:id="@+id/fragment_supervisory_exit_progress_bar" + /> </RelativeLayout> </LinearLayout> -- Gitblit v1.8.0