直播的UI先保存一下

This commit is contained in:
ningwenqiang 2024-10-30 19:00:54 +08:00
parent ccc4802a23
commit 4269288754
26 changed files with 1196 additions and 28 deletions

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white"/>
<corners android:radius="17dp" />
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

@ -135,7 +135,8 @@ import com.yunbao.main.views.MainHomeComViewHolder;
import com.yunbao.main.views.MainHomeCommunityViewHolder; import com.yunbao.main.views.MainHomeCommunityViewHolder;
import com.yunbao.main.views.MainHomeGameViewHolder; import com.yunbao.main.views.MainHomeGameViewHolder;
import com.yunbao.main.views.MainHomeLiveViewHolder; import com.yunbao.main.views.MainHomeLiveViewHolder;
import com.yunbao.main.views.MainHomeViewHolder;
import com.yunbao.main.views.MainHomeViewHolder2;
import com.yunbao.main.views.MainMeViewHolder; import com.yunbao.main.views.MainMeViewHolder;
import com.yunbao.main.views.MainMessageViewHolder; import com.yunbao.main.views.MainMessageViewHolder;
import com.yunbao.video.utils.VideoStorge; import com.yunbao.video.utils.VideoStorge;
@ -180,7 +181,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
private ViewPager mViewPager; private ViewPager mViewPager;
private List<FrameLayout> mViewList; private List<FrameLayout> mViewList;
private MainHomeComViewHolder mainHomeComViewHolder; private MainHomeComViewHolder mainHomeComViewHolder;
private MainHomeViewHolder mainHomeViewHolder; private MainHomeViewHolder2 mainHomeViewHolder;
private MainHomeCommunityViewHolder mMainHomeCommunityViewHolder; private MainHomeCommunityViewHolder mMainHomeCommunityViewHolder;
private MainHomeGameViewHolder mainHomeGameLiveViewHolder; private MainHomeGameViewHolder mainHomeGameLiveViewHolder;
private MainMessageViewHolder mainMessageViewHolder; private MainMessageViewHolder mainMessageViewHolder;
@ -1302,7 +1303,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
//mainHomeComViewHolder = new MainHomeComViewHolder(mContext, MainActivity.this, parent); //mainHomeComViewHolder = new MainHomeComViewHolder(mContext, MainActivity.this, parent);
vh = mainHomeComViewHolder; vh = mainHomeComViewHolder;
} else if (position == 1) { } else if (position == 1) {
mainHomeViewHolder = new MainHomeViewHolder(mContext, parent); mainHomeViewHolder = new MainHomeViewHolder2(mContext, parent);
vh = mainHomeViewHolder; vh = mainHomeViewHolder;
/* mMainHomeCommunityViewHolder = new MainHomeCommunityViewHolder(mContext, parent, this);//直播 /* mMainHomeCommunityViewHolder = new MainHomeCommunityViewHolder(mContext, parent, this);//直播
vh = mMainHomeCommunityViewHolder;*/ vh = mMainHomeCommunityViewHolder;*/

View File

@ -29,6 +29,7 @@ import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.NineGridLayout; import com.yunbao.common.views.NineGridLayout;
@ -156,6 +157,12 @@ public class MainHomeComAdapter2 extends RefreshAdapter<ActiveBean> {
attentionImg.setImageResource(R.mipmap.ic_yola_attention); attentionImg.setImageResource(R.mipmap.ic_yola_attention);
} }
author.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
RouteUtil.forwardUserHome(bean.getUser_id());
}
});
// likeImg.setOnClickListener(new View.OnClickListener() { // likeImg.setOnClickListener(new View.OnClickListener() {
// @Override // @Override
// public void onClick(View v) { // public void onClick(View v) {

View File

@ -19,6 +19,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.blankj.utilcode.util.LogUtils;
import com.opensource.svgaplayer.SVGADrawable; import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGAImageView; import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser; import com.opensource.svgaplayer.SVGAParser;
@ -52,13 +53,18 @@ public class MainHomeLiveAdapter extends RefreshAdapter<LiveBean> {
private Context context; private Context context;
private int Height; private int Height;
private int getWeekIntIndex = 0; private int getWeekIntIndex = 0;
private boolean showBaner =true;
public void setShowBaner(boolean showBaner) {
// this.showBaner = showBaner;
}
public MainHomeLiveAdapter(Context context, int h) { public MainHomeLiveAdapter(Context context, int h) {
super(context); super(context);
this.context = context; this.context = context;
this.Height = h; this.Height = h;
mHeadView = mInflater.inflate(R.layout.item_main_home_live_head, null, false); mHeadView = mInflater.inflate(R.layout.item_main_home_live_head, null, false);
mHeadView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DpUtil.dp2px(120))); mHeadView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DpUtil.dp2px(85)));
} }
public View getHeadView() { public View getHeadView() {
@ -67,10 +73,25 @@ public class MainHomeLiveAdapter extends RefreshAdapter<LiveBean> {
@Override @Override
public int getItemViewType(int position) { public int getItemViewType(int position) {
if (position == 0) { if (!showBaner){
if (position % 2 == 1) {
return RIGHT;
}else {
return LEFT;
}
}
if (position == 4) {
return HEAD; return HEAD;
} else if (position > 0) { } else{
LiveBean mode = mList.get(position - 1); LiveBean mode;
if(mList.size()<4){
if(position>=mList.size()){
return HEAD;
}
mode= mList.get(position);
}else {
mode = mList.get(position > 4 ? position - 1 : position);
}
if (TextUtils.equals(mode.getIs_week(), "1")) { if (TextUtils.equals(mode.getIs_week(), "1")) {
return WEEKLAYOUT; return WEEKLAYOUT;
} else { } else {
@ -114,8 +135,9 @@ public class MainHomeLiveAdapter extends RefreshAdapter<LiveBean> {
@Override @Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) { public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
int nowPosition = position>4?position-1:position;
if (vh instanceof MainHomeLiveWeekItemViewHolder) { if (vh instanceof MainHomeLiveWeekItemViewHolder) {
((MainHomeLiveWeekItemViewHolder) vh).loadViewDate(mList.get(position - 1), position - 1, Height, new MainHomeLiveWeekItemViewHolder.OnItemClickListener() { ((MainHomeLiveWeekItemViewHolder) vh).loadViewDate(mList.get(nowPosition), nowPosition, Height, new MainHomeLiveWeekItemViewHolder.OnItemClickListener() {
@Override @Override
public void onItemClick(LiveBean bean, int position) { public void onItemClick(LiveBean bean, int position) {
if (mOnItemClickListener != null) { if (mOnItemClickListener != null) {
@ -124,7 +146,7 @@ public class MainHomeLiveAdapter extends RefreshAdapter<LiveBean> {
} }
}); });
} else if (vh instanceof MainHomeLiveItemViewHolder) { } else if (vh instanceof MainHomeLiveItemViewHolder) {
((MainHomeLiveItemViewHolder) vh).loadViewDate(mList.get(position - 1), position - 1, Height, new MainHomeLiveItemViewHolder.OnItemClickListener() { ((MainHomeLiveItemViewHolder) vh).loadViewDate(mList.get(nowPosition), nowPosition, Height, new MainHomeLiveItemViewHolder.OnItemClickListener() {
@Override @Override
public void onItemClick(LiveBean bean, int position) { public void onItemClick(LiveBean bean, int position) {
if (mOnItemClickListener != null) { if (mOnItemClickListener != null) {
@ -137,6 +159,11 @@ public class MainHomeLiveAdapter extends RefreshAdapter<LiveBean> {
@Override @Override
public int getItemCount() { public int getItemCount() {
if (!showBaner)
return super.getItemCount();
if(mList.isEmpty()){
return 0;
}
return super.getItemCount()+1; return super.getItemCount()+1;
} }

View File

@ -3,13 +3,17 @@ package com.yunbao.main.adapter;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Build; import android.os.Build;
import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.bean.LiveClassBean; import com.yunbao.common.bean.LiveClassBean;
@ -57,7 +61,7 @@ public class MainHomeLivesClassAdapter extends RecyclerView.Adapter<MainHomeLive
@NonNull @NonNull
@Override @Override
public MainHomeLivesClassAdapter.Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public MainHomeLivesClassAdapter.Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
int res = R.layout.item_main_home_lives_class; int res = R.layout.item_main_live_com_class;
return new MainHomeLivesClassAdapter.Vh(mInflater.inflate(res, parent, false)); return new MainHomeLivesClassAdapter.Vh(mInflater.inflate(res, parent, false));
} }
@ -73,10 +77,12 @@ public class MainHomeLivesClassAdapter extends RecyclerView.Adapter<MainHomeLive
class Vh extends RecyclerView.ViewHolder { class Vh extends RecyclerView.ViewHolder {
TextView mName; TextView mName;
ImageView imageView;
public Vh(View itemView) { public Vh(View itemView) {
super(itemView); super(itemView);
mName = (TextView) itemView.findViewById(R.id.tv_class_name); mName = (TextView) itemView.findViewById(R.id.tv_class_name);
imageView =itemView.findViewById(R.id.index);
itemView.setOnClickListener(mOnClickListener); itemView.setOnClickListener(mOnClickListener);
} }
@ -96,11 +102,17 @@ public class MainHomeLivesClassAdapter extends RecyclerView.Adapter<MainHomeLive
} }
if (position == choice) { if (position == choice) {
mName.setBackgroundResource(R.drawable.button_ffc621); mName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
mName.setTextColor(Color.parseColor("#7d77fc")); //mName.setBackgroundResource(R.drawable.bg_main_community_type_01);
mName.setTextColor(ContextCompat.getColor(mContext, R.color.color_111111));
mName.setTypeface(null, Typeface.BOLD);
imageView.setVisibility(View.VISIBLE);
} else { } else {
mName.setBackgroundResource(R.drawable.button_cbd5e0); //mName.setBackgroundResource(R.drawable.bg_main_community_type_02);
mName.setTextColor(Color.parseColor("#484D68")); mName.setTextColor(ContextCompat.getColor(mContext, R.color.color_8a8a8a));
mName.setTypeface(null, Typeface.NORMAL);
mName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
imageView.setVisibility(View.GONE);
} }
} }
} }

View File

@ -0,0 +1,29 @@
package com.yunbao.main.views;
import android.content.Context;
import android.util.Log;
import android.view.ViewGroup;
import com.alibaba.fastjson.JSON;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.bean.AnchorRecommendModel;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.interfaces.OnItemClickListener;
interface LiveOptAgent extends OnItemClickListener<LiveBean> {
abstract public CommonRefreshView.DataHelper<LiveBean> getDataHelper();
abstract public void loadData();
abstract public void release();
}

View File

@ -0,0 +1,125 @@
package com.yunbao.main.views;
import android.content.Context;
import android.util.Log;
import com.alibaba.fastjson.JSON;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.bean.AnchorRecommendModel;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.main.activity.MainActivity;
import com.yunbao.main.activity.WeekWebViewActivity;
import com.yunbao.main.adapter.MainHomeLiveAdapter;
import com.yunbao.main.adapter.MainHomeRemFollLiveAdapter;
import com.yunbao.main.http.MainHttpConsts;
import com.yunbao.main.http.MainHttpUtil;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
public class LiveOptComAgent implements LiveOptAgent {
private MainHomeLiveAdapter mAdapter;
private Context mContext;
public void watchLive(LiveBean liveBean, String key, int position) {
((MainActivity) mContext).watchLive(liveBean, key, position);
}
public LiveOptComAgent(Context context,MainHomeLiveAdapter adapter) {
mContext = context;
mAdapter = adapter;
}
public static int pp;
@Override
public void onItemClick(LiveBean bean, int position) {
if ("1".equals(bean.getIslive())) {
watchLive(bean, Constants.LIVE_HOME, position);
} else if (bean.getIs_week() != null && bean.getIs_week().equals("1")) {
String url = CommonAppConfig.HOST + bean.getUrl() + "?a=1";
WeekWebViewActivity.forward(mContext, url, true);
} else {
RouteUtil.forwardUserHome(mContext, bean.getUid(), 0);
}
}
public CommonRefreshView.DataHelper<LiveBean> getDataHelper() {
return new CommonRefreshView.DataHelper<LiveBean>() {
@Override
public RefreshAdapter<LiveBean> getAdapter() {
// if (mAdapter == null) {
// mAdapter = new MainHomeRemFollLiveAdapter(mContext, MainActivity.Height);
// mAdapter.setOnItemClickListener(LiveOptComAgent.this);
// }
// Log.i("MainHomeViewHolder2", "LiveOptComAgent.getAdapter" );
return null;
}
@Override
public void loadData(int p, HttpCallback callback) {
pp = p;
Log.i("MainHomeViewHolder2", "LiveOptComAgent.loadData" );
MainHttpUtil.getRandom(p, callback);
}
@Override
public List<LiveBean> processData(String[] info) {
if(pp == 1){
return JSON.parseArray(Arrays.toString(info), LiveBean.class);
}else{
return null;
}
}
@Override
public void onRefreshSuccess(List<LiveBean> list, int count) {
SWAuManager.get().preloadChannel(list);
EventBus.getDefault().post(new AnchorRecommendModel());
}
@Override
public void onRefreshFailure() {
}
@Override
public void onLoadMoreSuccess(List<LiveBean> loadItemList, int loadItemCount) {
}
@Override
public void onLoadMoreFailure() {
}
};
}
public void loadData() {
if (mAdapter != null) {
SWAuManager.get().preloadChannel(mAdapter.getList());
}
}
public void release() {
MainHttpUtil.cancel(MainHttpConsts.GET_RANDOM);
}
}

View File

@ -0,0 +1,130 @@
package com.yunbao.main.views;
import android.content.Context;
import android.util.Log;
import com.alibaba.fastjson.JSON;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.bean.AnchorRecommendModel;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.main.activity.MainActivity;
import com.yunbao.main.activity.WeekWebViewActivity;
import com.yunbao.main.adapter.MainHomeLiveAdapter;
import com.yunbao.main.adapter.MainHomeRemFollLiveAdapter;
import com.yunbao.main.http.MainHttpConsts;
import com.yunbao.main.http.MainHttpUtil;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
public class LiveOptFollAgent implements LiveOptAgent {
private MainHomeLiveAdapter mAdapter;
private Context mContext;
public void watchLive(LiveBean liveBean, String key, int position) {
((MainActivity) mContext).watchLive(liveBean, key, position);
}
public LiveOptFollAgent(Context context,MainHomeLiveAdapter adapter) {
Log.i("MainHomeViewHolder2", "LiveOptFollAgent.LiveOptFollAgent");
mContext = context;
mAdapter = adapter;
}
@Override
public void onItemClick(LiveBean bean, int position) {
if ("1".equals(bean.getIslive())) {
watchLive(bean, Constants.LIVE_HOME, position);
} else if (bean.getIs_week() != null && bean.getIs_week().equals("1")) {
String url = CommonAppConfig.HOST + bean.getUrl() + "?a=1";
WeekWebViewActivity.forward(mContext, url, true);
} else {
RouteUtil.forwardUserHome(mContext, bean.getUid(), 0);
}
}
public CommonRefreshView.DataHelper<LiveBean> getDataHelper() {
return new CommonRefreshView.DataHelper<LiveBean>() {
@Override
public RefreshAdapter<LiveBean> getAdapter() {
// if (mAdapter == null) {
// mAdapter = new MainHomeRemFollLiveAdapter(mContext, MainActivity.Height);
// mAdapter.setOnItemClickListener(LiveOptFollAgent.this);
// }
// Log.i("MainHomeViewHolder2", "LiveOptFollAgent.getAdapter" );
return null;
}
@Override
public void loadData(int p, HttpCallback callback) {
Log.i("t2", "aaa" + p);
MainHttpUtil.getHomeFollow(p, callback);
Log.i("MainHomeViewHolder2", "LiveOptFollAgent.loadData" );
}
@Override
public List<LiveBean> processData(String[] info) {
return JSON.parseArray(Arrays.toString(info), LiveBean.class);
}
@Override
public void onRefreshSuccess(List<LiveBean> list, int count) {
SWAuManager.get().preloadChannel(list);
EventBus.getDefault().post(new AnchorRecommendModel());
}
@Override
public void onRefreshFailure() {
Log.i("MainHomeViewHolder2", "LiveOptFollAgent.onRefreshFailure" );
}
@Override
public void onLoadMoreSuccess(List<LiveBean> loadItemList, int loadItemCount) {
List<LiveBean> new_data = new ArrayList<>();
for (int j = 0; j < loadItemList.size(); j++) {
if (loadItemList.get(j).getUserNiceName() != null) {
new_data.add(loadItemList.get(j));
}
}
SWAuManager.get().preloadChannel(new_data);
mAdapter.insertList(new_data);
}
@Override
public void onLoadMoreFailure() {
Log.i("MainHomeViewHolder2", "LiveOptFollAgent.onLoadMoreFailure" );
}
};
}
public void loadData() {
if (mAdapter != null) {
SWAuManager.get().preloadChannel(mAdapter.getList());
}
}
public void release() {
MainHttpUtil.cancel(MainHttpConsts.GET_HOME_FOLLOW);
}
}

View File

@ -6,6 +6,8 @@ import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.graphics.Outline; import android.graphics.Outline;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
@ -163,14 +165,16 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override @Override
public int getSpanSize(int position) { public int getSpanSize(int position) {
if (position == 0) { if (position == 4) {
return 2;
}else if(mAdapter.getList().size()<4&&position==mAdapter.getList().size()){
return 2; return 2;
} }
return 1; return 1;
} }
}); });
mRefreshView.setLayoutManager(gridLayoutManager); mRefreshView.setLayoutManager(gridLayoutManager);
ItemDecoration decoration = new ItemDecoration(mContext, 0x00000000, 5, 0); ItemDecoration decoration = new ItemDecoration(mContext, 0x00000000, 7, 0);
decoration.setOnlySetItemOffsetsButNoDraw(true); decoration.setOnlySetItemOffsetsButNoDraw(true);
mRefreshView.setItemDecoration(decoration); mRefreshView.setItemDecoration(decoration);
mAdapter = new MainHomeLiveAdapter(mContext, MainActivity.Height); mAdapter = new MainHomeLiveAdapter(mContext, MainActivity.Height);
@ -189,6 +193,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
Log.i("t2", "aaa" + p); Log.i("t2", "aaa" + p);
if (TextUtils.equals(typeHot, "Hot") || TextUtils.equals(typeHot, "hot") || TextUtils.equals(typeHot, "熱門")) { if (TextUtils.equals(typeHot, "Hot") || TextUtils.equals(typeHot, "hot") || TextUtils.equals(typeHot, "熱門")) {
pp = 1; pp = 1;
// MainHttpUtil.getHot(p, callback);
LiveHttpUtil.getAnchorLastWeekList(new HttpCallback() { LiveHttpUtil.getAnchorLastWeekList(new HttpCallback() {
@Override @Override
public void onSuccess(int code, String msg, String[] info) { public void onSuccess(int code, String msg, String[] info) {
@ -226,7 +231,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
if (info.length > 0) { if (info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]); JSONObject obj = JSON.parseObject(info[0]);
mBannerList = JSON.parseArray(obj.getString("slide"), BannerBean.class); mBannerList = JSON.parseArray(obj.getString("slide_pic"), BannerBean.class);
if (!obj.containsKey("list")) { if (!obj.containsKey("list")) {
return new_data; return new_data;
} }
@ -330,9 +335,14 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
if (!canClick()) { if (!canClick()) {
return; return;
} }
// mRefreshView.getRefreshView().scrollToPosition(0);
mAdapter.clearData();
select = bean.getId(); select = bean.getId();
typeHot = bean.getEnglish(); typeHot = bean.getEnglish();
new Handler(Looper.getMainLooper())
.postDelayed(() -> {
mRefreshView.initData(); mRefreshView.initData();
}, 100);
topAdapter.choice = position; topAdapter.choice = position;
topAdapter.notifyDataSetChanged(); topAdapter.notifyDataSetChanged();
@ -348,7 +358,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
mBanner.setOutlineProvider(new ViewOutlineProvider() { mBanner.setOutlineProvider(new ViewOutlineProvider() {
@Override @Override
public void getOutline(View view, Outline outline) { public void getOutline(View view, Outline outline) {
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10); outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 30);
} }
}); });
mBanner.setClipToOutline(true); mBanner.setClipToOutline(true);

View File

@ -13,22 +13,18 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants; import com.yunbao.common.Constants;
import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.bean.ActiveBean; import com.yunbao.common.bean.ActiveBean;
import com.yunbao.common.bean.NewCommunityType; import com.yunbao.common.bean.NewCommunityType;
import com.yunbao.common.custom.CommonRefreshView; import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.custom.CommonRefreshWaterfallView;
import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.manager.CommunityTypeManager;
import com.yunbao.common.manager.OpenAdManager; import com.yunbao.common.manager.OpenAdManager;
import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.main.R; import com.yunbao.main.R;
import com.yunbao.main.adapter.MainHomeComAdapter2; import com.yunbao.main.adapter.MainHomeComAdapter2;
import com.yunbao.main.adapter.MainHomeComClassAdapter; import com.yunbao.main.adapter.MainHomeComClassAdapter;

View File

@ -125,7 +125,6 @@ public class MainHomeRecomLiveViewHolder extends AbsMainHomeChildViewHolder impl
} }
}); });
mRefreshView.initData(); mRefreshView.initData();
@ -149,9 +148,6 @@ public class MainHomeRecomLiveViewHolder extends AbsMainHomeChildViewHolder impl
@Override @Override
public void loadData() { public void loadData() {
// if (mRefreshView != null) {
// mRefreshView.initData();
// }
if (mAdapter != null) { if (mAdapter != null) {
SWAuManager.get().preloadChannel(mAdapter.getList()); SWAuManager.get().preloadChannel(mAdapter.getList());
} }

View File

@ -0,0 +1,683 @@
package com.yunbao.main.views;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Outline;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
import android.widget.ImageView;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.DrawableImageViewTarget;
import com.bumptech.glide.request.target.Target;
import com.ms.banner.Banner;
import com.ms.banner.listener.OnBannerClickListener;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.activity.WebViewActivity;
import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.bean.AnchorRecommendModel;
import com.yunbao.common.bean.BannerBean;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.bean.LiveClassBean;
import com.yunbao.common.bean.WeekListBean;
import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.custom.ItemDecoration;
import com.yunbao.common.dialog.GiftWallDialog;
import com.yunbao.common.event.LiveRoomChangeEvent;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.LiveClassManager;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
import com.yunbao.common.utils.MicStatusManager;
import com.yunbao.common.utils.MobclickAgent;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.CustomViewHolder;
import com.yunbao.live.utils.LiveStorge;
import com.yunbao.live.views.LiveRoomViewHolder;
import com.yunbao.main.R;
import com.yunbao.main.activity.MainActivity;
import com.yunbao.main.adapter.MainHomeLiveAdapter;
import com.yunbao.main.adapter.MainHomeLivesClassAdapter;
import com.yunbao.main.http.MainHttpConsts;
import com.yunbao.main.http.MainHttpUtil;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
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;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
/**
* Created by cxf on 2018/9/22.
* MainActivity 新的直播首页
*/
public class MainHomeViewHolder2 extends AbsMainHomeChildViewHolder implements OnItemClickListener<LiveBean>, LiveOptAgent {
private View mShadow;
private View mBtnDismiss;
public static CommonRefreshView mRefreshView;
private RecyclerView mClassRecyclerViewTop;
private MainHomeLiveAdapter mAdapter;
private ObjectAnimator mShowAnimator;
private ObjectAnimator mHideAnimator;
private Banner mBanner;
private boolean mBannerShowed;
private List<BannerBean> mBannerList;
private List<WeekListBean> mWeekListBean;
public static ImageView btnUseIco;
private int select = 0;
//是否是首頁
private int intoIndex = 0;
private List<LiveBean> new_data;
private boolean isHave = false;
private Map<String, String> gotoRoomKey = new HashMap<>();
private Dialog mShowLoadingDialog;
private String typeHot;
private LiveOptAgent mLiveOptFollAgent, mLiveOptComAgent;
private LiveOptAgent nowLiveOptAgent = this;
public MainHomeViewHolder2(Context context, ViewGroup parentView) {
super(context, parentView);
}
@Override
protected int getLayoutId() {
return R.layout.view_main_home2;
}
public static int pp;
//显示顶部商城tab时显示底部tabGroup
@Subscribe(threadMode = ThreadMode.MAIN)
public void onUpdata(String str) {
if ("Updata".equals(str)) {
if (mRefreshView != null) {
mRefreshView.showRefreshBar();
mRefreshView.mRecyclerView.scrollToPosition(0);
}
} else if ("blacklist".equals(str)) {
if (mRefreshView != null) {
mRefreshView.showRefreshBar();
}
}
}
@Override
public void init() {
List<LiveClassBean> list = new LiveClassManager(mContext).getLiveClass();
if (list != null && !list.isEmpty()) {
typeHot = list.get(0).getEnglish();
select = list.get(0).getId();
}
list.add(0, getAttentionLiveClass());
if (list.size() > 2) {
list.add(2, getCoLiveClass());
} else {
list.add(getCoLiveClass());
}
mShadow = findViewById(R.id.shadow);
mBtnDismiss = findViewById(R.id.btn_dismiss);
mBtnDismiss.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (canClick()) {
if (mShowAnimator != null) {
mShowAnimator.cancel();
}
if (mHideAnimator != null) {
mHideAnimator.start();
}
}
}
});
mRefreshView = (CommonRefreshView) findViewById(R.id.refreshView);
btnUseIco = (ImageView) findViewById(R.id.btn_use_ico);
mRefreshView.setEmptyLayoutId(R.layout.view_no_data_live);
EventBus.getDefault().register(this);
GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext, 2, GridLayoutManager.VERTICAL, false);
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
// if (nowLiveOptAgent!= MainHomeViewHolder2.this)
// return 1;
if (position == 4) {
return 2;
} else if (mAdapter.getList().size() < 4 && position == mAdapter.getList().size()) {
return 2;
}
return 1;
}
});
mRefreshView.setLayoutManager(gridLayoutManager);
ItemDecoration decoration = new ItemDecoration(mContext, 0x00000000, 5, 0);
decoration.setOnlySetItemOffsetsButNoDraw(true);
mRefreshView.setItemDecoration(decoration);
mAdapter = new MainHomeLiveAdapter(mContext, MainActivity.Height);
mAdapter.setOnItemClickListener(MainHomeViewHolder2.this);
mLiveOptFollAgent = new LiveOptFollAgent(mContext,mAdapter);
mLiveOptComAgent = new LiveOptComAgent(mContext,mAdapter);
mAdapter.setHasStableIds(true);//
mRefreshView.setLoadMoreEnable(true);
mRefreshView.setRecyclerViewAdapter(mAdapter);
mRefreshView.setDataHelper(getDataHelper());
mClassRecyclerViewTop = (RecyclerView) findViewById(R.id.topTitleRecyclerView);
mClassRecyclerViewTop.setHasFixedSize(true);
mClassRecyclerViewTop.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
if (list != null && list.size() > 0) {
List<LiveClassBean> targetList = new ArrayList<>();
if (list.size() <= 6) {
targetList.addAll(list);
} else {
targetList.addAll(list);
}
final MainHomeLivesClassAdapter topAdapter = new MainHomeLivesClassAdapter(mContext, targetList, false);
topAdapter.choice = 1;
topAdapter.setOnItemClickListener(new OnItemClickListener<LiveClassBean>() {
@Override
public void onItemClick(LiveClassBean bean, int position) {
switch (bean.getEnglish()) {
case "Hot":
MobclickAgent.onEvent(mContext, "home_page_recommend_hot", "热门");
break;
case "New":
MobclickAgent.onEvent(mContext, "home_page_recommend_new", "新秀");
break;
case "Pretty":
MobclickAgent.onEvent(mContext, "home_page_recommend_pretty", "颜值");
break;
case "Dance":
MobclickAgent.onEvent(mContext, "home_page_recommend_dance", "舞蹈");
break;
case "Mr.Right":
MobclickAgent.onEvent(mContext, "home_page_recommend_mr.right", "男神");
break;
case "Music":
MobclickAgent.onEvent(mContext, "home_page_recommend_music", "音乐");
break;
default:
MobclickAgent.onEvent(mContext, "home_page_recommend_other", "其他");
break;
}
if (!canClick()) {
return;
}
mAdapter.clearData();
select = bean.getId();
boolean flag = false;
if (position == 0) {
Log.i("MainHomeViewHolder2", "mLiveOptFollAgent:");
flag= changeLiveOptAgent(mLiveOptFollAgent);
} else if (position == 2) {
Log.i("MainHomeViewHolder2", "mLiveOptComAgent:");
flag= changeLiveOptAgent(mLiveOptComAgent);
} else {
Log.i("MainHomeViewHolder2", "MainHomeViewHolder2:");
flag= changeLiveOptAgent(MainHomeViewHolder2.this);
}
typeHot = bean.getEnglish();
if (!flag){
new Handler(Looper.getMainLooper())
.postDelayed(() -> {
mRefreshView.initData();
}, 100);
}
topAdapter.choice = position;
topAdapter.notifyDataSetChanged();
}
});
if (mClassRecyclerViewTop != null) {
mClassRecyclerViewTop.setAdapter(topAdapter);
}
}
View headView = mAdapter.getHeadView();
mBanner = (Banner) headView.findViewById(R.id.banner);
mRefreshView.initData();
mBanner.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10);
}
});
mBanner.setClipToOutline(true);
String adUrl = ((Activity) mContext).getIntent().getStringExtra("ad_url");
ImageView ad = headView.findViewById(R.id.ad_img);
if (StringUtil.isEmpty(adUrl)) {
ActivityCompat.startPostponedEnterTransition((Activity) mContext);
ad.setVisibility(View.GONE);
} else {
//ImgLoader.display(mContext, adUrl, ad);
Glide.with(mContext)
.load(adUrl)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
ActivityCompat.startPostponedEnterTransition((Activity) mContext);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
ActivityCompat.startPostponedEnterTransition((Activity) mContext);
return false;
}
})
/* .addListener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
ActivityCompat.startPostponedEnterTransition((Activity) mContext);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
ActivityCompat.startPostponedEnterTransition((Activity) mContext);
return false;
}
})*/
.error(R.mipmap.ic_launcher)
.into(new DrawableImageViewTarget(ad));
}
}
private boolean changeLiveOptAgent(LiveOptAgent liveOptAgent) {
if (nowLiveOptAgent == liveOptAgent) {
return false;
}
nowLiveOptAgent= liveOptAgent;
if (liveOptAgent==this){
// mRefreshView.setRecyclerViewAdapter(mAdapter);
mRefreshView.setDataHelper(getDataHelper());
mAdapter.setOnItemClickListener(this);
mAdapter.setShowBaner(true);
}else {
// mRefreshView.setRecyclerViewAdapter(liveOptAgent.getDataHelper().getAdapter());
mRefreshView.setDataHelper(liveOptAgent.getDataHelper());
mAdapter.setOnItemClickListener(liveOptAgent);
mAdapter.setShowBaner(false);
}
new Handler(Looper.getMainLooper())
.postDelayed(() -> {
mRefreshView.initData();
}, 100);
return true;
}
private void gotoLive(final String live_id) {
LiveHttpUtil.getLiveInfo(live_id, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
if (liveBean == null) {
return;
}
intoIndex = 1;
if (gotoRoomKey != null && gotoRoomKey.isEmpty()) {
gotoRoomKey = null;
}
liveBean.setParams(gotoRoomKey);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk, boolean isSw) {
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal), isSw);
}
@Override
public void onCheckError(String contextError) {
}
});
} else {
intoIndex = 1;
RouteUtil.forwardUserHome(mContext, live_id, 0);
}
}
});
}
private void showBanner() {
if (mBannerList == null || mBannerList.size() == 0 || mBanner == null) {
return;
}
if (mBannerShowed) {
return;
}
mBannerShowed = true;
mBanner.setAutoPlay(true)
.setPages(mBannerList, new CustomViewHolder())
.setDelayTime(3000)
.setOnBannerClickListener(new OnBannerClickListener() {
@Override
public void onBannerClick(List datas, int p) {
if (mBannerList != null) {
if (p >= 0 && p < mBannerList.size()) {
BannerBean bean = mBannerList.get(p);
if (bean != null) {
String link = bean.getLink();
if (bean.getType() == 2) {
if (bean.getLink().isEmpty()) {
ToastUtil.show("暫無法簽到,請稍後再試");
return;
} else {
if (gotoRoomKey == null) {
gotoRoomKey = new HashMap<>();
}
gotoRoomKey.put("OPEN", "NEWUSER");
}
}
showLoadingDialog();
Map<String, String> map_ekv = new HashMap<String, String>();
map_ekv.put("link", link);
MobclickAgent.onEvent(mContext, "home_page_recommend_banner", map_ekv);
if (link.contains("http")) {
WebViewActivity.forward(mContext, link, true, false);
} else if ("home_page_banner_battle".equals(link)) {
RouteUtil.forwardBattlePass();
} else if ("home_page_banner_giftwall".equals(link)) {
if (mShowLoadingDialog != null && mShowLoadingDialog.isShowing()) {
mShowLoadingDialog.dismiss();
}
new GiftWallDialog(mContext, IMLoginManager.get(mContext).getUserInfo().getId() + "",
IMLoginManager.get(mContext).getUserInfo().getUserNicename(), null
, false).setFullWindows(true).setTab2(true).showDialog();
} else {
gotoLive(link);
}
}
}
}
}
})
.start();
}
/**
* Banner双击可能会导致进入两次直播间点击Banner后需要展示加载中动画
*/
private void showLoadingDialog() {
mShowLoadingDialog = DialogUitl.loadingDialog(mContext);
mShowLoadingDialog.show();
}
@Override
public void onItemClick(LiveBean bean, int position) {
if ("1".equals(bean.getIslive())) {
intoIndex = 1;
watchLive(bean, Constants.LIVE_HOME, position);
} else if (bean.getIs_week() != null && bean.getIs_week().equals("1")) {
String url = CommonAppConfig.HOST + bean.getUrl() + "?a=1";
LiveHttpUtil.getLiveInfo(bean.getUid(), new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
if (liveBean == null) {
return;
}
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk, boolean isSw) {
if (LiveRoomViewHolder.mHandler != null) {
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
}
if (!"".endsWith(Constants.mStream)) {
if (MicStatusManager.getInstance().isMic(liveUid)) {
MicStatusManager.getInstance().showDownMicDialog(mContext);
return;
}
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, Integer.parseInt(liveTypeVal)));
} else {
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk), isSw);
}
}
@Override
public void onCheckError(String contextError) {
}
});
} else {
ToastUtil.show(msg);
}
}
});
} else {
intoIndex = 1;
RouteUtil.forwardUserHome(mContext, bean.getUid(), 0);
}
}
@Override
public CommonRefreshView.DataHelper<LiveBean> getDataHelper() {
return new CommonRefreshView.DataHelper<LiveBean>() {
@Override
public RefreshAdapter<LiveBean> getAdapter() {
return null;
}
@Override
public void loadData(int p, HttpCallback callback) {
Log.i("t2", "aaa" + p);
if (TextUtils.equals(typeHot, "Hot") || TextUtils.equals(typeHot, "hot") || TextUtils.equals(typeHot, "熱門")) {
pp = 1;
LiveHttpUtil.getAnchorLastWeekList(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (mWeekListBean != null) {
mWeekListBean.clear();
}
if (code == 0 && info.length > 0) {
mWeekListBean = JSON.parseArray(Arrays.toString(info), WeekListBean.class);
} else {
mWeekListBean = null;
}
if (mWeekListBean != null && mWeekListBean.size() > 0) {
mAdapter.setWeekList(mWeekListBean);
isHave = true;
} else {
mAdapter.moveWeekList();
isHave = false;
}
Constants.getWeekIntIndex = Constants.getWeekIntIndex + 1;
MainHttpUtil.getHot(p, callback);
}
});
} else {
pp = 0;
// if (select == 0) {
// select = list.get(0).getId();
// }
MainHttpUtil.getClassLive(select, p, callback);
}
}
@Override
public List<LiveBean> processData(String[] info) {
new_data = new ArrayList<>();
if (info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
mBannerList = JSON.parseArray(obj.getString("slide"), BannerBean.class);
if (!obj.containsKey("list")) {
return new_data;
}
List<LiveBean> old_data = JSON.parseArray(obj.getString("list"), LiveBean.class);
LiveBean liveModel = null;
if (old_data == null) {
return new_data;
}
for (LiveBean model : old_data) {
//判断周星榜数据
if (TextUtils.equals(model.getIs_week(), "1")) {
if (mWeekListBean != null && mWeekListBean.size() > 0) {
model.setmWeekList(mWeekListBean);
} else {
liveModel = model;
}
}
}
//满足有周星榜字段但是没有周星榜数据的删掉
if (liveModel != null) {
old_data.remove(liveModel);
}
SWAuManager.get().preloadChannel(old_data);
new_data.addAll(old_data);
}
return new_data;
}
@Override
public void onRefreshSuccess(List<LiveBean> list, int count) {
if (CommonAppConfig.LIVE_ROOM_SCROLL) {
LiveStorge.getInstance().put(Constants.LIVE_HOME, list);
}
showBanner();
EventBus.getDefault().post(new AnchorRecommendModel());
}
@Override
public void onRefreshFailure() {
}
@Override
public void onLoadMoreSuccess(List<LiveBean> loadItemList, int loadItemCount) {
new_data = new ArrayList<>();
for (int j = 0; j < loadItemList.size(); j++) {
if (loadItemList.get(j).getUserNiceName() != null) {
new_data.add(loadItemList.get(j));
}
}
if (loadItemList.size() > 0) {
SWAuManager.get().preloadChannel(new_data);
mAdapter.insertList(new_data);
}
}
@Override
public void onLoadMoreFailure() {
}
};
}
@Override
public void loadData() {
if (nowLiveOptAgent != this) {
nowLiveOptAgent.loadData();
} else {
if (mAdapter != null) {
SWAuManager.get().preloadChannel(mAdapter.getList());
}
}
}
@Override
public void release() {
MainHttpUtil.cancel(MainHttpConsts.GET_HOT);
if (mHideAnimator != null) {
mHideAnimator.cancel();
}
if (mShowAnimator != null) {
mShowAnimator.cancel();
}
if (mAdapter != null) {
mAdapter.clearAnimator();
}
mShowAnimator = null;
mHideAnimator = null;
mLiveOptFollAgent.release();
mLiveOptComAgent.release();
}
@Override
public void onDestroy() {
super.onDestroy();
release();
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void onPause() {
super.onPause();
if (mShowLoadingDialog != null) {
mShowLoadingDialog.dismiss();
mShowLoadingDialog = null;
}
}
//获取关注的
private LiveClassBean getAttentionLiveClass() {
LiveClassBean liveClassBean = new LiveClassBean("關注", "Follow");
liveClassBean.setId(Integer.MAX_VALUE);
return liveClassBean;
}
//获取推荐的
private LiveClassBean getCoLiveClass() {
LiveClassBean liveClassBean = new LiveClassBean("推薦", "Recommend");
liveClassBean.setId(Integer.MAX_VALUE);
return liveClassBean;
}
}

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:id="@+id/tv_class_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="音乐"
android:paddingStart="6dp"
android:paddingEnd="6dp"
android:layout_marginStart="6dp"
android:layout_marginEnd="6dp"
android:textColor="@color/color_3d3d3d"
android:textSize="15sp" />
<ImageView
android:layout_marginBottom="4dp"
android:id="@+id/index"
android:layout_width="12dp"
android:layout_height="6dp"
app:layout_constraintTop_toBottomOf="@+id/tv_class_name"
app:layout_constraintStart_toStartOf="@+id/tv_class_name"
app:layout_constraintEnd_toEndOf="@+id/tv_class_name"
android:src="@mipmap/ic_yola_item_select" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/cupImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="38dp"
android:src="@mipmap/ic_yola_cup"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/videoImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="38dp"
android:layout_marginEnd="16dp"
android:src="@mipmap/ic_yola_vido"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/searchView"
android:layout_width="0dp"
android:layout_height="34dp"
android:background="@drawable/bg_white_radius17"
app:layout_constraintBottom_toBottomOf="@+id/cupImg"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/cupImg"
app:layout_constraintWidth_percent="0.66" />
<ImageView
android:id="@+id/searchImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:src="@mipmap/ic_yola_search_small"
app:layout_constraintBottom_toBottomOf="@+id/searchView"
app:layout_constraintStart_toStartOf="@+id/searchView"
app:layout_constraintTop_toTopOf="@+id/searchView" />
<TextView
android:id="@+id/searchTipsTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="搜主播名字"
android:textColor="#99000000"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="@+id/searchView"
app:layout_constraintStart_toEndOf="@+id/searchImg"
app:layout_constraintTop_toTopOf="@+id/searchView" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/topTitleRecyclerView"
app:layout_constraintTop_toBottomOf="@+id/searchView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:itemCount="1"
android:layout_marginTop="7dp"
android:layout_marginStart="16dp"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<com.yunbao.common.custom.CommonRefreshView
android:id="@+id/refreshView"
app:layout_constraintTop_toBottomOf="@+id/topTitleRecyclerView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="7dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_width="0dp"
android:layout_height="0dp" />
<FrameLayout
android:id="@+id/btn_dismiss"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:visibility="gone">
<View
android:id="@+id/shadow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0"
android:background="#80000000" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/classRecyclerView_dialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:overScrollMode="never"
android:paddingBottom="10dp" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>