新增Banner进入直播间直接唤起新人特惠
修复新人特惠URL为null时依旧打开弹框 调整新人特惠红点入口 调整用户手动下载svga如网络失败时的操作
This commit is contained in:
parent
127490ca91
commit
f2a3f55e52
@ -13,6 +13,7 @@ public class BannerBean {
|
||||
private String mLink;
|
||||
private String show_type;
|
||||
private String mIntoUrl;
|
||||
private int type;
|
||||
|
||||
private StarChallengeStatusModel model;
|
||||
|
||||
@ -71,4 +72,13 @@ public class BannerBean {
|
||||
public void setmIntoUrl(String intoUrl) {
|
||||
mIntoUrl = intoUrl;
|
||||
}
|
||||
|
||||
@JSONField(name = "type")
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
@JSONField(name = "type")
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ public class NewPeopleInfo extends BaseModel{
|
||||
private int isShow;//是否展示入口
|
||||
@SerializedName("link")
|
||||
private String link;//入口地址
|
||||
@SerializedName("red_show")
|
||||
private int showRed=0;
|
||||
|
||||
public boolean getChargeHidden() {
|
||||
return chargeHidden==1;
|
||||
@ -49,6 +51,14 @@ public class NewPeopleInfo extends BaseModel{
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
public int getShowRed() {
|
||||
return showRed;
|
||||
}
|
||||
|
||||
public void setShowRed(int showRed) {
|
||||
this.showRed = showRed;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -10,6 +10,7 @@ import com.yunbao.common.http.CommonHttpConsts;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
@ -25,7 +26,7 @@ public class GiftCacheUtil {
|
||||
private Handler handler = new Handler(Looper.getMainLooper());
|
||||
private boolean pause = false;
|
||||
private boolean downloading = false;
|
||||
private int clickId = 0;
|
||||
private List<String> clickId = new ArrayList<>();
|
||||
|
||||
private GiftCacheUtil() {
|
||||
}
|
||||
@ -107,9 +108,10 @@ public class GiftCacheUtil {
|
||||
downloadCache.put(bean.getId(), bean);
|
||||
}
|
||||
}
|
||||
public void addDownloadList(List<LiveGiftBean> list){
|
||||
|
||||
public void addDownloadList(List<LiveGiftBean> list) {
|
||||
for (LiveGiftBean bean : list) {
|
||||
downloadCache.put(bean.getId(),bean);
|
||||
downloadCache.put(bean.getId(), bean);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,16 +126,18 @@ public class GiftCacheUtil {
|
||||
* 插队优先下载指定id礼物
|
||||
*/
|
||||
public void downloadGiftForId(LiveGiftBean bean, CommonCallback<File> mDownloadGifCallback) {
|
||||
if(checkGiftIsDownload(bean.getId())){
|
||||
if (checkGiftIsDownload(bean.getId())) {
|
||||
mDownloadGifCallback.callback(null);
|
||||
return;
|
||||
}
|
||||
this.clickId = bean.getId();
|
||||
clickId.add(bean.getId()+"");
|
||||
getFile(getDownloadSaveName(bean.getId()), bean.getSwf(), "0", new CommonCallback<File>() {
|
||||
@Override
|
||||
public void callback(File bean) {
|
||||
GiftCacheUtil.this.clickId = -1;
|
||||
downloadCache.remove(getIdForFileName(bean.getName()));
|
||||
if(bean!=null) {
|
||||
clickId.remove(getIdForFileName(bean.getName())+"");
|
||||
downloadCache.remove(getIdForFileName(bean.getName()));
|
||||
}
|
||||
mDownloadGifCallback.callback(bean);
|
||||
}
|
||||
});
|
||||
@ -149,7 +153,7 @@ public class GiftCacheUtil {
|
||||
/**
|
||||
* 恢复下载
|
||||
*/
|
||||
public void restart(){
|
||||
public void restart() {
|
||||
pause = false;
|
||||
startDownload();
|
||||
}
|
||||
@ -159,7 +163,9 @@ public class GiftCacheUtil {
|
||||
*/
|
||||
public void resetStatus() {
|
||||
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(() -> {
|
||||
File dir = new File(CommonAppConfig.GIF_PATH);
|
||||
DownloadUtil downloadUtil = new DownloadUtil();
|
||||
Object[] ids = downloadCache.keySet().toArray();
|
||||
for (Object _id :ids) {
|
||||
int id= (int) _id;
|
||||
for (Object _id : ids) {
|
||||
int id = (int) _id;
|
||||
if (pause) {
|
||||
return;
|
||||
}
|
||||
@ -212,7 +218,7 @@ public class GiftCacheUtil {
|
||||
if (bean == null) {
|
||||
continue;
|
||||
}
|
||||
if (clickId == id) {
|
||||
if (clickId.contains(id+"")) {
|
||||
continue;
|
||||
}
|
||||
if (bean.getSwf().isEmpty()) {
|
||||
@ -225,11 +231,11 @@ public class GiftCacheUtil {
|
||||
downloadCache.remove(getIdForFileName(file.getName()));
|
||||
if (downloadCache.isEmpty()) {
|
||||
downloading = false;
|
||||
}else{
|
||||
} else {
|
||||
//单线程下载,以便插队下载和及时停止下载
|
||||
startDownload();
|
||||
}
|
||||
// handler.post(() -> commonCallback.callback(file));
|
||||
// handler.post(() -> commonCallback.callback(file));
|
||||
commonCallback.callback(file);
|
||||
}
|
||||
|
||||
@ -246,7 +252,7 @@ public class GiftCacheUtil {
|
||||
});
|
||||
break;
|
||||
}
|
||||
if(downloadCache.isEmpty()){
|
||||
if (downloadCache.isEmpty()) {
|
||||
resetStatus();
|
||||
}
|
||||
}).start();
|
||||
|
@ -87,6 +87,7 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/10.
|
||||
@ -323,6 +324,7 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
manager.onAdd(liveBean1, liveType, liveTypeVal, liveSdk);
|
||||
//加载完页面后再后台静默下载礼物svga
|
||||
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,
|
||||
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.putExtra(Constants.LIVE_BEAN, liveBean);
|
||||
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_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());
|
||||
context.startActivity(intent);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -946,9 +961,10 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
/**
|
||||
* 后台下载所有礼物
|
||||
*/
|
||||
private void downloadAllGift(){
|
||||
private void downloadAllGift() {
|
||||
LiveHttpUtil.getNewGiftList(new HttpCallback() {
|
||||
List<LiveGiftBean> giftBeanList=new ArrayList<>();
|
||||
List<LiveGiftBean> giftBeanList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
@ -958,20 +974,21 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
CommonAppConfig.getInstance().setGiftListJson(obj.getString("listarray"));
|
||||
|
||||
for (Object o : list) {
|
||||
JSONObject item= (JSONObject) o;
|
||||
JSONObject item = (JSONObject) o;
|
||||
List<LiveGiftBean> giftlist = JSONArray.parseArray(item.getJSONArray("giftlist").toJSONString(), LiveGiftBean.class);
|
||||
for (LiveGiftBean bean : giftlist) {
|
||||
if(!bean.getSwf().isEmpty()){
|
||||
if (!bean.getSwf().isEmpty()) {
|
||||
giftBeanList.add(bean);
|
||||
}
|
||||
}
|
||||
}
|
||||
GiftCacheUtil.getInstance().setDownloadList(giftBeanList);
|
||||
GiftCacheUtil.getInstance().setCallback(new CommonCallback<File>() {
|
||||
int index=0;
|
||||
int index = 0;
|
||||
|
||||
@Override
|
||||
public void callback(File bean) {
|
||||
if(bean!=null){
|
||||
if (bean != null) {
|
||||
index++;
|
||||
Bus.get().post(new GiftCacheUtil.GiftDownloadStatus(index, giftBeanList.size(), GiftCacheUtil.getIdForFileName(bean.getName())));
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ 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.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.custom.GiftMarkView;
|
||||
|
||||
@ -199,8 +201,14 @@ public class LiveGiftAdapter extends RecyclerView.Adapter<LiveGiftAdapter.Vh> {
|
||||
GiftCacheUtil.getInstance().downloadGiftForId(bean, new CommonCallback<File>() {
|
||||
@Override
|
||||
public void callback(File bean) {
|
||||
mLoadingLayout.setVisibility(View.GONE);
|
||||
GiftCacheUtil.getInstance().restart();
|
||||
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);
|
||||
}
|
||||
GiftCacheUtil.getInstance().restart();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -53,16 +53,11 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 弹出全屏对话框
|
||||
*
|
||||
@ -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;
|
||||
@ -344,11 +326,4 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
|
||||
mWebView.destroy();
|
||||
}
|
||||
|
||||
public abstract static class WebInterface {
|
||||
public void showUserPreferentialRedDot() {
|
||||
}
|
||||
|
||||
public void hideUserPreferentialRedDot() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -298,10 +298,10 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
|
||||
LiveRoomViewHolder.insertChat(lvBean2, 1);
|
||||
}
|
||||
}, 10000);//3秒后执行Runnable中的run方法
|
||||
getNewPeopleInfo();
|
||||
getNewPeopleInfo(false);
|
||||
}
|
||||
|
||||
public void getNewPeopleInfo() {
|
||||
public void getNewPeopleInfo(boolean show) {
|
||||
API.get().pdLiveApi(mContext)
|
||||
.getNewPeopleInfo()
|
||||
.subscribeOn(Schedulers.io())
|
||||
@ -315,6 +315,12 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
|
||||
} else {
|
||||
newPeopleUrl = CommonAppConfig.HOST + "/" + peopleInfo.getLink();
|
||||
}
|
||||
setUserPreferentialRedDot(peopleInfo.getShowRed() == 1);
|
||||
if (show) {
|
||||
openNewPeopleDialog();
|
||||
}
|
||||
} else {
|
||||
liveNewPeople.setVisibility(View.GONE);
|
||||
}
|
||||
}, 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();
|
||||
String url = newPeopleUrl + "&g=Appapi&m=Turntable&a=tricky";
|
||||
url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token="
|
||||
@ -360,19 +370,6 @@ 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");
|
||||
}
|
||||
|
||||
@ -408,11 +405,13 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
|
||||
|
||||
/**
|
||||
* 显示/隐藏新人特惠礼物红点
|
||||
*
|
||||
* @param show true显示 false隐藏
|
||||
*/
|
||||
private void setUserPreferentialRedDot(boolean show){
|
||||
mNewPeopleRedDot.setVisibility(show?View.VISIBLE:View.GONE);
|
||||
private void setUserPreferentialRedDot(boolean show) {
|
||||
mNewPeopleRedDot.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出直播间
|
||||
*/
|
||||
|
@ -133,7 +133,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
//头部布局
|
||||
private LiveRoomViewHolder mLiveRoomViewHolder;
|
||||
//底部布局
|
||||
private LiveAudienceViewHolder mLiveAudienceViewHolder;
|
||||
public LiveAudienceViewHolder mLiveAudienceViewHolder;
|
||||
//观众与主播连麦逻辑
|
||||
private LiveLinkMicPresenter mLiveLinkMicPresenter;
|
||||
private LiveBean mLiveBean;
|
||||
|
@ -369,6 +369,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
android:visibility="invisible"
|
||||
android:src="@mipmap/live_icon_newpeople_en" />
|
||||
|
||||
<View
|
||||
@ -379,7 +380,7 @@
|
||||
android:layout_marginTop="0dp"
|
||||
android:layout_marginRight="0dp"
|
||||
android:background="@drawable/background_ff5075"
|
||||
android:visibility="visible" />
|
||||
android:visibility="invisible" />
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
|
@ -54,7 +54,9 @@ import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/22.
|
||||
@ -79,6 +81,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
|
||||
private int intoIndex = 0;
|
||||
private List<LiveBean> new_data;
|
||||
private boolean isHave = false;
|
||||
private Map<String,String> gotoRoomKey=new HashMap<>();
|
||||
|
||||
public MainHomeLiveViewHolder(Context context, ViewGroup parentView) {
|
||||
super(context, parentView);
|
||||
@ -312,7 +315,10 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
|
||||
return;
|
||||
}
|
||||
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);
|
||||
if (bean != null) {
|
||||
String link = bean.getLink();
|
||||
if(bean.getType()==2){
|
||||
gotoRoomKey.put("OPEN","NEWUSER");
|
||||
}
|
||||
if (link.contains("http")) {
|
||||
WebViewActivity.forward(mContext, link, true);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user