diff --git a/common/src/main/java/com/yunbao/common/bean/BlindBoxInfoModel.java b/common/src/main/java/com/yunbao/common/bean/BlindBoxInfoModel.java index 8451bb3a1..b80c81c4c 100644 --- a/common/src/main/java/com/yunbao/common/bean/BlindBoxInfoModel.java +++ b/common/src/main/java/com/yunbao/common/bean/BlindBoxInfoModel.java @@ -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 getItemName() { return itemName; diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java index 973dc1707..d02b45f0c 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java @@ -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 blindBoxInfoModels = new ArrayList<>(); @@ -743,21 +768,28 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On model = boxInfoModel; } } - if (model == null) return; - new SVGAParser(mContext).decodeFromAssets("hdsn.svga", new SVGAParser.ParseCompletion() { - @Override - public void onComplete(SVGAVideoEntity videoItem) { - SVGADrawable drawable = new SVGADrawable(videoItem); - blindSvga.setImageDrawable(drawable); - SVGAViewUtils.playEndClear(blindSvga, false); + if (model == null) return; + 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); + blindSvga.setImageDrawable(drawable); + SVGAViewUtils.playEndClear(blindSvga, false); - } + } - @Override - public void onError() { - Log.e("errqs", "errl"); - } - }, null); + @Override + public void onError() { + Log.e("errqs", "errl"); + } + }); + } 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())); diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java index 22298060a..888ce5c59 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java @@ -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; diff --git a/live/src/main/res/layout/view_blind_box.xml b/live/src/main/res/layout/view_blind_box.xml index d84c5522d..bf3c77821 100644 --- a/live/src/main/res/layout/view_blind_box.xml +++ b/live/src/main/res/layout/view_blind_box.xml @@ -1,127 +1,144 @@ - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + android:gravity="center_horizontal" + android:orientation="vertical"> + + - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file