From 3a11fd39558ec33ec1e47a5a52112965999c44d9 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Wed, 17 Aug 2022 15:16:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=A4=BC=E7=89=A9=EF=BC=8C?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common/bean/ActiveModel.java | 19 ++++ .../common}/event/LiveAudienceEvent.java | 18 +++- .../com/yunbao/common/glide/ImgLoader.java | 55 +++++++----- .../common/views/FunGamesViewHolder.java | 9 ++ config.gradle | 4 +- .../live/activity/LiveAudienceActivity.java | 27 +++++- .../live/views/LiveAudienceViewHolder.java | 23 +++-- .../yunbao/live/views/LiveRoomViewHolder.java | 2 +- .../main/res/drawable/border_translucent.xml | 4 +- live/src/main/res/layout/dialog_live_hd.xml | 87 ++++++++++--------- 10 files changed, 173 insertions(+), 75 deletions(-) rename {live/src/main/java/com/yunbao/live => common/src/main/java/com/yunbao/common}/event/LiveAudienceEvent.java (56%) diff --git a/common/src/main/java/com/yunbao/common/bean/ActiveModel.java b/common/src/main/java/com/yunbao/common/bean/ActiveModel.java index 79387f959..6dc80c326 100644 --- a/common/src/main/java/com/yunbao/common/bean/ActiveModel.java +++ b/common/src/main/java/com/yunbao/common/bean/ActiveModel.java @@ -1,6 +1,10 @@ package com.yunbao.common.bean; +import android.content.Context; + import com.google.gson.annotations.SerializedName; +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.manager.IMLoginManager; /** * 活动 @@ -69,4 +73,19 @@ public class ActiveModel extends BaseModel { this.showType = showType; return this; } + + /** + * 获取跳转网页地址 + * + * @return + */ + public String activityUrl(Context context, String liveUid) { + IMLoginModel userInfo = IMLoginManager.get(context).getUserInfo(); + String url = CommonAppConfig.HOST + "/" + activeSrc + + "?uid=" + userInfo.getId() + + "&token=" + userInfo.getToken() + + "&anchorUid=" + liveUid + + "&active_id=" + activeId; + return url; + } } diff --git a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java b/common/src/main/java/com/yunbao/common/event/LiveAudienceEvent.java similarity index 56% rename from live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java rename to common/src/main/java/com/yunbao/common/event/LiveAudienceEvent.java index e3693c53b..9d7260f34 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/common/src/main/java/com/yunbao/common/event/LiveAudienceEvent.java @@ -1,9 +1,20 @@ -package com.yunbao.live.event; +package com.yunbao.common.event; +import com.yunbao.common.bean.ActiveModel; import com.yunbao.common.bean.BaseModel; public class LiveAudienceEvent extends BaseModel { private LiveAudienceType type; + private ActiveModel model = new ActiveModel(); + + public ActiveModel getModel() { + return model; + } + + public LiveAudienceEvent setModel(ActiveModel model) { + this.model = model; + return this; + } public LiveAudienceType getType() { return type; @@ -16,7 +27,10 @@ public class LiveAudienceEvent extends BaseModel { public enum LiveAudienceType { SIDEBAR(1, "侧边栏"), - BOTTOMCOLLECTION(2, "底部合集"); + BOTTOMCOLLECTION(2, "底部合集"), + GIFTPOPUP(3, "礼物弹窗"), + CURRENTACTIVITY(4, "当前活动"); + private int type; private String name; diff --git a/common/src/main/java/com/yunbao/common/glide/ImgLoader.java b/common/src/main/java/com/yunbao/common/glide/ImgLoader.java index 399194296..afeb88fd0 100644 --- a/common/src/main/java/com/yunbao/common/glide/ImgLoader.java +++ b/common/src/main/java/com/yunbao/common/glide/ImgLoader.java @@ -4,11 +4,11 @@ import android.app.Activity; import android.content.Context; import android.graphics.drawable.Drawable; import android.net.Uri; +import android.widget.ImageView; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import android.widget.ImageView; - import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.SimpleTarget; @@ -29,70 +29,76 @@ public class ImgLoader { private static BlurTransformation sBlurTransformation; static { - sBlurTransformation= new BlurTransformation(25); + sBlurTransformation = new BlurTransformation(25); } public static void display(Context context, String url, ImageView imageView) { - if (!contextIsExist(context)){ + if (!contextIsExist(context)) { return; } Glide.with(context).asDrawable().load(url).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView); } public static void display2(Context context, String url, ImageView imageView) { - if (!contextIsExist(context)){ + if (!contextIsExist(context)) { return; } Glide.with(context).asDrawable().load(url).placeholder(imageView.getDrawable()).dontAnimate().skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView); } + public static void display2(Context context, int url, ImageView imageView) { - if (!contextIsExist(context)){ + if (!contextIsExist(context)) { return; } Glide.with(context).asDrawable().load(url).placeholder(imageView.getDrawable()).dontAnimate().skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView); } + public static void displayWithError(Context context, String url, ImageView imageView, int errorRes) { - if (!contextIsExist(context)){ + if (!contextIsExist(context)) { return; } - if (imageView == null){ + if (imageView == null) { return; } Glide.with(context).asDrawable().load(url).error(errorRes).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView); } + public static void displayWithError(Context context, int url, ImageView imageView, int errorRes) { - if (!contextIsExist(context)){ + if (!contextIsExist(context)) { return; } - if (imageView == null){ + if (imageView == null) { return; } Glide.with(context).asDrawable().load(url).error(errorRes).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView); } + public static void displayAvatar(Context context, String url, ImageView imageView) { - if (!contextIsExist(context)){ + if (!contextIsExist(context)) { return; } displayWithError(context, url, imageView, R.mipmap.icon_avatar_placeholder); } + public static void displayAvatar(Context context, int url, ImageView imageView) { - if (!contextIsExist(context)){ + if (!contextIsExist(context)) { return; } displayWithError(context, url, imageView, R.mipmap.icon_avatar_placeholder); } + public static void display(Context context, File file, ImageView imageView) { - if (!contextIsExist(context)){ + if (!contextIsExist(context)) { return; } Glide.with(context).asDrawable().load(file).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView); } public static void display(Context context, int res, ImageView imageView) { - if (!contextIsExist(context)){ + if (!contextIsExist(context)) { return; } Glide.with(context).asDrawable().load(res).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView); @@ -102,14 +108,24 @@ public class ImgLoader { * 显示视频封面缩略图 */ public static void displayVideoThumb(Context context, String videoPath, ImageView imageView) { - if (!contextIsExist(context)){ + if (!contextIsExist(context)) { return; } Glide.with(context).asDrawable().load(Uri.fromFile(new File(videoPath))).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView); } + /** + * 展示动图 + */ + public static void displayGif(Context context, int videoPath, ImageView imageView) { + if (!contextIsExist(context)) { + return; + } + Glide.with(context).asGif().load(videoPath).skipMemoryCache(SKIP_MEMORY_CACHE).into(imageView); + } + public static void displayDrawable(Context context, String url, final DrawableCallback callback) { - if (!contextIsExist(context)){ + if (!contextIsExist(context)) { return; } Glide.with(context).asDrawable().load(url).skipMemoryCache(SKIP_MEMORY_CACHE).into(new SimpleTarget() { @@ -131,19 +147,18 @@ public class ImgLoader { } public static void clear(Context context, ImageView imageView) { - if (!contextIsExist(context)){ + if (!contextIsExist(context)) { return; } Glide.with(context).clear(imageView); } - /** * 显示模糊的毛玻璃图片 */ public static void displayBlur(Context context, String url, ImageView imageView) { - if (!contextIsExist(context)){ + if (!contextIsExist(context)) { return; } Glide.with(context).asDrawable().load(url) @@ -153,7 +168,7 @@ public class ImgLoader { } private static boolean contextIsExist(Context context) { - if (context == null ) { + if (context == null) { return false; } if (context instanceof Activity) { diff --git a/common/src/main/java/com/yunbao/common/views/FunGamesViewHolder.java b/common/src/main/java/com/yunbao/common/views/FunGamesViewHolder.java index 1db03b551..3b73a5a04 100644 --- a/common/src/main/java/com/yunbao/common/views/FunGamesViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/FunGamesViewHolder.java @@ -9,7 +9,10 @@ import androidx.recyclerview.widget.RecyclerView; import com.yunbao.common.R; import com.yunbao.common.bean.ActiveModel; +import com.yunbao.common.event.LiveAudienceEvent; import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.views.weight.ViewClicksAntiShake; public class FunGamesViewHolder extends RecyclerView.ViewHolder { private ImageView funGamePic; @@ -19,6 +22,7 @@ public class FunGamesViewHolder extends RecyclerView.ViewHolder { super(itemView); funGamePic = itemView.findViewById(R.id.fun_game_pic); funGameName = itemView.findViewById(R.id.fun_game_name); + } /** @@ -29,5 +33,10 @@ public class FunGamesViewHolder extends RecyclerView.ViewHolder { public void showView(ActiveModel model) { ImgLoader.display(itemView.getContext(), model.getActiveImg(), funGamePic); funGameName.setText(model.getActiveName()); + ViewClicksAntiShake.clicksAntiShake(itemView, () -> { + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.CURRENTACTIVITY) + .setModel(model)); + }); } } diff --git a/config.gradle b/config.gradle index 3f66756b1..492fa93ba 100644 --- a/config.gradle +++ b/config.gradle @@ -9,9 +9,9 @@ ext { ] manifestPlaceholders = [ //正式 -// serverHost : "https://napi.yaoulive.com", + serverHost : "https://napi.yaoulive.com", //測試 - serverHost : "https://ceshi.yaoulive.com", +// serverHost : "https://ceshi.yaoulive.com", //腾讯地图 txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB", diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index 61b2c877c..5873bf11e 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -51,6 +51,7 @@ import com.yunbao.common.custom.ItemDecoration; import com.yunbao.common.custom.MyViewPager; import com.yunbao.common.dialog.LiveChargeDialogFragment; import com.yunbao.common.dialog.LiveTotalDialog; +import com.yunbao.common.event.LiveAudienceEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; @@ -79,9 +80,9 @@ import com.yunbao.live.bean.LivePKUserListBean; import com.yunbao.live.bean.LiveUserGiftBean; import com.yunbao.live.dialog.BlowkissDialog; import com.yunbao.live.dialog.LiveGiftDialogFragment; +import com.yunbao.live.dialog.LiveHDDialogFragment; import com.yunbao.live.dialog.NewUserDialog; import com.yunbao.live.event.LinkMicTxAccEvent; -import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.event.LiveRoomChangeEvent; import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; @@ -1384,14 +1385,34 @@ public class LiveAudienceActivity extends LiveActivity { @Subscribe(threadMode = ThreadMode.MAIN) public void onOpenDrawer(LiveAudienceEvent event) { + Bundle bundle = new Bundle(); switch (event.getType()) { case SIDEBAR: //从右边打开侧边栏 drawerLayout.openDrawer(GravityCompat.END); break; case BOTTOMCOLLECTION: - LiveTotalDialog fragment = new LiveTotalDialog(); - fragment.show(getSupportFragmentManager(), "LiveTotalDialog"); + LiveTotalDialog liveTotalDialog = new LiveTotalDialog(); + liveTotalDialog.show(getSupportFragmentManager(), "LiveTotalDialog"); + break; + case GIFTPOPUP: + if (TextUtils.isEmpty(mLiveUid) || TextUtils.isEmpty(mStream)) { + return; + } + LiveGiftDialogFragment liveGiftDialogFragment = new LiveGiftDialogFragment(); + liveGiftDialogFragment.setLiveGuardInfo(mLiveGuardInfo); + bundle.putString(Constants.LIVE_UID, mLiveUid); + bundle.putString(Constants.LIVE_STREAM, mStream); + liveGiftDialogFragment.setArguments(bundle); + liveGiftDialogFragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment"); + break; + case CURRENTACTIVITY: + bundle.putString("url", event.getModel().activityUrl(mContext, liveBean.getUid())); + int show = TextUtils.isEmpty(event.getModel().getShowType()) ? 0 : Integer.parseInt(event.getModel().getShowType()); + bundle.putInt("show_type", show); + LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment(); + liveHDDialogFragment.setArguments(bundle); + liveHDDialogFragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); break; } diff --git a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java index 77b12a771..6df5ce412 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java @@ -32,7 +32,6 @@ import com.opensource.svgaplayer.SVGAVideoEntity; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.bean.MsgModel; -import com.yunbao.common.dialog.LiveTotalDialog; import com.yunbao.common.event.MessageIMEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; @@ -49,7 +48,7 @@ import com.yunbao.live.bean.LiveChatBean; import com.yunbao.live.dialog.LiveHDDialogFragment; import com.yunbao.live.dialog.LiveMicUserDialogFragment; import com.yunbao.live.dialog.LivePromotionDialogFragment; -import com.yunbao.live.event.LiveAudienceEvent; +import com.yunbao.common.event.LiveAudienceEvent; import com.yunbao.live.http.LiveHttpUtil; import org.greenrobot.eventbus.EventBus; @@ -75,6 +74,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { private TextView goToRomm; private int icon = 0; private String nobleName, nobleTtext; + private ImageView giftImage; public LiveAudienceViewHolder(Context context, ViewGroup parentView) { super(context, parentView); @@ -129,7 +129,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { public void onError() { Log.e("errqs", "errl"); } - },null); + }, null); } private void svga_new_user_double() { @@ -146,7 +146,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { public void onError() { Log.e("errqs", "errl"); } - },null); + }, null); } private void svga_new_user_follow() { @@ -162,7 +162,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { public void onError() { Log.e("errqs", "errl"); } - },null); + }, null); } @@ -180,6 +180,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { findViewById(R.id.btn_red_pack).setOnClickListener(this); findViewById(R.id.btn_gift).setOnClickListener(this); findViewById(R.id.btn_zg).setOnClickListener(this); + giftImage = (ImageView) findViewById(R.id.gift_image); svga_new_user_gif = (SVGAImageView) findViewById(R.id.svga_new_user_gif); svga_new_user_double = (SVGAImageView) findViewById(R.id.svga_new_user_double); svga_new_user_follow = (SVGAImageView) findViewById(R.id.svga_new_user_follow); @@ -303,6 +304,16 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { } }); + //底部礼物弹窗 + ImgLoader.displayGif(mContext, R.mipmap.live_lw, giftImage); + + ViewClicksAntiShake.clicksAntiShake(giftImage, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.GIFTPOPUP)); + } + }); } public static Handler handler = new Handler(); @@ -664,7 +675,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { public void onError() { Log.e("errqs", "errl"); } - },null); + }, null); } } diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index ab91a90ac..8fa24be5d 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -79,7 +79,7 @@ import com.yunbao.live.custom.TopGradual; import com.yunbao.live.dialog.LiveFansMedalDialogFragment; import com.yunbao.live.dialog.LiveHDDialogFragment; import com.yunbao.live.dialog.LiveUserDialogFragment; -import com.yunbao.live.event.LiveAudienceEvent; +import com.yunbao.common.event.LiveAudienceEvent; import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveDanmuPresenter; diff --git a/live/src/main/res/drawable/border_translucent.xml b/live/src/main/res/drawable/border_translucent.xml index 71bb9360e..717ef1fb1 100644 --- a/live/src/main/res/drawable/border_translucent.xml +++ b/live/src/main/res/drawable/border_translucent.xml @@ -2,8 +2,8 @@ - + diff --git a/live/src/main/res/layout/dialog_live_hd.xml b/live/src/main/res/layout/dialog_live_hd.xml index f0338b0be..863587c0f 100644 --- a/live/src/main/res/layout/dialog_live_hd.xml +++ b/live/src/main/res/layout/dialog_live_hd.xml @@ -1,52 +1,61 @@ - + android:orientation="vertical" + app:cardCornerRadius="12dp" + app:cardElevation="16dp"> - + android:layout_height="match_parent" + android:orientation="vertical"> - + android:layout_height="50dp"> - + - + - + - + - \ No newline at end of file + + + + + \ No newline at end of file