版本优化:一些细节处理
This commit is contained in:
@@ -745,7 +745,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
|||||||
if (firstCharmRankUser.getUid() == 0) return;
|
if (firstCharmRankUser.getUid() == 0) return;
|
||||||
EventBus.getDefault().post(new ShowUserInfoDialogEvent(String.valueOf(firstCharmRankUser.getUid())));
|
EventBus.getDefault().post(new ShowUserInfoDialogEvent(String.valueOf(firstCharmRankUser.getUid())));
|
||||||
});
|
});
|
||||||
tvNickCharm.setText(StringExtensionKt.subAndReplaceDot(firstCharmRankUser.getNick(), 7));
|
tvNickCharm.setText(StringExtensionKt.subAndReplaceDot(firstCharmRankUser.getNick(), 6));
|
||||||
} else {
|
} else {
|
||||||
ivAvatarCharm.setOnClickListener(null);
|
ivAvatarCharm.setOnClickListener(null);
|
||||||
ivAvatarCharm.setImageResource(R.drawable.default_avatar);
|
ivAvatarCharm.setImageResource(R.drawable.default_avatar);
|
||||||
@@ -759,7 +759,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
|||||||
if (firstLevelRankUser.getUid() == 0) return;
|
if (firstLevelRankUser.getUid() == 0) return;
|
||||||
EventBus.getDefault().post(new ShowUserInfoDialogEvent(String.valueOf(firstLevelRankUser.getUid())));
|
EventBus.getDefault().post(new ShowUserInfoDialogEvent(String.valueOf(firstLevelRankUser.getUid())));
|
||||||
});
|
});
|
||||||
tvNickLevel.setText(StringExtensionKt.subAndReplaceDot(firstLevelRankUser.getNick(), 7));
|
tvNickLevel.setText(StringExtensionKt.subAndReplaceDot(firstLevelRankUser.getNick(), 6));
|
||||||
} else {
|
} else {
|
||||||
ivAvatarLevel.setOnClickListener(null);
|
ivAvatarLevel.setOnClickListener(null);
|
||||||
ivAvatarLevel.setImageResource(R.drawable.default_avatar);
|
ivAvatarLevel.setImageResource(R.drawable.default_avatar);
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package com.mango.moshen.ui.widget.drawgift;
|
package com.mango.moshen.ui.widget.drawgift;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
@@ -15,21 +16,16 @@ import java.util.List;
|
|||||||
|
|
||||||
public class DrawGiftPlayView extends View {
|
public class DrawGiftPlayView extends View {
|
||||||
|
|
||||||
|
private static final int DRAW_ONE_GIFT = 0;
|
||||||
//需要被画上的全部的礼物,采用链表的方式,每次取第0个
|
//需要被画上的全部的礼物,采用链表的方式,每次取第0个
|
||||||
private final LinkedList<List<DrawGiftModel>> allDrawGiftsLinkedList;
|
private final LinkedList<List<DrawGiftModel>> allDrawGiftsLinkedList;
|
||||||
|
//为了体现最后的消失动画效果,才引入了这个Paint
|
||||||
|
private final Paint mPaint = new Paint();
|
||||||
|
private final Handler mHandler;
|
||||||
|
;
|
||||||
//当前这幅画播放到第几个礼物
|
//当前这幅画播放到第几个礼物
|
||||||
private int currentGiftShowIndex;
|
private int currentGiftShowIndex;
|
||||||
|
|
||||||
private DrawAnimationListener onDrawAnimationListener;
|
private DrawAnimationListener onDrawAnimationListener;
|
||||||
|
|
||||||
//为了体现最后的消失动画效果,才引入了这个Paint
|
|
||||||
private final Paint mPaint = new Paint();;
|
|
||||||
|
|
||||||
private static final int DRAW_ONE_GIFT = 0;
|
|
||||||
|
|
||||||
private final Handler mHandler;
|
|
||||||
|
|
||||||
private final Handler.Callback mCallback = new Handler.Callback() {
|
private final Handler.Callback mCallback = new Handler.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public boolean handleMessage(Message msg) {
|
public boolean handleMessage(Message msg) {
|
||||||
@@ -39,17 +35,16 @@ public class DrawGiftPlayView extends View {
|
|||||||
currentGiftShowIndex = msg.arg1;
|
currentGiftShowIndex = msg.arg1;
|
||||||
invalidate();
|
invalidate();
|
||||||
|
|
||||||
if (currentGiftShowIndex == allDrawGiftsLinkedList.getFirst().size()){
|
if (currentGiftShowIndex == allDrawGiftsLinkedList.getFirst().size()) {
|
||||||
//进入这里,说明已经播放完最后一个礼物了
|
postDelayed(() -> {
|
||||||
//播放扩大动画,然后消失
|
//进入这里,说明已经播放完最后一个礼物了
|
||||||
ValueAnimator valueAnimator = ValueAnimator.ofFloat(1, 2);
|
//播放扩大动画,然后消失
|
||||||
valueAnimator.setDuration(500);
|
ValueAnimator valueAnimator = ValueAnimator.ofFloat(1, 2);
|
||||||
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
valueAnimator.setDuration(500);
|
||||||
@Override
|
valueAnimator.addUpdateListener(animation -> {
|
||||||
public void onAnimationUpdate(ValueAnimator animation) {
|
|
||||||
float p = (float) animation.getAnimatedValue();
|
float p = (float) animation.getAnimatedValue();
|
||||||
//透明效果(所有礼物都做这个动作)
|
//透明效果(所有礼物都做这个动作)
|
||||||
mPaint.setAlpha((int)((2.0F - p) * 255));
|
mPaint.setAlpha((int) ((2.0F - p) * 255));
|
||||||
//放大效果(所有礼物都做这个动作)
|
//放大效果(所有礼物都做这个动作)
|
||||||
for (DrawGiftModel giftModel : allDrawGiftsLinkedList.getFirst()) {
|
for (DrawGiftModel giftModel : allDrawGiftsLinkedList.getFirst()) {
|
||||||
|
|
||||||
@@ -59,54 +54,39 @@ public class DrawGiftPlayView extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
});
|
||||||
});
|
valueAnimator.addListener(new AnimatorListenerAdapter() {
|
||||||
valueAnimator.addListener(new Animator.AnimatorListener(){
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationStart(Animator animation) {
|
public void onAnimationEnd(Animator animation) {
|
||||||
|
//放大动画结束
|
||||||
|
mPaint.reset();
|
||||||
|
|
||||||
}
|
currentGiftShowIndex = 0;
|
||||||
|
allDrawGiftsLinkedList.removeFirst();
|
||||||
|
|
||||||
@Override
|
if (onDrawAnimationListener != null) {
|
||||||
public void onAnimationEnd(Animator animation) {
|
//当前的这一幅画结束
|
||||||
//放大动画结束
|
onDrawAnimationListener.onAnimationNodeEnd(DrawGiftPlayView.this);
|
||||||
mPaint.reset();
|
|
||||||
|
|
||||||
currentGiftShowIndex = 0;
|
if (allDrawGiftsLinkedList.isEmpty()) {
|
||||||
allDrawGiftsLinkedList.removeFirst();
|
//所有画全部结束
|
||||||
|
onDrawAnimationListener.onAnimationAllOver(DrawGiftPlayView.this);
|
||||||
|
} else {
|
||||||
|
//还有画没播完,继续画下一幅画
|
||||||
|
//要先清理掉画布上的上一幅画
|
||||||
|
invalidate();
|
||||||
|
|
||||||
if (onDrawAnimationListener != null) {
|
Message message = Message.obtain();
|
||||||
//当前的这一幅画结束
|
message.arg1 = 0;
|
||||||
onDrawAnimationListener.onAnimationNodeEnd(DrawGiftPlayView.this);
|
message.what = DRAW_ONE_GIFT;
|
||||||
|
mHandler.sendMessageDelayed(message, 50);
|
||||||
if (allDrawGiftsLinkedList.isEmpty()){
|
}
|
||||||
//所有画全部结束
|
|
||||||
onDrawAnimationListener.onAnimationAllOver(DrawGiftPlayView.this);
|
|
||||||
} else {
|
|
||||||
//还有画没播完,继续画下一幅画
|
|
||||||
//要先清理掉画布上的上一幅画
|
|
||||||
invalidate();
|
|
||||||
|
|
||||||
Message message = Message.obtain();
|
|
||||||
message.arg1 = 0;
|
|
||||||
message.what = DRAW_ONE_GIFT;
|
|
||||||
mHandler.sendMessageDelayed(message, 50);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
valueAnimator.start();
|
||||||
@Override
|
}, 1000);
|
||||||
public void onAnimationCancel(Animator animation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnimationRepeat(Animator animation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
valueAnimator.start();
|
|
||||||
} else {
|
} else {
|
||||||
//继续画下一个礼物
|
//继续画下一个礼物
|
||||||
Message message = Message.obtain();
|
Message message = Message.obtain();
|
||||||
@@ -145,16 +125,16 @@ public class DrawGiftPlayView extends View {
|
|||||||
super.onDraw(canvas);
|
super.onDraw(canvas);
|
||||||
|
|
||||||
int size = allDrawGiftsLinkedList.getFirst().size();
|
int size = allDrawGiftsLinkedList.getFirst().size();
|
||||||
for(int i = 0; i <= currentGiftShowIndex && i < size; i++) {
|
for (int i = 0; i <= currentGiftShowIndex && i < size; i++) {
|
||||||
DrawGiftModel giftModel = allDrawGiftsLinkedList.getFirst().get(i);
|
DrawGiftModel giftModel = allDrawGiftsLinkedList.getFirst().get(i);
|
||||||
canvas.drawBitmap(giftModel.getGiftBitmap(), giftModel.getMatrix(), mPaint);
|
canvas.drawBitmap(giftModel.getGiftBitmap(), giftModel.getMatrix(), mPaint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDrawGifts(List<DrawGiftModel> currentDrawGiftArray, boolean insertToFirst){
|
public void addDrawGifts(List<DrawGiftModel> currentDrawGiftArray, boolean insertToFirst) {
|
||||||
|
|
||||||
//处理每个小bitmap的大小和位置
|
//处理每个小bitmap的大小和位置
|
||||||
for(int i = 0; i < currentDrawGiftArray.size(); i++) {
|
for (int i = 0; i < currentDrawGiftArray.size(); i++) {
|
||||||
DrawGiftModel giftModel = currentDrawGiftArray.get(i);
|
DrawGiftModel giftModel = currentDrawGiftArray.get(i);
|
||||||
|
|
||||||
giftModel.getMatrix().reset();
|
giftModel.getMatrix().reset();
|
||||||
@@ -162,8 +142,8 @@ public class DrawGiftPlayView extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//添加到队列
|
//添加到队列
|
||||||
if (insertToFirst){
|
if (insertToFirst) {
|
||||||
if (allDrawGiftsLinkedList.size() > 0){
|
if (allDrawGiftsLinkedList.size() > 0) {
|
||||||
//说明队列里已经有画在draw了。
|
//说明队列里已经有画在draw了。
|
||||||
//由于我目前的逻辑是:取first节点,画完了再remove;而不是先remove再设置为全局变量。所以要插入到第1个元素
|
//由于我目前的逻辑是:取first节点,画完了再remove;而不是先remove再设置为全局变量。所以要插入到第1个元素
|
||||||
allDrawGiftsLinkedList.add(1, currentDrawGiftArray);
|
allDrawGiftsLinkedList.add(1, currentDrawGiftArray);
|
||||||
@@ -176,11 +156,11 @@ public class DrawGiftPlayView extends View {
|
|||||||
allDrawGiftsLinkedList.offerLast(currentDrawGiftArray);
|
allDrawGiftsLinkedList.offerLast(currentDrawGiftArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allDrawGiftsLinkedList.size() == 1){
|
if (allDrawGiftsLinkedList.size() == 1) {
|
||||||
//刚插入完,size==1,说明是刚开始,这时候要开始播放
|
//刚插入完,size==1,说明是刚开始,这时候要开始播放
|
||||||
List<DrawGiftModel> firstDrawGiftArray = this.allDrawGiftsLinkedList.getFirst();
|
List<DrawGiftModel> firstDrawGiftArray = this.allDrawGiftsLinkedList.getFirst();
|
||||||
|
|
||||||
if (firstDrawGiftArray != null){
|
if (firstDrawGiftArray != null) {
|
||||||
//说明有需要播放的,开始draw
|
//说明有需要播放的,开始draw
|
||||||
Message message = Message.obtain();
|
Message message = Message.obtain();
|
||||||
message.arg1 = 0;
|
message.arg1 = 0;
|
||||||
@@ -191,7 +171,7 @@ public class DrawGiftPlayView extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttachedToWindow(){
|
public void onAttachedToWindow() {
|
||||||
super.onAttachedToWindow();
|
super.onAttachedToWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,9 +187,10 @@ public class DrawGiftPlayView extends View {
|
|||||||
this.onDrawAnimationListener = onDrawAnimationListener;
|
this.onDrawAnimationListener = onDrawAnimationListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface DrawAnimationListener{
|
public interface DrawAnimationListener {
|
||||||
//礼物动画全部结束
|
//礼物动画全部结束
|
||||||
public void onAnimationNodeEnd(DrawGiftPlayView drawGiftPlayView);
|
public void onAnimationNodeEnd(DrawGiftPlayView drawGiftPlayView);
|
||||||
|
|
||||||
//礼物动画当前的这一幅画结束
|
//礼物动画当前的这一幅画结束
|
||||||
public void onAnimationAllOver(DrawGiftPlayView drawGiftPlayView);
|
public void onAnimationAllOver(DrawGiftPlayView drawGiftPlayView);
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 13 KiB |
@@ -95,7 +95,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="12dp"
|
android:layout_marginStart="12dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="本周该礼物冠名者"
|
android:text="该礼物冠名者"
|
||||||
android:textColor="@color/color_333333"
|
android:textColor="@color/color_333333"
|
||||||
android:textSize="10sp" />
|
android:textSize="10sp" />
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="12dp"
|
android:layout_marginStart="12dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="本周该礼物周星神豪"
|
android:text="该礼物周星神豪"
|
||||||
android:textColor="@color/color_333333"
|
android:textColor="@color/color_333333"
|
||||||
android:textSize="10sp" />
|
android:textSize="10sp" />
|
||||||
|
|
||||||
|
@@ -84,38 +84,6 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/ll_room_pk_order"
|
|
||||||
android:layout_width="72dp"
|
|
||||||
android:layout_height="72dp"
|
|
||||||
android:layout_below="@id/contribute_list"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:background="@drawable/bg_room_pk_order"
|
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="17dp"
|
|
||||||
android:includeFontPadding="false"
|
|
||||||
android:text="下一场PK"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
android:textSize="10sp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_room_pk_order_time"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="2dp"
|
|
||||||
android:includeFontPadding="false"
|
|
||||||
android:textColor="#fffff333"
|
|
||||||
android:textSize="10sp"
|
|
||||||
tools:text="04:55" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<com.mango.moshen.ui.widget.rollviewpager.RollPagerView
|
<com.mango.moshen.ui.widget.rollviewpager.RollPagerView
|
||||||
android:id="@+id/pager_view_wish_list"
|
android:id="@+id/pager_view_wish_list"
|
||||||
@@ -155,6 +123,39 @@
|
|||||||
android:src="@drawable/icon_music_flag"
|
android:src="@drawable/icon_music_flag"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/ll_room_pk_order"
|
||||||
|
android:layout_width="72dp"
|
||||||
|
android:layout_height="72dp"
|
||||||
|
android:layout_below="@id/tv_hour_rank"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:background="@drawable/bg_room_pk_order"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="17dp"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:text="下一场PK"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="10sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_room_pk_order_time"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:textColor="#fffff333"
|
||||||
|
android:textSize="10sp"
|
||||||
|
tools:text="04:55" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/ll_dating_step"
|
android:id="@+id/ll_dating_step"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
Reference in New Issue
Block a user