Skip to content

Commit

Permalink
added: 新增设置是否可以双击缩放
Browse files Browse the repository at this point in the history
  • Loading branch information
TxcA committed Nov 3, 2022
1 parent 13de0b9 commit e0d92af
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions form/src/main/java/com/bin/david/form/core/SmartTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,9 @@ public void setZoom(boolean zoom) {
* @param maxZoom 最大缩放值
* @param minZoom 最小缩放值
*/
public void setZoom(boolean zoom, float maxZoom, float minZoom) {

public void setZoom(boolean zoom, boolean enableDoubleTap, float maxZoom, float minZoom) {
matrixHelper.setCanZoom(zoom);
matrixHelper.setEnableDoubleTap(enableDoubleTap);
matrixHelper.setMinZoom(minZoom);
matrixHelper.setMaxZoom(maxZoom);
invalidate();
Expand Down
20 changes: 18 additions & 2 deletions form/src/main/java/com/bin/david/form/matrix/MatrixHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class MatrixHelper extends Observable<TableClickObserver> implements ITou
private ScaleGestureDetector mScaleGestureDetector;
private GestureDetector mGestureDetector;
private boolean isCanZoom = false;
private boolean isEnableDoubleTap = true;
private boolean isScale; //是否正在缩小
private Rect originalRect; //原始大小
private Rect zoomRect;
Expand Down Expand Up @@ -259,7 +260,7 @@ public boolean onDown(MotionEvent e) {
//双击
@Override
public boolean onDoubleTap(MotionEvent e) {
if (isCanZoom) {
if (isCanZoom && isEnableDoubleTap) {
float oldZoom = zoom;
if (isScale) { //缩小
zoom = zoom / 1.5f;
Expand Down Expand Up @@ -500,16 +501,23 @@ public Rect getOriginalRect() {
}



/**
* 是否可以缩放
* @return 是否可以缩放
*/
public boolean isCanZoom() {
zoom = 1f;
return isCanZoom;
}

/**
* 是否可以触摸缩放
* @return 是否可以触摸缩放
*/
public boolean isEnableDoubleTap() {
return isEnableDoubleTap;
}

/**
* 获取表格改变监听
* 主要用于SmartTable view监听matrixHelper 移动和缩放
Expand All @@ -528,6 +536,14 @@ public void setOnTableChangeListener(OnTableChangeListener onTableChangeListener
this.listener = onTableChangeListener;
}

/**
* 设置是否可以触摸缩放
* @param enableDoubleTap
*/
public void setEnableDoubleTap(boolean enableDoubleTap) {
isEnableDoubleTap = enableDoubleTap;
}

/**
* 设置是否可以缩放
* @param canZoom
Expand Down

0 comments on commit e0d92af

Please sign in to comment.