use of org.telegram.messenger.video.VideoPlayerRewinder in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatMessageCell method onLongPress.
@Override
protected boolean onLongPress() {
if (isRoundVideo && isPlayingRound && MediaController.getInstance().isPlayingMessage(currentMessageObject)) {
float touchRadius = (lastTouchX - photoImage.getCenterX()) * (lastTouchX - photoImage.getCenterX()) + (lastTouchY - photoImage.getCenterY()) * (lastTouchY - photoImage.getCenterY());
float r1 = (photoImage.getImageWidth() / 2f) * (photoImage.getImageWidth() / 2f);
if (touchRadius < r1 && (lastTouchX > photoImage.getCenterX() + photoImage.getImageWidth() / 4f || lastTouchX < photoImage.getCenterX() - photoImage.getImageWidth() / 4f)) {
boolean forward = lastTouchX > photoImage.getCenterX();
if (videoPlayerRewinder == null) {
videoForwardDrawable = new VideoForwardDrawable(true);
videoPlayerRewinder = new VideoPlayerRewinder() {
@Override
protected void onRewindCanceled() {
onTouchEvent(MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0, 0, 0));
videoForwardDrawable.setShowing(false);
}
@Override
protected void updateRewindProgressUi(long timeDiff, float progress, boolean rewindByBackSeek) {
videoForwardDrawable.setTime(Math.abs(timeDiff));
if (rewindByBackSeek) {
currentMessageObject.audioProgress = progress;
updatePlayingMessageProgress();
}
}
@Override
protected void onRewindStart(boolean rewindForward) {
videoForwardDrawable.setDelegate(new VideoForwardDrawable.VideoForwardDrawableDelegate() {
@Override
public void onAnimationEnd() {
}
@Override
public void invalidate() {
ChatMessageCell.this.invalidate();
}
});
videoForwardDrawable.setOneShootAnimation(false);
videoForwardDrawable.setLeftSide(!rewindForward);
videoForwardDrawable.setShowing(true);
invalidate();
}
};
getParent().requestDisallowInterceptTouchEvent(true);
}
videoPlayerRewinder.startRewind(MediaController.getInstance().getVideoPlayer(), forward, MediaController.getInstance().getPlaybackSpeed(false));
return false;
}
}
if (pressedLink instanceof URLSpanMono) {
delegate.didPressUrl(this, pressedLink, true);
return true;
} else if (pressedLink instanceof URLSpanNoUnderline) {
URLSpanNoUnderline url = (URLSpanNoUnderline) pressedLink;
if (ChatActivity.isClickableLink(url.getURL()) || url.getURL().startsWith("/")) {
delegate.didPressUrl(this, pressedLink, true);
return true;
}
} else if (pressedLink instanceof URLSpan) {
delegate.didPressUrl(this, pressedLink, true);
return true;
}
resetPressedLink(-1);
if (buttonPressed != 0 || miniButtonPressed != 0 || videoButtonPressed != 0 || pressedBotButton != -1) {
buttonPressed = 0;
miniButtonPressed = 0;
videoButtonPressed = 0;
pressedBotButton = -1;
invalidate();
}
linkPreviewPressed = false;
sideButtonPressed = false;
imagePressed = false;
timePressed = false;
gamePreviewPressed = false;
if (pressedVoteButton != -1 || pollHintPressed || psaHintPressed || instantPressed || otherPressed || commentButtonPressed) {
instantPressed = instantButtonPressed = commentButtonPressed = false;
pressedVoteButton = -1;
pollHintPressed = false;
psaHintPressed = false;
otherPressed = false;
if (Build.VERSION.SDK_INT >= 21) {
for (int a = 0; a < selectorDrawable.length; a++) {
if (selectorDrawable[a] != null) {
selectorDrawable[a].setState(StateSet.NOTHING);
}
}
}
invalidate();
}
if (delegate != null) {
boolean handled = false;
if (avatarPressed) {
if (currentUser != null) {
if (currentUser.id != 0) {
handled = delegate.didLongPressUserAvatar(this, currentUser, lastTouchX, lastTouchY);
}
} else if (currentChat != null) {
final int id;
if (currentMessageObject.messageOwner.fwd_from != null) {
if ((currentMessageObject.messageOwner.fwd_from.flags & 16) != 0) {
id = currentMessageObject.messageOwner.fwd_from.saved_from_msg_id;
} else {
id = currentMessageObject.messageOwner.fwd_from.channel_post;
}
} else {
id = 0;
}
handled = delegate.didLongPressChannelAvatar(this, currentChat, id, lastTouchX, lastTouchY);
}
}
if (!handled) {
delegate.didLongPress(this, lastTouchX, lastTouchY);
}
}
return true;
}
Aggregations