use of com.github.obsessive.simplifyreader.ui.activity.qrcode.utils.BeepManager in project SimplifyReader by chentao0707.
the class CaptureActivity method initViewsAndEvents.
@Override
protected void initViewsAndEvents() {
hasSurface = false;
mInactivityTimer = new InactivityTimer(this);
mBeepManager = new BeepManager(this);
initCropViewAnimator();
capturePictureBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
readyGoForResult(CommonImagePickerListActivity.class, IMAGE_PICKER_REQUEST_CODE);
}
});
captureLightBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isLightOn) {
cameraManager.setTorch(false);
captureLightBtn.setSelected(false);
} else {
cameraManager.setTorch(true);
captureLightBtn.setSelected(true);
}
isLightOn = !isLightOn;
}
});
captureModeGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId == R.id.capture_mode_barcode) {
PropertyValuesHolder qr2barWidthVH = PropertyValuesHolder.ofFloat("width", 1.0f, (float) mBarcodeCropWidth / mQrcodeCropWidth);
PropertyValuesHolder qr2barHeightVH = PropertyValuesHolder.ofFloat("height", 1.0f, (float) mBarcodeCropHeight / mQrcodeCropHeight);
ValueAnimator valueAnimator = ValueAnimator.ofPropertyValuesHolder(qr2barWidthVH, qr2barHeightVH);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
Float fractionW = (Float) animation.getAnimatedValue("width");
Float fractionH = (Float) animation.getAnimatedValue("height");
RelativeLayout.LayoutParams parentLayoutParams = (RelativeLayout.LayoutParams) captureCropView.getLayoutParams();
parentLayoutParams.width = (int) (mQrcodeCropWidth * fractionW);
parentLayoutParams.height = (int) (mQrcodeCropHeight * fractionH);
captureCropView.setLayoutParams(parentLayoutParams);
}
});
valueAnimator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
initCrop();
setDataMode(DecodeUtils.DECODE_DATA_MODE_BARCODE);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
valueAnimator.start();
} else if (checkedId == R.id.capture_mode_qrcode) {
PropertyValuesHolder bar2qrWidthVH = PropertyValuesHolder.ofFloat("width", 1.0f, (float) mQrcodeCropWidth / mBarcodeCropWidth);
PropertyValuesHolder bar2qrHeightVH = PropertyValuesHolder.ofFloat("height", 1.0f, (float) mQrcodeCropHeight / mBarcodeCropHeight);
ValueAnimator valueAnimator = ValueAnimator.ofPropertyValuesHolder(bar2qrWidthVH, bar2qrHeightVH);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
Float fractionW = (Float) animation.getAnimatedValue("width");
Float fractionH = (Float) animation.getAnimatedValue("height");
RelativeLayout.LayoutParams parentLayoutParams = (RelativeLayout.LayoutParams) captureCropView.getLayoutParams();
parentLayoutParams.width = (int) (mBarcodeCropWidth * fractionW);
parentLayoutParams.height = (int) (mBarcodeCropHeight * fractionH);
captureCropView.setLayoutParams(parentLayoutParams);
}
});
valueAnimator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
initCrop();
setDataMode(DecodeUtils.DECODE_DATA_MODE_QRCODE);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
valueAnimator.start();
}
}
});
}
Aggregations