Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -31,6 +31,7 @@ public class OlineListAdapter extends RecyclerView.Adapter {
|
||||
}
|
||||
|
||||
public void addAll(List<Map<Integer, List<OlineUserlistModel>>> models) {
|
||||
mapList.clear();
|
||||
mapList.addAll(models);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ public class OlineListItemAdapter extends RecyclerView.Adapter {
|
||||
private List<OlineUserlistModel> models = new ArrayList<>();
|
||||
|
||||
public void addAll(List<OlineUserlistModel> userlistModels) {
|
||||
models.clear();
|
||||
models.addAll(userlistModels);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@@ -31,17 +31,23 @@ import com.yunbao.common.bean.BaseModel;
|
||||
import com.yunbao.common.bean.NobleTrumpetModel;
|
||||
import com.yunbao.common.custom.MyRadioButton;
|
||||
import com.yunbao.common.dialog.AbsDialogFragment;
|
||||
import com.yunbao.common.event.LiveInputEvent;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.AtTextWatcher;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.activity.LiveActivity;
|
||||
import com.yunbao.live.activity.LiveRyAnchorActivity;
|
||||
import com.yunbao.live.views.OlineListActivity;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -69,7 +75,7 @@ public class LiveInputDialogFragment extends AbsDialogFragment implements View.O
|
||||
private long nobleId;//贵族等级
|
||||
private long trumpetNum;//喇叭数量
|
||||
private String mLiveUid;//主播ID
|
||||
|
||||
private AtTextWatcher atTextWatcher;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -100,7 +106,7 @@ public class LiveInputDialogFragment extends AbsDialogFragment implements View.O
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
Bus.getOn(this);
|
||||
imm = (InputMethodManager) mContext.getSystemService(INPUT_METHOD_SERVICE);
|
||||
mInput = (EditText) mRootView.findViewById(R.id.input);
|
||||
radioHornType = mRootView.findViewById(R.id.radio_horn_type);
|
||||
@@ -185,7 +191,8 @@ public class LiveInputDialogFragment extends AbsDialogFragment implements View.O
|
||||
getActivity().startActivity(intent);
|
||||
}
|
||||
});
|
||||
;
|
||||
atTextWatcher = new AtTextWatcher();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -247,6 +254,7 @@ public class LiveInputDialogFragment extends AbsDialogFragment implements View.O
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
Bus.getOff(this);
|
||||
mContext = null;
|
||||
}
|
||||
|
||||
@@ -356,4 +364,10 @@ public class LiveInputDialogFragment extends AbsDialogFragment implements View.O
|
||||
}
|
||||
};
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onLiveInputEvent(LiveInputEvent event) {
|
||||
atTextWatcher.insertTextForAt(event.getModel(), mInput);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.yunbao.live.views;
|
||||
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
@@ -9,11 +13,18 @@ import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.OlineModel;
|
||||
import com.yunbao.common.bean.OlineUserlistModel;
|
||||
import com.yunbao.common.event.LiveInputEvent;
|
||||
import com.yunbao.common.event.OlineEvent;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.WordsTypeUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.adapter.OlineListAdapter;
|
||||
import com.yunbao.live.http.LiveHttpUtil;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -22,6 +33,8 @@ import java.util.Map;
|
||||
public class OlineListActivity extends AbsActivity {
|
||||
private RecyclerView audienceList;
|
||||
private OlineListAdapter itemAdapter;
|
||||
private EditText edit;
|
||||
private List<OlineUserlistModel> userlistModels = null;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -32,6 +45,7 @@ public class OlineListActivity extends AbsActivity {
|
||||
@Override
|
||||
protected void main() {
|
||||
super.main();
|
||||
Bus.getOn(this);
|
||||
initView();
|
||||
initData();
|
||||
}
|
||||
@@ -47,40 +61,140 @@ public class OlineListActivity extends AbsActivity {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
OlineModel responseData = GsonUtils.fromJson(info[0], OlineModel.class);
|
||||
List<OlineUserlistModel> userlistModels = responseData.getUserlist();
|
||||
List<OlineUserlistModel> noblelistModels = new ArrayList<>();
|
||||
List<OlineUserlistModel> audiencelistModels = new ArrayList<>();
|
||||
List<Map<Integer, List<OlineUserlistModel>>> mapList = new ArrayList<>();
|
||||
//讲贵族前置顺序
|
||||
for (OlineUserlistModel model : userlistModels) {
|
||||
int nobleId = Integer.parseInt(model.getNobleId());
|
||||
if (nobleId > 0) {
|
||||
noblelistModels.add(model);
|
||||
} else {
|
||||
audiencelistModels.add(model);
|
||||
}
|
||||
}
|
||||
Map<Integer, List<OlineUserlistModel>> noblerMap = new HashMap<>();
|
||||
noblerMap.put(0, noblelistModels);
|
||||
Map<Integer, List<OlineUserlistModel>> audienceMap = new HashMap<>();
|
||||
audienceMap.put(1,audiencelistModels);
|
||||
mapList.add(0,noblerMap);
|
||||
mapList.add(1, audienceMap);
|
||||
itemAdapter.addAll(mapList);
|
||||
userlistModels = responseData.getUserlist();
|
||||
|
||||
starData();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 原始数据
|
||||
*/
|
||||
private void starData() {
|
||||
List<OlineUserlistModel> noblelistModels = new ArrayList<>();
|
||||
List<OlineUserlistModel> audiencelistModels = new ArrayList<>();
|
||||
List<Map<Integer, List<OlineUserlistModel>>> mapList = new ArrayList<>();
|
||||
//讲贵族前置顺序
|
||||
for (OlineUserlistModel model : userlistModels) {
|
||||
int nobleId = Integer.parseInt(model.getNobleId());
|
||||
if (nobleId > 0) {
|
||||
noblelistModels.add(model);
|
||||
} else {
|
||||
audiencelistModels.add(model);
|
||||
}
|
||||
}
|
||||
Map<Integer, List<OlineUserlistModel>> noblerMap = new HashMap<>();
|
||||
noblerMap.put(0, noblelistModels);
|
||||
Map<Integer, List<OlineUserlistModel>> audienceMap = new HashMap<>();
|
||||
audienceMap.put(1, audiencelistModels);
|
||||
mapList.add(0, noblerMap);
|
||||
mapList.add(1, audienceMap);
|
||||
itemAdapter.addAll(mapList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化控件
|
||||
*/
|
||||
private void initView() {
|
||||
itemAdapter = new OlineListAdapter(mContext);
|
||||
audienceList = findViewById(R.id.audience_list);
|
||||
TextView titleView = findViewById(R.id.titleView);
|
||||
TextView titleView = findViewById(R.id.titleView);
|
||||
titleView.setText(R.string.online_audience);
|
||||
audienceList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
audienceList.setAdapter(itemAdapter);
|
||||
edit = findViewById(R.id.edit);
|
||||
|
||||
edit.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if (!TextUtils.isEmpty(s.toString().trim())) {
|
||||
//繁体转成简体
|
||||
String simplified = WordsTypeUtil.changeSimplified(s.toString());
|
||||
//简体转繁体
|
||||
String traditional = WordsTypeUtil.changeTraditional(s.toString());
|
||||
if (TextUtils.equals(simplified, traditional)) {
|
||||
searchList(simplified, null);
|
||||
} else {
|
||||
searchList(simplified, traditional);
|
||||
}
|
||||
} else {
|
||||
starData();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void searchList(String keyWorld, String keyWorld2) {
|
||||
if (userlistModels == null) return;
|
||||
if (TextUtils.isEmpty(keyWorld2)) {
|
||||
List<OlineUserlistModel> noblelistModels = new ArrayList<>();
|
||||
List<OlineUserlistModel> audiencelistModels = new ArrayList<>();
|
||||
List<Map<Integer, List<OlineUserlistModel>>> mapList = new ArrayList<>();
|
||||
//讲贵族前置顺序
|
||||
for (OlineUserlistModel model : userlistModels) {
|
||||
int nobleId = Integer.parseInt(model.getNobleId());
|
||||
if (nobleId > 0 && model.getUserNicename().contains(keyWorld)) {
|
||||
noblelistModels.add(model);
|
||||
} else if (nobleId == 0 && model.getUserNicename().contains(keyWorld)) {
|
||||
audiencelistModels.add(model);
|
||||
}
|
||||
}
|
||||
Map<Integer, List<OlineUserlistModel>> noblerMap = new HashMap<>();
|
||||
noblerMap.put(0, noblelistModels);
|
||||
Map<Integer, List<OlineUserlistModel>> audienceMap = new HashMap<>();
|
||||
audienceMap.put(1, audiencelistModels);
|
||||
mapList.add(0, noblerMap);
|
||||
mapList.add(1, audienceMap);
|
||||
itemAdapter.addAll(mapList);
|
||||
} else {
|
||||
List<OlineUserlistModel> noblelistModels = new ArrayList<>();
|
||||
List<OlineUserlistModel> audiencelistModels = new ArrayList<>();
|
||||
List<Map<Integer, List<OlineUserlistModel>>> mapList = new ArrayList<>();
|
||||
//讲贵族前置顺序
|
||||
for (OlineUserlistModel model : userlistModels) {
|
||||
int nobleId = Integer.parseInt(model.getNobleId());
|
||||
if (nobleId > 0 && model.getUserNicename().contains(keyWorld)) {
|
||||
noblelistModels.add(model);
|
||||
} else if (nobleId == 0 && model.getUserNicename().contains(keyWorld)) {
|
||||
audiencelistModels.add(model);
|
||||
} else if (nobleId > 0 && model.getUserNicename().contains(keyWorld2)) {
|
||||
noblelistModels.add(model);
|
||||
} else if (nobleId == 0 && model.getUserNicename().contains(keyWorld2)) {
|
||||
audiencelistModels.add(model);
|
||||
}
|
||||
}
|
||||
Map<Integer, List<OlineUserlistModel>> noblerMap = new HashMap<>();
|
||||
noblerMap.put(0, noblelistModels);
|
||||
Map<Integer, List<OlineUserlistModel>> audienceMap = new HashMap<>();
|
||||
audienceMap.put(1, audiencelistModels);
|
||||
mapList.add(0, noblerMap);
|
||||
mapList.add(1, audienceMap);
|
||||
itemAdapter.addAll(mapList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
Bus.getOff(this);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onOlineEvent(OlineEvent event) {
|
||||
Bus.get().post(new LiveInputEvent().setModel(event.getModel()));
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,11 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.bean.OlineUserlistModel;
|
||||
import com.yunbao.common.event.OlineEvent;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.views.weight.ClipPathCircleImage;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.live.R;
|
||||
|
||||
public class OlineListItemViewHolder extends RecyclerView.ViewHolder {
|
||||
@@ -29,5 +32,11 @@ public class OlineListItemViewHolder extends RecyclerView.ViewHolder {
|
||||
public void setData(OlineUserlistModel model) {
|
||||
ImgLoader.displayAvatar(itemView.getContext(), model.getAvatar(), avatar);
|
||||
userName.setText(model.getUserNicename());
|
||||
ViewClicksAntiShake.clicksAntiShake(itemView, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
Bus.get().post(new OlineEvent().setModel(model));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user