根据文档修改新礼物UI
移除主界面预下载所有礼物svga入口 获取直播间状态后开始下载所有礼物svga GiftCacheUtil改为单例并支持顺序下载所有礼物及插队下载 预处理新人特惠红点显示/隐藏接口 获取svga播放时间统一由SVGAViewUtils处理
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
/**
|
||||
* 退出直播间
|
||||
*/
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user