直播关闭
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package com.yunbao.common.views.weight;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
|
||||
/**
|
||||
* 圓形圖片
|
||||
*/
|
||||
public class ClipPathCircleImage extends ImageView {
|
||||
private int width;
|
||||
private int height;
|
||||
private Path path;
|
||||
|
||||
public ClipPathCircleImage(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
path = new Path();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
canvas.save();
|
||||
path.reset();
|
||||
path.addCircle(width / 2, height / 2, width / 2, Path.Direction.CCW);//CCW:逆时针,这里是一个简单的园,无影响
|
||||
canvas.clipPath(path);
|
||||
super.onDraw(canvas);
|
||||
canvas.restore();
|
||||
//使用Path时,如果不与Paint进行共同操作,无法解决抗锯齿问题。
|
||||
//这时候只能使用Paint的PorterDuff.Mode替代Path实现所需要的效果
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
width = w;
|
||||
height = h;
|
||||
}
|
||||
|
||||
public ClipPathCircleImage(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
this(context, attrs, defStyleAttr, 0);
|
||||
}
|
||||
|
||||
public ClipPathCircleImage(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public ClipPathCircleImage(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
7
common/src/main/res/anim/vice_banner_come_in.xml
Normal file
7
common/src/main/res/anim/vice_banner_come_in.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<alpha
|
||||
android:duration="700"
|
||||
android:fromXDelta="100%p"
|
||||
android:toXDelta="0%p" />
|
||||
</set>
|
||||
8
common/src/main/res/anim/vice_screen_come_out.xml
Normal file
8
common/src/main/res/anim/vice_screen_come_out.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<alpha
|
||||
android:duration="1500"
|
||||
android:fromAlpha="1.0"
|
||||
android:toAlpha="0.0" />
|
||||
</set>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="20dp" />
|
||||
<gradient android:angle="360" android:endColor="#f249A6FC" android:startColor="#f2D480FF" />
|
||||
</shape>
|
||||
|
||||
</item>
|
||||
</selector>
|
||||
5
common/src/main/res/drawable/bg_white_clip.xml
Normal file
5
common/src/main/res/drawable/bg_white_clip.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="60dp" />
|
||||
<solid android:color="@color/white" />
|
||||
</shape>
|
||||
36
common/src/main/res/layout/view_home_float_banner.xml
Normal file
36
common/src/main/res/layout/view_home_float_banner.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="123dp"
|
||||
android:layout_height="35.33dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="123dp"
|
||||
android:layout_height="35.33dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:background="@drawable/background_new_home_folat_banner"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="7dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingEnd="7dp"
|
||||
android:paddingBottom="5dp" />
|
||||
|
||||
<ViewFlipper
|
||||
android:id="@+id/banner"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="25dp" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:text="@string/wonderful_live"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="9sp" />
|
||||
</RelativeLayout>
|
||||
34
common/src/main/res/layout/view_home_float_banner_item.xml
Normal file
34
common/src/main/res/layout/view_home_float_banner_item.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/root_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/banner_layout2"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@drawable/bg_white_clip">
|
||||
|
||||
<com.yunbao.common.views.weight.ClipPathCircleImage
|
||||
android:id="@+id/clip_image"
|
||||
android:layout_width="23.5dp"
|
||||
android:layout_height="23.5dp"
|
||||
android:layout_gravity="center" />
|
||||
</FrameLayout>
|
||||
|
||||
<!-- <FrameLayout-->
|
||||
<!-- android:id="@+id/banner_layout"-->
|
||||
<!-- android:layout_width="30dp"-->
|
||||
<!-- android:layout_height="30dp"-->
|
||||
|
||||
<!-- android:background="@drawable/bg_white_clip">-->
|
||||
|
||||
<!-- <com.yunbao.common.views.weight.ClipPathCircleImage-->
|
||||
<!-- android:id="@+id/banner_layout_image"-->
|
||||
<!-- android:layout_width="29dp"-->
|
||||
<!-- android:layout_height="29dp"-->
|
||||
<!-- android:layout_gravity="center" />-->
|
||||
<!-- </FrameLayout>-->
|
||||
</FrameLayout>
|
||||
@@ -870,4 +870,5 @@
|
||||
<string name="you_may_also_like">猜你喜歡</string>
|
||||
<string name="anchor">主播</string>
|
||||
<string name="anchor_more">更多</string>
|
||||
<string name="wonderful_live">精彩直播</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user