diff --git a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java index 62a343db3..bbe9a4e77 100644 --- a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java +++ b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java @@ -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]); diff --git a/common/src/main/java/com/yunbao/common/utils/GifCacheUtil.java b/common/src/main/java/com/yunbao/common/utils/GifCacheUtil.java deleted file mode 100644 index b3d5f64c5..000000000 --- a/common/src/main/java/com/yunbao/common/utils/GifCacheUtil.java +++ /dev/null @@ -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 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); - } - }); - } - } - -} diff --git a/common/src/main/java/com/yunbao/common/utils/GiftCacheUtil.java b/common/src/main/java/com/yunbao/common/utils/GiftCacheUtil.java new file mode 100644 index 000000000..18312f81b --- /dev/null +++ b/common/src/main/java/com/yunbao/common/utils/GiftCacheUtil.java @@ -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 downloadCache = new LinkedHashMap<>(); + private CommonCallback 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 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 list) { + for (LiveGiftBean bean : list) { + downloadCache.put(bean.getId(), bean); + } + } + + /** + * 设置监听回调 + */ + public void setCallback(CommonCallback commonCallback) { + this.commonCallback = commonCallback; + } + + /** + * 插队优先下载指定id礼物 + */ + public void downloadGiftForId(LiveGiftBean bean, CommonCallback mDownloadGifCallback) { + if(checkGiftIsDownload(bean.getId())){ + mDownloadGifCallback.callback(null); + return; + } + this.clickId = bean.getId(); + getFile(getDownloadSaveName(bean.getId()), bean.getSwf(), "0", new CommonCallback() { + @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 + + '}'; + } + } + +} diff --git a/common/src/main/java/com/yunbao/common/utils/NobleUtil.java b/common/src/main/java/com/yunbao/common/utils/NobleUtil.java new file mode 100644 index 000000000..e03d24ccd --- /dev/null +++ b/common/src/main/java/com/yunbao/common/utils/NobleUtil.java @@ -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; + } +} diff --git a/common/src/main/java/com/yunbao/common/utils/SVGAViewUtils.java b/common/src/main/java/com/yunbao/common/utils/SVGAViewUtils.java index 87b7b7391..daa47b0f6 100644 --- a/common/src/main/java/com/yunbao/common/utils/SVGAViewUtils.java +++ b/common/src/main/java/com/yunbao/common/utils/SVGAViewUtils.java @@ -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; + } } diff --git a/common/src/main/java/com/yunbao/common/views/weight/FullServiceNotificationView.java b/common/src/main/java/com/yunbao/common/views/weight/FullServiceNotificationView.java index e83e8060f..3513d1d4e 100644 --- a/common/src/main/java/com/yunbao/common/views/weight/FullServiceNotificationView.java +++ b/common/src/main/java/com/yunbao/common/views/weight/FullServiceNotificationView.java @@ -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(); } diff --git a/common/src/main/java/com/yunbao/common/views/weight/NobleNoticeView.java b/common/src/main/java/com/yunbao/common/views/weight/NobleNoticeView.java index 3a231da57..371e892b0 100644 --- a/common/src/main/java/com/yunbao/common/views/weight/NobleNoticeView.java +++ b/common/src/main/java/com/yunbao/common/views/weight/NobleNoticeView.java @@ -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(); } diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index 9897a0683..a09e91e4f 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -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 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 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() { + 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(); + } + } + + }); + } } diff --git a/live/src/main/java/com/yunbao/live/adapter/GiftTopAdapter.java b/live/src/main/java/com/yunbao/live/adapter/GiftTopAdapter.java index 1b9d740f2..268d52c36 100644 --- a/live/src/main/java/com/yunbao/live/adapter/GiftTopAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/GiftTopAdapter.java @@ -62,6 +62,10 @@ public class GiftTopAdapter extends RecyclerView.Adapter { } } + public void setChoice(int choice) { + this.choice = choice; + } + @NonNull @Override public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveGiftAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveGiftAdapter.java index c3ea818a6..3303cd246 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveGiftAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveGiftAdapter.java @@ -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 { 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 list, String coinName) { - mContext=context; + public LiveGiftAdapter(Context context, LayoutInflater inflater, List list, String coinName) { + mContext = context; mInflater = inflater; mList = list; mCoinName = coinName; @@ -65,6 +71,7 @@ public class LiveGiftAdapter extends RecyclerView.Adapter { mActionListener.onCancel(); } } + bean.setChecked(true); notifyItemChanged(position, Constants.PAYLOAD); View view = bean.getView(); @@ -109,6 +116,10 @@ public class LiveGiftAdapter extends RecyclerView.Adapter { return mList.size(); } + public List getList() { + return mList; + } + /** * 取消选中 */ @@ -160,6 +171,9 @@ public class LiveGiftAdapter extends RecyclerView.Adapter { 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 { 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() { + @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 { 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 { } 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); } } diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveGiftPagerAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveGiftPagerAdapter.java index 7990d971f..062e6889a 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveGiftPagerAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveGiftPagerAdapter.java @@ -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 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 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(); diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java index 08b8fa9ae..de0fd975b 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java @@ -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 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 list = JSON.parseArray(giftJson, LiveGiftBean.class); showGiftList(list); + mGiftPackage.setTextColor(Color.parseColor("#FFFFFF")); } private void loadWrapListData() { - List 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 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 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 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 { diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java index b4dfb8738..341571bac 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java @@ -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() { + } + } } diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveEnterRoomAnimPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveEnterRoomAnimPresenter.java index 023586bed..3649807e9 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveEnterRoomAnimPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveEnterRoomAnimPresenter.java @@ -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; } diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java index 252bebc1d..91ece6f48 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java @@ -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); } } diff --git a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java index a157b1f6f..9ecb96a00 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java @@ -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); + } /** * 退出直播间 */ diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index eff91cd4e..a22e75200 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -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() { diff --git a/live/src/main/res/anim/anim_loading_gift.xml b/live/src/main/res/anim/anim_loading_gift.xml new file mode 100644 index 000000000..f66388842 --- /dev/null +++ b/live/src/main/res/anim/anim_loading_gift.xml @@ -0,0 +1,11 @@ + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_live_gift.xml b/live/src/main/res/drawable/bg_live_gift.xml new file mode 100644 index 000000000..0f713fa4a --- /dev/null +++ b/live/src/main/res/drawable/bg_live_gift.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_live_gift_buy.xml b/live/src/main/res/drawable/bg_live_gift_buy.xml new file mode 100644 index 000000000..a4e416086 --- /dev/null +++ b/live/src/main/res/drawable/bg_live_gift_buy.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_live_gift_download_all.xml b/live/src/main/res/drawable/bg_live_gift_download_all.xml new file mode 100644 index 000000000..5a263ed01 --- /dev/null +++ b/live/src/main/res/drawable/bg_live_gift_download_all.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_live_gift_items.xml b/live/src/main/res/drawable/bg_live_gift_items.xml new file mode 100644 index 000000000..ab8df02fd --- /dev/null +++ b/live/src/main/res/drawable/bg_live_gift_items.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_live_gift_package_line.xml b/live/src/main/res/drawable/bg_live_gift_package_line.xml new file mode 100644 index 000000000..662427256 --- /dev/null +++ b/live/src/main/res/drawable/bg_live_gift_package_line.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_live_vip_gold.xml b/live/src/main/res/drawable/bg_live_vip_gold.xml new file mode 100644 index 000000000..3ac1e0560 --- /dev/null +++ b/live/src/main/res/drawable/bg_live_vip_gold.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/dialog_live_gift_wrap.xml b/live/src/main/res/layout/dialog_live_gift_wrap.xml index 77e4ce720..2d9d4abe3 100644 --- a/live/src/main/res/layout/dialog_live_gift_wrap.xml +++ b/live/src/main/res/layout/dialog_live_gift_wrap.xml @@ -1,239 +1,315 @@ - - - - + - - - - - - - - - - + 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"> - + - - - + + + + + + - - - - - - - - - - - - - + - - - - + android:layout_height="match_parent" + android:layout_gravity="center" + android:textColor="#FFFFFF" + android:text="開通貴族" + android:textSize="11.52sp" /> + + - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/item_live_gift.xml b/live/src/main/res/layout/item_live_gift.xml index 01c6b3863..741e89bb1 100644 --- a/live/src/main/res/layout/item_live_gift.xml +++ b/live/src/main/res/layout/item_live_gift.xml @@ -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" > + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/view_live_audience.xml b/live/src/main/res/layout/view_live_audience.xml index 2cbe474d2..2c0fa5c85 100644 --- a/live/src/main/res/layout/view_live_audience.xml +++ b/live/src/main/res/layout/view_live_audience.xml @@ -348,14 +348,39 @@ android:src="@mipmap/live_lw" /> + android:visibility="gone" /> + + + + + + + diff --git a/live/src/main/res/mipmap-xxxhdpi/icon_download_gift.png b/live/src/main/res/mipmap-xxxhdpi/icon_download_gift.png new file mode 100644 index 000000000..bd09b6126 Binary files /dev/null and b/live/src/main/res/mipmap-xxxhdpi/icon_download_gift.png differ diff --git a/live/src/main/res/mipmap-xxxhdpi/icon_loading_gift.png b/live/src/main/res/mipmap-xxxhdpi/icon_loading_gift.png new file mode 100644 index 000000000..d49d84a10 Binary files /dev/null and b/live/src/main/res/mipmap-xxxhdpi/icon_loading_gift.png differ diff --git a/live/src/main/res/mipmap-xxxhdpi/icon_small_download.png b/live/src/main/res/mipmap-xxxhdpi/icon_small_download.png new file mode 100644 index 000000000..f4532c135 Binary files /dev/null and b/live/src/main/res/mipmap-xxxhdpi/icon_small_download.png differ diff --git a/live/src/main/res/mipmap-xxxhdpi/icon_vip_gold.png b/live/src/main/res/mipmap-xxxhdpi/icon_vip_gold.png new file mode 100644 index 000000000..b7ad6a7cb Binary files /dev/null and b/live/src/main/res/mipmap-xxxhdpi/icon_vip_gold.png differ diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index 527c8ade6..3e77de365 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -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() { + GiftCacheUtil.getFile(Constants.GIF_GIFT_PREFIX + list.get(j).getId(), list.get(j).getSwf(), "0", new CommonCallback() { @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() { + GiftCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback() { @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操作 } } } diff --git a/main/src/main/java/com/yunbao/main/activity/RewardActivity.java b/main/src/main/java/com/yunbao/main/activity/RewardActivity.java index 77fed05c4..bce0b84e1 100644 --- a/main/src/main/java/com/yunbao/main/activity/RewardActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/RewardActivity.java @@ -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() { + GiftCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback() { @Override public void callback(File bean) { diff --git a/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java b/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java index 841d7ea18..29e8e3a96 100644 --- a/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java @@ -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() { + GiftCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback() { @Override public void callback(File bean) { diff --git a/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java b/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java index 9e49a4473..d4917458d 100644 --- a/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java +++ b/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java @@ -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"));