From 2016d43cb1bba65e5304db641aead6950e5a166c Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Wed, 10 Aug 2022 20:51:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95=E9=97=AE?= =?UTF-8?q?=E9=A2=98,shouye=20ytuijian?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../res/layout/view_home_float_banner.xml | 6 ++--- .../yunbao/main/activity/MainActivity.java | 14 +++++++--- .../yunbao/main/views/FloatBannerView.java | 26 +++++++++---------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/common/src/main/res/layout/view_home_float_banner.xml b/common/src/main/res/layout/view_home_float_banner.xml index c05462cb9..7002c06fa 100644 --- a/common/src/main/res/layout/view_home_float_banner.xml +++ b/common/src/main/res/layout/view_home_float_banner.xml @@ -22,7 +22,7 @@ android:layout_width="25dp" android:layout_height="25dp" android:layout_centerVertical="true" - android:layout_marginStart="25dp" + android:layout_marginStart="23dp" android:gravity="center" android:padding="1dp" android:background="@drawable/bg_white_clip" @@ -43,7 +43,7 @@ android:gravity="center" android:padding="1dp" android:layout_centerVertical="true" - android:layout_marginStart="25dp" + android:layout_marginStart="23dp" android:background="@drawable/bg_white_clip"> diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index f3e0b2437..c0608c006 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -163,6 +163,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene private ImageView waitingTip; private FloatBannerView floatBanner; private boolean isClickfloatBanner = false; + private boolean isfloatBannernet = true; @Override @@ -365,7 +366,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene mViewPager.setCurrentItem(0); mTabButtonGroup.setCurPosition(0); isInstructor(); - initAnchorRecommendBanner(); findViewById(R.id.banner_click).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -391,10 +391,11 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene }); mCheckLivePresenter.checkLive(liveBean); + isClickfloatBanner = false; } else { - RouteUtil.forwardUserHome(mContext,Uid, 0); - + RouteUtil.forwardUserHome(mContext, Uid, 0); + isClickfloatBanner = false; } } }); @@ -408,9 +409,12 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene if (index == 0) { floatBanner.setVisibility(View.VISIBLE); findViewById(R.id.banner_click).setVisibility(View.VISIBLE); + isfloatBannernet = true; } else { floatBanner.setVisibility(View.GONE); findViewById(R.id.banner_click).setVisibility(View.GONE); + isfloatBannernet = false; + isClickfloatBanner = false; } }); } @@ -418,7 +422,8 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene /** * 首页推荐位 */ - private void initAnchorRecommendBanner() { + private synchronized void initAnchorRecommendBanner() { + if (!isfloatBannernet) return; MainNetManager.get(mContext) .anchorRecommend("10", new com.yunbao.common.http.base.HttpCallback() { @Override @@ -1181,6 +1186,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene @Subscribe(threadMode = ThreadMode.MAIN) public void onAnchorRecommendModel(AnchorRecommendModel event) { initAnchorRecommendBanner(); + findViewById(R.id.banner_click).setVisibility(View.VISIBLE); } } diff --git a/main/src/main/java/com/yunbao/main/views/FloatBannerView.java b/main/src/main/java/com/yunbao/main/views/FloatBannerView.java index 78df29c84..f6f53dbca 100644 --- a/main/src/main/java/com/yunbao/main/views/FloatBannerView.java +++ b/main/src/main/java/com/yunbao/main/views/FloatBannerView.java @@ -8,7 +8,6 @@ import android.view.View; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.animation.AnimationSet; -import android.view.animation.ScaleAnimation; import android.view.animation.TranslateAnimation; import android.widget.FrameLayout; import android.widget.LinearLayout; @@ -34,7 +33,7 @@ public class FloatBannerView extends FrameLayout { private ClipPathCircleImage clipImage1, clipImage2, clipImage3; private List list = new ArrayList<>(); //默认定时器时间 - private int delayMillis = 1400; + private int delayMillis = 1500; //Handler定时加载下一张的数据 private Handler bannerHandler = new Handler(); private int index = 0; @@ -72,7 +71,8 @@ public class FloatBannerView extends FrameLayout { */ public void showBanner(List mList) { list.clear(); - list.addAll(mList);release(); + list.addAll(mList); + release(); bannerHandler.post(mFlipRunnable); } @@ -95,21 +95,16 @@ public class FloatBannerView extends FrameLayout { Uid = String.valueOf(list.get(next).getUid()); ImgLoader.displayAvatar(getContext(), list.get(next).getAvatar(), clipImage3); ImgLoader.displayAvatar(getContext(), list.get(next).getAvatar(), clipImage2); - if (index == 0) { - ImgLoader.displayAvatar(getContext(), list.get(index).getAvatar(), clipImage1); - } - TranslateAnimation animationTranslate = new TranslateAnimation(0, -27, 0, 0.2f); -// ScaleAnimation scaleAnim = new ScaleAnimation(1f, 1.16f, 1f, 1.16f); + ImgLoader.displayAvatar(getContext(), list.get(index).getAvatar(), clipImage1); + TranslateAnimation animationTranslate = new TranslateAnimation(0, -30, 0, 0.2f); AnimationSet animationSet1 = new AnimationSet(true); animationSet1.setFillAfter(true); - animationSet1.setDuration(700); + animationSet1.setDuration(650); animationSet1.addAnimation(animationTranslate); -// animationSet1.addAnimation(scaleAnim); - AlphaAnimation animationAlpha = new AlphaAnimation(1, 0); AnimationSet animationSet2 = new AnimationSet(true); animationSet2.setFillAfter(true); - animationSet2.setDuration(800); + animationSet2.setDuration(850); animationSet2.addAnimation(animationAlpha); animationSet2.addAnimation(animationTranslate); bannerLayout1.startAnimation(animationSet2); @@ -117,13 +112,18 @@ public class FloatBannerView extends FrameLayout { animationSet1.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { - + int page3 = finalNext + 1; + page3 = (page3 == list.size() ? 0 : page3); + ImgLoader.displayAvatar(getContext(), list.get(page3).getAvatar(), clipImage2); } @Override public void onAnimationEnd(Animation animation) { bannerLayout3.clearAnimation(); ImgLoader.displayAvatar(getContext(), list.get(finalNext).getAvatar(), clipImage1); + int page3 = finalNext + 1; + page3 = (page3 == list.size() ? 0 : page3); + ImgLoader.displayAvatar(getContext(), list.get(page3).getAvatar(), clipImage3); } @Override