修改公会名逻辑修改

This commit is contained in:
huangjian
2021-09-07 18:42:16 +08:00
parent 4b42a98534
commit b71a9f145d
6 changed files with 43 additions and 49 deletions

View File

@@ -35,8 +35,12 @@ public class HallNameSettingActivity extends BaseMvpActivity<IHallNameView, Hall
*/ */
private final static int MAX_HALL_NAME_LIMIT = 15; private final static int MAX_HALL_NAME_LIMIT = 15;
public static void start(Context context) { private long hallId;
public static void start(Context context,String hallName,long hallId) {
Intent intent = new Intent(context, HallNameSettingActivity.class); Intent intent = new Intent(context, HallNameSettingActivity.class);
intent.putExtra("hallName",hallName);
intent.putExtra("hallId",hallId);
context.startActivity(intent); context.startActivity(intent);
} }
@@ -49,8 +53,8 @@ public class HallNameSettingActivity extends BaseMvpActivity<IHallNameView, Hall
initWhiteTitleBar("设置房间名"); initWhiteTitleBar("设置房间名");
setRightOption(); setRightOption();
hallId = getIntent().getLongExtra("hallId",0);
String hallName = HallDataManager.get().getHallName(); String hallName = getIntent().getStringExtra("hallName");
if (!TextUtils.isEmpty(hallName)) { if (!TextUtils.isEmpty(hallName)) {
etHallName.setTextAutoCursor(hallName); etHallName.setTextAutoCursor(hallName);
} }
@@ -86,13 +90,12 @@ public class HallNameSettingActivity extends BaseMvpActivity<IHallNameView, Hall
return; return;
} }
getMvpPresenter().updateHallName(hallName); getMvpPresenter().updateHallName(hallName,hallId);
} }
@Override @Override
public void updateHallNameSuccess(String newHallName) { public void updateHallNameSuccess(String newHallName) {
SingleToastUtil.showToastShort("保存成功"); SingleToastUtil.showToastShort("保存成功");
HallDataManager.get().updateHallName(newHallName);
finish(); finish();
} }

View File

@@ -108,22 +108,18 @@ public class ModuleClanActivity extends BaseActivity implements View.OnClickList
} }
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
binding.nsvHall.setNestedScrollingEnabled(false); binding.nsvHall.setNestedScrollingEnabled(false);
initClanAndHall();
} }
@Override
protected void onResume() {
super.onResume();
initClanAndHall();
}
@SuppressLint({"CheckResult", "SetTextI18n"}) @SuppressLint({"CheckResult", "SetTextI18n"})
private void initClanAndHall() { private void initClanAndHall() {
//没有家族才更新顶部公会名,有的话重新加载公会列表 //没有家族才更新顶部公会名,有的话重新加载公会列表
HallDataManager.get().registerName(this, hallName -> {
if (TextUtils.isEmpty(hallName)) return;
if (clanInfo == null || clanInfo.getId() == 0) {
binding.tvTitle.setText(hallName);
} else {
loadHallList();
}
});
HallModel.get().getUserHallAndClan(otherUid) HallModel.get().getUserHallAndClan(otherUid)
.compose(bindToLifecycle()) .compose(bindToLifecycle())
.subscribe(clanAndHallInfo -> { .subscribe(clanAndHallInfo -> {
@@ -263,12 +259,6 @@ public class ModuleClanActivity extends BaseActivity implements View.OnClickList
} }
} }
@Override
protected void onResume() {
super.onResume();
onReloadDate();
}
@Override @Override
protected boolean needSteepStateBar() { protected boolean needSteepStateBar() {
return true; return true;

View File

@@ -8,6 +8,7 @@ import android.text.SpannableString;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View; import android.view.View;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import com.netease.nim.uikit.StatusBarUtil; import com.netease.nim.uikit.StatusBarUtil;
@@ -67,6 +68,9 @@ public class ModuleHallActivity extends BaseMvpActivity<IModuleHallView, ModuleH
private long ownerUid; private long ownerUid;
private long otherUid; private long otherUid;
@Nullable
private HallInfo hallInfo;
private ActivityModuleHallBinding binding; private ActivityModuleHallBinding binding;
public static void start(Context context, long hallId, long ownerUid, long otherUid) { public static void start(Context context, long hallId, long ownerUid, long otherUid) {
@@ -127,24 +131,24 @@ public class ModuleHallActivity extends BaseMvpActivity<IModuleHallView, ModuleH
setTvCount(0); setTvCount(0);
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
binding.nsvHall.setNestedScrollingEnabled(false); binding.nsvHall.setNestedScrollingEnabled(false);
initClanAndHall(); }
@Override
protected void onResume() {
super.onResume();
initClanAndHall();
loadMembers(true);
} }
@SuppressLint({"CheckResult", "SetTextI18n"}) @SuppressLint({"CheckResult", "SetTextI18n"})
private void initClanAndHall() { private void initClanAndHall() {
//没有家族才更新顶部公会名,有的话重新加载公会列表
HallDataManager.get().registerName(this, hallName -> {
if (TextUtils.isEmpty(hallName)) return;
binding.tvTitle.setText(hallName);
});
HallModel.get().getUserHallAndClan(ownerUid) HallModel.get().getUserHallAndClan(ownerUid)
.compose(bindToLifecycle()) .compose(bindToLifecycle())
.subscribe(clanAndHallInfo -> { .subscribe(clanAndHallInfo -> {
HallInfo hallInfo = clanAndHallInfo.getHall(); HallInfo hallInfo = clanAndHallInfo.getHall();
setSettingOption((HallDataManager.get().isManager() && isSelfHall) || clanAndHallInfo.isManageHall()); setSettingOption((HallDataManager.get().isManager() && isSelfHall) || clanAndHallInfo.isManageHall());
if (hallInfo != null && hallInfo.getHallId() != 0) { if (hallInfo != null && hallInfo.getHallId() != 0) {
this.hallInfo = hallInfo;
binding.clHall.setVisibility(View.VISIBLE); binding.clHall.setVisibility(View.VISIBLE);
binding.clHall.setOnClickListener(v -> UserInfoActivity.Companion.start(context, hallInfo.getOwnerUid())); binding.clHall.setOnClickListener(v -> UserInfoActivity.Companion.start(context, hallInfo.getOwnerUid()));
binding.tvHallId.setText("房间ID:" + hallInfo.getOwnerErbanNo()); binding.tvHallId.setText("房间ID:" + hallInfo.getOwnerErbanNo());
@@ -191,12 +195,6 @@ public class ModuleHallActivity extends BaseMvpActivity<IModuleHallView, ModuleH
} }
} }
@Override
public void onReloadDate() {
super.onReloadDate();
loadMembers(true);
}
private long mTargetUid; private long mTargetUid;
private void showRemoveDialog(long targetUid, int targetRoleType, String targetNick) { private void showRemoveDialog(long targetUid, int targetRoleType, String targetNick) {
@@ -355,7 +353,11 @@ public class ModuleHallActivity extends BaseMvpActivity<IModuleHallView, ModuleH
finish(); finish();
break; break;
case R.id.iv_setting: case R.id.iv_setting:
HallNameSettingActivity.start(ModuleHallActivity.this); if (hallInfo != null) {
HallNameSettingActivity.start(ModuleHallActivity.this, hallInfo.getHallName(), hallId);
} else {
toast("加载数据中,请稍后...");
}
break; break;
case R.id.tv_exit: case R.id.tv_exit:
showExitDialog(); showExitDialog();
@@ -404,9 +406,12 @@ public class ModuleHallActivity extends BaseMvpActivity<IModuleHallView, ModuleH
break; break;
case AuthInfo.AUTH_HALL_NAME_SET: case AuthInfo.AUTH_HALL_NAME_SET:
HallNameSettingActivity.start(ModuleHallActivity.this); if (hallInfo != null) {
HallNameSettingActivity.start(ModuleHallActivity.this, hallInfo.getHallName(), hallId);
} else {
toast("加载数据中,请稍后...");
}
break; break;
default: default:
Logger.e("本版本不能识别的权限"); Logger.e("本版本不能识别的权限");
break; break;
@@ -428,12 +433,6 @@ public class ModuleHallActivity extends BaseMvpActivity<IModuleHallView, ModuleH
}); });
} }
@Override
protected void onResume() {
super.onResume();
onReloadDate();
}
@Override @Override
protected boolean needSteepStateBar() { protected boolean needSteepStateBar() {
return true; return true;

View File

@@ -9,8 +9,8 @@ import io.reactivex.disposables.Disposable;
public class HallNamePresenter extends BaseMvpPresenter<IHallNameView> { public class HallNamePresenter extends BaseMvpPresenter<IHallNameView> {
public void updateHallName(String hallName) { public void updateHallName(String hallName,long hallId) {
HallNameModel.get().updateHallName(hallName) HallNameModel.get().updateHallName(hallName,hallId)
.compose(bindToLifecycle()) .compose(bindToLifecycle())
.subscribe(new SingleObserver<String>() { .subscribe(new SingleObserver<String>() {
@Override @Override

View File

@@ -27,8 +27,8 @@ public class HallNameModel extends BaseModel implements IHallNameModel {
} }
@Override @Override
public Single<String> updateHallName(String hallName) { public Single<String> updateHallName(String hallName,long hallId) {
return api.updateHallName(AuthModel.get().getCurrentUid(), hallName) return api.updateHallName(AuthModel.get().getCurrentUid(), hallName,hallId)
.compose(RxHelper.handleSchAndExce()) .compose(RxHelper.handleSchAndExce())
.flatMap(response -> { .flatMap(response -> {
if (response.isSuccess()) { if (response.isSuccess()) {
@@ -49,7 +49,9 @@ public class HallNameModel extends BaseModel implements IHallNameModel {
* 厅主id * 厅主id
*/ */
@POST("/hall/updateHallName") @POST("/hall/updateHallName")
Single<ServiceResult> updateHallName(@Query("uid") long uid, @Query("hallName") String hallName); Single<ServiceResult> updateHallName(@Query("uid") long uid,
@Query("hallName") String hallName,
@Query("hallId") long hallId);
} }
} }

View File

@@ -5,5 +5,5 @@ import com.yizhuan.xchat_android_core.base.IModel;
import io.reactivex.Single; import io.reactivex.Single;
public interface IHallNameModel extends IModel { public interface IHallNameModel extends IModel {
Single<String> updateHallName(String hallName); Single<String> updateHallName(String hallName,long hallId);
} }