diff --git a/common/src/main/java/com/yunbao/common/views/weight/FloatBannerView.java b/common/src/main/java/com/yunbao/common/views/weight/FloatBannerView.java deleted file mode 100644 index 01981d02a..000000000 --- a/common/src/main/java/com/yunbao/common/views/weight/FloatBannerView.java +++ /dev/null @@ -1,143 +0,0 @@ -package com.yunbao.common.views.weight; - -import android.animation.Animator; -import android.content.Context; -import android.graphics.Canvas; -import android.os.Handler; -import android.util.AttributeSet; -import android.view.View; -import android.view.animation.DecelerateInterpolator; -import android.view.animation.TranslateAnimation; -import android.widget.FrameLayout; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.RelativeLayout; -import android.widget.ViewFlipper; - -import com.yunbao.common.R; -import com.yunbao.common.bean.AnchorRecommendItemModel; -import com.yunbao.common.glide.ImgLoader; - -import java.util.List; - -/** - * 首页精彩推荐banner自定义组件 - */ -public class FloatBannerView extends RelativeLayout { - private View rootView; - private LinearLayout rootLayout; - private ViewFlipper homeBanner; - private FrameLayout bannerLayout, bannerLayout2, bannerLayoutC; - private ClipPathCircleImage clipImage, bigclipImage; - private List list; - //默认定时器时间 - private int delayMillis = 800; - //Handler定时加载下一张的数据 - private Handler bannerHandler = new Handler(); - private int index = 0; - - public FloatBannerView(Context context) { - super(context); - } - - public FloatBannerView(Context context, AttributeSet attrs) { - super(context, attrs); - rootView = View.inflate(context, R.layout.view_home_float_banner, this); - homeBanner = rootView.findViewById(R.id.banner); -// bigclipImage = rootView.findViewById(R.id.banner_layout_image); -// bannerLayout = rootView.findViewById(R.id.banner_layout); -// bannerLayout2 = rootView.findViewById(R.id.banner_layout2); -// bannerLayoutC = rootView.findViewById(R.id.banner_layout_c); - } - - @Override - protected void onDraw(Canvas canvas) { - - super.onDraw(canvas); - } - - - /** - * 设置轮播数据 - * - * @param list - */ - public void showBanner(List list) { - for (int i = 0; i < list.size(); i++) { - View contextView = View.inflate(getContext(), R.layout.view_home_float_banner_item, null); - ImageView imageView = contextView.findViewById(R.id.clip_image); - ImgLoader.display2(getContext(), list.get(i).getAvatar(), imageView); - homeBanner.addView(contextView); - } - TranslateAnimation translateAnimation = new TranslateAnimation(homeBanner.getX(), homeBanner.getY(), homeBanner.getX() / 3 * 2, homeBanner.getY() / 3 * 2); - homeBanner.setOutAnimation(translateAnimation); - post(new Runnable() { - @Override - public void run() { - bannerHandler.removeCallbacks(mFlipRunnable); - bannerHandler.postDelayed(mFlipRunnable, delayMillis); - } - }); - - - } - - //轮播动起来 - private void carouselMoving() { - if (null == list || list.size() <= 0) return; - //获取轮播展示的下标 - //如果轮播展示的是最后一张底图展示第一张 - if (index == (list.size() - 1)) { - ImgLoader.display2(getContext(), list.get(0).getAvatar(), clipImage); - } else { - ImgLoader.display2(getContext(), list.get(index + 1).getAvatar(), clipImage); - } - } - - private final Runnable mFlipRunnable = new Runnable() { - @Override - public void run() { - homeBanner.showNext(); - bannerHandler.postDelayed(mFlipRunnable, delayMillis); - } - }; - - /**/ - private void moveViewToTargetView(View view, View targetView) { - final float x = view.getX() / 3 * 2; - final float y = view.getY() / 2; - - final float targetX = targetView.getX() / 3 * 2; - final float targetY = targetView.getY() / 2; - view.animate() - .translationX(-(x - targetX)) - .translationY(-(y - targetY)) - .scaleX(1.2f) - .scaleY(1.2f) - .setDuration(700) - .setInterpolator(new DecelerateInterpolator()) - .withLayer() - .setListener(new Animator.AnimatorListener() { - @Override - public void onAnimationStart(Animator animation) { - - } - - @Override - public void onAnimationEnd(Animator animation) { - view.animate().cancel(); - } - - @Override - public void onAnimationCancel(Animator animation) { - - } - - @Override - public void onAnimationRepeat(Animator animation) { - - } - }) - .start(); - } -} 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 80efacd87..ea6ce9d15 100644 --- a/common/src/main/res/layout/view_home_float_banner.xml +++ b/common/src/main/res/layout/view_home_float_banner.xml @@ -2,6 +2,8 @@ - + android:layout_marginStart="25dp" + android:background="@drawable/bg_white_clip" + android:visibility="visible"> + + + + + + + + + + + + + + () { + @Override + public void onSuccess(LiveInfoModel data) { + LiveRoomCheckLivePresenter mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, (liveBean, liveType, liveTypeVal, liveSdk) -> { + if (liveBean == null) { + return; + } + LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", 0, liveSdk); + + }); + //讲数据转成json + String json = GsonUtils.toJson(data); + LiveBean liveBean = GsonUtils.fromJson(json, LiveBean.class); + mCheckLivePresenter.checkLive(liveBean); + } + + @Override + public void onError(String error) { + + RouteUtil.forwardUserHome(mContext, String.valueOf(Uid), 0); + + } + }); + } + }); } /** @@ -378,8 +414,14 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene .anchorRecommend("10", new com.yunbao.common.http.base.HttpCallback() { @Override public void onSuccess(AnchorRecommendModel data) { + if (data.getListShow() == 1) { + floatBanner.setVisibility(View.VISIBLE); + floatBanner.showBanner(data.getList()); + } else { + floatBanner.setVisibility(View.GONE); + } fragment.dismiss(); - floatBanner.showBanner(data.getList()); + } diff --git a/main/src/main/java/com/yunbao/main/views/FloatBannerView.java b/main/src/main/java/com/yunbao/main/views/FloatBannerView.java new file mode 100644 index 000000000..fd381f47c --- /dev/null +++ b/main/src/main/java/com/yunbao/main/views/FloatBannerView.java @@ -0,0 +1,140 @@ +package com.yunbao.main.views; + +import android.content.Context; +import android.graphics.Canvas; +import android.os.Handler; +import android.util.AttributeSet; +import android.view.View; +import android.view.ViewGroup; +import android.view.animation.AlphaAnimation; +import android.view.animation.Animation; +import android.view.animation.TranslateAnimation; +import android.widget.FrameLayout; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.ViewFlipper; + +import com.yunbao.common.R; +import com.yunbao.common.bean.AnchorRecommendItemModel; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.views.weight.ClipPathCircleImage; + +import java.util.List; + +/** + * 首页精彩推荐banner自定义组件 + */ +public class FloatBannerView extends FrameLayout { + private View rootView; + private LinearLayout rootLayout; + private ViewFlipper homeBanner; + private FrameLayout bannerLayout1, bannerLayout2, bannerLayout3; + private ClipPathCircleImage clipImage1, clipImage2, clipImage3; + private List list; + //默认定时器时间 + private int delayMillis = 800; + //Handler定时加载下一张的数据 + private Handler bannerHandler = new Handler(); + private int index = 0; + private String Uid; + + public FloatBannerView(Context context) { + super(context); + } + + public FloatBannerView(Context context, AttributeSet attrs) { + super(context, attrs); + rootView = View.inflate(context, R.layout.view_home_float_banner, this); + //banner_layout3 + clipImage3 = rootView.findViewById(R.id.clip_image3); + clipImage2 = rootView.findViewById(R.id.clip_image2); + clipImage1 = rootView.findViewById(R.id.clip_image1); + bannerLayout1 = rootView.findViewById(R.id.banner_layout1); + bannerLayout2 = rootView.findViewById(R.id.banner_layout2); + bannerLayout3 = rootView.findViewById(R.id.banner_layout3); + + } + + @Override + protected void onDraw(Canvas canvas) { + + super.onDraw(canvas); + } + + public String getUid() { + return Uid; + } + + /** + * 设置轮播数据 + * + * @param list + */ + public void showBanner(List list) { + this.list = list; + bannerHandler.post(mFlipRunnable); + + } + + + private final Runnable mFlipRunnable = new Runnable() { + @Override + public void run() { + if (index == list.size()) { + index = 0; + } + int next = index + 1; + next =( next == list.size() ? 0 : next); + Uid = String.valueOf(list.get(next).getUid()); + ImgLoader.displayAvatar(getContext(), list.get(index).getAvatar(), clipImage3); + ImgLoader.displayAvatar(getContext(), list.get(next).getAvatar(), clipImage2); + ImgLoader.displayAvatar(getContext(), list.get(index).getAvatar(), clipImage1); + Animation animation = new TranslateAnimation(0, -40, 0, 0); + animation.setFillAfter(true); + animation.setDuration(700); + + Animation animation2 = new AlphaAnimation(1, 0); + animation2.setFillAfter(true); + animation2.setDuration(800); + + animation.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + + } + + @Override + public void onAnimationEnd(Animation animation) { + bannerLayout3.clearAnimation(); + bannerLayout1.startAnimation(animation2); + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + }); + + animation2.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + + } + + @Override + public void onAnimationEnd(Animation animation) { + bannerLayout1.clearAnimation(); + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + }); + bannerLayout3.startAnimation(animation); + index = index + 1; + bannerHandler.postDelayed(mFlipRunnable, delayMillis); + } + }; + +} diff --git a/main/src/main/res/layout/view_homemain.xml b/main/src/main/res/layout/view_homemain.xml index a129af697..0ffb076c8 100644 --- a/main/src/main/res/layout/view_homemain.xml +++ b/main/src/main/res/layout/view_homemain.xml @@ -173,14 +173,23 @@ android:layout_weight="1" /> - + android:visibility="visible" /> +