Skip to content

Commit

Permalink
fix: ProfileGalleryView LongClick
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed Feb 7, 2024
1 parent 9bd30e8 commit 529455e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,6 @@ public void onRelease() {
postInvalidateOnAnimation();
}

@Override
public void onClick() {
}

@Override
public void onPhotosLoaded() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public class ProfileGalleryView extends CircularViewPager implements Notificatio

private int imagesLayerNum;

private long lastDownTime;

public void setHasActiveVideo(boolean hasActiveVideo) {
this.hasActiveVideo = hasActiveVideo;
}
Expand Down Expand Up @@ -129,7 +131,7 @@ public interface Callback {

void onRelease();

void onClick();
default void onClick() {};

void onPhotosLoaded();

Expand Down Expand Up @@ -411,6 +413,22 @@ public void setAnimatedFileMaybe(AnimatedFileDrawable drawable) {

@Override
public boolean onTouchEvent(MotionEvent ev) {
// nekox: long click
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
lastDownTime = System.currentTimeMillis();
isDownReleased = false;
case MotionEvent.ACTION_MOVE:
break;
case MotionEvent.ACTION_UP:
long pressDuration = System.currentTimeMillis() - lastDownTime;
if (pressDuration >= 5000 && !isDownReleased) {
isDownReleased = true;
callback.onClick();
}
break;
}

if (adapter == null) {
return false;
}
Expand Down Expand Up @@ -1227,10 +1245,6 @@ public void onAnimationReady(ImageReceiver imageReceiver) {

item.imageView.setRoundRadius(roundTopRadius, roundTopRadius, roundBottomRadius, roundBottomRadius);

item.imageView.setOnClickListener(__ -> {
callback.onClick();
});

item.imageView.setTag(realPosition);

return item;
Expand Down

0 comments on commit 529455e

Please sign in to comment.