|
|
@@ -273,37 +273,37 @@ public class ActMain extends BaseActYmPermissionCheck {
|
|
|
}*/
|
|
|
tabs.add(view);
|
|
|
final int position = index;
|
|
|
- view.setOnClickListener(v -> {
|
|
|
- long currentTime = System.currentTimeMillis();
|
|
|
- if ((currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) && gifComplete) {
|
|
|
- int animResource = R.drawable.gif_bottom_home;
|
|
|
- int endResource = R.drawable.shouye_c;
|
|
|
- ImageView animTarget = view.findViewById(R.id.tab_1_iv);
|
|
|
- if (position == 0) {
|
|
|
- //首页
|
|
|
- animResource = R.drawable.gif_bottom_home;
|
|
|
- animTarget = view.findViewById(R.id.tab_1_iv);
|
|
|
- endResource = R.drawable.shouye_c;
|
|
|
- } else if (position == 1) {
|
|
|
-
|
|
|
- } else if (position == 2) {
|
|
|
- //游戏
|
|
|
- animResource = R.drawable.gif_bottom_game;
|
|
|
- animTarget = view.findViewById(R.id.tab_3_iv);
|
|
|
- endResource = R.drawable.youxi_c;
|
|
|
+ if (position != 1) {
|
|
|
+ view.setOnClickListener(v -> {
|
|
|
+ long currentTime = System.currentTimeMillis();
|
|
|
+ if ((currentTime - lastClickTime > MIN_CLICK_DELAY_TIME)) {
|
|
|
+ int animResource = R.drawable.gif_bottom_home;
|
|
|
+ int endResource = R.drawable.shouye_c;
|
|
|
+ ImageView animTarget = view.findViewById(R.id.tab_1_iv);
|
|
|
+ if (position == 0) {
|
|
|
+ //首页
|
|
|
+ animResource = R.drawable.gif_bottom_home;
|
|
|
+ animTarget = view.findViewById(R.id.tab_1_iv);
|
|
|
+ endResource = R.drawable.shouye_c;
|
|
|
+ } else if (position == 2) {
|
|
|
+ //游戏
|
|
|
+ animResource = R.drawable.gif_bottom_game;
|
|
|
+ animTarget = view.findViewById(R.id.tab_3_iv);
|
|
|
+ endResource = R.drawable.youxi_c;
|
|
|
+ }
|
|
|
+ resetBottomTabImage();
|
|
|
+ loadGifOnlyOnce(animResource, animTarget, endResource);
|
|
|
+ lastClickTime = currentTime;
|
|
|
+ switchFragment(position);
|
|
|
+ checkWhichPage(position);
|
|
|
}
|
|
|
- resetBottomTabImage();
|
|
|
- loadGifOnlyOnce(animResource, animTarget, endResource);
|
|
|
- lastClickTime = currentTime;
|
|
|
- switchFragment(position);
|
|
|
- checkWhichPage(position);
|
|
|
- }
|
|
|
- });
|
|
|
+ });
|
|
|
+ }
|
|
|
index++;
|
|
|
}
|
|
|
findViewById(R.id.tab_2).setOnClickListener(v -> {
|
|
|
long currentTime = System.currentTimeMillis();
|
|
|
- if ((currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) && gifComplete) {
|
|
|
+ if ((currentTime - lastClickTime > MIN_CLICK_DELAY_TIME)) {
|
|
|
resetBottomTabImage();
|
|
|
playWXHBAnima((ImageView) v);
|
|
|
//loadGifOnlyOnce(R.drawable.gif_bottom_wxhb, (ImageView) v);
|
|
|
@@ -320,22 +320,14 @@ public class ActMain extends BaseActYmPermissionCheck {
|
|
|
|
|
|
//播放微信红包动画
|
|
|
private void playWXHBAnima(ImageView imageView) {
|
|
|
- gifComplete = false;
|
|
|
animationDrawable = (AnimationDrawable) imageView.getBackground();
|
|
|
+ animationDrawable.stop();
|
|
|
animationDrawable.start();
|
|
|
- Completable.timer(2300, TimeUnit.MILLISECONDS)
|
|
|
- .doOnComplete(() -> {
|
|
|
- animationDrawable.stop();
|
|
|
- gifComplete = true;
|
|
|
- }).subscribe();
|
|
|
- }
|
|
|
|
|
|
- //GIF是否播放完成
|
|
|
- boolean gifComplete = true;
|
|
|
+ }
|
|
|
|
|
|
//播放一次gif
|
|
|
private void loadGifOnlyOnce(int gifResource, ImageView targetView, int endResource) {
|
|
|
- gifComplete = false;
|
|
|
Glide.with(ActMain.this)
|
|
|
.load(gifResource)
|
|
|
.skipMemoryCache(true)
|
|
|
@@ -360,7 +352,6 @@ public class ActMain extends BaseActYmPermissionCheck {
|
|
|
public void onAnimationEnd(Drawable drawable) {
|
|
|
super.onAnimationEnd(drawable);
|
|
|
targetView.setImageResource(endResource);
|
|
|
- gifComplete = true;
|
|
|
}
|
|
|
});
|
|
|
}
|