更新CameraX至v1.2.2

This commit is contained in:
Jenly
2023-04-15 16:45:34 +08:00
parent 863f1ab1b4
commit 2359695964
33 changed files with 734 additions and 319 deletions

View File

@@ -77,7 +77,7 @@ public class CustomCaptureActivity extends CaptureActivity {
getCameraScan().setPlayBeep(true)//设置是否播放音效默认为false
.setVibrate(true)//设置是否震动默认为false
// .setCameraConfig(new CameraConfig())//设置相机配置信息CameraConfig可覆写options方法自定义配置
.setCameraConfig(new ResolutionCameraConfig(this))//设置CameraConfig可以根据自己的需求去自定义配置
// .setCameraConfig(new ResolutionCameraConfig(this))//设置CameraConfig可以根据自己的需求去自定义配置
.setNeedAutoZoom(false)//二维码太小时可自动缩放默认为false
.setNeedTouchZoom(true)//支持多指触摸捏合缩放默认为true
.setDarkLightLux(45f)//设置光线足够暗的阈值单位lux需要通过{@link #bindFlashlightView(View)}绑定手电筒才有效
@@ -117,12 +117,10 @@ public class CustomCaptureActivity extends CaptureActivity {
}
private void showToast(String text){
if(toast == null){
toast = Toast.makeText(this,text,Toast.LENGTH_SHORT);
}else{
toast.setText(text);
toast.setDuration(Toast.LENGTH_SHORT);
if(toast != null){
toast.cancel();
}
toast = Toast.makeText(this,text,Toast.LENGTH_SHORT);
toast.show();
}

View File

@@ -32,6 +32,8 @@ import com.king.zxing.util.LogUtils;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
@@ -72,6 +74,8 @@ public class MainActivity extends AppCompatActivity implements EasyPermissions.P
private Toast toast;
private ExecutorService executor = Executors.newSingleThreadExecutor();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -97,12 +101,10 @@ public class MainActivity extends AppCompatActivity implements EasyPermissions.P
}
private void showToast(String text){
if(toast == null){
toast = Toast.makeText(this,text,Toast.LENGTH_SHORT);
}else{
toast.setDuration(Toast.LENGTH_SHORT);
toast.setText(text);
if(toast != null){
toast.cancel();
}
toast = Toast.makeText(this,text,Toast.LENGTH_SHORT);
toast.show();
}
@@ -165,7 +167,7 @@ public class MainActivity extends AppCompatActivity implements EasyPermissions.P
}
private void asyncThread(Runnable runnable){
new Thread(runnable).start();
executor.execute(runnable);
}
/**

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@@ -13,7 +13,10 @@
android:id="@+id/viewfinderView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:viewfinderStyle="popular"/>
app:viewfinderStyle="popular"
app:laserStyle="image"
app:laserDrawableRatio="0.8"
app:laserDrawable="@drawable/ic_laser_line"/>
<ImageView
android:id="@+id/ivFlash"
android:layout_width="wrap_content"