首页底部Tab增加SVGA切换效果支持
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.yizhuan.erban.avroom.widget;
|
||||
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_VIP_ROOM_BROADCAST;
|
||||
|
||||
import android.animation.Keyframe;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.PropertyValuesHolder;
|
||||
@@ -23,6 +25,8 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.netease.nim.uikit.api.NimUIKit;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.netease.nimlib.sdk.msg.model.RecentContact;
|
||||
import com.netease.nimlib.sdk.uinfo.model.UserInfo;
|
||||
import com.yizhuan.erban.R;
|
||||
@@ -31,8 +35,10 @@ import com.yizhuan.erban.ui.utils.ImageLoadUtils;
|
||||
import com.yizhuan.erban.vip.VipMainActivity;
|
||||
import com.yizhuan.tutu.room_chat.activity.RoomMsgActivity;
|
||||
import com.yizhuan.xchat_android_core.helper.ImHelperUtils;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.VipMessageAttachment;
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
|
||||
import com.yizhuan.xchat_android_core.manager.IMMessageManager;
|
||||
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
|
||||
import com.yizhuan.xchat_android_core.pay.event.FirstChargeEvent;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomModeType;
|
||||
|
@@ -293,6 +293,9 @@ public class RouterHandler {
|
||||
case RouterType.CP_WARE:
|
||||
MyDecorationActivity.start(context, 0);
|
||||
break;
|
||||
case RouterType.USER_BUBBLE:
|
||||
MyDecorationActivity.start(context, 4);
|
||||
break;
|
||||
default:
|
||||
SingleToastUtil.showToast("暂不支持哟!");
|
||||
return false;
|
||||
|
@@ -3,7 +3,6 @@ package com.yizhuan.erban.ui.widget;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -13,10 +12,19 @@ import androidx.annotation.Nullable;
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||
import com.netease.nim.uikit.common.ui.draggablebubbles.BubbleView;
|
||||
import com.netease.nim.uikit.support.glide.GlideApp;
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.common.svga.SimpleSvgaCallback;
|
||||
import com.yizhuan.xchat_android_core.home.bean.MainTabInfo;
|
||||
import com.yizhuan.xchat_android_core.home.bean.MainTabType;
|
||||
import com.yizhuan.xchat_android_core.utils.CheckUtils;
|
||||
import com.yizhuan.xchat_android_core.utils.TextUtils;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* <p> main tab 有消息个数 控件
|
||||
@@ -24,7 +32,7 @@ import com.yizhuan.xchat_android_core.utils.CheckUtils;
|
||||
* Created by Administrator on 2017/11/14.
|
||||
*/
|
||||
public class MainRedPointTab extends RelativeLayout {
|
||||
private final ImageView ivTabIcon;
|
||||
private final SVGAImageView ivTabIcon;
|
||||
private final TextView tvTabName;
|
||||
private final TextView mTvNum;
|
||||
private MainTabInfo tabInfo;
|
||||
@@ -44,6 +52,12 @@ public class MainRedPointTab extends RelativeLayout {
|
||||
ivTabIcon = findViewById(R.id.iv_tab_icon);
|
||||
tvTabName = findViewById(R.id.tv_tab_name);
|
||||
mTvNum = findViewById(R.id.msg_number);
|
||||
ivTabIcon.setCallback(new SimpleSvgaCallback() {
|
||||
@Override
|
||||
public void onFinished() {
|
||||
updateIcon();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setMainTabInfo(@NonNull MainTabInfo tabInfo) {
|
||||
@@ -60,8 +74,47 @@ public class MainRedPointTab extends RelativeLayout {
|
||||
if (tabInfo == null) return;
|
||||
tvTabName.setSelected(select);
|
||||
isSelected = select;
|
||||
int defaultRes = getDefaultRes(tabInfo.getTabType(), select);
|
||||
GlideApp.with(ivTabIcon).load(select ? tabInfo.getTabSelectedIcon() : tabInfo.getTabIcon())
|
||||
if (!TextUtils.isEmptyText(tabInfo.getTabSelectedAnimation()) && select) {
|
||||
URL url = null;
|
||||
try {
|
||||
url = new URL(tabInfo.getTabSelectedAnimation());
|
||||
} catch (MalformedURLException e) {
|
||||
updateIcon();
|
||||
}
|
||||
if (url == null) {
|
||||
updateIcon();
|
||||
} else {
|
||||
SVGAParser.Companion.shareParser()
|
||||
.decodeFromURL(
|
||||
url,
|
||||
new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(@NonNull SVGAVideoEntity svgaVideoEntity) {
|
||||
SVGADrawable drawable = new SVGADrawable(svgaVideoEntity);
|
||||
ivTabIcon.setLoops(1);
|
||||
ivTabIcon.setImageDrawable(drawable);
|
||||
ivTabIcon.startAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
updateIcon();
|
||||
}
|
||||
}, list -> {
|
||||
|
||||
});
|
||||
}
|
||||
} else {
|
||||
updateIcon();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateIcon() {
|
||||
if (tabInfo == null) return;
|
||||
ivTabIcon.stopAnimation();
|
||||
int defaultRes = getDefaultRes(tabInfo.getTabType(), isSelected);
|
||||
GlideApp.with(ivTabIcon).load(isSelected ? tabInfo.getTabSelectedIcon() : tabInfo.getTabIcon())
|
||||
.dontAnimate()
|
||||
.placeholder(defaultRes)
|
||||
.error(defaultRes)
|
||||
|
@@ -1,10 +1,12 @@
|
||||
package com.yizhuan.erban.vip
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.FrameLayout
|
||||
import androidx.core.animation.doOnEnd
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.Observer
|
||||
@@ -47,11 +49,35 @@ class VipBroadcastView @JvmOverloads constructor(
|
||||
|
||||
private fun addMessage(chatRoomMessage: ChatRoomMessage) {
|
||||
messages.add(chatRoomMessage)
|
||||
isVisible = true
|
||||
if (isGone) {
|
||||
isVisible = true
|
||||
ObjectAnimator.ofFloat(
|
||||
this,
|
||||
"alpha",
|
||||
0f,
|
||||
1f
|
||||
)
|
||||
.setDuration(200)
|
||||
.start()
|
||||
}
|
||||
if (disposable == null || messages.size == 1) {
|
||||
disposable = Observable.interval(0, 5, TimeUnit.SECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnDispose { isGone = true }
|
||||
.doOnDispose {
|
||||
ObjectAnimator.ofFloat(
|
||||
this,
|
||||
"alpha",
|
||||
1f,
|
||||
0f
|
||||
)
|
||||
.setDuration(200)
|
||||
.apply {
|
||||
doOnEnd {
|
||||
isGone = true
|
||||
}
|
||||
}
|
||||
.start()
|
||||
}
|
||||
.takeWhile { messages.size > 0 }
|
||||
.subscribe {
|
||||
showMessage(messages.removeAt(0))
|
||||
|
@@ -14,7 +14,7 @@
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
<com.opensource.svgaplayer.SVGAImageView
|
||||
android:id="@+id/iv_tab_icon"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
|
@@ -200,7 +200,7 @@
|
||||
android:id="@+id/activity_img"
|
||||
android:layout_width="65dp"
|
||||
android:layout_height="70dp"
|
||||
android:layout_alignTop="@id/message_view"
|
||||
android:layout_below="@id/micro_view"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginTop="@dimen/dp_5"
|
||||
android:layout_marginEnd="16dp"
|
||||
|
@@ -4,5 +4,6 @@ data class MainTabInfo(
|
||||
val tabIcon: String = "",
|
||||
val tabSelectedIcon: String = "",
|
||||
val tabName: String = "",
|
||||
val tabType: Int = 0
|
||||
val tabType: Int = 0,
|
||||
val tabSelectedAnimation: String? = null
|
||||
)
|
@@ -214,4 +214,10 @@ public class RouterType {
|
||||
*/
|
||||
|
||||
public static final int CP_WARE = 63;
|
||||
|
||||
|
||||
/**
|
||||
* 65-资料卡装扮
|
||||
*/
|
||||
public static final int USER_BUBBLE = 56;
|
||||
}
|
||||
|
@@ -437,31 +437,36 @@ public class InitialModel extends BaseModel implements IInitialModel {
|
||||
"",
|
||||
"",
|
||||
"派对",
|
||||
MainTabType.TAB_TYPE_HOME
|
||||
MainTabType.TAB_TYPE_HOME,
|
||||
null
|
||||
),
|
||||
new MainTabInfo(
|
||||
"",
|
||||
"",
|
||||
"广场",
|
||||
MainTabType.TAB_TYPE_SQUARE
|
||||
MainTabType.TAB_TYPE_SQUARE,
|
||||
null
|
||||
),
|
||||
new MainTabInfo(
|
||||
"",
|
||||
"",
|
||||
"赛事",
|
||||
MainTabType.TAB_TYPE_GAME
|
||||
MainTabType.TAB_TYPE_GAME,
|
||||
null
|
||||
),
|
||||
new MainTabInfo(
|
||||
"",
|
||||
"",
|
||||
"消息",
|
||||
MainTabType.TAB_TYPE_MSG
|
||||
MainTabType.TAB_TYPE_MSG,
|
||||
null
|
||||
),
|
||||
new MainTabInfo(
|
||||
"",
|
||||
"",
|
||||
"我的",
|
||||
MainTabType.TAB_TYPE_ME
|
||||
MainTabType.TAB_TYPE_ME,
|
||||
null
|
||||
)
|
||||
));
|
||||
}
|
||||
|
Reference in New Issue
Block a user