Browse Source

一些log和新增方法

xulh 7 months ago
parent
commit
7ad62d5525

+ 14 - 9
datalibrary/src/main/java/com/example/datalibrary/gatecamera/CameraPreviewManager.java

@@ -128,9 +128,9 @@ public class CameraPreviewManager implements SurfaceHolder.Callback , TextureVie
             this.previewHeight = height;
             this.videoDirection = videoDirection;
 
-            Log.e("TEST","previewWidth--"+previewWidth);
-            Log.e("TEST","previewHeight--"+previewHeight);
-            Log.e("TEST","videoDirection--"+videoDirection);
+            Log.e(TAG,"previewWidth--"+previewWidth);
+            Log.e(TAG,"previewHeight--"+previewHeight);
+            Log.e(TAG,"videoDirection--"+videoDirection);
 
         }else {
             this.previewWidth = width;
@@ -140,10 +140,10 @@ public class CameraPreviewManager implements SurfaceHolder.Callback , TextureVie
             this.mirrorVideoRGB = textureView.getMirrorRGB();
 
 
-            Log.e("TEST","previewWidth--"+previewWidth);
-            Log.e("TEST","previewHeight--"+previewHeight);
-            Log.e("TEST","videoDirection--"+videoDirection);
-            Log.e("TEST","mirrorVideoRGB--"+mirrorVideoRGB);
+            Log.e(TAG,"previewWidth--"+previewWidth);
+            Log.e(TAG,"previewHeight--"+previewHeight);
+            Log.e(TAG,"videoDirection--"+videoDirection);
+            Log.e(TAG,"mirrorVideoRGB--"+mirrorVideoRGB);
 
             mSurfaceTexture = mTextureView.getTextureView().getSurfaceTexture();
             mTextureView.getTextureView().setSurfaceTextureListener(this);
@@ -176,6 +176,7 @@ public class CameraPreviewManager implements SurfaceHolder.Callback , TextureVie
     }
 
     public int[] initCamera(){
+        Log.e(TAG, "initCamera---");
         try {
             if (mCamera == null) {
                 mCamera = Camera.open(cameraFacing);
@@ -234,6 +235,7 @@ public class CameraPreviewManager implements SurfaceHolder.Callback , TextureVie
                 } catch (Exception e) {
                     e.printStackTrace();
                     Log.e(TAG, e.getMessage());
+                    Log.e(TAG, "e:"+e.toString());
                 }
             }
             if (surfaceView != null){
@@ -243,6 +245,7 @@ public class CameraPreviewManager implements SurfaceHolder.Callback , TextureVie
 
         }catch (Exception e){
             e.printStackTrace();
+            Log.e(TAG, "e:"+e.toString());
         }
         return new int[]{videoWidth , videoHeight};
     }
@@ -250,7 +253,7 @@ public class CameraPreviewManager implements SurfaceHolder.Callback , TextureVie
      * 开启摄像头
      */
     public void openCamera() {
-
+        Log.e(TAG, "---openCamera");
         try {
             try {
                 mCamera.setPreviewTexture(surfaceView.getFramebuffer());
@@ -351,17 +354,19 @@ public class CameraPreviewManager implements SurfaceHolder.Callback , TextureVie
                 mPreviewed = true;
             }
         } catch (Exception exception) {
+            Log.e(TAG, "IOException caused by setPreviewDisplay()---exception:"+exception);
             Log.e("chaixiaogang", "IOException caused by setPreviewDisplay()", exception);
         }
     }
 
     @Override
     public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int i, int i1) {
-        Log.e(TAG, "--surfaceTexture--TextureSizeChanged");
+        Log.e(TAG, "--surfaceTexture--TextureSizeChanged--i:"+i+"    i1:"+i1);
     }
 
     @Override
     public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
+        Log.e(TAG, "onSurfaceTextureDestroyed");
         if (mCamera != null) {
             // mCamera.stopPreview();
             mPreviewed = false;

+ 17 - 0
lib_base/src/main/java/com/common/lib_base/utils/ui/UIUtils.java

@@ -18,6 +18,7 @@ import android.text.SpannedString;
 import android.text.TextUtils;
 import android.text.style.AbsoluteSizeSpan;
 import android.text.style.ForegroundColorSpan;
+import android.util.DisplayMetrics;
 import android.view.View;
 import android.view.ViewTreeObserver;
 import android.view.WindowManager;
@@ -591,4 +592,20 @@ public final class UIUtils {
     }
 
 
+    // 获取设备宽
+    public static int getScreenWidth(Context context){
+        DisplayMetrics dm = context.getResources().getDisplayMetrics();
+        int displayWidth = dm.widthPixels;
+        return displayWidth;
+    }
+
+    // 获取设备高
+    public static int getScreenHeight(Context context){
+        DisplayMetrics dm = context.getResources().getDisplayMetrics();
+        int heightPixels = dm.heightPixels;
+        return heightPixels;
+    }
+
+
+
 }