新增Banner进入直播间直接唤起新人特惠

修复新人特惠URL为null时依旧打开弹框
调整新人特惠红点入口
调整用户手动下载svga如网络失败时的操作
This commit is contained in:
zlzw 2022-10-11 14:11:12 +08:00
parent 127490ca91
commit f2a3f55e52
10 changed files with 107 additions and 72 deletions

View File

@ -13,6 +13,7 @@ public class BannerBean {
private String mLink; private String mLink;
private String show_type; private String show_type;
private String mIntoUrl; private String mIntoUrl;
private int type;
private StarChallengeStatusModel model; private StarChallengeStatusModel model;
@ -71,4 +72,13 @@ public class BannerBean {
public void setmIntoUrl(String intoUrl) { public void setmIntoUrl(String intoUrl) {
mIntoUrl = intoUrl; mIntoUrl = intoUrl;
} }
@JSONField(name = "type")
public int getType() {
return type;
}
@JSONField(name = "type")
public void setType(int type) {
this.type = type;
}
} }

View File

@ -16,6 +16,8 @@ public class NewPeopleInfo extends BaseModel{
private int isShow;//是否展示入口 private int isShow;//是否展示入口
@SerializedName("link") @SerializedName("link")
private String link;//入口地址 private String link;//入口地址
@SerializedName("red_show")
private int showRed=0;
public boolean getChargeHidden() { public boolean getChargeHidden() {
return chargeHidden==1; return chargeHidden==1;
@ -49,6 +51,14 @@ public class NewPeopleInfo extends BaseModel{
this.link = link; this.link = link;
} }
public int getShowRed() {
return showRed;
}
public void setShowRed(int showRed) {
this.showRed = showRed;
}
@NonNull @NonNull
@Override @Override
public String toString() { public String toString() {

View File

@ -10,6 +10,7 @@ import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.CommonCallback;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@ -25,7 +26,7 @@ public class GiftCacheUtil {
private Handler handler = new Handler(Looper.getMainLooper()); private Handler handler = new Handler(Looper.getMainLooper());
private boolean pause = false; private boolean pause = false;
private boolean downloading = false; private boolean downloading = false;
private int clickId = 0; private List<String> clickId = new ArrayList<>();
private GiftCacheUtil() { private GiftCacheUtil() {
} }
@ -107,9 +108,10 @@ public class GiftCacheUtil {
downloadCache.put(bean.getId(), bean); downloadCache.put(bean.getId(), bean);
} }
} }
public void addDownloadList(List<LiveGiftBean> list){
public void addDownloadList(List<LiveGiftBean> list) {
for (LiveGiftBean bean : list) { for (LiveGiftBean bean : list) {
downloadCache.put(bean.getId(),bean); downloadCache.put(bean.getId(), bean);
} }
} }
@ -124,16 +126,18 @@ public class GiftCacheUtil {
* 插队优先下载指定id礼物 * 插队优先下载指定id礼物
*/ */
public void downloadGiftForId(LiveGiftBean bean, CommonCallback<File> mDownloadGifCallback) { public void downloadGiftForId(LiveGiftBean bean, CommonCallback<File> mDownloadGifCallback) {
if(checkGiftIsDownload(bean.getId())){ if (checkGiftIsDownload(bean.getId())) {
mDownloadGifCallback.callback(null); mDownloadGifCallback.callback(null);
return; return;
} }
this.clickId = bean.getId(); clickId.add(bean.getId()+"");
getFile(getDownloadSaveName(bean.getId()), bean.getSwf(), "0", new CommonCallback<File>() { getFile(getDownloadSaveName(bean.getId()), bean.getSwf(), "0", new CommonCallback<File>() {
@Override @Override
public void callback(File bean) { public void callback(File bean) {
GiftCacheUtil.this.clickId = -1; if(bean!=null) {
clickId.remove(getIdForFileName(bean.getName())+"");
downloadCache.remove(getIdForFileName(bean.getName())); downloadCache.remove(getIdForFileName(bean.getName()));
}
mDownloadGifCallback.callback(bean); mDownloadGifCallback.callback(bean);
} }
}); });
@ -149,7 +153,7 @@ public class GiftCacheUtil {
/** /**
* 恢复下载 * 恢复下载
*/ */
public void restart(){ public void restart() {
pause = false; pause = false;
startDownload(); startDownload();
} }
@ -159,7 +163,9 @@ public class GiftCacheUtil {
*/ */
public void resetStatus() { public void resetStatus() {
downloading = false; downloading = false;
pause=false; pause = false;
clickId.clear();
downloadCache.clear();
} }
/** /**
@ -192,13 +198,13 @@ public class GiftCacheUtil {
/** /**
* 开始下载 * 开始下载
*/ */
private void startDownload(){ private void startDownload() {
new Thread(() -> { new Thread(() -> {
File dir = new File(CommonAppConfig.GIF_PATH); File dir = new File(CommonAppConfig.GIF_PATH);
DownloadUtil downloadUtil = new DownloadUtil(); DownloadUtil downloadUtil = new DownloadUtil();
Object[] ids = downloadCache.keySet().toArray(); Object[] ids = downloadCache.keySet().toArray();
for (Object _id :ids) { for (Object _id : ids) {
int id= (int) _id; int id = (int) _id;
if (pause) { if (pause) {
return; return;
} }
@ -212,7 +218,7 @@ public class GiftCacheUtil {
if (bean == null) { if (bean == null) {
continue; continue;
} }
if (clickId == id) { if (clickId.contains(id+"")) {
continue; continue;
} }
if (bean.getSwf().isEmpty()) { if (bean.getSwf().isEmpty()) {
@ -225,7 +231,7 @@ public class GiftCacheUtil {
downloadCache.remove(getIdForFileName(file.getName())); downloadCache.remove(getIdForFileName(file.getName()));
if (downloadCache.isEmpty()) { if (downloadCache.isEmpty()) {
downloading = false; downloading = false;
}else{ } else {
//单线程下载以便插队下载和及时停止下载 //单线程下载以便插队下载和及时停止下载
startDownload(); startDownload();
} }
@ -246,7 +252,7 @@ public class GiftCacheUtil {
}); });
break; break;
} }
if(downloadCache.isEmpty()){ if (downloadCache.isEmpty()) {
resetStatus(); resetStatus();
} }
}).start(); }).start();

View File

@ -87,6 +87,7 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* Created by cxf on 2018/10/10. * Created by cxf on 2018/10/10.
@ -323,6 +324,7 @@ public class LiveAudienceActivity extends LiveActivity {
manager.onAdd(liveBean1, liveType, liveTypeVal, liveSdk); manager.onAdd(liveBean1, liveType, liveTypeVal, liveSdk);
//加载完页面后再后台静默下载礼物svga //加载完页面后再后台静默下载礼物svga
downloadAllGift(); downloadAllGift();
over();
} }
}); });
@ -336,7 +338,11 @@ public class LiveAudienceActivity extends LiveActivity {
} }
} }
}; };
private void over(){
if("NEWUSER".equals(getIntent().getStringExtra("OPEN"))){
manager.mLiveAudienceViewHolder.openNewPeopleDialog();
}
}
/** /**
* 打开礼物窗口 * 打开礼物窗口
@ -897,6 +903,11 @@ public class LiveAudienceActivity extends LiveActivity {
*/ */
public static void forward(Context context, LiveBean liveBean, int liveType, public static void forward(Context context, LiveBean liveBean, int liveType,
int liveTypeVal, String key, int position, int liveSdk) { int liveTypeVal, String key, int position, int liveSdk) {
forward(context, liveBean, liveType, liveTypeVal, key, null, position, liveSdk);
}
public static void forward(Context context, LiveBean liveBean, int liveType,
int liveTypeVal, String key, Map<String, String> map, int position, int liveSdk) {
Intent intent = new Intent(context, LiveAudienceActivity.class); Intent intent = new Intent(context, LiveAudienceActivity.class);
intent.putExtra(Constants.LIVE_BEAN, liveBean); intent.putExtra(Constants.LIVE_BEAN, liveBean);
intent.putExtra(Constants.LIVE_TYPE, liveType); intent.putExtra(Constants.LIVE_TYPE, liveType);
@ -905,9 +916,13 @@ public class LiveAudienceActivity extends LiveActivity {
intent.putExtra(Constants.LIVE_POSITION, position); intent.putExtra(Constants.LIVE_POSITION, position);
intent.putExtra(Constants.LIVE_SDK, liveSdk); intent.putExtra(Constants.LIVE_SDK, liveSdk);
intent.putExtra(Constants.LIVE_SDK, liveSdk); intent.putExtra(Constants.LIVE_SDK, liveSdk);
if (map != null) {
for (String _key : map.keySet()) {
intent.putExtra(_key, map.get(_key));
}
}
intent.putExtra("landscape", liveBean.getLandscape()); intent.putExtra("landscape", liveBean.getLandscape());
context.startActivity(intent); context.startActivity(intent);
} }
@ -946,9 +961,10 @@ public class LiveAudienceActivity extends LiveActivity {
/** /**
* 后台下载所有礼物 * 后台下载所有礼物
*/ */
private void downloadAllGift(){ private void downloadAllGift() {
LiveHttpUtil.getNewGiftList(new HttpCallback() { LiveHttpUtil.getNewGiftList(new HttpCallback() {
List<LiveGiftBean> giftBeanList=new ArrayList<>(); List<LiveGiftBean> giftBeanList = new ArrayList<>();
@Override @Override
public void onSuccess(int code, String msg, String[] info) { public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) { if (code == 0 && info.length > 0) {
@ -958,20 +974,21 @@ public class LiveAudienceActivity extends LiveActivity {
CommonAppConfig.getInstance().setGiftListJson(obj.getString("listarray")); CommonAppConfig.getInstance().setGiftListJson(obj.getString("listarray"));
for (Object o : list) { for (Object o : list) {
JSONObject item= (JSONObject) o; JSONObject item = (JSONObject) o;
List<LiveGiftBean> giftlist = JSONArray.parseArray(item.getJSONArray("giftlist").toJSONString(), LiveGiftBean.class); List<LiveGiftBean> giftlist = JSONArray.parseArray(item.getJSONArray("giftlist").toJSONString(), LiveGiftBean.class);
for (LiveGiftBean bean : giftlist) { for (LiveGiftBean bean : giftlist) {
if(!bean.getSwf().isEmpty()){ if (!bean.getSwf().isEmpty()) {
giftBeanList.add(bean); giftBeanList.add(bean);
} }
} }
} }
GiftCacheUtil.getInstance().setDownloadList(giftBeanList); GiftCacheUtil.getInstance().setDownloadList(giftBeanList);
GiftCacheUtil.getInstance().setCallback(new CommonCallback<File>() { GiftCacheUtil.getInstance().setCallback(new CommonCallback<File>() {
int index=0; int index = 0;
@Override @Override
public void callback(File bean) { public void callback(File bean) {
if(bean!=null){ if (bean != null) {
index++; index++;
Bus.get().post(new GiftCacheUtil.GiftDownloadStatus(index, giftBeanList.size(), GiftCacheUtil.getIdForFileName(bean.getName()))); Bus.get().post(new GiftCacheUtil.GiftDownloadStatus(index, giftBeanList.size(), GiftCacheUtil.getIdForFileName(bean.getName())));
} }

View File

@ -28,6 +28,8 @@ import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.GiftCacheUtil; import com.yunbao.common.utils.GiftCacheUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R; import com.yunbao.live.R;
import com.yunbao.live.custom.GiftMarkView; import com.yunbao.live.custom.GiftMarkView;
@ -199,7 +201,13 @@ public class LiveGiftAdapter extends RecyclerView.Adapter<LiveGiftAdapter.Vh> {
GiftCacheUtil.getInstance().downloadGiftForId(bean, new CommonCallback<File>() { GiftCacheUtil.getInstance().downloadGiftForId(bean, new CommonCallback<File>() {
@Override @Override
public void callback(File bean) { public void callback(File bean) {
if(bean==null){
ToastUtil.show(WordUtil.getString(R.string.load_failure_2));
mLoading.setImageResource(R.mipmap.icon_download_gift);
mLoading.getAnimation().cancel();
}else {
mLoadingLayout.setVisibility(View.GONE); mLoadingLayout.setVisibility(View.GONE);
}
GiftCacheUtil.getInstance().restart(); GiftCacheUtil.getInstance().restart();
} }
}); });

View File

@ -53,16 +53,11 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
private int showType = 0; private int showType = 0;
private boolean isFullWindow = false; private boolean isFullWindow = false;
private String roomId; private String roomId;
private WebInterface webInterface;
public LiveHDDialogFragment() { public LiveHDDialogFragment() {
} }
public void setWebInterface(WebInterface webInterface) {
this.webInterface = webInterface;
}
/** /**
* 弹出全屏对话框 * 弹出全屏对话框
* *
@ -263,19 +258,6 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
} }
@JavascriptInterface
public void androidShowUserPreferentialRedDot() {
if (webInterface != null) {
webInterface.showUserPreferentialRedDot();
}
}
@JavascriptInterface
public void androidHideUserPreferentialRedDot() {
if (webInterface != null) {
webInterface.hideUserPreferentialRedDot();
}
}
} }
private LiveRoomCheckLivePresenter mCheckLivePresenter; private LiveRoomCheckLivePresenter mCheckLivePresenter;
@ -344,11 +326,4 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
mWebView.destroy(); mWebView.destroy();
} }
public abstract static class WebInterface {
public void showUserPreferentialRedDot() {
}
public void hideUserPreferentialRedDot() {
}
}
} }

View File

@ -298,10 +298,10 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
LiveRoomViewHolder.insertChat(lvBean2, 1); LiveRoomViewHolder.insertChat(lvBean2, 1);
} }
}, 10000);//3秒后执行Runnable中的run方法 }, 10000);//3秒后执行Runnable中的run方法
getNewPeopleInfo(); getNewPeopleInfo(false);
} }
public void getNewPeopleInfo() { public void getNewPeopleInfo(boolean show) {
API.get().pdLiveApi(mContext) API.get().pdLiveApi(mContext)
.getNewPeopleInfo() .getNewPeopleInfo()
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
@ -315,6 +315,12 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
} else { } else {
newPeopleUrl = CommonAppConfig.HOST + "/" + peopleInfo.getLink(); newPeopleUrl = CommonAppConfig.HOST + "/" + peopleInfo.getLink();
} }
setUserPreferentialRedDot(peopleInfo.getShowRed() == 1);
if (show) {
openNewPeopleDialog();
}
} else {
liveNewPeople.setVisibility(View.GONE);
} }
}, Throwable::printStackTrace).isDisposed(); }, Throwable::printStackTrace).isDisposed();
} }
@ -351,7 +357,11 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
/** /**
* 打开新人特惠对话框 * 打开新人特惠对话框
*/ */
private void openNewPeopleDialog() { public void openNewPeopleDialog() {
if (newPeopleUrl == null) {
getNewPeopleInfo(true);
return;
}
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
String url = newPeopleUrl + "&g=Appapi&m=Turntable&a=tricky"; String url = newPeopleUrl + "&g=Appapi&m=Turntable&a=tricky";
url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token="
@ -360,19 +370,6 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
bundle.putInt("show_type", 0); bundle.putInt("show_type", 0);
LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment(); LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment();
liveHDDialogFragment.setArguments(bundle); 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"); liveHDDialogFragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
} }
@ -408,11 +405,13 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
/** /**
* 显示/隐藏新人特惠礼物红点 * 显示/隐藏新人特惠礼物红点
*
* @param show true显示 false隐藏 * @param show true显示 false隐藏
*/ */
private void setUserPreferentialRedDot(boolean show){ private void setUserPreferentialRedDot(boolean show) {
mNewPeopleRedDot.setVisibility(show?View.VISIBLE:View.GONE); mNewPeopleRedDot.setVisibility(show ? View.VISIBLE : View.GONE);
} }
/** /**
* 退出直播间 * 退出直播间
*/ */

View File

@ -133,7 +133,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
//头部布局 //头部布局
private LiveRoomViewHolder mLiveRoomViewHolder; private LiveRoomViewHolder mLiveRoomViewHolder;
//底部布局 //底部布局
private LiveAudienceViewHolder mLiveAudienceViewHolder; public LiveAudienceViewHolder mLiveAudienceViewHolder;
//观众与主播连麦逻辑 //观众与主播连麦逻辑
private LiveLinkMicPresenter mLiveLinkMicPresenter; private LiveLinkMicPresenter mLiveLinkMicPresenter;
private LiveBean mLiveBean; private LiveBean mLiveBean;

View File

@ -369,6 +369,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_centerInParent="true" android:layout_centerInParent="true"
android:visibility="invisible"
android:src="@mipmap/live_icon_newpeople_en" /> android:src="@mipmap/live_icon_newpeople_en" />
<View <View
@ -379,7 +380,7 @@
android:layout_marginTop="0dp" android:layout_marginTop="0dp"
android:layout_marginRight="0dp" android:layout_marginRight="0dp"
android:background="@drawable/background_ff5075" android:background="@drawable/background_ff5075"
android:visibility="visible" /> android:visibility="invisible" />
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>

View File

@ -54,7 +54,9 @@ import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* Created by cxf on 2018/9/22. * Created by cxf on 2018/9/22.
@ -79,6 +81,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
private int intoIndex = 0; private int intoIndex = 0;
private List<LiveBean> new_data; private List<LiveBean> new_data;
private boolean isHave = false; private boolean isHave = false;
private Map<String,String> gotoRoomKey=new HashMap<>();
public MainHomeLiveViewHolder(Context context, ViewGroup parentView) { public MainHomeLiveViewHolder(Context context, ViewGroup parentView) {
super(context, parentView); super(context, parentView);
@ -312,7 +315,10 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
return; return;
} }
intoIndex = 1; intoIndex = 1;
LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", 0, liveSdk); if(gotoRoomKey.isEmpty()){
gotoRoomKey=null;
}
LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "",gotoRoomKey, 0, liveSdk);
} }
}); });
@ -345,6 +351,9 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
BannerBean bean = mBannerList.get(p); BannerBean bean = mBannerList.get(p);
if (bean != null) { if (bean != null) {
String link = bean.getLink(); String link = bean.getLink();
if(bean.getType()==2){
gotoRoomKey.put("OPEN","NEWUSER");
}
if (link.contains("http")) { if (link.contains("http")) {
WebViewActivity.forward(mContext, link, true); WebViewActivity.forward(mContext, link, true);
} else { } else {