优化细节
This commit is contained in:
@@ -117,7 +117,7 @@ implementation 'com.king.zxing:zxing-lite:1.1.9'
|
|||||||
|
|
||||||
#### v1.x 说明
|
#### v1.x 说明
|
||||||
|
|
||||||
[【v1.1.9】](https://github.com/jenly1314/ZXingLite/tree/androidx) 如果您正在使用 **1.x** 版本请点击下面的链接查看分支版本,当前 **2.x** 版本已经基于 **Camerx** 进行重构,不支持升级,请在新项目中使用。
|
[【v1.1.9】](https://github.com/jenly1314/ZXingLite/tree/androidx) 如果您正在使用 **1.x** 版本请点击下面的链接查看分支版本,当前 **2.x** 版本已经基于 **CameraX** 进行重构,不支持升级,请在新项目中使用。
|
||||||
|
|
||||||
查看AndroidX版 **1.x** 分支 [请戳此处](https://github.com/jenly1314/ZXingLite/tree/androidx)
|
查看AndroidX版 **1.x** 分支 [请戳此处](https://github.com/jenly1314/ZXingLite/tree/androidx)
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -1,6 +1,7 @@
|
|||||||
package com.king.zxing.app;
|
package com.king.zxing.app;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.google.zxing.Result;
|
import com.google.zxing.Result;
|
||||||
@@ -79,4 +80,12 @@ public class QRCodeActivity extends CaptureActivity {
|
|||||||
*/
|
*/
|
||||||
return super.onScanResultCallback(result);
|
return super.onScanResultCallback(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onClick(View v){
|
||||||
|
switch (v.getId()){
|
||||||
|
case R.id.ivLeft:
|
||||||
|
finish();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ ext.app_version = app_version
|
|||||||
//build version
|
//build version
|
||||||
def build_versions = [:]
|
def build_versions = [:]
|
||||||
build_versions.minSdk = 21
|
build_versions.minSdk = 21
|
||||||
build_versions.targetSdk = 28
|
build_versions.targetSdk = 29
|
||||||
build_versions.compileSdk = 28
|
build_versions.compileSdk = 29
|
||||||
build_versions.buildTools = "28.0.3"
|
build_versions.buildTools = "29.0.3"
|
||||||
ext.build_versions = build_versions
|
ext.build_versions = build_versions
|
||||||
|
|
||||||
ext.deps = [:]
|
ext.deps = [:]
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ import android.util.DisplayMetrics;
|
|||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.king.zxing.util.LogUtils;
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
import androidx.annotation.ColorRes;
|
import androidx.annotation.ColorRes;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@@ -113,6 +115,15 @@ public class ViewfinderView extends View {
|
|||||||
*/
|
*/
|
||||||
public int scannerEnd = 0;
|
public int scannerEnd = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 扫码初始框宽
|
||||||
|
*/
|
||||||
|
private int initFrameWidth;
|
||||||
|
/**
|
||||||
|
* 扫码初始框高
|
||||||
|
*/
|
||||||
|
private int initFrameHeight;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扫码框宽
|
* 扫码框宽
|
||||||
*/
|
*/
|
||||||
@@ -278,8 +289,8 @@ public class ViewfinderView extends View {
|
|||||||
labelTextWidth = array.getDimensionPixelSize(R.styleable.ViewfinderView_labelTextWidth,0);
|
labelTextWidth = array.getDimensionPixelSize(R.styleable.ViewfinderView_labelTextWidth,0);
|
||||||
labelTextLocation = TextLocation.getFromInt(array.getInt(R.styleable.ViewfinderView_labelTextLocation,0));
|
labelTextLocation = TextLocation.getFromInt(array.getInt(R.styleable.ViewfinderView_labelTextLocation,0));
|
||||||
|
|
||||||
frameWidth = array.getDimensionPixelSize(R.styleable.ViewfinderView_frameWidth,0);
|
initFrameWidth = array.getDimensionPixelSize(R.styleable.ViewfinderView_frameWidth,0);
|
||||||
frameHeight = array.getDimensionPixelSize(R.styleable.ViewfinderView_frameHeight,0);
|
initFrameHeight = array.getDimensionPixelSize(R.styleable.ViewfinderView_frameHeight,0);
|
||||||
|
|
||||||
laserStyle = LaserStyle.getFromInt(array.getInt(R.styleable.ViewfinderView_laserStyle,LaserStyle.LINE.mValue));
|
laserStyle = LaserStyle.getFromInt(array.getInt(R.styleable.ViewfinderView_laserStyle,LaserStyle.LINE.mValue));
|
||||||
gridColumn = array.getInt(R.styleable.ViewfinderView_gridColumn,20);
|
gridColumn = array.getInt(R.styleable.ViewfinderView_gridColumn,20);
|
||||||
@@ -328,22 +339,30 @@ public class ViewfinderView extends View {
|
|||||||
this.labelTextSize = textSize;
|
this.labelTextSize = textSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||||
|
super.onLayout(changed, left, top, right, bottom);
|
||||||
|
LogUtils.d("onLayout" + getWidth() + "," + getHeight());
|
||||||
|
initFrame(getWidth(),getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||||
super.onSizeChanged(w, h, oldw, oldh);
|
super.onSizeChanged(w, h, oldw, oldh);
|
||||||
initFrame(w,h);
|
LogUtils.d("onSizeChanged" + w + "," + h);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initFrame(int width,int height){
|
private void initFrame(int width,int height){
|
||||||
|
|
||||||
int size = (int)(Math.min(width,height) * frameRatio);
|
int size = (int)(Math.min(width,height) * frameRatio);
|
||||||
|
|
||||||
if(frameWidth <= 0 || frameWidth > width){
|
if(initFrameWidth <= 0 || initFrameWidth > width){
|
||||||
frameWidth = size;
|
frameWidth = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(frameHeight <= 0 || frameHeight > height){
|
if(initFrameHeight <= 0 || initFrameHeight > height){
|
||||||
frameHeight = size;
|
frameHeight = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user