diff --git a/live/src/main/res/drawable/bg_white_radius17.xml b/live/src/main/res/drawable/bg_white_radius17.xml
new file mode 100644
index 000000000..fae1b862c
--- /dev/null
+++ b/live/src/main/res/drawable/bg_white_radius17.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/live/src/main/res/mipmap-mdpi/ic_yola_cup.png b/live/src/main/res/mipmap-mdpi/ic_yola_cup.png
new file mode 100644
index 000000000..9bc4970b2
Binary files /dev/null and b/live/src/main/res/mipmap-mdpi/ic_yola_cup.png differ
diff --git a/live/src/main/res/mipmap-mdpi/ic_yola_fire.png b/live/src/main/res/mipmap-mdpi/ic_yola_fire.png
new file mode 100644
index 000000000..3423d0bec
Binary files /dev/null and b/live/src/main/res/mipmap-mdpi/ic_yola_fire.png differ
diff --git a/live/src/main/res/mipmap-mdpi/ic_yola_search_small.png b/live/src/main/res/mipmap-mdpi/ic_yola_search_small.png
new file mode 100644
index 000000000..608088fb9
Binary files /dev/null and b/live/src/main/res/mipmap-mdpi/ic_yola_search_small.png differ
diff --git a/live/src/main/res/mipmap-mdpi/ic_yola_vido.png b/live/src/main/res/mipmap-mdpi/ic_yola_vido.png
new file mode 100644
index 000000000..681ce9139
Binary files /dev/null and b/live/src/main/res/mipmap-mdpi/ic_yola_vido.png differ
diff --git a/live/src/main/res/mipmap-xxhdpi/ic_yola_cup.png b/live/src/main/res/mipmap-xxhdpi/ic_yola_cup.png
new file mode 100644
index 000000000..0f4097767
Binary files /dev/null and b/live/src/main/res/mipmap-xxhdpi/ic_yola_cup.png differ
diff --git a/live/src/main/res/mipmap-xxhdpi/ic_yola_fire.png b/live/src/main/res/mipmap-xxhdpi/ic_yola_fire.png
new file mode 100644
index 000000000..52b9266d0
Binary files /dev/null and b/live/src/main/res/mipmap-xxhdpi/ic_yola_fire.png differ
diff --git a/live/src/main/res/mipmap-xxhdpi/ic_yola_search_small.png b/live/src/main/res/mipmap-xxhdpi/ic_yola_search_small.png
new file mode 100644
index 000000000..cf917d352
Binary files /dev/null and b/live/src/main/res/mipmap-xxhdpi/ic_yola_search_small.png differ
diff --git a/live/src/main/res/mipmap-xxhdpi/ic_yola_vido.png b/live/src/main/res/mipmap-xxhdpi/ic_yola_vido.png
new file mode 100644
index 000000000..d16d80ed9
Binary files /dev/null and b/live/src/main/res/mipmap-xxhdpi/ic_yola_vido.png differ
diff --git a/live/src/main/res/mipmap-xxxhdpi/ic_yola_cup.png b/live/src/main/res/mipmap-xxxhdpi/ic_yola_cup.png
new file mode 100644
index 000000000..c4db862d8
Binary files /dev/null and b/live/src/main/res/mipmap-xxxhdpi/ic_yola_cup.png differ
diff --git a/live/src/main/res/mipmap-xxxhdpi/ic_yola_fire.png b/live/src/main/res/mipmap-xxxhdpi/ic_yola_fire.png
new file mode 100644
index 000000000..a6fd3e671
Binary files /dev/null and b/live/src/main/res/mipmap-xxxhdpi/ic_yola_fire.png differ
diff --git a/live/src/main/res/mipmap-xxxhdpi/ic_yola_search_small.png b/live/src/main/res/mipmap-xxxhdpi/ic_yola_search_small.png
new file mode 100644
index 000000000..8217ad45b
Binary files /dev/null and b/live/src/main/res/mipmap-xxxhdpi/ic_yola_search_small.png differ
diff --git a/live/src/main/res/mipmap-xxxhdpi/ic_yola_vido.png b/live/src/main/res/mipmap-xxxhdpi/ic_yola_vido.png
new file mode 100644
index 000000000..149901d8f
Binary files /dev/null and b/live/src/main/res/mipmap-xxxhdpi/ic_yola_vido.png differ
diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java
index cdcf77842..baf82436d 100644
--- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java
+++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java
@@ -135,7 +135,8 @@ import com.yunbao.main.views.MainHomeComViewHolder;
import com.yunbao.main.views.MainHomeCommunityViewHolder;
import com.yunbao.main.views.MainHomeGameViewHolder;
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.MainMessageViewHolder;
import com.yunbao.video.utils.VideoStorge;
@@ -180,7 +181,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
private ViewPager mViewPager;
private List mViewList;
private MainHomeComViewHolder mainHomeComViewHolder;
- private MainHomeViewHolder mainHomeViewHolder;
+ private MainHomeViewHolder2 mainHomeViewHolder;
private MainHomeCommunityViewHolder mMainHomeCommunityViewHolder;
private MainHomeGameViewHolder mainHomeGameLiveViewHolder;
private MainMessageViewHolder mainMessageViewHolder;
@@ -1302,7 +1303,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
//mainHomeComViewHolder = new MainHomeComViewHolder(mContext, MainActivity.this, parent);
vh = mainHomeComViewHolder;
} else if (position == 1) {
- mainHomeViewHolder = new MainHomeViewHolder(mContext, parent);
+ mainHomeViewHolder = new MainHomeViewHolder2(mContext, parent);
vh = mainHomeViewHolder;
/* mMainHomeCommunityViewHolder = new MainHomeCommunityViewHolder(mContext, parent, this);//直播
vh = mMainHomeCommunityViewHolder;*/
diff --git a/main/src/main/java/com/yunbao/main/adapter/MainHomeComAdapter2.java b/main/src/main/java/com/yunbao/main/adapter/MainHomeComAdapter2.java
index 84ad73bcc..0748666eb 100644
--- a/main/src/main/java/com/yunbao/main/adapter/MainHomeComAdapter2.java
+++ b/main/src/main/java/com/yunbao/main/adapter/MainHomeComAdapter2.java
@@ -29,6 +29,7 @@ import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.CommonCallback;
+import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.NineGridLayout;
@@ -156,6 +157,12 @@ public class MainHomeComAdapter2 extends RefreshAdapter {
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() {
// @Override
// public void onClick(View v) {
diff --git a/main/src/main/java/com/yunbao/main/adapter/MainHomeLiveAdapter.java b/main/src/main/java/com/yunbao/main/adapter/MainHomeLiveAdapter.java
index 4f58b217e..78e6ad58b 100644
--- a/main/src/main/java/com/yunbao/main/adapter/MainHomeLiveAdapter.java
+++ b/main/src/main/java/com/yunbao/main/adapter/MainHomeLiveAdapter.java
@@ -19,6 +19,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
+import com.blankj.utilcode.util.LogUtils;
import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser;
@@ -52,13 +53,18 @@ public class MainHomeLiveAdapter extends RefreshAdapter {
private Context context;
private int Height;
private int getWeekIntIndex = 0;
+ private boolean showBaner =true;
+
+ public void setShowBaner(boolean showBaner) {
+ // this.showBaner = showBaner;
+ }
public MainHomeLiveAdapter(Context context, int h) {
super(context);
this.context = context;
this.Height = h;
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() {
@@ -67,10 +73,25 @@ public class MainHomeLiveAdapter extends RefreshAdapter {
@Override
public int getItemViewType(int position) {
- if (position == 0) {
+ if (!showBaner){
+ if (position % 2 == 1) {
+ return RIGHT;
+ }else {
+ return LEFT;
+ }
+ }
+ if (position == 4) {
return HEAD;
- } else if (position > 0) {
- LiveBean mode = mList.get(position - 1);
+ } else{
+ 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")) {
return WEEKLAYOUT;
} else {
@@ -114,8 +135,9 @@ public class MainHomeLiveAdapter extends RefreshAdapter {
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
+ int nowPosition = position>4?position-1:position;
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
public void onItemClick(LiveBean bean, int position) {
if (mOnItemClickListener != null) {
@@ -124,7 +146,7 @@ public class MainHomeLiveAdapter extends RefreshAdapter {
}
});
} 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
public void onItemClick(LiveBean bean, int position) {
if (mOnItemClickListener != null) {
@@ -137,7 +159,12 @@ public class MainHomeLiveAdapter extends RefreshAdapter {
@Override
public int getItemCount() {
- return super.getItemCount() + 1;
+ if (!showBaner)
+ return super.getItemCount();
+ if(mList.isEmpty()){
+ return 0;
+ }
+ return super.getItemCount()+1;
}
class HeadVh extends RecyclerView.ViewHolder {
diff --git a/main/src/main/java/com/yunbao/main/adapter/MainHomeLivesClassAdapter.java b/main/src/main/java/com/yunbao/main/adapter/MainHomeLivesClassAdapter.java
index c082df357..b85baf801 100644
--- a/main/src/main/java/com/yunbao/main/adapter/MainHomeLivesClassAdapter.java
+++ b/main/src/main/java/com/yunbao/main/adapter/MainHomeLivesClassAdapter.java
@@ -3,13 +3,17 @@ package com.yunbao.main.adapter;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
+import android.graphics.Typeface;
import android.os.Build;
+import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
+import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.bean.LiveClassBean;
@@ -57,7 +61,7 @@ public class MainHomeLivesClassAdapter extends RecyclerView.Adapter {
+
+
+ abstract public CommonRefreshView.DataHelper getDataHelper();
+
+
+ abstract public void loadData();
+
+
+ abstract public void release();
+
+}
+
diff --git a/main/src/main/java/com/yunbao/main/views/LiveOptComAgent.java b/main/src/main/java/com/yunbao/main/views/LiveOptComAgent.java
new file mode 100644
index 000000000..024b3b197
--- /dev/null
+++ b/main/src/main/java/com/yunbao/main/views/LiveOptComAgent.java
@@ -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 getDataHelper() {
+ return new CommonRefreshView.DataHelper() {
+ @Override
+ public RefreshAdapter 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 processData(String[] info) {
+ if(pp == 1){
+ return JSON.parseArray(Arrays.toString(info), LiveBean.class);
+ }else{
+ return null;
+ }
+ }
+
+ @Override
+ public void onRefreshSuccess(List list, int count) {
+ SWAuManager.get().preloadChannel(list);
+ EventBus.getDefault().post(new AnchorRecommendModel());
+ }
+
+ @Override
+ public void onRefreshFailure() {
+
+ }
+
+ @Override
+ public void onLoadMoreSuccess(List 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);
+
+ }
+
+
+}
+
diff --git a/main/src/main/java/com/yunbao/main/views/LiveOptFollAgent.java b/main/src/main/java/com/yunbao/main/views/LiveOptFollAgent.java
new file mode 100644
index 000000000..46126a586
--- /dev/null
+++ b/main/src/main/java/com/yunbao/main/views/LiveOptFollAgent.java
@@ -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 getDataHelper() {
+ return new CommonRefreshView.DataHelper() {
+ @Override
+ public RefreshAdapter 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 processData(String[] info) {
+ return JSON.parseArray(Arrays.toString(info), LiveBean.class);
+ }
+
+ @Override
+ public void onRefreshSuccess(List 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 loadItemList, int loadItemCount) {
+ List 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);
+
+ }
+
+
+}
+
diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java
index 1fe92a305..95d866d30 100644
--- a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java
+++ b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java
@@ -6,6 +6,8 @@ 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;
@@ -163,14 +165,16 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
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 1;
}
});
mRefreshView.setLayoutManager(gridLayoutManager);
- ItemDecoration decoration = new ItemDecoration(mContext, 0x00000000, 5, 0);
+ ItemDecoration decoration = new ItemDecoration(mContext, 0x00000000, 7, 0);
decoration.setOnlySetItemOffsetsButNoDraw(true);
mRefreshView.setItemDecoration(decoration);
mAdapter = new MainHomeLiveAdapter(mContext, MainActivity.Height);
@@ -189,6 +193,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
Log.i("t2", "aaa" + p);
if (TextUtils.equals(typeHot, "Hot") || TextUtils.equals(typeHot, "hot") || TextUtils.equals(typeHot, "熱門")) {
pp = 1;
+// MainHttpUtil.getHot(p, callback);
LiveHttpUtil.getAnchorLastWeekList(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
@@ -226,7 +231,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
if (info.length > 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")) {
return new_data;
}
@@ -330,9 +335,14 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
if (!canClick()) {
return;
}
+ // mRefreshView.getRefreshView().scrollToPosition(0);
+ mAdapter.clearData();
select = bean.getId();
typeHot = bean.getEnglish();
- mRefreshView.initData();
+ new Handler(Looper.getMainLooper())
+ .postDelayed(() -> {
+ mRefreshView.initData();
+ }, 100);
topAdapter.choice = position;
topAdapter.notifyDataSetChanged();
@@ -348,7 +358,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
mBanner.setOutlineProvider(new ViewOutlineProvider() {
@Override
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);
diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeNewViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeNewViewHolder.java
index 6c4215c9a..7dda1f333 100644
--- a/main/src/main/java/com/yunbao/main/views/MainHomeNewViewHolder.java
+++ b/main/src/main/java/com/yunbao/main/views/MainHomeNewViewHolder.java
@@ -13,22 +13,18 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.fastjson.JSON;
-import com.google.gson.Gson;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.bean.ActiveBean;
import com.yunbao.common.bean.NewCommunityType;
import com.yunbao.common.custom.CommonRefreshView;
-import com.yunbao.common.custom.CommonRefreshWaterfallView;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.OnItemClickListener;
-import com.yunbao.common.manager.CommunityTypeManager;
import com.yunbao.common.manager.OpenAdManager;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.RouteUtil;
-import com.yunbao.common.utils.StringUtil;
import com.yunbao.main.R;
import com.yunbao.main.adapter.MainHomeComAdapter2;
import com.yunbao.main.adapter.MainHomeComClassAdapter;
diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeRecomLiveViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeRecomLiveViewHolder.java
index ec5025544..12b2b3fb7 100644
--- a/main/src/main/java/com/yunbao/main/views/MainHomeRecomLiveViewHolder.java
+++ b/main/src/main/java/com/yunbao/main/views/MainHomeRecomLiveViewHolder.java
@@ -125,7 +125,6 @@ public class MainHomeRecomLiveViewHolder extends AbsMainHomeChildViewHolder impl
}
});
-
mRefreshView.initData();
@@ -149,9 +148,6 @@ public class MainHomeRecomLiveViewHolder extends AbsMainHomeChildViewHolder impl
@Override
public void loadData() {
-// if (mRefreshView != null) {
-// mRefreshView.initData();
-// }
if (mAdapter != null) {
SWAuManager.get().preloadChannel(mAdapter.getList());
}
diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder2.java b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder2.java
new file mode 100644
index 000000000..297585b55
--- /dev/null
+++ b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder2.java
@@ -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, 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 mBannerList;
+ private List mWeekListBean;
+ public static ImageView btnUseIco;
+ private int select = 0;
+ //是否是首頁
+ private int intoIndex = 0;
+ private List new_data;
+ private boolean isHave = false;
+ private Map 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 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 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() {
+ @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() {
+ @Override
+ public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
+ ActivityCompat.startPostponedEnterTransition((Activity) mContext);
+ return false;
+ }
+
+ @Override
+ public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) {
+ ActivityCompat.startPostponedEnterTransition((Activity) mContext);
+ return false;
+ }
+ })
+ /* .addListener(new RequestListener() {
+ @Override
+ public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
+ ActivityCompat.startPostponedEnterTransition((Activity) mContext);
+ return false;
+ }
+
+ @Override
+ public boolean onResourceReady(Drawable resource, Object model, Target 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 map_ekv = new HashMap();
+ 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 getDataHelper() {
+ return new CommonRefreshView.DataHelper() {
+ @Override
+ public RefreshAdapter 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 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 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 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 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;
+ }
+}
diff --git a/main/src/main/res/layout/item_main_live_com_class.xml b/main/src/main/res/layout/item_main_live_com_class.xml
new file mode 100644
index 000000000..540247ced
--- /dev/null
+++ b/main/src/main/res/layout/item_main_live_com_class.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/src/main/res/layout/view_main_home2.xml b/main/src/main/res/layout/view_main_home2.xml
new file mode 100644
index 000000000..a1fa19e54
--- /dev/null
+++ b/main/src/main/res/layout/view_main_home2.xml
@@ -0,0 +1,111 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file