视频播放UI
动态页面UI
This commit is contained in:
@@ -12,35 +12,37 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.bean.ActiveBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/26.
|
||||
* 首页 直播
|
||||
* 首页 社区
|
||||
*/
|
||||
|
||||
public class MainHomeComAdapter extends RefreshAdapter<LiveBean> {
|
||||
|
||||
public class MainHomeComAdapter extends RefreshAdapter<ActiveBean> {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private View.OnClickListener mOnClickListener;
|
||||
|
||||
public void setmOnClickListener(View.OnClickListener mOnClickListener) {
|
||||
this.mOnClickListener = mOnClickListener;
|
||||
}
|
||||
|
||||
private List<Integer> heightList = new ArrayList<>();
|
||||
|
||||
public MainHomeComAdapter(Context context) {
|
||||
super(context);
|
||||
this.mContext = context;
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null && mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick((ActiveBean) tag, 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -60,13 +62,13 @@ public class MainHomeComAdapter extends RefreshAdapter<LiveBean> {
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView name;
|
||||
TextView title;
|
||||
TextView likeCount;
|
||||
ImageView img;
|
||||
ImageView author;
|
||||
LinearLayout heightLayout;
|
||||
ImageView isVideo;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
@@ -76,16 +78,30 @@ public class MainHomeComAdapter extends RefreshAdapter<LiveBean> {
|
||||
author = itemView.findViewById(R.id.author);
|
||||
likeCount = itemView.findViewById(R.id.like_count);
|
||||
heightLayout = itemView.findViewById(R.id.imgLayout);
|
||||
isVideo = itemView.findViewById(R.id.isVideo);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(LiveBean bean, int position) {
|
||||
void setData(ActiveBean bean, int position) {
|
||||
itemView.setTag(bean);
|
||||
//name.setText(bean.getCity());
|
||||
//title.setText(bean.getCity());
|
||||
likeCount.setText(bean.getNums());
|
||||
ImgLoader.display(mContext, "https://img2.baidu.com/it/u=1540900496,2036305732&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500", img);
|
||||
ImgLoader.display(mContext, bean.getAvatar(), author);
|
||||
if (bean.getImg_or_video().equals("1")) {
|
||||
JSONArray jsonArray = (JSONArray) JSONArray.parse(bean.getImg_json());
|
||||
if (jsonArray.size() != 0) {
|
||||
ImgLoader.display(mContext, String.valueOf(jsonArray.get(0)), img);
|
||||
}
|
||||
isVideo.setVisibility(View.GONE);
|
||||
} else {
|
||||
ImgLoader.display(mContext, bean.getUser_avatar(), img);
|
||||
isVideo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
name.setText(bean.getUser_name());
|
||||
JSONObject json = JSONObject.parseObject(bean.getContent());
|
||||
if (json != null) {
|
||||
String content = (String) json.get("msg");
|
||||
title.setText(content);
|
||||
}
|
||||
likeCount.setText(bean.getLove_num());
|
||||
ImgLoader.display(mContext, bean.getUser_avatar(), author);
|
||||
|
||||
if (position == 0) {
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) heightLayout.getLayoutParams();
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.activity.CommunitySendActivity;
|
||||
import com.yunbao.common.event.FloatWarOrderEvent;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.animation.ObjectAnimator;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -14,36 +15,36 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.CommunityDetailsActivity;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.bean.AnchorRecommendModel;
|
||||
import com.yunbao.common.bean.ActiveBean;
|
||||
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.bean.VideoBean;
|
||||
import com.yunbao.common.custom.CommonRefreshWaterfallView;
|
||||
import com.yunbao.common.event.LiveRoomChangeEvent;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.manager.LiveClassManager;
|
||||
import com.yunbao.common.manager.OpenAdManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.common.utils.MicStatusManager;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.live.utils.LiveStorge;
|
||||
import com.yunbao.live.views.LiveRoomViewHolder;
|
||||
import com.yunbao.live.adapter.LiveAdminRoomAdapter;
|
||||
import com.yunbao.live.bean.LiveAdminRoomBean;
|
||||
import com.yunbao.live.views.LiveMyRoomViewHolder;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.MainHomeComAdapter;
|
||||
import com.yunbao.main.adapter.MainHomeComClassAdapter;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
import com.yunbao.video.activity.VideoPlayActivity;
|
||||
import com.yunbao.video.http.VideoHttpUtil;
|
||||
import com.yunbao.video.interfaces.VideoScrollDataHelper;
|
||||
import com.yunbao.video.utils.VideoStorge;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@@ -60,23 +61,18 @@ import java.util.Map;
|
||||
* MainActivity 社区-热门
|
||||
*/
|
||||
|
||||
public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements OnItemClickListener<LiveBean> {
|
||||
private View mShadow;
|
||||
public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements OnItemClickListener<ActiveBean> {
|
||||
private View mBtnDismiss;
|
||||
public static CommonRefreshWaterfallView mRefreshView;
|
||||
private RecyclerView mClassRecyclerViewTop;
|
||||
private MainHomeComAdapter mAdapter;
|
||||
private ObjectAnimator mShowAnimator;
|
||||
private ObjectAnimator mHideAnimator;
|
||||
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 List<ActiveBean> new_data;
|
||||
private Map<String, String> gotoRoomKey = new HashMap<>();
|
||||
private Dialog mShowLoadingDialog;
|
||||
private String typeHot;
|
||||
@@ -114,7 +110,6 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements
|
||||
typeHot = list.get(0).getEnglish();
|
||||
select = list.get(0).getId();
|
||||
}
|
||||
mShadow = findViewById(R.id.shadow);
|
||||
mBtnDismiss = findViewById(R.id.btn_dismiss);
|
||||
mBtnDismiss.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -134,22 +129,16 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements
|
||||
mRefreshView.setEmptyLayoutId(R.layout.view_no_data_live);
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
mAdapter = new MainHomeComAdapter(mContext);
|
||||
mAdapter.setmOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(mContext, CommunityDetailsActivity.class);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
});
|
||||
mAdapter.setOnItemClickListener(MainHomeNewViewHolder.this);
|
||||
mAdapter.setHasStableIds(true);//
|
||||
mRefreshView.setLoadMoreEnable(true);
|
||||
mRefreshView.setRecyclerViewAdapter(mAdapter);
|
||||
mRefreshView.setDataHelper(new CommonRefreshWaterfallView.DataHelper<LiveBean>() {
|
||||
mRefreshView.setDataHelper(new CommonRefreshWaterfallView.DataHelper<ActiveBean>() {
|
||||
@Override
|
||||
public RefreshAdapter<LiveBean> getAdapter() {
|
||||
return null;
|
||||
public RefreshAdapter<ActiveBean> getAdapter() {
|
||||
if (mAdapter == null) {
|
||||
mAdapter = new MainHomeComAdapter(mContext);
|
||||
mAdapter.setOnItemClickListener(MainHomeNewViewHolder.this);
|
||||
}
|
||||
return mAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,26 +146,7 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements
|
||||
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) {
|
||||
isHave = true;
|
||||
} else {
|
||||
isHave = false;
|
||||
}
|
||||
Constants.getWeekIntIndex = Constants.getWeekIntIndex + 1;
|
||||
MainHttpUtil.getHot(p, callback);
|
||||
}
|
||||
});
|
||||
CommonHttpUtil.getCommunityHotList(p, callback);
|
||||
} else {
|
||||
pp = 0;
|
||||
MainHttpUtil.getClassLive(select, p, callback);
|
||||
@@ -184,46 +154,15 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LiveBean> processData(String[] info) {
|
||||
public List<ActiveBean> 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);
|
||||
}
|
||||
new_data.addAll(old_data);
|
||||
|
||||
}
|
||||
new_data = JSON.parseArray(Arrays.toString(info), ActiveBean.class);
|
||||
return new_data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshSuccess(List<LiveBean> list, int count) {
|
||||
if (CommonAppConfig.LIVE_ROOM_SCROLL) {
|
||||
LiveStorge.getInstance().put(Constants.LIVE_HOME, list);
|
||||
}
|
||||
EventBus.getDefault().post(new AnchorRecommendModel());
|
||||
public void onRefreshSuccess(List<ActiveBean> list, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -232,12 +171,10 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreSuccess(List<LiveBean> loadItemList, int loadItemCount) {
|
||||
public void onLoadMoreSuccess(List<ActiveBean> 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));
|
||||
}
|
||||
new_data.add(loadItemList.get(j));
|
||||
}
|
||||
if (loadItemList.size() > 0) {
|
||||
mAdapter.insertList(new_data);
|
||||
@@ -295,7 +232,6 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements
|
||||
mRefreshView.initData();
|
||||
topAdapter.choice = position;
|
||||
topAdapter.notifyDataSetChanged();
|
||||
|
||||
}
|
||||
});
|
||||
if (mClassRecyclerViewTop != null) {
|
||||
@@ -305,39 +241,40 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements
|
||||
mRefreshView.initData();
|
||||
}
|
||||
|
||||
private VideoScrollDataHelper mVideoScrollDataHelper;
|
||||
|
||||
private void gotoLive(final String live_id) {
|
||||
LiveHttpUtil.getLiveInfo(live_id, new HttpCallback() {
|
||||
@Override
|
||||
public void onItemClick(ActiveBean bean, int position) {
|
||||
Intent intent = new Intent(mContext, CommunityDetailsActivity.class);
|
||||
intent.putExtra("active", (Parcelable) bean);
|
||||
mContext.startActivity(intent);
|
||||
|
||||
/*if (bean.getImg_or_video().equals("2")) {
|
||||
if (mVideoScrollDataHelper == null) {
|
||||
mVideoScrollDataHelper = new VideoScrollDataHelper() {
|
||||
@Override
|
||||
public void loadData(int p, HttpCallback callback) {
|
||||
VideoHttpUtil.getHomeVideoList(p, callback);
|
||||
}
|
||||
};
|
||||
}
|
||||
VideoStorge.getInstance().putDataHelper(Constants.VIDEO_HOME, mVideoScrollDataHelper);
|
||||
VideoPlayActivity.forward(mContext, position, Constants.VIDEO_HOME, 1);
|
||||
}*/
|
||||
/*VideoHttpUtil.getHomeVideoList(1, 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;
|
||||
if (code == 0) {
|
||||
List<VideoBean> tempList = new ArrayList<>();
|
||||
for (String s : info) {
|
||||
VideoBean videoBean = JSONObject.parseObject(s, VideoBean.class);
|
||||
tempList.add(videoBean);
|
||||
}
|
||||
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) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
intoIndex = 1;
|
||||
RouteUtil.forwardUserHome(mContext, live_id, 0);
|
||||
VideoStorge.getInstance().put(Constants.VIDEO_HOME, tempList);
|
||||
VideoPlayActivity.forward(mContext, position, Constants.VIDEO_HOME, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
});*/
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,58 +285,6 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements
|
||||
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) {
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
intoIndex = 1;
|
||||
RouteUtil.forwardUserHome(mContext, bean.getUid(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void loadData() {
|
||||
}
|
||||
@@ -437,4 +322,5 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements
|
||||
mShowLoadingDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
android:id="@+id/appBarLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="70dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:fadingEdge="none"
|
||||
app:elevation="0dp"
|
||||
|
||||
Reference in New Issue
Block a user