根据文档修改新礼物UI

移除主界面预下载所有礼物svga入口
获取直播间状态后开始下载所有礼物svga
GiftCacheUtil改为单例并支持顺序下载所有礼物及插队下载
预处理新人特惠红点显示/隐藏接口
获取svga播放时间统一由SVGAViewUtils处理
This commit is contained in:
zlzw 2022-10-10 11:00:46 +08:00
parent 3a87583340
commit 5060d647fb
35 changed files with 1066 additions and 421 deletions

View File

@ -291,6 +291,7 @@ public class IMLoginManager extends BaseCacheManager {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
SpUtil.setStringValue("userData",info[0]);
userInfo = new Gson().fromJson(info[0], IMLoginModel.class);
if (!TextUtils.isEmpty(uidAndToken[1])) {
userInfo.setToken(uidAndToken[1]);

View File

@ -1,52 +0,0 @@
package com.yunbao.common.utils;
import android.util.Log;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.interfaces.CommonCallback;
import java.io.File;
/**
* Created by cxf on 2018/10/17.
*/
public class GifCacheUtil {
public static void getFile(String fileName, String url,String forwhat, final CommonCallback<File> commonCallback) {
if (commonCallback == null) {
return;
}
File dir = new File(CommonAppConfig.GIF_PATH);
if (!dir.exists()) {
dir.mkdirs();
}
File file1 = new File(dir, fileName+".svga");
if (file1.exists()) {
commonCallback.callback(file1);
} else {
DownloadUtil downloadUtil = new DownloadUtil();
if(forwhat.equals("1")){
ToastUtil.show("礼物正在获取中...");
}
downloadUtil.download(CommonHttpConsts.DOWNLOAD_GIF, dir, fileName, url, new DownloadUtil.Callback() {
@Override
public void onSuccess(File file) {
commonCallback.callback(file);
}
@Override
public void onProgress(int progress) {
}
@Override
public void onError(Throwable e) {
commonCallback.callback(null);
}
});
}
}
}

View File

@ -0,0 +1,285 @@
package com.yunbao.common.utils;
import android.os.Handler;
import android.os.Looper;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.LiveGiftBean;
import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.interfaces.CommonCallback;
import java.io.File;
import java.util.LinkedHashMap;
import java.util.List;
/**
* svga礼物缓存工具
* Created by cxf on 2018/10/17.
*/
public class GiftCacheUtil {
private static GiftCacheUtil manager;
private LinkedHashMap<Integer, LiveGiftBean> downloadCache = new LinkedHashMap<>();
private CommonCallback<File> commonCallback;
private Handler handler = new Handler(Looper.getMainLooper());
private boolean pause = false;
private boolean downloading = false;
private int clickId = 0;
private GiftCacheUtil() {
}
public static GiftCacheUtil getInstance() {
if (manager == null) {
manager = new GiftCacheUtil();
}
return manager;
}
/**
* 单独下载
*/
public static void getFile(String fileName, String url, String forwhat, final CommonCallback<File> commonCallback) {
if (commonCallback == null) {
return;
}
File dir = new File(CommonAppConfig.GIF_PATH);
if (!dir.exists()) {
dir.mkdirs();
}
File file1 = new File(dir, fileName + ".svga");
if (file1.exists()) {
commonCallback.callback(file1);
} else {
DownloadUtil downloadUtil = new DownloadUtil();
if (forwhat.equals("1")) {
ToastUtil.show("礼物正在获取中...");
}
downloadUtil.download(CommonHttpConsts.DOWNLOAD_GIF, dir, fileName, url, new DownloadUtil.Callback() {
@Override
public void onSuccess(File file) {
commonCallback.callback(file);
}
@Override
public void onProgress(int progress) {
}
@Override
public void onError(Throwable e) {
commonCallback.callback(null);
}
});
}
}
/**
* 通过id获取保存的文件名
*/
public static String getDownloadSaveName(int id) {
return Constants.GIF_GIFT_PREFIX + id;
}
/**
* 检测礼物是否已经下载完毕
*/
public static boolean checkGiftIsDownload(int id) {
return new File(CommonAppConfig.GIF_PATH, getDownloadSaveName(id) + ".svga").exists();
}
/**
* 根据文件名返回id
*/
public static int getIdForFileName(String name) {
return Integer.parseInt(name
.replace(Constants.GIF_GIFT_PREFIX, "")
.replace(".svga", ""));
}
/**
* 设置下载列表
*/
public void setDownloadList(List<LiveGiftBean> list) {
for (LiveGiftBean bean : list) {
downloadCache.put(bean.getId(), bean);
}
}
/**
* 设置监听回调
*/
public void setCallback(CommonCallback<File> commonCallback) {
this.commonCallback = commonCallback;
}
/**
* 插队优先下载指定id礼物
*/
public void downloadGiftForId(LiveGiftBean bean, CommonCallback<File> mDownloadGifCallback) {
if(checkGiftIsDownload(bean.getId())){
mDownloadGifCallback.callback(null);
return;
}
this.clickId = bean.getId();
getFile(getDownloadSaveName(bean.getId()), bean.getSwf(), "0", new CommonCallback<File>() {
@Override
public void callback(File bean) {
GiftCacheUtil.this.clickId = -1;
downloadCache.remove(getIdForFileName(bean.getName()));
mDownloadGifCallback.callback(bean);
}
});
}
/**
* 暂停下载
*/
public void pause() {
pause = true;
}
/**
* 恢复下载
*/
public void restart(){
pause = false;
startDownload();
}
/**
* 重置下载状态
*/
public void resetStatus() {
downloading = false;
pause=false;
}
/**
* 是否下载中
*/
public boolean isDownloading() {
return downloading;
}
/**
* 下载列表中所有文件
*/
public void downloadAllGift() {
File dir = new File(CommonAppConfig.GIF_PATH);
if (!dir.exists()) {
dir.mkdirs();
}
if (commonCallback == null) {
return;
}
if (downloading) {
commonCallback.callback(null);
return;
}
downloading = true;
startDownload();
}
/**
* 开始下载
*/
private void startDownload(){
new Thread(() -> {
File dir = new File(CommonAppConfig.GIF_PATH);
DownloadUtil downloadUtil = new DownloadUtil();
Object[] ids = downloadCache.keySet().toArray();
for (Object _id :ids) {
int id= (int) _id;
if (pause) {
return;
}
File file = new File(dir, Constants.GIF_GIFT_PREFIX + id + ".svga");
if (file.exists()) {
handler.post(() -> commonCallback.callback(file));
downloadCache.remove(id);
continue;
}
LiveGiftBean bean = downloadCache.get(id);
if (bean == null) {
continue;
}
if (clickId == id) {
continue;
}
if (bean.getSwf().isEmpty()) {
handler.post(() -> commonCallback.callback(null));
continue;
}
downloadUtil.download(CommonHttpConsts.DOWNLOAD_GIF, dir, Constants.GIF_GIFT_PREFIX + bean.getId(), bean.getSwf(), new DownloadUtil.Callback() {
@Override
public void onSuccess(File file) {
downloadCache.remove(getIdForFileName(file.getName()));
if (downloadCache.isEmpty()) {
downloading = false;
}else{
//单线程下载以便插队下载和及时停止下载
startDownload();
}
handler.post(() -> commonCallback.callback(file));
}
@Override
public void onProgress(int progress) {
}
@Override
public void onError(Throwable e) {
handler.post(() -> commonCallback.callback(null));
e.printStackTrace();
}
});
break;
}
if(downloadCache.isEmpty()){
downloading = false;
}
}).start();
}
/**
* 下载状态
*/
public static class GiftDownloadStatus {
private int download = 0;
private int size = 0;
private int id;
public GiftDownloadStatus(int download, int size, int id) {
this.download = download;
this.size = size;
this.id = id;
}
public int getDownload() {
return download;
}
public int getSize() {
return size;
}
public int getId() {
return id;
}
@Override
public String toString() {
return "GiftDownloadStatus{" +
"download=" + download +
", size=" + size +
", id=" + id +
'}';
}
}
}

View File

@ -0,0 +1,25 @@
package com.yunbao.common.utils;
import com.yunbao.common.R;
public class NobleUtil {
/**
* 来自User.getBaseInfos接口
* 根据noble_id返回对应的图片资源
* id来自
* @see com.yunbao.common.views.weight.NobleNoticeView.RoleType
*/
public static int nobleIdToImageResId(int id){
switch (id){
case 1:return R.mipmap.icon_open_nanjue;
case 2:return R.mipmap.icon_open_zijue;
case 3:return R.mipmap.icon_open_houjue;
case 4:return R.mipmap.icon_open_gongjue;
case 5:return R.mipmap.icon_open_guowang;
case 6:return R.mipmap.icon_open_huangdi;
case 7:return R.mipmap.icon_open_chaohuang;
}
return -1;
}
}

View File

@ -1,8 +1,11 @@
package com.yunbao.common.utils;
import android.animation.ValueAnimator;
import com.opensource.svgaplayer.SVGACallback;
import com.opensource.svgaplayer.SVGAImageView;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
@ -58,4 +61,21 @@ public class SVGAViewUtils {
public static void playEndClear(SVGAImageView svga) {
playEndClear(svga, true);
}
/**
* 获取svga动画播放时间
*/
public static long getPlayTimer(SVGAImageView svga){
try {
Field mAnimator = svga.getClass().getDeclaredField("mAnimator");
mAnimator.setAccessible(true);
ValueAnimator animator = (ValueAnimator) mAnimator.get(svga);
if(animator!=null) {
return animator.getDuration();
}
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
}

View File

@ -24,6 +24,7 @@ import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAVideoEntity;
import com.yunbao.common.R;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.SVGAViewUtils;
import org.jetbrains.annotations.NotNull;
@ -127,15 +128,7 @@ public class FullServiceNotificationView extends FrameLayout {
svagaBc.setVisibility(VISIBLE);
SVGADrawable imageView = new SVGADrawable(svgaVideoEntity);
svagaBc.setImageDrawable(imageView);
try {
Field mAnimator = svagaBc.getClass().getDeclaredField("mAnimator");
mAnimator.setAccessible(true);
ValueAnimator animator = (ValueAnimator) mAnimator.get(svagaBc);
animationTime = animator.getDuration();
System.out.println("播放时间 = " + animator.getDuration());
} catch (Exception e) {
e.printStackTrace();
}
animationTime= SVGAViewUtils.getPlayTimer(svagaBc);
svagaBc.setLoops(1);
svagaBc.startAnimation();
}

View File

@ -28,6 +28,7 @@ import com.opensource.svgaplayer.SVGAVideoEntity;
import com.yunbao.common.R;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.BitmapUtil;
import com.yunbao.common.utils.SVGAViewUtils;
import org.jetbrains.annotations.NotNull;
@ -204,15 +205,7 @@ public class NobleNoticeView extends FrameLayout {
dynamicEntity.setDynamicImage(bitmap, "psd_31");
SVGADrawable imageView = new SVGADrawable(svgaVideoEntity, dynamicEntity);
svagaBc.setImageDrawable(imageView);
try {
Field mAnimator = svagaBc.getClass().getDeclaredField("mAnimator");
mAnimator.setAccessible(true);
ValueAnimator animator = (ValueAnimator) mAnimator.get(svagaBc);
animationTime = animator.getDuration();
System.out.println("播放时间 = " + animator.getDuration());
} catch (Exception e) {
e.printStackTrace();
}
animationTime= SVGAViewUtils.getPlayTimer(svagaBc);
svagaBc.setLoops(1);
svagaBc.startAnimation();
}

View File

@ -22,6 +22,7 @@ import androidx.viewpager.widget.ViewPager;
import com.adjust.sdk.Adjust;
import com.adjust.sdk.AdjustEvent;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.GsonUtils;
import com.facebook.appevents.AppEventsLogger;
@ -33,6 +34,7 @@ import com.yunbao.common.activity.WebViewActivity;
import com.yunbao.common.bean.AnchorRecommendItemModel;
import com.yunbao.common.bean.AnchorRecommendModel;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.LiveGiftBean;
import com.yunbao.common.bean.SlideInfoModel;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.dialog.EffectsSettingsDialog;
@ -45,11 +47,13 @@ import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.http.main.MainNetManager;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.pay.PayCallback;
import com.yunbao.common.pay.PayPresenter;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.GiftCacheUtil;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ProcessResultUtil;
import com.yunbao.common.utils.ToastUtil;
@ -79,6 +83,7 @@ import com.yunbao.live.views.PortraitLiveManager;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -316,6 +321,8 @@ public class LiveAudienceActivity extends LiveActivity {
mViewGroup.addView(manager.getRootView());
manager.onAdd(liveBean1, liveType, liveTypeVal, liveSdk);
//加载完页面后再后台静默下载礼物svga
downloadAllGift();
}
});
@ -484,6 +491,7 @@ public class LiveAudienceActivity extends LiveActivity {
protected void onPause() {
super.onPause();
manager.onPause();
GiftCacheUtil.getInstance().pause();
}
/**
@ -608,6 +616,7 @@ public class LiveAudienceActivity extends LiveActivity {
protected void onResume() {
super.onResume();
manager.onResume();
GiftCacheUtil.getInstance().restart();
}
@ -930,4 +939,46 @@ public class LiveAudienceActivity extends LiveActivity {
public void onFollowEvent(FollowEvent e) {
manager.onFollowEvent(e);
}
/**
* 后台下载所有礼物
*/
private void downloadAllGift(){
LiveHttpUtil.getNewGiftList(new HttpCallback() {
List<LiveGiftBean> giftBeanList=new ArrayList<>();
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
JSONArray list = obj.getJSONArray("listarray");
Log.i("tttts", obj.getString("listarray") + "");
CommonAppConfig.getInstance().setGiftListJson(obj.getString("listarray"));
for (Object o : list) {
JSONObject item= (JSONObject) o;
List<LiveGiftBean> giftlist = JSONArray.parseArray(item.getJSONArray("giftlist").toJSONString(), LiveGiftBean.class);
for (LiveGiftBean bean : giftlist) {
if(!bean.getSwf().isEmpty()){
giftBeanList.add(bean);
}
}
}
GiftCacheUtil.getInstance().setDownloadList(giftBeanList);
GiftCacheUtil.getInstance().setCallback(new CommonCallback<File>() {
int index=0;
@Override
public void callback(File bean) {
if(bean!=null){
index++;
Bus.get().post(new GiftCacheUtil.GiftDownloadStatus(index, giftBeanList.size(), GiftCacheUtil.getIdForFileName(bean.getName())));
}
}
});
GiftCacheUtil.getInstance().resetStatus();
GiftCacheUtil.getInstance().downloadAllGift();
}
}
});
}
}

View File

@ -62,6 +62,10 @@ public class GiftTopAdapter extends RecyclerView.Adapter<GiftTopAdapter.Vh> {
}
}
public void setChoice(int choice) {
this.choice = choice;
}
@NonNull
@Override
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

View File

@ -12,8 +12,11 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.view.animation.ScaleAnimation;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.yunbao.common.CommonAppConfig;
@ -22,10 +25,13 @@ import com.yunbao.common.bean.LiveGiftBean;
import com.yunbao.common.bean.LiveGiftBean2;
import com.yunbao.common.custom.MyRadioButton;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.GiftCacheUtil;
import com.yunbao.live.R;
import com.yunbao.live.custom.GiftMarkView;
import java.io.File;
import java.util.List;
/**
@ -43,10 +49,10 @@ public class LiveGiftAdapter extends RecyclerView.Adapter<LiveGiftAdapter.Vh> {
private int mCheckedPosition = -1;
private ScaleAnimation mAnimation;
private View mAnimView;
private String mName1,mName2;
private String mName1, mName2;
public LiveGiftAdapter(Context context,LayoutInflater inflater, List<LiveGiftBean> list, String coinName) {
mContext=context;
public LiveGiftAdapter(Context context, LayoutInflater inflater, List<LiveGiftBean> list, String coinName) {
mContext = context;
mInflater = inflater;
mList = list;
mCoinName = coinName;
@ -65,6 +71,7 @@ public class LiveGiftAdapter extends RecyclerView.Adapter<LiveGiftAdapter.Vh> {
mActionListener.onCancel();
}
}
bean.setChecked(true);
notifyItemChanged(position, Constants.PAYLOAD);
View view = bean.getView();
@ -109,6 +116,10 @@ public class LiveGiftAdapter extends RecyclerView.Adapter<LiveGiftAdapter.Vh> {
return mList.size();
}
public List<LiveGiftBean> getList() {
return mList;
}
/**
* 取消选中
*/
@ -160,6 +171,9 @@ public class LiveGiftAdapter extends RecyclerView.Adapter<LiveGiftAdapter.Vh> {
TextView tvRedpoint;
ImageView mPayico;
TextView expire;
ImageView mLoading;
LinearLayout mLoadingLayout;
public Vh(View itemView) {
super(itemView);
mMark = (GiftMarkView) itemView.findViewById(R.id.mark);
@ -169,65 +183,81 @@ public class LiveGiftAdapter extends RecyclerView.Adapter<LiveGiftAdapter.Vh> {
mRadioButton = (MyRadioButton) itemView.findViewById(R.id.radioButton);
tvRedpoint = (TextView) itemView.findViewById(R.id.tvRedpoint);
mPayico = (ImageView) itemView.findViewById(R.id.pay_ico);
expire = (TextView)itemView.findViewById(R.id.expire);
expire = (TextView) itemView.findViewById(R.id.expire);
mRadioButton.setOnClickListener(mOnClickListener);
mLoading = itemView.findViewById(R.id.gift_loading);
mLoadingLayout = itemView.findViewById(R.id.gift_loading_layout);
mLoadingLayout.setOnClickListener(v -> {
mLoading.setImageResource(R.mipmap.icon_loading_gift);
Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.anim_loading_gift);
animation.setRepeatMode(Animation.RESTART);
animation.setRepeatCount(Animation.INFINITE);
animation.setInterpolator(new LinearInterpolator());
mLoading.startAnimation(animation);
LiveGiftBean bean = mList.get((Integer) v.getTag());
GiftCacheUtil.getInstance().pause();
GiftCacheUtil.getInstance().downloadGiftForId(bean, new CommonCallback<File>() {
@Override
public void callback(File bean) {
mLoadingLayout.setVisibility(View.GONE);
GiftCacheUtil.getInstance().restart();
}
});
});
}
void setData(LiveGiftBean bean, int position, Object payload) {
if( IMLoginManager.get(mContext).isNewUserGif()== true) {
if (position == 0 && bean.getTag()!=null) {
if (IMLoginManager.get(mContext).isNewUserGif()) {
if (position == 0 && bean.getTag() != null) {
mRadioButton.setBackgroundResource(R.mipmap.live_gift_light_bg);
}
}
if (payload == null) {
ImgLoader.display(mContext,bean.getIcon(), mIcon);
ImgLoader.display(mContext, bean.getIcon(), mIcon);
bean.setView(mIcon);
mName.setText(bean.getName());
if (bean.getSendType() != null && bean.getSendType().equals("1"))
{
if (bean.getSendType() != null && bean.getSendType().equals("1")) {
// mCoinName = mName2;
mPayico.setImageResource(R.mipmap.gold_coin);
}else {
} else {
// mCoinName = mName1;
mPayico.setImageResource(R.mipmap.diamond);
}
mPrice.setText(bean.getPrice());
if (IMLoginManager.get(mContext).isNewUserGif() == true && position == 0 && bean.getTag() != null) {
if (IMLoginManager.get(mContext).isNewUserGif() && position == 0 && bean.getTag() != null) {
mPayico.setVisibility(View.GONE);
mPrice.setText(R.string.free);
mPrice.setTextColor(Color.parseColor("#FFF269"));
}
expire.setVisibility(View.GONE);
if(bean.getEnd_time()!=null){
if (bean.getEnd_time() != null) {
expire.setVisibility(View.VISIBLE);
expire.setText(bean.getEnd_time());
}
//包裹数量
if (!TextUtils.isEmpty(bean.getGiftNum())){
if (!TextUtils.isEmpty(bean.getGiftNum())) {
try {
tvRedpoint.setVisibility(View.VISIBLE);
tvRedpoint.setText(bean.getGiftNum());
}catch (Exception e){e.printStackTrace();}
} catch (Exception e) {
e.printStackTrace();
}
}
int mark=bean.getMark();
int mark = bean.getMark();
if (bean.getSwf()!=null&&!bean.getSwf().contains("svga")) {
if (mark== LiveGiftBean2.MARK_HOT) {
if (bean.getSwf() != null && !bean.getSwf().contains("svga")) {
if (mark == LiveGiftBean2.MARK_HOT) {
mMark.setIconRes(R.mipmap.icon_live_gift_hot, 0);
}
else if (mark == LiveGiftBean2.MARK_GUARD) {
} else if (mark == LiveGiftBean2.MARK_GUARD) {
mMark.setIconRes(R.mipmap.icon_live_gift_guard, 0);
}
else if (mark == LiveGiftBean2.MARK_LUCK) {
} else if (mark == LiveGiftBean2.MARK_LUCK) {
mMark.setIconRes(R.mipmap.icon_live_gift_luck, 0);
}
else if (bean.getIsweek()!=null&&bean.getIsweek().equals("1")) {
mMark.setIconRes(0,R.mipmap.icon_live_gift_weekstar);
}
else {
} else if (bean.getIsweek() != null && bean.getIsweek().equals("1")) {
mMark.setIconRes(0, R.mipmap.icon_live_gift_weekstar);
} else {
mMark.setIconRes(0, 0);
}
} else {
@ -235,14 +265,11 @@ public class LiveGiftAdapter extends RecyclerView.Adapter<LiveGiftAdapter.Vh> {
mMark.setIconRes(R.mipmap.icon_live_gift_hot, R.mipmap.icon_live_gift_hao);
} else if (mark == LiveGiftBean2.MARK_GUARD) {
mMark.setIconRes(R.mipmap.icon_live_gift_guard, R.mipmap.icon_live_gift_hao);
}
else if (mark == LiveGiftBean2.MARK_LUCK) {
} else if (mark == LiveGiftBean2.MARK_LUCK) {
mMark.setIconRes(R.mipmap.icon_live_gift_luck, R.mipmap.icon_live_gift_hao);
}
else if (bean.getIsweek()!=null && bean.getIsweek().equals("1")) {
mMark.setIconRes(0,R.mipmap.icon_live_gift_weekstar);
}
else {
} else if (bean.getIsweek() != null && bean.getIsweek().equals("1")) {
mMark.setIconRes(0, R.mipmap.icon_live_gift_weekstar);
} else {
mMark.setIconRes(0, R.mipmap.icon_live_gift_hao);
}
@ -250,6 +277,12 @@ public class LiveGiftAdapter extends RecyclerView.Adapter<LiveGiftAdapter.Vh> {
}
mRadioButton.setTag(position);
mRadioButton.doChecked(bean.isChecked());
if (bean.getSwf().isEmpty()) {
mLoadingLayout.setVisibility(View.GONE);
return;
}
mLoadingLayout.setVisibility(GiftCacheUtil.checkGiftIsDownload(bean.getId()) ? View.GONE : View.VISIBLE);
mLoadingLayout.setTag(position);
}
}

View File

@ -1,9 +1,11 @@
package com.yunbao.live.adapter;
import android.content.Context;
import androidx.viewpager.widget.PagerAdapter;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -23,12 +25,12 @@ public class LiveGiftPagerAdapter extends PagerAdapter {
private Context mContext;
private List<RecyclerView> mViewList;
private static final int GIFT_COUNT = 10;//每页10个礼物
private static final int GIFT_COUNT = 8;//每页8个礼物
private int mPage = -1;
private ActionListener mActionListener;
public LiveGiftPagerAdapter(Context context, List<LiveGiftBean> giftList) {
mContext=context;
mContext = context;
mViewList = new ArrayList<>();
int fromIndex = 0;
int size = giftList.size();
@ -60,7 +62,7 @@ public class LiveGiftPagerAdapter extends PagerAdapter {
for (int i = 0; i < pageCount; i++) {
RecyclerView recyclerView = (RecyclerView) inflater.inflate(R.layout.view_gift_page, null, false);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new GridLayoutManager(context, 5, GridLayoutManager.VERTICAL, false));
recyclerView.setLayoutManager(new GridLayoutManager(context, 4, GridLayoutManager.VERTICAL, false));
int endIndex = fromIndex + GIFT_COUNT;
if (endIndex > size) {
endIndex = size;
@ -71,7 +73,7 @@ public class LiveGiftPagerAdapter extends PagerAdapter {
bean.setPage(i);
list.add(bean);
}
LiveGiftAdapter adapter = new LiveGiftAdapter(mContext,inflater, list, coinName);
LiveGiftAdapter adapter = new LiveGiftAdapter(mContext, inflater, list, coinName);
adapter.setActionListener(actionListener);
recyclerView.setAdapter(adapter);
mViewList.add(recyclerView);
@ -79,7 +81,26 @@ public class LiveGiftPagerAdapter extends PagerAdapter {
}
}
public void notifyRefresh(){
/**
* 刷新指定礼物id的item 界面
* @param giftId
*/
public void refreshId(int giftId) {
for (RecyclerView recyclerView : mViewList) {
RecyclerView.Adapter<?> adapter = recyclerView.getAdapter();
if (adapter instanceof LiveGiftAdapter) {
for (int i = 0; i < ((LiveGiftAdapter) adapter).getList().size(); i++) {
if(((LiveGiftAdapter) adapter).getList().get(i).getId()==giftId){
adapter.notifyItemChanged(i);
return;
}
}
}
}
}
public void notifyRefresh() {
if (mViewList != null) {
for (RecyclerView recyclerView : mViewList) {
LiveGiftAdapter adapter = (LiveGiftAdapter) recyclerView.getAdapter();
@ -89,7 +110,8 @@ public class LiveGiftPagerAdapter extends PagerAdapter {
}
}
}
public void notifyRefresh(int position){
public void notifyRefresh(int position) {
if (mViewList != null) {
for (RecyclerView recyclerView : mViewList) {
LiveGiftAdapter adapter = (LiveGiftAdapter) recyclerView.getAdapter();
@ -100,6 +122,7 @@ public class LiveGiftPagerAdapter extends PagerAdapter {
}
}
@Override
public int getCount() {
return mViewList.size();

View File

@ -1,5 +1,6 @@
package com.yunbao.live.dialog;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@ -13,6 +14,8 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RadioButton;
import android.widget.RadioGroup;
@ -38,9 +41,12 @@ import com.yunbao.common.dialog.AbsDialogFragment;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.GiftCacheUtil;
import com.yunbao.common.utils.NobleUtil;
import com.yunbao.common.utils.SpUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.adapter.GiftTopAdapter;
@ -51,9 +57,10 @@ import com.yunbao.live.bean.LiveGuardInfo;
import com.yunbao.live.http.LiveHttpConsts;
import com.yunbao.live.http.LiveHttpUtil;
import com.yunbao.live.utils.ToolsButton;
import com.yunbao.live.views.LiveRoomViewHolder;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.List;
@ -110,10 +117,16 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
private LiveGiftBean mBeanFromWish;
private RecyclerView items;
private LinearLayout mVipGold;
private GiftTopAdapter giftTopAdapter;
public int type = 0;
private static String type_name = "熱門";
JSONArray lsit;
JSONArray list;
private ImageView mVipGoldIcon;
private TextView mVipGoldTitle;
private TextView mVipGoldDesc;
private TextView mGiftPackage;
@Override
protected int getLayoutId() {
@ -172,32 +185,16 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
giftTopAdapter.notifyDataSetChanged();
type = position;
type_name = bean.getName();
if (!bean.getName().equals(WordUtil.getString(R.string.live_wrap))) {
upData();
//点击礼物展示礼物列表
mCurrentId = 0;
if (mViewPager != null) {
mViewPager.setVisibility(View.VISIBLE);
mRadioGroup.setVisibility(View.VISIBLE);
}
if (mVPWrapList != null) {
mVPWrapList.setVisibility(View.GONE);
mRGroupWrap.setVisibility(View.GONE);
}
} else {
//点击包裹展示包裹列表
mCurrentId = 1;
loadWrapListData();
if (mViewPager != null) {
mViewPager.setVisibility(View.GONE);
mRadioGroup.setVisibility(View.GONE);
}
if (mVPWrapList != null) {
mVPWrapList.setVisibility(View.VISIBLE);
mRGroupWrap.setVisibility(View.VISIBLE);
}
upData();
//点击礼物展示礼物列表
mCurrentId = 0;
if (mViewPager != null) {
mViewPager.setVisibility(View.VISIBLE);
mRadioGroup.setVisibility(View.VISIBLE);
}
if (mVPWrapList != null) {
mVPWrapList.setVisibility(View.GONE);
mRGroupWrap.setVisibility(View.GONE);
}
});
mViewPager.setOffscreenPageLimit(5);
@ -249,7 +246,14 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
mCoin.setOnClickListener(this);
mTvGoCharge.setOnClickListener(this);
mTvGoldCoin.setOnClickListener(this);
mRootView.findViewById(R.id.btn_luck_gift_tip).setOnClickListener(this);
mVipGold = mRootView.findViewById(R.id.btn_luck_gift_tip);
mVipGoldIcon = mRootView.findViewById(R.id.vipGoldIcon);
mVipGoldTitle = mRootView.findViewById(R.id.vipGoldTitle);
mVipGoldDesc = mRootView.findViewById(R.id.vipGoldDesc);
mVipGold.setOnClickListener(this);
mGiftPackage= mRootView.findViewById(R.id.btn_gift_package);
mGiftPackage.setOnClickListener(this);
mRootView.findViewById(R.id.live_gift_download_all).setOnClickListener(this);
mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
@ -274,7 +278,25 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
by = bundle.getString("by");
}
loadGiftListData();
loadUserVip();
}
/**
* 设置贵族状态
*/
private void loadUserVip() {
String userData = SpUtil.getStringValue("userData");
if (userData != null && !userData.isEmpty()) {
JSONObject user = JSONObject.parseObject(userData);
int nobleId = user.getIntValue("noble_id");
int resId = NobleUtil.nobleIdToImageResId(nobleId);
if(resId!=-1){
mVipGoldIcon.setImageResource(resId);
mVipGoldTitle.setText(user.getString("noble_name"));
mVipGoldDesc.setText("前往貴族中心");
}
}
}
private void loadGiftListData() {
@ -285,25 +307,27 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
String giftListJson = CommonAppConfig.getInstance().getGiftListJson();
if (!TextUtils.isEmpty(giftListJson)) {
try {
lsit = JSON.parseArray(giftListJson);
list = JSON.parseArray(giftListJson);
Bus.getOn(this);
} catch (Exception e) {
e.printStackTrace();
}
}
}
if (lsit == null) {
if (list == null) {
LiveHttpUtil.getNewGiftList(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
lsit = obj.getJSONArray("listarray");
list = obj.getJSONArray("listarray");
Log.i("tttts", obj.getString("listarray") + "");
CommonAppConfig.getInstance().setGiftListJson(obj.getString("listarray"));
upData();
mCoin.setText(obj.getString("coin"));
mTvGoldCoin.setText(obj.getString("gold"));
Bus.getOn(LiveGiftDialogFragment.this);
}
}
@ -331,56 +355,50 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
public void upData() {
List<GiftTopBean> name = new ArrayList<>();
for (int i = 0; i < lsit.size(); i++) {
JSONObject data = lsit.getJSONObject(i);
for (int i = 0; i < list.size(); i++) {
JSONObject data = list.getJSONObject(i);
GiftTopBean giftTopBean = new GiftTopBean();
giftTopBean.setName(data.getString("name"));
name.add(giftTopBean);
}
GiftTopBean data = new GiftTopBean();
data.setName(WordUtil.getString(R.string.live_wrap));
name.add(data);
giftTopAdapter.setList(name);
JSONObject obj2 = lsit.getJSONObject(type);
JSONObject obj2 = list.getJSONObject(type);
String giftJson = obj2.getString("giftlist");
List<LiveGiftBean> list = JSON.parseArray(giftJson, LiveGiftBean.class);
showGiftList(list);
mGiftPackage.setTextColor(Color.parseColor("#FFFFFF"));
}
private void loadWrapListData() {
List<LiveGiftBean> wrapList = null;
if (wrapList == null) {
LiveHttpUtil.getWrapList(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
String giftJson = obj.getString("giftlist");
List<LiveGiftBean> list = JSON.parseArray(giftJson, LiveGiftBean.class);
int size = list.size();
if (size <= 0) {
mVPWrapList.setBackground(getResources().getDrawable(R.mipmap.wrap_empty));
} else {
mVPWrapList.setBackground(getResources().getDrawable(R.mipmap.bg_gift_list));
}
showWrapList(list);
LiveHttpUtil.getWrapList(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
String giftJson = obj.getString("giftlist");
List<LiveGiftBean> list = JSON.parseArray(giftJson, LiveGiftBean.class);
int size = list.size();
if (size <= 0) {
mVPWrapList.setBackground(getResources().getDrawable(R.mipmap.wrap_empty));
} else {
mVPWrapList.setBackground(getResources().getDrawable(R.mipmap.bg_gift_list));
}
showWrapList(list);
}
}
@Override
public void onFinish() {
if (mLoading != null) {
mLoading.setVisibility(View.INVISIBLE);
}
@Override
public void onFinish() {
if (mLoading != null) {
mLoading.setVisibility(View.INVISIBLE);
}
});
} else {
}
}
});
}
private void showGiftList(List<LiveGiftBean> list) {
if (IMLoginManager.get(mContext).isNewUserGif() == true && type_name.equals("熱門") || type_name.equals("Hot")) {
if (IMLoginManager.get(mContext).isNewUserGif() && type_name.equals("熱門") || type_name.equals("Hot")) {
list.add(0, bean1);
if (mWishGiftId == null) {
mWishGiftId = "" + bean1.getId();
@ -438,10 +456,14 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
}
mRGroupWrap.addView(radioButton);
}
mGiftPackage.setTextColor(Color.parseColor("#FFBE41"));
giftTopAdapter.setChoice(-1);
giftTopAdapter.notifyDataSetChanged();
}
@Override
public void onDestroy() {
Bus.getOff(this);
if (mHandler != null) {
mHandler.removeCallbacksAndMessages(null);
}
@ -482,11 +504,21 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
} else if (i == R.id.btn_luck_gift_tip) {
dismiss();
((LiveActivity) mContext).openLuckGiftTip();
} else if (i == R.id.btn_gift_package) {
//点击包裹展示包裹列表
mCurrentId = 1;
loadWrapListData();
if (mViewPager != null) {
mViewPager.setVisibility(View.GONE);
mRadioGroup.setVisibility(View.GONE);
}
if (mVPWrapList != null) {
mVPWrapList.setVisibility(View.VISIBLE);
mRGroupWrap.setVisibility(View.VISIBLE);
}
}
}
//包裹列表局部刷新
private void refreshWrapListAfterSend() {
if (mObjGiftSendback != null) {
@ -668,6 +700,14 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
}
}
/**
* 收到礼物下载完成的通知
* @param status
*/
@Subscribe(threadMode = ThreadMode.MAIN)
public void updateDownload(GiftCacheUtil.GiftDownloadStatus status) {
mLiveGiftPagerAdapter.refreshId(status.getId());
}
private class SendGiftCallback extends HttpCallback {

View File

@ -53,11 +53,16 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
private int showType = 0;
private boolean isFullWindow = false;
private String roomId;
private WebInterface webInterface;
public LiveHDDialogFragment() {
}
public void setWebInterface(WebInterface webInterface) {
this.webInterface = webInterface;
}
/**
* 弹出全屏对话框
*
@ -195,7 +200,7 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
@JavascriptInterface
public String androidMethodClickUser(String userId, String liveId) {
if(mContext instanceof LiveRyAnchorActivity){
if (mContext instanceof LiveRyAnchorActivity) {
return "";
}
//点击用户头像
@ -226,7 +231,7 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
@JavascriptInterface
public void androidMethodLookToLive(String liveId) {
if(mContext instanceof LiveRyAnchorActivity){
if (mContext instanceof LiveRyAnchorActivity) {
return;
}
mWebView.post(new Runnable() {
@ -257,6 +262,20 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
mContext.startActivity(intent);
}
@JavascriptInterface
public void androidShowUserPreferentialRedDot() {
if (webInterface != null) {
webInterface.showUserPreferentialRedDot();
}
}
@JavascriptInterface
public void androidHideUserPreferentialRedDot() {
if (webInterface != null) {
webInterface.hideUserPreferentialRedDot();
}
}
}
private LiveRoomCheckLivePresenter mCheckLivePresenter;
@ -324,4 +343,12 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
//结束webview的加载
mWebView.destroy();
}
public abstract static class WebInterface {
public void showUserPreferentialRedDot() {
}
public void hideUserPreferentialRedDot() {
}
}
}

View File

@ -38,7 +38,7 @@ import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.GifCacheUtil;
import com.yunbao.common.utils.GiftCacheUtil;
import com.yunbao.common.utils.SVGAViewUtils;
import com.yunbao.common.utils.ScreenDimenUtil;
import com.yunbao.live.R;
@ -442,7 +442,7 @@ public class LiveEnterRoomAnimPresenter {
playText = car.getUser_nicename() + mContext.getResources().getString(R.string.enter_room);
}
if (IMLoginManager.get(mContext).isMountEffect()) {
GifCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", mDownloadGifCallback);
GiftCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", mDownloadGifCallback);
} else {
mIsAnimating = false;
}

View File

@ -43,7 +43,7 @@ import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.GifCacheUtil;
import com.yunbao.common.utils.GiftCacheUtil;
import com.yunbao.common.utils.HtmlTagHandler;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ToastUtil;
@ -1132,7 +1132,7 @@ public class LiveGiftAnimPresenter {
}
});
} else {
GifCacheUtil.getFile(Constants.GIF_GIFT_PREFIX + bean.getGiftId(), url, "1", mDownloadGifCallback);
GiftCacheUtil.getFile(Constants.GIF_GIFT_PREFIX + bean.getGiftId(), url, "1", mDownloadGifCallback);
}
}

View File

@ -78,6 +78,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
private String nobleName, nobleTtext;
private ImageView giftImage, liveNewPeople;
private String newPeopleUrl = null;
private View mNewPeopleRedDot;
public LiveAudienceViewHolder(Context context, ViewGroup parentView) {
super(context, parentView);
@ -194,6 +195,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
svga_new_user_follow = (SVGAImageView) findViewById(R.id.svga_new_user_follow);
viewFlipper = (ViewFlipper) findViewById(R.id.viewflipper_banner);
stationHornBanner = findViewById(R.id.station_horn_banner);
mNewPeopleRedDot = findViewById(R.id.live_new_people_red_dot);
liveNewPeople.setOnClickListener(this);
svga_new_user_double.setOnClickListener(new View.OnClickListener() {
@Override
@ -358,6 +360,19 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
bundle.putInt("show_type", 0);
LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment();
liveHDDialogFragment.setArguments(bundle);
liveHDDialogFragment.setWebInterface(new LiveHDDialogFragment.WebInterface(){
@Override
public void showUserPreferentialRedDot() {
super.showUserPreferentialRedDot();
setUserPreferentialRedDot(true);
}
@Override
public void hideUserPreferentialRedDot() {
super.hideUserPreferentialRedDot();
setUserPreferentialRedDot(false);
}
});
liveHDDialogFragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
}
@ -391,6 +406,13 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
}
}
/**
* 显示/隐藏新人特惠礼物红点
* @param show true显示 false隐藏
*/
private void setUserPreferentialRedDot(boolean show){
mNewPeopleRedDot.setVisibility(show?View.VISIBLE:View.GONE);
}
/**
* 退出直播间
*/

View File

@ -1548,7 +1548,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
}
//上角显示对方主播头像及昵称
//上角显示对方主播头像及昵称
public void setOtherInfo(String touids, String url, String name) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:duration="1500"
android:fromDegrees="0"
android:repeatCount="-1"
android:toDegrees="359"
android:pivotX="50%"
android:pivotY="50%"
/>
</set>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="360dp" android:height="306dp">
<shape android:shape="rectangle">
<solid android:color="#ff000000" />
<gradient android:type="linear" android:useLevel="true" android:startColor="#ff181a34" android:endColor="#ff080a1b" android:angle="0" />
<corners android:topLeftRadius="8dp" android:topRightRadius="8dp" android:bottomLeftRadius="0dp" android:bottomRightRadius="0dp" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:topRightRadius="15dp"
android:bottomLeftRadius="15dp"
android:bottomRightRadius="15dp"
android:topLeftRadius="15dp" />
<stroke
android:width="2dp"
android:color="@color/yellow5" />
</shape>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="151dp" android:height="32dp">
<shape android:shape="rectangle">
<solid android:color="#ffffbe41" />
<corners android:topLeftRadius="16dp" android:topRightRadius="16dp" android:bottomLeftRadius="16dp" android:bottomRightRadius="16dp" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="0.3dp"
android:color="#1F245C" />
</shape>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="1dp" android:height="23dp">
<shape android:shape="rectangle">
<solid android:color="#ff626262" />
<corners android:topLeftRadius="1dp" android:topRightRadius="1dp" android:bottomLeftRadius="1dp" android:bottomRightRadius="1dp" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="105dp" android:height="32dp">
<shape android:shape="rectangle">
<solid android:color="#ff000000" />
<gradient android:type="linear" android:useLevel="true" android:startColor="#ff26294c" android:endColor="#ff080a1b" android:angle="0" />
<corners android:topLeftRadius="16dp" android:topRightRadius="16dp" android:bottomLeftRadius="16dp" android:bottomRightRadius="16dp" />
</shape>
</item>
</selector>

View File

@ -1,239 +1,315 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout 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="wrap_content"
android:background="@drawable/border_translucent">
<ScrollView android:id="@+id/tabview"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_marginBottom="10dp"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/items"
android:layout_marginLeft="10dp"
android:layout_marginRight="80dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
</ScrollView>
<com.yunbao.common.custom.DrawableTextView
android:id="@+id/btn_luck_gift_tip"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:drawablePadding="2dp"
android:drawableTint="@color/gray1"
android:gravity="center_vertical"
android:text="@string/live_ktgz"
android:textColor="@color/gray1"
android:textSize="12sp"
app:dt_right_drawable="@mipmap/icon_arrow_right_3"
app:dt_right_height="12dp"
app:dt_right_width="12dp"
/>
<LinearLayout
android:id="@+id/group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tabview"
android:orientation="vertical"
>
android:id="@+id/live_gift_download_all"
android:layout_width="155dp"
android:layout_height="32dp"
android:layout_marginStart="12dp"
android:layout_alignParentStart="true"
android:background="@drawable/bg_live_gift_download_all"
android:gravity="center"
android:visibility="invisible"
android:orientation="horizontal">
<com.yunbao.live.custom.GiftPageViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="5dp"
android:background="@mipmap/bg_gift_list"
/>
<ImageView
android:layout_width="19dp"
android:layout_height="19dp"
android:layout_marginEnd="7dp"
android:src="@mipmap/icon_small_download" />
<com.yunbao.live.custom.GiftPageViewPager
android:visibility="gone"
android:id="@+id/vpWrapList"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="5dp"
android:background="@mipmap/bg_gift_list"
/>
<RadioGroup
android:id="@+id/radio_group"
<TextView
android:layout_width="wrap_content"
android:layout_height="6dp"
android:layout_gravity="center_horizontal"
android:orientation="horizontal"
/>
<RadioGroup
android:visibility="gone"
android:id="@+id/radio_group_wrap"
android:layout_height="match_parent"
android:gravity="center"
android:visibility="visible"
android:text="一鍵下載所有禮物動畫"
android:textSize="10sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/btn_luck_gift_tip"
android:layout_width="105.27dp"
android:layout_alignParentEnd="true"
android:layout_height="32dp"
android:layout_marginEnd="12dp"
android:background="@drawable/bg_live_vip_gold"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/vipGoldIcon"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginEnd="7dp"
android:scaleType="centerCrop"
android:src="@mipmap/icon_vip_gold" />
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="6dp"
android:layout_gravity="center_horizontal"
android:orientation="horizontal"
/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="46dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
>
<RelativeLayout
android:id="@+id/btn_send_group"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/btn_send"
android:layout_width="60dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:background="@drawable/bg_live_gift_send_2"
android:enabled="false"
android:gravity="center"
android:text="@string/live_gift_send"
android:textColor="@color/fg_btn_gift_send"
android:textSize="14sp"
/>
<TextView
android:id="@+id/btn_choose"
android:layout_width="60dp"
android:layout_height="30dp"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/btn_send"
android:background="@drawable/bg_live_gift_choose"
android:gravity="center"
android:paddingRight="13dp"
android:text="1"
android:textColor="@color/global"
android:textSize="14sp"
android:visibility="invisible"
/>
<ImageView
android:id="@+id/arrow"
android:layout_width="13dp"
android:layout_height="7dp"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:layout_toLeftOf="@id/btn_send"
android:rotation="180"
android:src="@mipmap/icon_live_gift_2"
android:tint="@color/global"
android:visibility="invisible"
/>
</RelativeLayout>
<LinearLayout
android:gravity="center"
android:layout_height="wrap_content">
<TextView
android:id="@+id/vipGoldTitle"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<com.yunbao.common.custom.DrawableTextView
android:id="@+id/coin"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:textColor="@color/white"
android:textSize="12sp"
app:dt_left_drawable="@mipmap/diamond"
app:dt_left_height="20dp"
app:dt_left_width="20dp"
app:dt_right_height="14dp"
app:dt_right_width="14dp"
/>
<com.yunbao.common.custom.DrawableTextView
android:id="@+id/goldCoin"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:textColor="@color/white"
android:textSize="12sp"
app:dt_left_drawable="@mipmap/gold_coin"
app:dt_left_height="20dp"
app:dt_left_width="20dp"
app:dt_right_height="14dp"
app:dt_right_width="14dp"
/>
<com.yunbao.common.custom.DrawableTextView
android:id="@+id/go_charge"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:text="@string/charge"
android:textColor="@color/yellow5"
android:textSize="12sp"
app:dt_left_height="20dp"
app:dt_left_width="20dp"
app:dt_right_height="14dp"
app:dt_right_width="14dp"/>
</LinearLayout>
android:layout_height="match_parent"
android:layout_gravity="center"
android:textColor="#FFFFFF"
android:text="開通貴族"
android:textSize="11.52sp" />
<TextView
android:id="@+id/vipGoldDesc"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:textColor="#999999"
android:text="享受專屬特權!"
android:textSize="7.68sp" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
<ProgressBar
android:id="@+id/loading"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:layout_marginBottom="8dp"
android:layout_marginTop="14dp"
android:indeterminateBehavior="repeat"
android:indeterminateDrawable="@drawable/anim_loading"
android:indeterminateOnly="true"
/>
<RelativeLayout
android:id="@+id/btn_send_lian"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignBottom="@id/group"
android:layout_alignParentRight="true"
android:layout_marginBottom="5dp"
android:layout_marginRight="10dp"
android:background="@mipmap/icon_live_gift_lian"
android:visibility="invisible"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="@string/live_gift_send_lian"
android:textColor="@color/white"
android:textSize="12sp"
/>
<TextView
android:id="@+id/lian_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="35dp"
android:textColor="#fff"
android:textSize="14sp"/>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_live_gift">
<LinearLayout
android:id="@+id/gift_tab_layout"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/items"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="5dp" />
<ImageView
android:layout_marginEnd="15dp"
android:layout_width="wrap_content"
android:src="@drawable/bg_live_gift_package_line"
android:layout_gravity="center"
android:layout_height="23dp"/>
<com.yunbao.common.custom.DrawableTextView
android:id="@+id/btn_gift_package"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginEnd="10dp"
android:drawablePadding="2dp"
android:gravity="center_vertical"
android:text="@string/live_wrap"
android:textColor="#FFFFFF"
android:textSize="12sp"
app:dt_left_height="23dp"
app:dt_left_width="1.3dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/gift_tab_layout"
android:orientation="vertical">
<com.yunbao.live.custom.GiftPageViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="8dp"/>
<com.yunbao.live.custom.GiftPageViewPager
android:id="@+id/vpWrapList"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="8dp"
android:background="@mipmap/bg_gift_list"
android:visibility="gone" />
<RadioGroup
android:id="@+id/radio_group"
android:layout_width="wrap_content"
android:layout_height="6dp"
android:layout_marginEnd="30dp"
android:layout_gravity="end"
android:orientation="horizontal" />
<RadioGroup
android:id="@+id/radio_group_wrap"
android:layout_width="wrap_content"
android:layout_height="6dp"
android:layout_gravity="center_horizontal"
android:orientation="horizontal"
android:visibility="gone" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="66dp"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<RelativeLayout
android:id="@+id/btn_send_group"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/btn_send"
android:layout_width="60dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="10dp"
android:background="@drawable/bg_live_gift_send_2"
android:enabled="false"
android:gravity="center"
android:text="@string/live_gift_send"
android:textColor="@color/fg_btn_gift_send"
android:textSize="14sp" />
<TextView
android:id="@+id/btn_choose"
android:layout_width="60dp"
android:layout_height="30dp"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/btn_send"
android:background="@drawable/bg_live_gift_choose"
android:gravity="center"
android:paddingRight="13dp"
android:text="1"
android:textColor="@color/global"
android:textSize="14sp"
android:visibility="invisible" />
<ImageView
android:id="@+id/arrow"
android:layout_width="13dp"
android:layout_height="7dp"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:layout_toLeftOf="@id/btn_send"
android:src="@mipmap/icon_live_gift_2"
app:tint="@color/global"
android:visibility="invisible" />
</RelativeLayout>
<LinearLayout
android:orientation="horizontal"
android:gravity="bottom"
android:layout_marginBottom="5dp"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<com.yunbao.common.custom.DrawableTextView
android:id="@+id/goldCoin"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:textColor="@color/white"
android:textSize="12sp"
app:dt_left_drawable="@mipmap/gold_coin"
app:dt_left_height="20dp"
app:dt_left_width="20dp"
app:dt_right_height="14dp"
app:dt_right_width="14dp" />
<com.yunbao.common.custom.DrawableTextView
android:id="@+id/coin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:textColor="@color/white"
android:textSize="12sp"
app:dt_left_drawable="@mipmap/diamond"
app:dt_left_height="20dp"
app:dt_left_width="20dp"
app:dt_right_height="14dp"
app:dt_right_width="14dp" />
</LinearLayout>
<com.yunbao.common.custom.DrawableTextView
android:id="@+id/go_charge"
android:layout_width="42dp"
android:layout_height="22dp"
android:layout_marginStart="10dp"
android:layout_marginBottom="5dp"
android:drawablePadding="4dp"
android:gravity="center"
android:text="@string/charge"
android:background="@drawable/bg_live_gift_buy"
android:textColor="@color/yellow5"
android:textSize="12sp"
app:dt_left_height="20dp"
app:dt_left_width="20dp"
app:dt_right_height="14dp"
app:dt_right_width="14dp" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
<ProgressBar
android:id="@+id/loading"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:layout_marginTop="14dp"
android:layout_marginBottom="8dp"
android:indeterminateBehavior="repeat"
android:indeterminateDrawable="@drawable/anim_loading"
android:indeterminateOnly="true" />
<RelativeLayout
android:id="@+id/btn_send_lian"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignBottom="@id/group"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginBottom="5dp"
android:background="@mipmap/icon_live_gift_lian"
android:visibility="invisible">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="@string/live_gift_send_lian"
android:textColor="@color/white"
android:textSize="12sp" />
<TextView
android:id="@+id/lian_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="35dp"
android:textColor="#fff"
android:textSize="14sp" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>

View File

@ -3,8 +3,8 @@
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"
app:mfl_ratio="1.25"
android:layout_height="wrap_content"
android:background="@drawable/bg_live_gift_items"
>
<com.yunbao.common.custom.MyRadioButton
@ -98,4 +98,20 @@
android:paddingRight="3dp"
android:textColor="@color/white"
android:textSize="10sp" />
<LinearLayout
android:id="@+id/gift_loading_layout"
android:background="#C0000000"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="match_parent">
<ImageView
android:id="@+id/gift_loading"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="30dp"
android:src="@mipmap/icon_download_gift"
/>
</LinearLayout>
</com.yunbao.common.custom.MyFrameLayout2>

View File

@ -348,14 +348,39 @@
android:src="@mipmap/live_lw" />
<ImageView
android:id="@+id/live_new_people"
android:id="@+id/live_new_people1"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_toStartOf="@id/gift_image"
android:padding="4dp"
android:src="@mipmap/live_icon_newpeople_en"
android:visibility="visible" />
android:visibility="gone" />
<RelativeLayout
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_toStartOf="@id/gift_image"
android:padding="4dp">
<ImageView
android:id="@+id/live_new_people"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:src="@mipmap/live_icon_newpeople_en" />
<View
android:id="@+id/live_new_people_red_dot"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_alignParentRight="true"
android:layout_marginTop="0dp"
android:layout_marginRight="0dp"
android:background="@drawable/background_ff5075"
android:visibility="visible" />
</RelativeLayout>
</RelativeLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -33,8 +33,6 @@ import androidx.viewpager.widget.ViewPager;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.android.billingclient.api.Purchase;
import com.android.billingclient.api.SkuDetails;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.messaging.FirebaseMessaging;
@ -74,10 +72,8 @@ import com.yunbao.common.manager.NoviceInstructorManager;
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.GifCacheUtil;
import com.yunbao.common.utils.GoogleBillingUtil;
import com.yunbao.common.utils.GiftCacheUtil;
import com.yunbao.common.utils.LocationUtil;
import com.yunbao.common.utils.OnGoogleBillingListener;
import com.yunbao.common.utils.ProcessResultUtil;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.SpUtil;
@ -122,7 +118,6 @@ import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@ -752,7 +747,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
Log.e("--->", list.get(j).getGiftname() + list.get(j).getSwf());
GifCacheUtil.getFile(Constants.GIF_GIFT_PREFIX + list.get(j).getId(), list.get(j).getSwf(), "0", new CommonCallback<File>() {
GiftCacheUtil.getFile(Constants.GIF_GIFT_PREFIX + list.get(j).getId(), list.get(j).getSwf(), "0", new CommonCallback<File>() {
@Override
public void callback(File bean) {
@ -793,7 +788,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
Log.e("tx", id);
GifCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback<File>() {
GiftCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback<File>() {
@Override
public void callback(File bean) {
// Log.e("111",bean.getPath()+"");
@ -871,7 +866,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
public void onViewPagerScroll(String str) {
if ("oneUesrOver".equals(str)) {
if (IMLoginManager.get(mContext).isisNewUserOne() == false) {
getD();
//getD(); //取消在首页下载礼物svga操作
}
}
}

View File

@ -42,7 +42,7 @@ import com.yunbao.common.interfaces.ActivityResultCallback;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.interfaces.ImageResultCallback;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.GifCacheUtil;
import com.yunbao.common.utils.GiftCacheUtil;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ProcessImageUtil;
import com.yunbao.common.utils.RouteUtil;
@ -204,7 +204,7 @@ public class RewardActivity extends AbsActivity {
} else {
url1 = svg;
}
GifCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback<File>() {
GiftCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback<File>() {
@Override
public void callback(File bean) {

View File

@ -37,7 +37,7 @@ import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.GifCacheUtil;
import com.yunbao.common.utils.GiftCacheUtil;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.SVGAViewUtils;
@ -196,7 +196,7 @@ public class ZhuangBanActivity extends AbsActivity {
} else {
url1 = svg;
}
GifCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback<File>() {
GiftCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback<File>() {
@Override
public void callback(File bean) {

View File

@ -237,6 +237,7 @@ public class MainHttpUtil {
if (code == 0 && info.length > 0) {
IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).upDataUserInfo(info[0]);
JSONObject obj = JSON.parseObject(info[0]);
SpUtil.setStringValue("userData",info[0]);
UserBean bean = JSON.toJavaObject(obj, UserBean.class);
bean.setMedalName(obj.getString("medal_name"));
bean.setMedalLevel(obj.getIntValue("medal_level"));