use of com.cjt2325.cameralibrary.listener.TypeListener in project CameraView by CJT2325.
the class JCameraView method initView.
private void initView() {
setWillNotDraw(false);
View view = LayoutInflater.from(mContext).inflate(R.layout.camera_view, this);
mVideoView = (VideoView) view.findViewById(R.id.video_preview);
mPhoto = (ImageView) view.findViewById(R.id.image_photo);
mSwitchCamera = (ImageView) view.findViewById(R.id.image_switch);
mSwitchCamera.setImageResource(iconSrc);
mFlashLamp = (ImageView) view.findViewById(R.id.image_flash);
setFlashRes();
mFlashLamp.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
type_flash++;
if (type_flash > 0x023)
type_flash = TYPE_FLASH_AUTO;
setFlashRes();
}
});
mCaptureLayout = (CaptureLayout) view.findViewById(R.id.capture_layout);
mCaptureLayout.setDuration(duration);
mCaptureLayout.setIconSrc(iconLeft, iconRight);
mFoucsView = (FoucsView) view.findViewById(R.id.fouce_view);
mVideoView.getHolder().addCallback(this);
// 切换摄像头
mSwitchCamera.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
machine.swtich(mVideoView.getHolder(), screenProp);
}
});
// 拍照 录像
mCaptureLayout.setCaptureLisenter(new CaptureListener() {
@Override
public void takePictures() {
mSwitchCamera.setVisibility(INVISIBLE);
mFlashLamp.setVisibility(INVISIBLE);
machine.capture();
}
@Override
public void recordStart() {
mSwitchCamera.setVisibility(INVISIBLE);
mFlashLamp.setVisibility(INVISIBLE);
machine.record(mVideoView.getHolder().getSurface(), screenProp);
}
@Override
public void recordShort(final long time) {
mCaptureLayout.setTextWithAnimation("录制时间过短");
mSwitchCamera.setVisibility(VISIBLE);
mFlashLamp.setVisibility(VISIBLE);
postDelayed(new Runnable() {
@Override
public void run() {
machine.stopRecord(true, time);
}
}, 1500 - time);
}
@Override
public void recordEnd(long time) {
machine.stopRecord(false, time);
}
@Override
public void recordZoom(float zoom) {
LogUtil.i("recordZoom");
machine.zoom(zoom, CameraInterface.TYPE_RECORDER);
}
@Override
public void recordError() {
if (errorLisenter != null) {
errorLisenter.AudioPermissionError();
}
}
});
// 确认 取消
mCaptureLayout.setTypeLisenter(new TypeListener() {
@Override
public void cancel() {
machine.cancle(mVideoView.getHolder(), screenProp);
}
@Override
public void confirm() {
machine.confirm();
}
});
// 退出
// mCaptureLayout.setReturnLisenter(new ReturnListener() {
// @Override
// public void onReturn() {
// if (jCameraLisenter != null) {
// jCameraLisenter.quit();
// }
// }
// });
mCaptureLayout.setLeftClickListener(new ClickListener() {
@Override
public void onClick() {
if (leftClickListener != null) {
leftClickListener.onClick();
}
}
});
mCaptureLayout.setRightClickListener(new ClickListener() {
@Override
public void onClick() {
if (rightClickListener != null) {
rightClickListener.onClick();
}
}
});
}
Aggregations