update 自由PK
This commit is contained in:
parent
576a30d1be
commit
8e45e17768
@ -392,8 +392,8 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
break;
|
||||
case Constants.LIVE_FUNC_LINK_MIC://连麦
|
||||
if (isDRPK != 1) {
|
||||
openLinkMicAnchorWindow(false);
|
||||
//openFreePkWindow();
|
||||
//openLinkMicAnchorWindow(false);
|
||||
openFreePkWindow();
|
||||
} else {
|
||||
ToastUtil.show("您已在PK中");
|
||||
}
|
||||
|
@ -13,7 +13,10 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.bean.RandomPkUserBean;
|
||||
import com.yunbao.common.bean.SetAttentsModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.manager.IMRTCManager;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.live.R;
|
||||
@ -43,9 +46,9 @@ public class RandomPkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> {
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if (getItemViewType(position) == ITEM) {
|
||||
((ItemViewHolder) holder).setData(mList.get(position-1));
|
||||
}else{
|
||||
((HeadViewHolder) holder).setData(mList.get(position));
|
||||
((ItemViewHolder) holder).setData(mList.get(position ), position );
|
||||
} else {
|
||||
((HeadViewHolder) holder).setData(mList.get(position), position);
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +72,7 @@ public class RandomPkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
public void setData(RandomPkUserBean bean) {
|
||||
public void setData(RandomPkUserBean bean, int position) {
|
||||
|
||||
}
|
||||
}
|
||||
@ -103,12 +106,33 @@ public class RandomPkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> {
|
||||
((LiveRyAnchorActivity) mContext).buildLinkMicJSON().toString()
|
||||
);
|
||||
});
|
||||
mFollow.setOnClickListener(v -> {
|
||||
RandomPkUserBean bean = (RandomPkUserBean) itemView.getTag();
|
||||
LiveNetManager.get(mContext).setAttents(bean.getId(), new HttpCallback<SetAttentsModel>() {
|
||||
@Override
|
||||
public void onSuccess(SetAttentsModel data) {
|
||||
bean.setAttention(data.getIsattent());
|
||||
if ("1" .equals(data.getIsattent())) {
|
||||
ToastUtil.show(R.string.following);
|
||||
mOnItemClickListener.onItemClick(bean, 1);
|
||||
} else {
|
||||
ToastUtil.show(R.string.unfollow_cancel);
|
||||
mOnItemClickListener.onItemClick(bean, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(RandomPkUserBean bean) {
|
||||
super.setData(bean);
|
||||
int position = getAbsoluteAdapterPosition();
|
||||
public void setData(RandomPkUserBean bean, int position) {
|
||||
super.setData(bean, position);
|
||||
if (bean == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.yunbao.live.bean;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/11/15.
|
||||
@ -19,6 +20,20 @@ public class LivePkBean {
|
||||
private int level;
|
||||
private int levelAnchor;
|
||||
private int sex;
|
||||
private String attention;
|
||||
|
||||
@JSONField(name = "isattention")
|
||||
public String getAttention() {
|
||||
if(StringUtil.isEmpty(attention)){
|
||||
attention="0";
|
||||
}
|
||||
return attention;
|
||||
}
|
||||
|
||||
@JSONField(name = "isattention")
|
||||
public void setAttention(String attention) {
|
||||
this.attention = attention;
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
@ -56,6 +71,9 @@ public class LivePkBean {
|
||||
|
||||
@JSONField(name = "pkuid")
|
||||
public String getPkUid() {
|
||||
if (pkUid == null) {
|
||||
pkUid = "0";
|
||||
}
|
||||
return pkUid;
|
||||
}
|
||||
|
||||
@ -94,7 +112,7 @@ public class LivePkBean {
|
||||
* 是否在连麦中
|
||||
*/
|
||||
public boolean isLinkMic() {
|
||||
return !TextUtils.isEmpty(pkUid) && !"0".equals(pkUid);
|
||||
return !TextUtils.isEmpty(pkUid) && !"0" .equals(pkUid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
package com.yunbao.live.dialog;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
@ -13,7 +10,6 @@ import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
@ -21,18 +17,14 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.bean.HttpCallbackModel;
|
||||
import com.yunbao.common.bean.RandomPkUserBean;
|
||||
import com.yunbao.common.custom.CommonRefreshView;
|
||||
import com.yunbao.common.dialog.AbsDialogFragment;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.manager.RandomPkManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.WordsTypeUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.adapter.RandomPkRecyclerAdapter;
|
||||
@ -42,8 +34,6 @@ import com.yunbao.live.http.LiveHttpUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/**
|
||||
* 自由PK
|
||||
@ -137,10 +127,18 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
|
||||
|
||||
private void initRecycler() {
|
||||
helper = new DataHelper();
|
||||
helper.setStatus(DataHelper.LIST_MODEL_LIST);
|
||||
adapter = new RandomPkRecyclerAdapter(mContext);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
mRecyclerView.setDataHelper(helper);
|
||||
mRecyclerView.initData();
|
||||
mRecyclerView.setEmptyLayoutId(R.layout.view_live_search_list_empty);
|
||||
adapter.setOnItemClickListener(new OnItemClickListener<RandomPkUserBean>() {
|
||||
@Override
|
||||
public void onItemClick(RandomPkUserBean bean, int position) {
|
||||
mRecyclerView.initData();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -166,13 +164,19 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
|
||||
mSearchLayout.setVisibility(View.GONE);
|
||||
switch (tabStatus) {
|
||||
case TAB_STATUS_SEARCH:
|
||||
helper.setStatus(DataHelper.LIST_MODEL_LIST);
|
||||
mSearchLayout.setVisibility(View.VISIBLE);
|
||||
mRecyclerView.setVisibility(View.VISIBLE);
|
||||
mRecyclerView.initData();
|
||||
mRecyclerView.setRefreshEnable(false);
|
||||
mRecyclerView.showEmpty();
|
||||
break;
|
||||
case TAB_STATUS_FOLLOW:
|
||||
mSearch.setText("");
|
||||
helper.setStatus(DataHelper.LIST_MODEL_FOLLOW);
|
||||
mRecyclerView.setVisibility(View.VISIBLE);
|
||||
mRecyclerView.initData();
|
||||
mRecyclerView.setRefreshEnable(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -202,12 +206,31 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
|
||||
}
|
||||
|
||||
public class DataHelper implements CommonRefreshView.DataHelper<RandomPkUserBean> {
|
||||
private final static int LIST_MODEL_LIST = 0;
|
||||
private final static int LIST_MODEL_FOLLOW = 1;
|
||||
private int status;
|
||||
private String searchKey;
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public void search(String key) {
|
||||
if (StringUtil.isEmpty(key)) {
|
||||
adapter.getList().clear();
|
||||
adapter.notifyDataSetChanged();
|
||||
mRecyclerView.showEmpty();
|
||||
searchKey = null;
|
||||
return;
|
||||
}
|
||||
searchKey = key;
|
||||
LiveNetManager.get(mContext)
|
||||
.randomPkSearchUser(key, WordsTypeUtil.changeTraditional(key), new com.yunbao.common.http.base.HttpCallback<List<RandomPkUserBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<RandomPkUserBean> data) {
|
||||
if (!data.isEmpty()) {
|
||||
mRecyclerView.hideEmpty();
|
||||
}
|
||||
List<RandomPkUserBean> list = new ArrayList<>();
|
||||
list.add(null);
|
||||
list.addAll(data);
|
||||
@ -228,7 +251,16 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
|
||||
|
||||
@Override
|
||||
public void loadData(int p, HttpCallback callback) {
|
||||
LiveHttpUtil.getLivePkList(p, callback);
|
||||
if (status == LIST_MODEL_LIST) {
|
||||
if (searchKey == null) {
|
||||
callback.onSuccess(0, "", new String[]{});
|
||||
mRecyclerView.showEmpty();
|
||||
return;
|
||||
}
|
||||
search(searchKey);
|
||||
} else {
|
||||
LiveHttpUtil.getHomeFollow(p, callback);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -236,14 +268,14 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
|
||||
Log.i(TAG, "processData: 获取数据成功");
|
||||
List<LivePkBean> beans = JSON.parseArray(Arrays.toString(info), LivePkBean.class);
|
||||
List<RandomPkUserBean> list = new ArrayList<>();
|
||||
list.add(null);
|
||||
for (LivePkBean bean : beans) {
|
||||
RandomPkUserBean userBean = new RandomPkUserBean();
|
||||
userBean.setId(bean.getUid());
|
||||
userBean.setSex(bean.getSex());
|
||||
userBean.setUserNiceName(bean.getUserNiceName());
|
||||
userBean.setAvatar(bean.getAvatar());
|
||||
userBean.setPk(bean.getPkUid().equals("0") ? 0 : 1);
|
||||
userBean.setAttention("0");
|
||||
userBean.setAttention("1");
|
||||
list.add(userBean);
|
||||
}
|
||||
return list;
|
||||
@ -256,7 +288,7 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
|
||||
|
||||
@Override
|
||||
public void onRefreshFailure() {
|
||||
|
||||
mRecyclerView.showEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -266,7 +298,7 @@ public class FreePkDialogFragment extends AbsDialogFragment implements View.OnCl
|
||||
|
||||
@Override
|
||||
public void onLoadMoreFailure() {
|
||||
|
||||
mRecyclerView.showEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -917,4 +917,13 @@ public class LiveHttpUtil {
|
||||
.execute(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页关注直播
|
||||
*/
|
||||
public static void getHomeFollow(int p, HttpCallback callback) {
|
||||
HttpClient.getInstance().get("Home.getFollow", "Home.getFollow")
|
||||
.params("p", p)
|
||||
.execute(callback);
|
||||
}
|
||||
|
||||
}
|
||||
|
27
live/src/main/res/layout/view_live_search_list_empty.xml
Normal file
27
live/src/main/res/layout/view_live_search_list_empty.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<?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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@mipmap/img_live_search_list_empty" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="25dp"
|
||||
android:text="沒有找到匹配結果~"
|
||||
android:textColor="#C4C4C4"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView3" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
BIN
live/src/main/res/mipmap-xxxhdpi/img_live_search_list_empty.png
Normal file
BIN
live/src/main/res/mipmap-xxxhdpi/img_live_search_list_empty.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
Loading…
Reference in New Issue
Block a user