Skip to content

Commit

Permalink
#45 fixed #46
Browse files Browse the repository at this point in the history
  • Loading branch information
ielse committed Sep 14, 2018
1 parent 9d4b910 commit e1cde92
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 31 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
### 示例下载
略。

`1.1.3`
* 新增-不需要传ImageView的show方法。
* 修复-下拉返回不灵

`1.1.2`

* 修复-图片切换中多指触碰导致页面停滞
Expand Down Expand Up @@ -51,7 +55,7 @@ allprojects {
Add the dependency
```
dependencies {
implementation 'com.github.iielse:ImageWatcher:1.1.2'
implementation 'com.github.iielse:ImageWatcher:1.1.3'
}
```

Expand Down
26 changes: 13 additions & 13 deletions app/src/main/java/ch/ielse/demo/p02/SimpleLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ class SimpleLoader implements ImageWatcher.Loader {
public void load(Context context, Uri uri, final ImageWatcher.LoadCallback lc) {
Glide.with(context).load(uri)
.into(new SimpleTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
lc.onResourceReady(resource);
}
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
lc.onResourceReady(resource);
}

@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
lc.onLoadFailed(errorDrawable);
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
lc.onLoadFailed(errorDrawable);
}

@Override
public void onLoadStarted(@Nullable Drawable placeholder) {
lc.onLoadStarted(placeholder);
}
});
@Override
public void onLoadStarted(@Nullable Drawable placeholder) {
lc.onLoadStarted(placeholder);
}
});
}
}
4 changes: 2 additions & 2 deletions imagewatcher/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
versionCode 5
versionName "1.1.2"
versionCode 6
versionName "1.1.3"

}
buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,12 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve
final ViewState vsCurrent = ViewState.write(iSource, ViewState.STATE_CURRENT);
final ViewState vsDefault = ViewState.read(iSource, ViewState.STATE_DEFAULT);
if (vsDefault == null) return false;
final String imageOrientation = (String) iSource.getTag(R.id.image_orientation);

if (velocityX > 0 && vsCurrent.translationX == (vsDefault.width * (vsCurrent.scaleX - 1) / 2)) {
return false; // 当前图片左侧边缘手指右划
} else if (velocityX < 0 && -vsCurrent.translationX == vsDefault.width * (vsCurrent.scaleX - 1) / 2) {
return false; // 当前图片右侧边缘手指左划
if (velocityX > 0 && vsCurrent.translationX == (vsDefault.width * (vsCurrent.scaleX - 1) / 2) && "horizontal".equals(imageOrientation)) {
return false; // 当前图片[横图]左侧边缘手指右划
} else if (velocityX < 0 && -vsCurrent.translationX == vsDefault.width * (vsCurrent.scaleX - 1) / 2 && "horizontal".equals(imageOrientation)) {
return false; // 当前图片[横图]右侧边缘手指左划
} else if (e1 != null && e2 != null && (Math.abs(e1.getX() - e2.getX()) > 50 || Math.abs(e1.getY() - e2.getY()) > 50) && (Math.abs(velocityX) > 500 || Math.abs(velocityY) > 500)) {
// 满足fling手势
float maxVelocity = Math.max(Math.abs(velocityX), Math.abs(velocityY));
Expand Down Expand Up @@ -679,17 +680,17 @@ private void handleDoubleTapTouchResult() {
float expectedScale = (MAX_SCALE - vsDefault.scaleX) * 0.4f + vsDefault.scaleX;

// 横向超长图片双击无法看清楚的问题
// final String imageOrientation = (String) iSource.getTag(R.id.image_orientation);
// if (imageOrientation.equals("horizontal")) {
// ViewState viewState = ViewState.read(iSource, ViewState.STATE_DEFAULT);
// //图片在双击的时候放大的倍数,如果图片过长看不放大根本看不见 #45 hu670014125
// final float scale = viewState.width / viewState.height;
// float maxScale = MAX_SCALE;
// if (scale > 2.0f) {
// maxScale = MAX_SCALE * scale / 2;
// }
// expectedScale = (maxScale - vsDefault.scaleX) * 0.4f + vsDefault.scaleX;
// }
final String imageOrientation = (String) iSource.getTag(R.id.image_orientation);
if (imageOrientation.equals("horizontal")) {
ViewState viewState = ViewState.read(iSource, ViewState.STATE_DEFAULT);
//图片在双击的时候放大的倍数,如果图片过长看不放大根本看不见 #45 hu670014125
final float scale = viewState.width / viewState.height;
float maxScale = MAX_SCALE;
if (scale > 2.0f) {
maxScale = MAX_SCALE * scale / 2;
}
expectedScale = (maxScale - vsDefault.scaleX) * 0.4f + vsDefault.scaleX;
}

animSourceViewStateTransform(iSource,
ViewState.write(iSource, ViewState.STATE_TEMP).scaleX(expectedScale).scaleY(expectedScale));
Expand Down

0 comments on commit e1cde92

Please sign in to comment.