@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user