fix公会移除成员搜索
This commit is contained in:
@@ -1019,6 +1019,9 @@
|
||||
<activity
|
||||
android:name=".module_hall.hall.activity.GroupMemberListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".module_hall.hall.activity.RemoveMemberListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".module_hall.hall.activity.AdminListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
@@ -19,6 +19,7 @@ import com.yizhuan.erban.base.BaseMvpActivity;
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager;
|
||||
import com.yizhuan.erban.module_hall.HallDataManager;
|
||||
import com.yizhuan.erban.module_hall.hall.adapter.GroupMemberListAdapter;
|
||||
import com.yizhuan.erban.module_hall.hall.event.RemoveMemberEvent;
|
||||
import com.yizhuan.erban.module_hall.hall.presenter.AdminAddPresenter;
|
||||
import com.yizhuan.erban.module_hall.hall.view.IAdminAddView;
|
||||
import com.yizhuan.xchat_android_core.module_hall.hall.HallModel;
|
||||
@@ -164,6 +165,8 @@ public class AdminAddActivity extends BaseMvpActivity<IAdminAddView, AdminAddPre
|
||||
getMvpPresenter().setManager(targetUid);
|
||||
else
|
||||
getMvpPresenter().removeManager(targetUid);
|
||||
|
||||
EventBus.getDefault().post(new RemoveMemberEvent());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -575,7 +575,7 @@ public class ModuleHallActivity extends BaseMvpActivity<IModuleHallView, ModuleH
|
||||
break;
|
||||
|
||||
case AuthInfo.AUTH_MEMBER_EXIT_MANAGER:
|
||||
GroupMemberListActivity.start(ModuleHallActivity.this);
|
||||
RemoveMemberListActivity.start(ModuleHallActivity.this);
|
||||
break;
|
||||
|
||||
case AuthInfo.AUTH_HALL_MANAGER_SET:
|
||||
|
@@ -0,0 +1,386 @@
|
||||
package com.yizhuan.erban.module_hall.hall.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.Editable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.UIHelper;
|
||||
import com.yizhuan.erban.base.BaseMvpActivity;
|
||||
import com.yizhuan.erban.base.TitleBar;
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager;
|
||||
import com.yizhuan.erban.module_hall.HallDataManager;
|
||||
import com.yizhuan.erban.module_hall.hall.adapter.GroupMemberListAdapter;
|
||||
import com.yizhuan.erban.module_hall.hall.event.RemoveMemberEvent;
|
||||
import com.yizhuan.erban.module_hall.hall.presenter.GroupMemberPresenter;
|
||||
import com.yizhuan.erban.module_hall.hall.view.IGroupMemberView;
|
||||
import com.yizhuan.erban.module_hall.hall.view.dialog.HallMenuDialog;
|
||||
import com.yizhuan.erban.module_hall.secretcode.PwdCodeMgr;
|
||||
import com.yizhuan.xchat_android_core.module_hall.hall.HallModel;
|
||||
import com.yizhuan.xchat_android_core.module_hall.hall.bean.AuthInfo;
|
||||
import com.yizhuan.xchat_android_core.module_hall.hall.bean.MemberInfo;
|
||||
import com.yizhuan.xchat_android_core.module_hall.income.event.UpdateMemberListEvent;
|
||||
import com.yizhuan.xchat_android_core.statistic.StatisticManager;
|
||||
import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol;
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper;
|
||||
import com.yizhuan.xchat_android_library.base.factory.CreatePresenter;
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
@CreatePresenter(GroupMemberPresenter.class)
|
||||
public class RemoveMemberListActivity extends BaseMvpActivity<IGroupMemberView, GroupMemberPresenter>
|
||||
implements IGroupMemberView{
|
||||
|
||||
@BindView(R.id.srl_group)
|
||||
SwipeRefreshLayout srlGroup;
|
||||
@BindView(R.id.recycler_view)
|
||||
RecyclerView recyclerView;
|
||||
@BindView(R.id.et_search)
|
||||
EditText etSearch;
|
||||
private static final int MSG_UPDATE_SEARCH_RESULT = 1001;
|
||||
|
||||
private GroupMemberListAdapter mGroupMemberListAdapter;
|
||||
private List<MemberInfo> searchList = new ArrayList<>();
|
||||
private List<MemberInfo> orignalList = new ArrayList<>();
|
||||
private List<AuthInfo> mAuthInfoList;
|
||||
|
||||
private int page = 1;
|
||||
|
||||
private int pageSize = 50;
|
||||
|
||||
private boolean isLoading, noMoreData;
|
||||
|
||||
private CharSequence searchStr;
|
||||
|
||||
private Handler mHandler = new Handler(){
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what){
|
||||
case MSG_UPDATE_SEARCH_RESULT:
|
||||
mGroupMemberListAdapter.setNewData(searchList);
|
||||
mGroupMemberListAdapter.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static void start(Context context) {
|
||||
Intent intent = new Intent(context, RemoveMemberListActivity.class);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_remove_member);
|
||||
|
||||
ButterKnife.bind(this);
|
||||
|
||||
etSearch.addTextChangedListener(new SearchListener());
|
||||
srlGroup.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
if (isLoading) {
|
||||
return;
|
||||
}
|
||||
page = 1;
|
||||
loadMembers();
|
||||
}
|
||||
});
|
||||
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
mGroupMemberListAdapter = new GroupMemberListAdapter(this, null);
|
||||
mGroupMemberListAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
|
||||
@Override
|
||||
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
|
||||
List<MemberInfo> memberInfoList = mGroupMemberListAdapter.getData();
|
||||
if (memberInfoList.size() > 0) {
|
||||
MemberInfo memberInfo = memberInfoList.get(position);
|
||||
|
||||
int type = mGroupMemberListAdapter.getmType();
|
||||
if (type == GroupMemberListAdapter.TYPE_REMOVE) {
|
||||
if (view.getId() == R.id.iv_remove) {
|
||||
showRemoveDialog(memberInfo.getUid(), memberInfo.getRoleType(), memberInfo.getNick());
|
||||
}
|
||||
} else {
|
||||
UIHelper.showUserInfoAct(RemoveMemberListActivity.this, memberInfo.getUid());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
recyclerView.setAdapter(mGroupMemberListAdapter);
|
||||
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
if (isLoading || noMoreData) {
|
||||
return;
|
||||
}
|
||||
LinearLayoutManager manager = (LinearLayoutManager) recyclerView.getLayoutManager();
|
||||
int lastfirst = manager.findLastVisibleItemPosition();
|
||||
int itemCount = mGroupMemberListAdapter.getItemCount();
|
||||
if (lastfirst >= itemCount - 2) {
|
||||
loadMembers();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
loadMembers();
|
||||
getMvpPresenter().getHallAuths();
|
||||
|
||||
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void displayNotEmptyQueuingMic(UpdateMemberListEvent event) {
|
||||
onReloadDate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReloadDate() {
|
||||
page = 1;
|
||||
loadMembers();
|
||||
}
|
||||
|
||||
private void loadMembers() {
|
||||
isLoading = true;
|
||||
HallModel.get().getAllMembers(HallDataManager.get().getHallId(), page, pageSize)
|
||||
.compose(RxHelper.bindActivity(this))
|
||||
.subscribe((listMemberInfo, throwable) -> {
|
||||
srlGroup.setRefreshing(false);
|
||||
isLoading = false;
|
||||
if (throwable != null) {
|
||||
Logger.i("模厅成员加载失败...");
|
||||
if (page == 1) {
|
||||
showNetworkErr();
|
||||
}
|
||||
} else {
|
||||
List<MemberInfo> list = listMemberInfo.getMembers();
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
if (list.size() == 0) {
|
||||
noMoreData = true;
|
||||
if (page == 1) {
|
||||
showNoData();
|
||||
}
|
||||
} else {
|
||||
noMoreData = false;
|
||||
hideStatus();
|
||||
if (page == 1) {
|
||||
mGroupMemberListAdapter.setNewData(list);
|
||||
} else {
|
||||
mGroupMemberListAdapter.addData(list);
|
||||
}
|
||||
page ++;
|
||||
}
|
||||
orignalList.clear();
|
||||
orignalList.addAll(mGroupMemberListAdapter.getData());
|
||||
mGroupMemberListAdapter.setmType(GroupMemberListAdapter.TYPE_REMOVE);
|
||||
mGroupMemberListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void statusNone() {
|
||||
mGroupMemberListAdapter.setmType(GroupMemberListAdapter.TYPE_NONE);
|
||||
mGroupMemberListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
|
||||
if (mGroupMemberListAdapter.getmType() == GroupMemberListAdapter.TYPE_REMOVE) {
|
||||
statusNone();
|
||||
} else
|
||||
super.onBackPressed();
|
||||
|
||||
}
|
||||
|
||||
private long mTargetUid;
|
||||
private void showRemoveDialog(long targetUid, int targetRoleType, String targetNick) {
|
||||
mTargetUid = targetUid;
|
||||
SpannableString spannableString = getMvpPresenter().getRemoveTips(this, targetRoleType, targetNick);
|
||||
|
||||
getDialogManager().showOkCancelWithTitleDialog("提示", spannableString, "确定", "取消", new DialogManager.OkCancelDialogListener() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
mTargetUid = -1;
|
||||
statusNone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOk() {
|
||||
getMvpPresenter().remove(targetUid);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("NonConstantResourceId")
|
||||
@OnClick({R.id.iv_back,R.id.tv_search})
|
||||
public void onViewClicked(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.iv_back:
|
||||
finish();
|
||||
break;
|
||||
case R.id.tv_search:
|
||||
doSearch(searchStr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLeftClickListener() {
|
||||
onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHallAuthsSuccess(List<AuthInfo> authInfoList) {
|
||||
mAuthInfoList = authInfoList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHallAuthsFail(String message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void quitSuccess(String message) {
|
||||
toast(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void quitFail(String message) {
|
||||
toast(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAllMembersSuccess(List<MemberInfo> memberInfoList) {
|
||||
hideStatus();
|
||||
mGroupMemberListAdapter.setNewData(memberInfoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAllMembersFail(String message) {
|
||||
hideStatus();
|
||||
showNoData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSuccess(String message) {
|
||||
if (mTargetUid == -1)
|
||||
return;
|
||||
|
||||
List<MemberInfo> memberInfoList = mGroupMemberListAdapter.getData();
|
||||
if (memberInfoList.size() > 0) {
|
||||
for (MemberInfo memberInfo : memberInfoList) {
|
||||
if (memberInfo.getUid() == mTargetUid) {
|
||||
memberInfoList.remove(memberInfo);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
EventBus.getDefault().post(new RemoveMemberEvent());
|
||||
statusNone();
|
||||
mTargetUid = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFail(String message) {
|
||||
mTargetUid = -1;
|
||||
toast(message);
|
||||
}
|
||||
|
||||
class SearchListener implements TextWatcher {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {//表示最终内容
|
||||
// Log.d("afterTextChanged", s.toString());
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param s
|
||||
* @param start 开始的位置
|
||||
* @param count 被改变的旧内容数
|
||||
* @param after 改变后的内容数量
|
||||
*/
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
//这里的s表示改变之前的内容,通常start和count组合,可以在s中读取本次改变字段中被改变的内容。而after表示改变后新的内容的数量。
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param s
|
||||
* @param start 开始位置
|
||||
* @param before 改变前的内容数量
|
||||
* @param count 新增数
|
||||
*/
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
//这里的s表示改变之后的内容,通常start和count组合,可以在s中读取本次改变字段中新的内容。而before表示被改变的内容的数量。
|
||||
|
||||
// doSearch(s);
|
||||
searchStr = s;
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<MemberInfo> mTempBeansList;
|
||||
|
||||
private void doSearch(CharSequence str) {
|
||||
mTempBeansList = new ArrayList<>();
|
||||
// 如果需要排序考虑 Pair
|
||||
for(int i=0;i<orignalList.size();i++){
|
||||
if(orignalList.get(i).getNick().contains(str)
|
||||
||String.valueOf(orignalList.get(i).getErbanNo()).contains(str)){
|
||||
mTempBeansList.add(orignalList.get(i));
|
||||
}
|
||||
}
|
||||
searchList.clear();
|
||||
if (!ListUtils.isListEmpty(mTempBeansList)){
|
||||
searchList.addAll(mTempBeansList);
|
||||
}else {
|
||||
searchList.addAll(orignalList);
|
||||
}
|
||||
mHandler.sendEmptyMessage(MSG_UPDATE_SEARCH_RESULT);
|
||||
mTempBeansList.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/white">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_search"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:layout_marginTop="7dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/icon_arrow_left_black"
|
||||
android:paddingStart="15dp"
|
||||
android:paddingEnd="8dp"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:layout_marginEnd="55dp"
|
||||
android:layout_toEndOf="@id/iv_back"
|
||||
android:layout_marginStart="@dimen/dp_10"
|
||||
android:background="@drawable/bg_member_search_edit">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="10dp"
|
||||
android:src="@mipmap/icon_little_search" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_search"
|
||||
android:hint="搜索用户昵称/66号"
|
||||
android:textSize="@dimen/sp_13"
|
||||
android:textColor="@color/color_333333"
|
||||
android:textColorHint="@color/color_999999"
|
||||
android:layout_marginStart="29dp"
|
||||
android:layout_marginEnd="29dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@null" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_search"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#343434"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:textSize="16dp"
|
||||
android:text="@string/search" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.yizhuan.erban.common.widget.StatusLayout
|
||||
android:id="@+id/status_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/srl_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
</com.yizhuan.erban.common.widget.StatusLayout>
|
||||
|
||||
</LinearLayout>
|
Reference in New Issue
Block a user