盲盒礼物开箱动画
This commit is contained in:
parent
b0008405e2
commit
db165cc05d
@ -20,6 +20,28 @@ public class BlindBoxInfoModel extends BaseModel {
|
||||
private String blindBoxType;
|
||||
@SerializedName("blind_box_id")
|
||||
private String blindBoxId;
|
||||
@SerializedName("blind_box_swf")
|
||||
private String blindBoxSwf;
|
||||
@SerializedName("threshold_effect_src")
|
||||
private String thresholdEffectSrc;
|
||||
|
||||
public String getThresholdEffectSrc() {
|
||||
return thresholdEffectSrc;
|
||||
}
|
||||
|
||||
public BlindBoxInfoModel setThresholdEffectSrc(String thresholdEffectSrc) {
|
||||
this.thresholdEffectSrc = thresholdEffectSrc;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBlindBoxSwf() {
|
||||
return blindBoxSwf;
|
||||
}
|
||||
|
||||
public BlindBoxInfoModel setBlindBoxSwf(String blindBoxSwf) {
|
||||
this.blindBoxSwf = blindBoxSwf;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getItemName() {
|
||||
return itemName;
|
||||
|
@ -40,6 +40,7 @@ import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.opensource.svgaplayer.SVGACallback;
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
@ -47,6 +48,7 @@ import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.BlindBoxInfoModel;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.LiveGiftBean;
|
||||
import com.yunbao.common.bean.LiveGiftBean2;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
@ -66,8 +68,10 @@ import com.yunbao.common.utils.NobleUtil;
|
||||
import com.yunbao.common.utils.SVGAViewUtils;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.activity.LiveActivity;
|
||||
import com.yunbao.live.activity.LiveAudienceActivity;
|
||||
import com.yunbao.live.adapter.GiftTopAdapter;
|
||||
import com.yunbao.live.adapter.LiveGiftCountAdapter;
|
||||
import com.yunbao.live.adapter.LiveGiftPagerAdapter;
|
||||
@ -83,6 +87,8 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -139,7 +145,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
|
||||
public int type = 0;
|
||||
private static String type_name = "熱門";
|
||||
JSONArray list;
|
||||
private ImageView mVipGoldIcon;
|
||||
private ImageView mVipGoldIcon, description;
|
||||
private TextView mVipGoldTitle;
|
||||
private TextView mVipGoldDesc;
|
||||
private TextView mGiftPackage, blindNumber, textBlindProgress, textBlindGiftName;
|
||||
@ -147,7 +153,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
|
||||
private int isContactGift = 0;
|
||||
DialogInterface.OnDismissListener onDismissListener;
|
||||
DialogInterface.OnShowListener onShowListener;
|
||||
private SVGAImageView blindSvga;
|
||||
private SVGAImageView blindSvga, blindBoxOpen;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@ -217,6 +223,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
|
||||
mArrow = mRootView.findViewById(R.id.arrow);
|
||||
iconMasking = mRootView.findViewById(R.id.icon_masking);
|
||||
blindSvga = mRootView.findViewById(R.id.blind_svga);
|
||||
blindBoxOpen = mRootView.findViewById(R.id.blind_box_open);
|
||||
mBtnSend = mRootView.findViewById(R.id.btn_send);
|
||||
mBtnSendGroup = mRootView.findViewById(R.id.btn_send_group);
|
||||
mBtnSendLian = mRootView.findViewById(R.id.btn_send_lian);
|
||||
@ -306,6 +313,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
|
||||
mTvGoldCoin.setOnClickListener(this);
|
||||
mVipGold = mRootView.findViewById(R.id.btn_luck_gift_tip);
|
||||
mVipGoldIcon = mRootView.findViewById(R.id.vipGoldIcon);
|
||||
description = mRootView.findViewById(R.id.description);
|
||||
mVipGoldTitle = mRootView.findViewById(R.id.vipGoldTitle);
|
||||
mVipGoldDesc = mRootView.findViewById(R.id.vipGoldDesc);
|
||||
mVipGold.setOnClickListener(this);
|
||||
@ -348,6 +356,23 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
|
||||
mVipGold.setVisibility(View.GONE);
|
||||
}
|
||||
getBlindBoxInfo();
|
||||
ViewClicksAntiShake.clicksAntiShake(description, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
|
||||
StringBuffer htmlUrl = new StringBuffer();
|
||||
htmlUrl.append(CommonAppConfig.HOST)
|
||||
.append("/h5/info/index.html?uid=")
|
||||
.append(userInfo.getId())
|
||||
.append("&token=")
|
||||
.append(userInfo.getToken());
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", htmlUrl.toString());
|
||||
LiveHDDialogFragment fragment = new LiveHDDialogFragment();
|
||||
fragment.setArguments(bundle);
|
||||
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<BlindBoxInfoModel> blindBoxInfoModels = new ArrayList<>();
|
||||
@ -744,7 +769,11 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
|
||||
}
|
||||
}
|
||||
if (model == null) return;
|
||||
new SVGAParser(mContext).decodeFromAssets("hdsn.svga", new SVGAParser.ParseCompletion() {
|
||||
blindBoxOpen.clear();
|
||||
blindBoxOpen.setVisibility(View.GONE);
|
||||
try {
|
||||
blindSvga.clear();
|
||||
new SVGAParser(mContext).parse(new URL(model.getThresholdEffectSrc()), new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(SVGAVideoEntity videoItem) {
|
||||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||||
@ -757,7 +786,10 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
|
||||
public void onError() {
|
||||
Log.e("errqs", "errl");
|
||||
}
|
||||
}, null);
|
||||
});
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mArrow.setVisibility(View.GONE);
|
||||
mBtnChooseCount.setEnabled(false);
|
||||
mVipGold.setVisibility(View.GONE);
|
||||
@ -1043,6 +1075,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onSendBlindGiftEvent(SendBlindGiftEvent event) {
|
||||
BlindBoxInfoModel model = null;
|
||||
@ -1053,8 +1086,53 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
|
||||
model = blindBoxInfoModels.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
long userID = IMLoginManager.get(mContext).getUserInfo().getId();
|
||||
String boxBlindName;
|
||||
try {
|
||||
if (!blindBoxOpen.isAnimating()) {
|
||||
new SVGAParser(mContext).parse(new URL(model.getBlindBoxSwf()), new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(SVGAVideoEntity videoItem) {
|
||||
blindBoxOpen.setVisibility(View.VISIBLE);
|
||||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||||
blindBoxOpen.setImageDrawable(drawable);
|
||||
blindBoxOpen.setLoops(1);
|
||||
blindBoxOpen.startAnimation();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
}
|
||||
});
|
||||
|
||||
blindBoxOpen.setCallback(new SVGACallback() {
|
||||
@Override
|
||||
public void onPause() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinished() {
|
||||
blindBoxOpen.clear();
|
||||
blindBoxOpen.setVisibility(View.GONE);
|
||||
Log.e("礼物盲盒", "结束播放");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRepeat() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStep(int i, double v) {
|
||||
Log.e("礼物盲盒", "onStep: frame " + i + " percentage " + v);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//判断送礼用户更新送礼用户进度
|
||||
if (TextUtils.equals(String.valueOf(userID), event.getUid()) && blindBoxType == Integer.parseInt(event.getBoxType())) {
|
||||
switch (blindBoxType) {
|
||||
@ -1159,7 +1237,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
|
||||
if (stringBuilders != null && stringBuilders.size() > 0) {
|
||||
SpannableStringBuilder stringBuilder = stringBuilders.get(0);
|
||||
textBlindGiftName.setText(stringBuilder);
|
||||
boxBlindHandler.postDelayed(boxBlindRunnable, 1100);
|
||||
boxBlindHandler.postDelayed(boxBlindRunnable, 1500);
|
||||
stringBuilders.remove(0);
|
||||
} else {
|
||||
textBlindGiftName.setText(String.format(mContext.getString(R.string.random_availability), blindGiftNamesBuffer.toString()));
|
||||
|
@ -343,7 +343,7 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
|
||||
dismiss();
|
||||
((LiveAudienceActivity) mContext).openGiftWindow();
|
||||
} else if (TextUtils.equals(event.getMethod(), "androidGoBack")) {
|
||||
// dismiss();
|
||||
dismiss();
|
||||
} else if (TextUtils.equals(event.getMethod(), "androidMethodLookToLive")) {
|
||||
if (mContext instanceof LiveRyAnchorActivity) {
|
||||
return;
|
||||
|
@ -1,7 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="170dp"
|
||||
android:layout_height="110dp">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_gravity="end"
|
||||
android:layout_width="159dp"
|
||||
android:layout_height="110dp"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
<!--凤凰,龙,麒麟-->
|
||||
@ -22,7 +28,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<com.yunbao.common.views.weight.ClipPathCircleImage
|
||||
<ImageView
|
||||
android:id="@+id/icon_masking"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@ -95,12 +101,15 @@
|
||||
android:textSize="8sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="13dp"
|
||||
android:layout_height="13dp"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="40dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:src="@mipmap/icon_what" />
|
||||
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
@ -124,4 +133,12 @@
|
||||
android:textColor="@color/white"
|
||||
android:textSize="10sp" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<com.opensource.svgaplayer.SVGAImageView
|
||||
android:id="@+id/blind_box_open"
|
||||
android:layout_width="61dp"
|
||||
android:layout_marginTop="1dp"
|
||||
android:layout_height="110dp"
|
||||
android:layout_marginStart="7dp" />
|
||||
</FrameLayout>
|
Loading…
Reference in New Issue
Block a user