添加礼物,活动

This commit is contained in:
18401019693 2022-08-17 15:16:14 +08:00
parent 062040ce15
commit 3a11fd3955
10 changed files with 173 additions and 75 deletions

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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<Drawable>() {
@ -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) {

View File

@ -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));
});
}
}

View File

@ -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",

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -2,8 +2,8 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:topLeftRadius="10dp"
android:topRightRadius="10dp"/>
<corners android:topLeftRadius="12dp"
android:topRightRadius="12dp"/>
<solid android:color="#f5121001" />
</shape>
</item>

View File

@ -1,52 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:orientation="vertical"
app:cardCornerRadius="12dp"
app:cardElevation="16dp">
<RelativeLayout
android:id="@+id/title_laout"
<LinearLayout
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="50dp">
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/titleView"
<RelativeLayout
android:id="@+id/title_laout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:gravity="center"
android:textColor="@color/textColor"
android:textSize="18sp"
android:textStyle="bold" />
android:layout_height="50dp">
<ImageView
android:id="@+id/btn_back"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:onClick="backClick"
android:padding="9dp"
android:src="@mipmap/icon_back"
android:tint="@color/textColor" />
<TextView
android:id="@+id/titleView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:gravity="center"
android:textColor="@color/textColor"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/img_more"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:padding="9dp"
android:src="@mipmap/btn_more_black"
android:tint="@color/textColor"
android:visibility="gone" />
<ImageView
android:id="@+id/btn_back"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:onClick="backClick"
android:padding="9dp"
android:src="@mipmap/icon_back"
android:tint="@color/textColor" />
</RelativeLayout>
<ImageView
android:id="@+id/img_more"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:padding="9dp"
android:src="@mipmap/btn_more_black"
android:tint="@color/textColor"
android:visibility="gone" />
<WebView
android:id="@+id/rlWebview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
</LinearLayout>
<WebView
android:id="@+id/rlWebview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</androidx.cardview.widget.CardView>