修改测试问题,shouye ytuijian
This commit is contained in:
parent
cec82501db
commit
aa3be0a4e9
@ -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<AnchorRecommendItemModel> 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<AnchorRecommendItemModel> 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();
|
||||
}
|
||||
}
|
@ -2,6 +2,8 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="123dp"
|
||||
android:layout_height="35.33dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<RelativeLayout
|
||||
@ -15,15 +17,58 @@
|
||||
android:paddingEnd="7dp"
|
||||
android:paddingBottom="5dp" />
|
||||
|
||||
<ViewFlipper
|
||||
android:id="@+id/banner"
|
||||
<FrameLayout
|
||||
android:id="@+id/banner_layout2"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="25dp" />
|
||||
android:layout_marginStart="25dp"
|
||||
android:background="@drawable/bg_white_clip"
|
||||
android:visibility="visible">
|
||||
|
||||
<com.yunbao.common.views.weight.ClipPathCircleImage
|
||||
android:id="@+id/clip_image2"
|
||||
android:layout_width="23.5dp"
|
||||
android:layout_height="23.5dp"
|
||||
|
||||
android:layout_gravity="center" />
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/banner_layout3"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="25dp"
|
||||
android:background="@drawable/bg_white_clip">
|
||||
|
||||
<com.yunbao.common.views.weight.ClipPathCircleImage
|
||||
android:id="@+id/clip_image3"
|
||||
android:layout_width="23.5dp"
|
||||
android:layout_height="23.5dp"
|
||||
android:layout_gravity="center" />
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/banner_layout1"
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="10dp"
|
||||
android:background="@drawable/bg_white_clip"
|
||||
android:visibility="visible">
|
||||
|
||||
<com.yunbao.common.views.weight.ClipPathCircleImage
|
||||
android:id="@+id/clip_image1"
|
||||
android:layout_width="26.5dp"
|
||||
android:layout_height="26.5dp"
|
||||
android:layout_gravity="center" />
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
|
@ -15,6 +15,7 @@ import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
@ -31,6 +32,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.android.billingclient.api.Purchase;
|
||||
import com.android.billingclient.api.SkuDetails;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.imsdk.v2.V2TIMCallback;
|
||||
@ -46,6 +48,7 @@ import com.yunbao.common.bean.AnchorRecommendModel;
|
||||
import com.yunbao.common.bean.ChatRemarksBean;
|
||||
import com.yunbao.common.bean.ConfigBean;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.LiveInfoModel;
|
||||
import com.yunbao.common.bean.LiveSvgGiftBean;
|
||||
import com.yunbao.common.bean.UpdataListBean;
|
||||
import com.yunbao.common.custom.TabButtonGroup;
|
||||
@ -58,6 +61,7 @@ import com.yunbao.common.event.RongIMConnectionStatusEvent;
|
||||
import com.yunbao.common.event.UpdateTablePointMe;
|
||||
import com.yunbao.common.http.CommonHttpConsts;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.http.main.MainNetManager;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
@ -76,7 +80,9 @@ import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.VersionUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.AbsMainViewHolder;
|
||||
import com.yunbao.common.views.weight.FloatBannerView;
|
||||
import com.yunbao.live.activity.LiveAudienceActivity;
|
||||
import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.main.views.FloatBannerView;
|
||||
import com.yunbao.live.bean.LiveBean;
|
||||
import com.yunbao.live.http.LiveHttpConsts;
|
||||
import com.yunbao.live.http.LiveHttpUtil;
|
||||
@ -364,7 +370,37 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
mTabButtonGroup.setCurPosition(0);
|
||||
isInstructor();
|
||||
initAnchorRecommendBanner();
|
||||
findViewById(R.id.banner_click).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String Uid = floatBanner.getUid();
|
||||
LiveNetManager.get(mContext)
|
||||
.getLiveInfo(String.valueOf(Uid), new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() {
|
||||
@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<AnchorRecommendModel>() {
|
||||
@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());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
140
main/src/main/java/com/yunbao/main/views/FloatBannerView.java
Normal file
140
main/src/main/java/com/yunbao/main/views/FloatBannerView.java
Normal file
@ -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<AnchorRecommendItemModel> 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<AnchorRecommendItemModel> 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);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
@ -173,14 +173,23 @@
|
||||
android:layout_weight="1" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.yunbao.common.views.weight.FloatBannerView
|
||||
<com.yunbao.main.views.FloatBannerView
|
||||
android:id="@+id/float_banner_home"
|
||||
android:layout_above="@id/rt_main_tab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/rt_main_tab"
|
||||
android:layout_alignParentRight="true"
|
||||
android:visibility="gone"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_height="wrap_content" />
|
||||
android:visibility="visible" />
|
||||
|
||||
<View
|
||||
android:id="@+id/banner_click"
|
||||
android:layout_width="123dp"
|
||||
android:layout_height="35.33dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:layout_above="@id/rt_main_tab"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="10dp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user