6.5.4礼物栏优化
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.yunbao.common.adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.GiftQuantityModel;
|
||||
import com.yunbao.common.views.GiftNumber;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GiftNumberAdapter extends RecyclerView.Adapter {
|
||||
private List<GiftQuantityModel> giftQuantityModels;
|
||||
|
||||
public GiftNumberAdapter(List<GiftQuantityModel> giftQuantityModels) {
|
||||
this.giftQuantityModels = giftQuantityModels;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View robotSayHelloView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_gift_number, parent, false);
|
||||
return new GiftNumber(robotSayHelloView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
GiftNumber giftNumber = (GiftNumber) holder;
|
||||
giftNumber.showData(giftQuantityModels.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return giftQuantityModels.size();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.yunbao.common.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* 礼物选择数量
|
||||
*/
|
||||
public class GiftQuantityModel extends BaseModel {
|
||||
|
||||
@SerializedName("id")
|
||||
private String id;
|
||||
@SerializedName("gift_quantity")
|
||||
private String giftQuantity;
|
||||
@SerializedName("font_colour")
|
||||
private String fontColour;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public GiftQuantityModel setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getGiftQuantity() {
|
||||
return giftQuantity;
|
||||
}
|
||||
|
||||
public GiftQuantityModel setGiftQuantity(String giftQuantity) {
|
||||
this.giftQuantity = giftQuantity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFontColour() {
|
||||
return fontColour;
|
||||
}
|
||||
|
||||
public GiftQuantityModel setFontColour(String fontColour) {
|
||||
this.fontColour = fontColour;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class LiveGiftBean {
|
||||
private String name;
|
||||
private String price;
|
||||
private String icon;
|
||||
private boolean checked;
|
||||
private boolean checked = false;
|
||||
private int page;
|
||||
private View mView;
|
||||
private String sendType;//支付是金币还是钻石
|
||||
@@ -36,6 +36,30 @@ public class LiveGiftBean {
|
||||
private String tag;
|
||||
@JSONField(name = "blind_box_type")
|
||||
private int blind_box_type = 0;
|
||||
//礼物角标
|
||||
|
||||
@JSONField(name = "corner_mark")
|
||||
private String cornerMark;
|
||||
@JSONField(name = "gift_description")
|
||||
private String giftDescription;
|
||||
|
||||
public String getGiftDescription() {
|
||||
return giftDescription;
|
||||
}
|
||||
|
||||
public LiveGiftBean setGiftDescription(String giftDescription) {
|
||||
this.giftDescription = giftDescription;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCornerMark() {
|
||||
return cornerMark;
|
||||
}
|
||||
|
||||
public LiveGiftBean setCornerMark(String cornerMark) {
|
||||
this.cornerMark = cornerMark;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getBlind_box_type() {
|
||||
return blind_box_type;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.yunbao.common.event;
|
||||
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
public class GiftNumberEvent extends BaseModel {
|
||||
private String mCount;
|
||||
|
||||
public String getmCount() {
|
||||
return mCount;
|
||||
}
|
||||
|
||||
public GiftNumberEvent setmCount(String mCount) {
|
||||
this.mCount = mCount;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -336,6 +336,18 @@ public class ImgLoader {
|
||||
builder.into(imageView);
|
||||
}
|
||||
|
||||
public static void displayBlurLive(Context context, int url, ImageView imageView) {
|
||||
if (!contextIsExist(context)) {
|
||||
return;
|
||||
}
|
||||
RequestBuilder<Drawable> builder = Glide.with(context)
|
||||
.load(url)
|
||||
.thumbnail(thumbnail)
|
||||
.apply(RequestOptions.bitmapTransform(new BlurTransformation(20)))
|
||||
.placeholder(R.mipmap.live_bg);
|
||||
builder.into(imageView);
|
||||
}
|
||||
|
||||
private static boolean contextIsExist(Context context) {
|
||||
if (context == null) {
|
||||
return false;
|
||||
|
||||
@@ -19,13 +19,13 @@ import com.yunbao.common.bean.ConfigBean;
|
||||
import com.yunbao.common.event.FollowEvent;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.APKManager;
|
||||
import com.yunbao.common.manager.GiftQuantityManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.LiveClassManager;
|
||||
import com.yunbao.common.manager.NewLevelManager;
|
||||
import com.yunbao.common.utils.AppManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.MD5Util;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.VersionUtil;
|
||||
@@ -231,6 +231,10 @@ public class CommonHttpUtil {
|
||||
if (obj.containsKey("defaultBubbleUrl")) {
|
||||
IMLoginManager.get(context).setDefaultBubbleUrl(obj.getString("defaultBubbleUrl"));
|
||||
}
|
||||
if (obj.containsKey("gift_quantity")) {
|
||||
JSONArray giftQuantity = obj.getJSONArray("gift_quantity");
|
||||
new GiftQuantityManager(context).UpGiftQuantity(giftQuantity.toJSONString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
String error = "info[0]:" + info[0] + "\n\n\n" + "Exception:" + e.getClass() + "---message--->" + e.getMessage();
|
||||
|
||||
@@ -829,4 +829,5 @@ public interface PDLiveApi {
|
||||
@Query("stream") String stream,
|
||||
@Query("red_packet_id") String redPacketId
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.yunbao.common.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.yunbao.common.bean.GiftQuantityModel;
|
||||
import com.yunbao.common.bean.LiveClassBean;
|
||||
import com.yunbao.common.manager.base.BaseCacheManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GiftQuantityManager extends BaseCacheManager {
|
||||
private final static String KEY_GIFT_QUANTITY = "GiftQuantity";
|
||||
private static GiftQuantityManager manager;
|
||||
private Context context;
|
||||
private List<GiftQuantityModel> giftQuantityModels;
|
||||
|
||||
public GiftQuantityManager(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指导员备注信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<GiftQuantityModel> getGiftQuantity() {
|
||||
List<GiftQuantityModel> giftQuantityModels = getList(KEY_GIFT_QUANTITY, new TypeToken<List<GiftQuantityModel>>() {
|
||||
}.getType());
|
||||
if (giftQuantityModels == null || giftQuantityModels.size() == 0) {
|
||||
giftQuantityModels.add(new GiftQuantityModel().setGiftQuantity("1").setFontColour("#ffffff"));
|
||||
giftQuantityModels.add(new GiftQuantityModel().setGiftQuantity("10").setFontColour("#ffffff"));
|
||||
giftQuantityModels.add(new GiftQuantityModel().setGiftQuantity("66").setFontColour("#ffffff"));
|
||||
giftQuantityModels.add(new GiftQuantityModel().setGiftQuantity("88").setFontColour("#FA62A1"));
|
||||
giftQuantityModels.add(new GiftQuantityModel().setGiftQuantity("100").setFontColour("#9B62FF"));
|
||||
giftQuantityModels.add(new GiftQuantityModel().setGiftQuantity("520").setFontColour("#65BFFB"));
|
||||
giftQuantityModels.add(new GiftQuantityModel().setGiftQuantity("1314").setFontColour("#05F3EC"));
|
||||
}
|
||||
return giftQuantityModels;
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存等级图标
|
||||
*
|
||||
* @param json
|
||||
*/
|
||||
public void UpGiftQuantity(String json) {
|
||||
giftQuantityModels = new Gson().fromJson(json, new TypeToken<List<GiftQuantityModel>>() {
|
||||
}.getType());
|
||||
put(KEY_GIFT_QUANTITY, giftQuantityModels);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.yunbao.common.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.renderscript.Allocation;
|
||||
import android.renderscript.Element;
|
||||
import android.renderscript.RenderScript;
|
||||
import android.renderscript.ScriptIntrinsicBlur;
|
||||
|
||||
/**
|
||||
* Created by L on 2017/10/12.
|
||||
*/
|
||||
|
||||
public class BlurBitmapUtil {
|
||||
/**
|
||||
* 图片缩放比例
|
||||
*/
|
||||
private static final float BITMAP_SCALE = 0.4f;
|
||||
/**
|
||||
* 最大模糊度(在0.0到25.0之间)
|
||||
*/
|
||||
private static final float BLUR_RADIUS = 25f;
|
||||
/**
|
||||
* 模糊图片的具体方法
|
||||
*
|
||||
* @param context 上下文对象
|
||||
* @param image 需要模糊的图片
|
||||
* @return 模糊处理后的图片
|
||||
*/
|
||||
public static Bitmap blur(Context context, Bitmap image) {
|
||||
// 计算图片缩小后的长宽
|
||||
int width = Math.round(image.getWidth() * BITMAP_SCALE);
|
||||
int height = Math.round(image.getHeight() * BITMAP_SCALE);
|
||||
// 将缩小后的图片做为预渲染的图片。
|
||||
Bitmap inputBitmap = Bitmap.createScaledBitmap(image, width, height, false);
|
||||
// 创建一张渲染后的输出图片。
|
||||
Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap);
|
||||
// 创建RenderScript内核对象
|
||||
RenderScript rs = RenderScript.create(context);
|
||||
// 创建一个模糊效果的RenderScript的工具对象
|
||||
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
|
||||
// 由于RenderScript并没有使用VM来分配内存,所以需要使用Allocation类来创建和分配内存空间。
|
||||
// 创建Allocation对象的时候其实内存是空的,需要使用copyTo()将数据填充进去。
|
||||
Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
|
||||
Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap);
|
||||
// 设置渲染的模糊程度, 25f是最大模糊度
|
||||
blurScript.setRadius(BLUR_RADIUS);
|
||||
// 设置blurScript对象的输入内存
|
||||
blurScript.setInput(tmpIn);
|
||||
// 将输出数据保存到输出内存中
|
||||
blurScript.forEach(tmpOut);
|
||||
// 将数据填充到Allocation中
|
||||
tmpOut.copyTo(outputBitmap);
|
||||
return outputBitmap;
|
||||
}
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public class CustomDrawerPopupView extends DrawerPopupView {
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.online), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
XPopup.Builder builder = new XPopup.Builder(getContext()).atView(findViewById(R.id.more_menu));
|
||||
XPopup.Builder builder = new XPopup.Builder(getContext()).atView(findViewById(R.id.diamond_linear));
|
||||
builder.hasShadowBg(false)
|
||||
.isDestroyOnDismiss(true)
|
||||
.isLightStatusBar(false)
|
||||
|
||||
34
common/src/main/java/com/yunbao/common/views/GiftNumber.java
Normal file
34
common/src/main/java/com/yunbao/common/views/GiftNumber.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.yunbao.common.views;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.GiftQuantityModel;
|
||||
import com.yunbao.common.event.GiftNumberEvent;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
public class GiftNumber extends RecyclerView.ViewHolder {
|
||||
private TextView customQuantity;
|
||||
|
||||
public GiftNumber(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
customQuantity = itemView.findViewById(R.id.custom_quantity);
|
||||
}
|
||||
|
||||
public void showData(GiftQuantityModel quantityModel) {
|
||||
customQuantity.setText(quantityModel.getGiftQuantity());
|
||||
customQuantity.setTextColor(Color.parseColor(quantityModel.getFontColour()));
|
||||
ViewClicksAntiShake.clicksAntiShake(customQuantity, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
Bus.get().post(new GiftNumberEvent().setmCount(quantityModel.getGiftQuantity()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.yunbao.common.views;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.lxj.xpopup.core.BottomPopupView;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.adapter.GiftNumberAdapter;
|
||||
import com.yunbao.common.event.GiftNumberEvent;
|
||||
import com.yunbao.common.manager.GiftQuantityManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
public class GiftNumberPopup extends BottomPopupView {
|
||||
public GiftNumberPopup(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
// 返回自定义弹窗的布局
|
||||
@Override
|
||||
protected int getImplLayoutId() {
|
||||
return R.layout.view_live_gift_number;
|
||||
}
|
||||
|
||||
// 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
Bus.getOn(this);
|
||||
super.onCreate();
|
||||
RecyclerView giftList = findViewById(R.id.gift_list);
|
||||
giftList.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
GiftNumberAdapter giftNumberAdapter = new GiftNumberAdapter(new GiftQuantityManager(getContext()).getGiftQuantity());
|
||||
giftList.setAdapter(giftNumberAdapter);
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.to_can), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDismiss() {
|
||||
super.onDismiss();
|
||||
Bus.getOff(this);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onGiftNumberEvent(GiftNumberEvent event) {
|
||||
dismiss();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user