-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from SMask/master
图片预览PhotoView冲突;RecyclerView监听onScrollStateChanged回调调整
- Loading branch information
Showing
3 changed files
with
90 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
easyPhotos/src/main/java/com/huantansheng/easyphotos/ui/widget/PreviewRecyclerView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.huantansheng.easyphotos.ui.widget; | ||
|
||
import android.content.Context; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.Nullable; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.util.AttributeSet; | ||
import android.view.MotionEvent; | ||
|
||
/** | ||
* 图片预览 RecyclerView | ||
* Create By lishilin On 2019/3/25 | ||
*/ | ||
public class PreviewRecyclerView extends RecyclerView { | ||
|
||
private boolean isLock;// 是否锁住 RecyclerView ,避免和 PhotoView 双指放大缩小操作冲突 | ||
|
||
public PreviewRecyclerView(@NonNull Context context) { | ||
super(context); | ||
} | ||
|
||
public PreviewRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
public PreviewRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) { | ||
super(context, attrs, defStyle); | ||
} | ||
|
||
@Override | ||
public boolean onInterceptTouchEvent(MotionEvent event) { | ||
switch (event.getActionMasked()) { | ||
case MotionEvent.ACTION_POINTER_DOWN:// 非第一个触点按下 | ||
isLock = true; | ||
break; | ||
case MotionEvent.ACTION_UP:// 最后一个触点抬起 | ||
isLock = false; | ||
break; | ||
} | ||
if (isLock) { | ||
return false;// 不拦截,交给子View处理 | ||
} | ||
return super.onInterceptTouchEvent(event); | ||
} | ||
|
||
@Override | ||
public boolean dispatchTouchEvent(MotionEvent event) { | ||
switch (event.getActionMasked()) { | ||
case MotionEvent.ACTION_POINTER_DOWN:// 非第一个触点按下 | ||
isLock = true; | ||
break; | ||
case MotionEvent.ACTION_UP:// 最后一个触点抬起 | ||
isLock = false; | ||
break; | ||
} | ||
return super.dispatchTouchEvent(event); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters