Skip to content

Commit

Permalink
添加显示区域
Browse files Browse the repository at this point in the history
  • Loading branch information
ZyElite committed Nov 13, 2018
1 parent bb22fcd commit 5ace388
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
14 changes: 9 additions & 5 deletions sketch/src/main/java/me/panpf/sketch/zoom/ImageZoomer.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ public boolean canScrollVertically() {
}


/**
* 获取显示区域
*
* @return
*/
public RectF getDisplayRect() {
return scaleDragHelper.getDisplayRect();
}

/**
* 当 {@link ImageView} 的 {@link Drawable}、{@link ScaleType}、尺寸发生改变或旋转角度、阅读模式修改了需要调用此方法重置
*
Expand Down Expand Up @@ -579,11 +588,6 @@ public void setReadMode(boolean vReadMode, boolean hReadMode) {
}
this.vReadMode = vReadMode;
this.hReadMode = hReadMode;
// if (this.readMode == readMode) {
// return;
// }
//
// this.readMode = readMode;
reset("setReadMode");
}

Expand Down
24 changes: 24 additions & 0 deletions sketch/src/main/java/me/panpf/sketch/zoom/ScaleDragHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.view.MotionEvent;
import android.view.ViewParent;
import android.widget.ImageView;
Expand Down Expand Up @@ -584,6 +585,29 @@ void setZooming(boolean zooming) {
this.zooming = zooming;
}

/**
* 获取显示区域
*
* @return
*/
protected RectF getDisplayRect() {
checkMatrixBounds();
return getDisplayRect(getDrawMatrix());
}

private final RectF mDisplayRect = new RectF();

private RectF getDisplayRect(Matrix matrix) {
Drawable d = imageZoomer.getImageView().getDrawable();
if (d != null) {
mDisplayRect.set(0, 0, d.getIntrinsicWidth(),
d.getIntrinsicHeight());
matrix.mapRect(mDisplayRect);
return mDisplayRect;
}
return null;
}

/**
* 获取绘制区域
*/
Expand Down

0 comments on commit 5ace388

Please sign in to comment.