* 内置手电筒按钮,当光线太暗时,自动显示手电筒 fix(#58)

*  生成二维码时Logo支持自定义大小 fix(#62)
This commit is contained in:
jenly1314
2019-11-15 17:29:37 +08:00
parent 004bd683a1
commit b830b89b5f
31 changed files with 411 additions and 151 deletions

View File

@@ -38,6 +38,7 @@ public class CaptureFragment extends Fragment implements OnCaptureCallback {
private SurfaceView surfaceView;
private ViewfinderView viewfinderView;
private View ivTorch;
private CaptureHelper mCaptureHelper;
@@ -67,7 +68,12 @@ public class CaptureFragment extends Fragment implements OnCaptureCallback {
public void initUI(){
surfaceView = mRootView.findViewById(getSurfaceViewId());
viewfinderView = mRootView.findViewById(getViewfinderViewId());
mCaptureHelper = new CaptureHelper(this,surfaceView,viewfinderView);
int ivTorchId = getIvTorchId();
if(ivTorchId != 0){
ivTorch = mRootView.findViewById(ivTorchId);
ivTorch.setVisibility(View.INVISIBLE);
}
mCaptureHelper = new CaptureHelper(this,surfaceView,viewfinderView,ivTorch);
mCaptureHelper.setOnCaptureCallback(this);
}
@@ -96,7 +102,6 @@ public class CaptureFragment extends Fragment implements OnCaptureCallback {
return R.id.viewfinderView;
}
/**
* 预览界面{@link #surfaceView} 的id
* @return
@@ -105,6 +110,14 @@ public class CaptureFragment extends Fragment implements OnCaptureCallback {
return R.id.surfaceView;
}
/**
* 获取 {@link #ivTorch} 的ID
* @return 默认返回{@code R.id.ivTorch}, 如果不需要手电筒按钮可以返回0
*/
public int getIvTorchId(){
return R.id.ivTorch;
}
/**
* Get {@link CaptureHelper}
* @return {@link #mCaptureHelper}