|
|
|
@ -117,8 +117,8 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
private SocketClient localSocketClient; |
|
|
|
private volatile Map<String, Uri> videoMap = new HashMap<>(); |
|
|
|
private final Handler mainHandler = new Handler(Looper.getMainLooper()); |
|
|
|
private String videoAfter = ""; |
|
|
|
private String language = "zh_cn"; |
|
|
|
private final Handler videoHandler = new Handler(Looper.getMainLooper()); |
|
|
|
private String pendingVideoType = "bg"; |
|
|
|
private int countConect=0; |
|
|
|
|
|
|
|
Handler handler = new Handler() { |
|
|
|
@ -258,6 +258,21 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
|
|
|
|
//切换视频
|
|
|
|
public void changeVideo(String type) { |
|
|
|
if (type == null) { |
|
|
|
type = "bg"; |
|
|
|
} |
|
|
|
pendingVideoType = type; |
|
|
|
videoHandler.removeCallbacks(videoTask); |
|
|
|
videoHandler.postDelayed(videoTask, 350); |
|
|
|
} |
|
|
|
//视频切换防抖
|
|
|
|
private final Runnable videoTask = new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
changeVideoInternal(pendingVideoType); |
|
|
|
} |
|
|
|
}; |
|
|
|
private void changeVideoInternal(String type){ |
|
|
|
LoggerUtil.e("changeVideo", type); |
|
|
|
if (type == null) { |
|
|
|
type = "bg"; |
|
|
|
@ -301,18 +316,20 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
nextVideo.animate().cancel(); |
|
|
|
nextVideo.clearAnimation(); |
|
|
|
proVideo = currentVideo; |
|
|
|
if (proVideo != null) { |
|
|
|
proVideo.animate() |
|
|
|
final VideoView oldVideo = proVideo; |
|
|
|
if (oldVideo != null) { |
|
|
|
oldVideo.animate().setListener(null); |
|
|
|
oldVideo.animate() |
|
|
|
.alpha(0.5f) |
|
|
|
.setDuration(240) |
|
|
|
.setListener(new AnimatorListenerAdapter() { |
|
|
|
@Override |
|
|
|
public void onAnimationEnd(Animator animation) { |
|
|
|
super.onAnimationEnd(animation); |
|
|
|
if (proVideo != null) { |
|
|
|
proVideo.pause(); |
|
|
|
proVideo.setVisibility(View.GONE); |
|
|
|
proVideo.setAlpha(1.0f); |
|
|
|
if (oldVideo != null) { |
|
|
|
oldVideo.pause(); |
|
|
|
oldVideo.setVisibility(View.GONE); |
|
|
|
oldVideo.setAlpha(1.0f); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
@ -323,17 +340,20 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
|
|
|
|
currentVideo = nextVideo; |
|
|
|
// 开始淡入动画
|
|
|
|
currentVideo.animate() |
|
|
|
final VideoView newVideo = currentVideo; |
|
|
|
newVideo.animate().setListener(null); |
|
|
|
newVideo.animate() |
|
|
|
.alpha(1.0f) |
|
|
|
.setDuration(300) |
|
|
|
.setListener(new AnimatorListenerAdapter() { |
|
|
|
@Override |
|
|
|
public void onAnimationEnd(Animator animation) { |
|
|
|
super.onAnimationEnd(animation); |
|
|
|
if (currentVideo != null) { |
|
|
|
//currentVideo.seekTo(0);
|
|
|
|
currentVideo.start(); |
|
|
|
currentVideo.setAlpha(1.0f); |
|
|
|
if (newVideo != null) { |
|
|
|
newVideo.setAlpha(1.0f); |
|
|
|
if (!newVideo.isPlaying()) { |
|
|
|
newVideo.start(); |
|
|
|
} |
|
|
|
LoggerUtil.e("切换视频:","动画播放完成"); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -476,6 +496,9 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
if (handler != null) { |
|
|
|
handler.removeCallbacksAndMessages(null); |
|
|
|
} |
|
|
|
if (videoHandler != null) { |
|
|
|
videoHandler.removeCallbacksAndMessages(null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void loadH5Url(boolean loadUrl) { |
|
|
|
|