|
@@ -0,0 +1,144 @@
|
|
|
+package com.cooleshow.chatmodule.ui;
|
|
|
+
|
|
|
+import android.content.Intent;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.text.Editable;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.text.TextWatcher;
|
|
|
+import android.view.View;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.EditText;
|
|
|
+
|
|
|
+import com.alibaba.android.arouter.facade.annotation.Route;
|
|
|
+import com.cooleshow.base.common.BaseApplication;
|
|
|
+import com.cooleshow.base.ui.activity.BaseMVPActivity;
|
|
|
+import com.cooleshow.base.utils.ToastUtil;
|
|
|
+import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
|
|
|
+import com.cooleshow.chatmodule.constants.Constants;
|
|
|
+import com.cooleshow.chatmodule.constants.TCChatRouterPath;
|
|
|
+import com.cooleshow.chatmodule.contract.GroupIntroduceContract;
|
|
|
+import com.cooleshow.chatmodule.databinding.TcActivityGroupIntroduceBinding;
|
|
|
+import com.cooleshow.chatmodule.presenter.GroupIntroducePresenter;
|
|
|
+
|
|
|
+import java.util.Locale;
|
|
|
+
|
|
|
+import androidx.annotation.Nullable;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 创建日期:2022/6/11 19:25
|
|
|
+ *
|
|
|
+ * @author Ryan
|
|
|
+ * 类说明:
|
|
|
+ */
|
|
|
+@Route(path = TCChatRouterPath.CHAT_GROUP_INTRODUCE)
|
|
|
+public class GroupIntroduceActivity extends BaseMVPActivity<TcActivityGroupIntroduceBinding, GroupIntroducePresenter> implements GroupIntroduceContract.View {
|
|
|
+
|
|
|
+ EditText etNotice;
|
|
|
+ Button btnCommit;
|
|
|
+ private String targetId;
|
|
|
+ private String contentText;
|
|
|
+
|
|
|
+ private TextWatcher mContentWatcher = 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) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable s) {
|
|
|
+ formatTextNum2();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ QMUIStatusBarHelper.setStatusBarLightMode(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initView() {
|
|
|
+ etNotice = viewBinding.etNotice;
|
|
|
+ btnCommit = viewBinding.btnCommit;
|
|
|
+
|
|
|
+ Intent intent = getIntent();
|
|
|
+ targetId = intent.getStringExtra(Constants.TARGET_ID_KEY);
|
|
|
+ initMidTitleToolBar(viewBinding.toolbarInclude.toolbar, "群简介");
|
|
|
+ contentText = intent.getStringExtra(Constants.COMMON_EXTRA_KEY);
|
|
|
+ etNotice.setText(contentText);
|
|
|
+ initListener();
|
|
|
+ formatTextNum2();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initData() {
|
|
|
+ super.initData();
|
|
|
+ if(BaseApplication.Companion.isTeacherClient()){
|
|
|
+ viewBinding.tvContentTextNum.setVisibility(View.VISIBLE);
|
|
|
+ viewBinding.btnCommit.setVisibility(View.VISIBLE);
|
|
|
+ etNotice.setFocusable(true);
|
|
|
+ etNotice.setFocusableInTouchMode(true);
|
|
|
+ }else{
|
|
|
+ viewBinding.tvContentTextNum.setVisibility(View.GONE);
|
|
|
+ viewBinding.btnCommit.setVisibility(View.GONE);
|
|
|
+ etNotice.setFocusable(false);
|
|
|
+ etNotice.setFocusableInTouchMode(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initListener() {
|
|
|
+ viewBinding.etNotice.addTextChangedListener(mContentWatcher);
|
|
|
+ btnCommit.setOnClickListener(v -> {
|
|
|
+ String content = etNotice.getText().toString().trim();
|
|
|
+ if (TextUtils.isEmpty(content)) {
|
|
|
+ ToastUtil.getInstance().showShort("请输入群简介");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ presenter.updateGroupIntroduce(targetId, content);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected TcActivityGroupIntroduceBinding getLayoutView() {
|
|
|
+ return TcActivityGroupIntroduceBinding.inflate(getLayoutInflater());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected GroupIntroducePresenter createPresenter() {
|
|
|
+ return new GroupIntroducePresenter();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void formatTextNum2() {
|
|
|
+ String text = viewBinding.etNotice.getText().toString().trim();
|
|
|
+ int cLength = text.length();
|
|
|
+ viewBinding.tvContentTextNum.setText(String.format(Locale.getDefault(), "%d/200", cLength));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroy() {
|
|
|
+ removeTextWatcher();
|
|
|
+ super.onDestroy();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void removeTextWatcher() {
|
|
|
+ if (viewBinding != null) {
|
|
|
+ viewBinding.etNotice.removeTextChangedListener(mContentWatcher);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updateGroupIntroduceSuccess() {
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ToastUtil.getInstance().showShort("保存成功");
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+}
|