马达新增向前向后

mada
liuguijing 3 months ago
parent 8f5b5694c8
commit 00e8bce527

@ -8,7 +8,7 @@ android {
defaultConfig {
applicationId "com.xypower.mppreview"
minSdk 28
minSdk 30
targetSdk 30
versionCode 3
versionName "1.2"

@ -34,7 +34,6 @@ import com.xypower.mppreview.ui.CameraChannelActivity;
import com.xypower.mppreview.utils.PhotoUtil;
import com.xypower.mppreview.bean.Contants;
import com.xypower.mppreview.utils.CameraUtils;
import com.xypower.mppreview.utils.RouteManager;
import java.io.File;
@ -213,6 +212,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
CameraManager manager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
try {
String[] cameraIds = manager.getCameraIdList();
return cameraIds.length;
} catch (CameraAccessException e) {
e.printStackTrace();

@ -71,11 +71,23 @@ public class CameraChannelActivity extends AppCompatActivity implements View.OnC
private void initEvent() {
viewBinding.imageCaptureButton.setOnClickListener(this);
viewBinding.foward.setOnClickListener(this);
viewBinding.back.setOnClickListener(this);
}
@Override
public void onClick(View v) {
takePhoto();
switch (v.getId()) {
case R.id.image_capture_button:
takePhoto();
break;
case R.id.foward:
setInt(311, 101);
break;
case R.id.back:
setInt(311, 201);
break;
}
}
private void startCamera(int cameraid) {
@ -110,7 +122,7 @@ public class CameraChannelActivity extends AppCompatActivity implements View.OnC
processCameraProvider.unbindAll();
// 绑定用例至相机
processCameraProvider.bindToLifecycle(CameraChannelActivity.this, cameraSelector, preview,imageCapture,imageAnalysis);
processCameraProvider.bindToLifecycle(CameraChannelActivity.this, cameraSelector, preview, imageCapture, imageAnalysis);
} catch (Exception e) {
Log.e(Contants.TAG, "用例绑定失败!" + e);

@ -12,17 +12,28 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- <Button-->
<!-- android:id="@+id/image_capture_button"-->
<!-- android:layout_width="110dp"-->
<!-- android:layout_height="110dp"-->
<!-- android:layout_marginEnd="50dp"-->
<!-- android:layout_marginBottom="50dp"-->
<!-- android:elevation="2dp"-->
<!-- android:text="拍照"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintEnd_toStartOf="@id/vertical_centerline"-->
<!-- app:layout_constraintLeft_toLeftOf="parent" />-->
<Button
android:id="@+id/foward"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginLeft="20dp"
android:layout_marginBottom="40dp"
android:shadowColor="@null"
android:text="向前"
app:layout_constraintBottom_toTopOf="@+id/image_capture_button"
app:layout_constraintLeft_toLeftOf="parent" />
<Button
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginLeft="30dp"
android:layout_marginBottom="40dp"
android:shadowColor="@null"
android:text="向后"
app:layout_constraintBottom_toTopOf="@+id/image_capture_button"
app:layout_constraintLeft_toRightOf="@+id/foward" />
<Button
android:id="@+id/image_capture_button"
android:layout_width="50dp"
@ -35,7 +46,6 @@
app:layout_constraintRight_toRightOf="parent" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/vertical_centerline"
android:layout_width="wrap_content"

Loading…
Cancel
Save