添加礼物,活动
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
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;
|
||||
}
|
||||
|
||||
public LiveAudienceEvent setType(LiveAudienceType type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public enum LiveAudienceType {
|
||||
SIDEBAR(1, "侧边栏"),
|
||||
BOTTOMCOLLECTION(2, "底部合集"),
|
||||
GIFTPOPUP(3, "礼物弹窗"),
|
||||
CURRENTACTIVITY(4, "当前活动");
|
||||
|
||||
|
||||
private int type;
|
||||
private String name;
|
||||
|
||||
LiveAudienceType(int type, String name) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user