Browse Source

修改创建群组页面路径

Pq 1 year ago
parent
commit
d410698f7d

+ 6 - 0
chatModule/src/main/AndroidManifest.xml

@@ -57,6 +57,12 @@
             android:configChanges="orientation|screenSize|keyboardHidden|fontScale|smallestScreenSize|screenLayout"
             android:windowSoftInputMode="adjustNothing|stateHidden"/>
 
+        <activity
+            android:name=".ui.CreateGroupActivity"
+            android:windowSoftInputMode="adjustPan"
+            android:configChanges="orientation|screenSize|keyboardHidden"
+            android:screenOrientation="portrait" />
+
         <provider
             android:name=".widget.CustomChatGroupTopRightIconExtension"
             android:authorities="${applicationId}.TUIGroup.ClassicUI.Init"

+ 9 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/api/IMApi.java

@@ -149,4 +149,13 @@ public interface IMApi {
      */
     @POST("{group_name}" + "/music/sheet/list")
     Observable<BaseResponse<MusicSheetListBean>> queryMusicList(@Body RequestBody body,@Path("group_name")String group_name);
+
+    /**
+     * 创建粉丝群
+     *
+     * @param body
+     * @return
+     */
+    @POST(TEACHER_GROUP + "imGroup/create")
+    Observable<BaseResponse<Object>> createImGroup(@Body RequestBody body);
 }

+ 18 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/contract/CreateGroupContract.java

@@ -0,0 +1,18 @@
+package com.cooleshow.chatmodule.contract;
+
+import com.cooleshow.base.presenter.view.BaseView;
+
+/**
+ * 创建日期:2022/6/10 17:40
+ *
+ * @author Ryan
+ * 类说明:
+ */
+public interface CreateGroupContract {
+    interface CreateGroupView extends BaseView {
+        void createImGroupSuccess();
+    }
+
+    interface Presenter {
+    }
+}

+ 43 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/presenter/CreateGroupPresenter.java

@@ -0,0 +1,43 @@
+package com.cooleshow.chatmodule.presenter;
+
+import com.cooleshow.base.presenter.BasePresenter;
+import com.cooleshow.base.rx.BaseObserver;
+import com.cooleshow.base.utils.RequestBodyUtil;
+import com.cooleshow.chatmodule.api.IMApi;
+import com.cooleshow.chatmodule.contract.CreateGroupContract;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ * 创建日期:2022/6/10 17:39
+ *
+ * @author Ryan
+ * 类说明:
+ */
+public class CreateGroupPresenter extends BasePresenter<CreateGroupContract.CreateGroupView> implements CreateGroupContract.Presenter {
+    public void createGroup(String name,String introduce){
+        JSONObject jsonObject = new JSONObject();
+        try {
+            jsonObject.put("name", name);
+            jsonObject.put("introduce", introduce);
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+        addSubscribe(create(IMApi.class).createImGroup(RequestBodyUtil.convertToRequestBodyJson(jsonObject.toString())), new BaseObserver<Object>(getView()) {
+            @Override
+            protected void onSuccess(Object data) {
+                if (getView() != null) {
+                    getView().createImGroupSuccess();
+                }
+            }
+
+            @Override
+            public void onComplete() {
+                super.onComplete();
+                getView().hideLoading();
+            }
+
+        });
+    }
+}

+ 2 - 1
chatModule/src/main/java/com/cooleshow/chatmodule/ui/ChatFragment.java

@@ -14,6 +14,7 @@ import com.cooleshow.base.utils.SizeUtils;
 import com.cooleshow.base.utils.Utils;
 import com.cooleshow.chatmodule.R;
 import com.cooleshow.chatmodule.adapter.MessagePagerAdapter;
+import com.cooleshow.chatmodule.constants.TCChatRouterPath;
 import com.cooleshow.chatmodule.contract.IUnReadMessageObserver;
 import com.cooleshow.chatmodule.databinding.TcFragmentChatLayoutBinding;
 import com.cooleshow.chatmodule.manager.IMCenter;
@@ -146,7 +147,7 @@ public class ChatFragment extends BaseFragment<TcFragmentChatLayoutBinding> impl
     @Override
     public void onClick(View v) {
         if (v.getId() == R.id.im_create_group) {
-            ARouter.getInstance().build(RouterPath.ChatCenter.CHAT_CREATE_GROUP)
+            ARouter.getInstance().build(TCChatRouterPath.CHAT_CREATE_GROUP)
                     .navigation();
             return;
         }

+ 72 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/ui/CreateGroupActivity.java

@@ -0,0 +1,72 @@
+package com.cooleshow.chatmodule.ui;
+
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.View;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.cooleshow.base.router.RouterPath;
+import com.cooleshow.base.ui.activity.BaseMVPActivity;
+import com.cooleshow.base.utils.ToastUtil;
+import com.cooleshow.base.utils.UiUtils;
+import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
+import com.cooleshow.chatmodule.R;
+import com.cooleshow.chatmodule.constants.TCChatRouterPath;
+import com.cooleshow.chatmodule.contract.CreateGroupContract;
+import com.cooleshow.chatmodule.databinding.ActivityCreateGroupBinding;
+import com.cooleshow.chatmodule.presenter.CreateGroupPresenter;
+
+import androidx.annotation.Nullable;
+
+/**
+ * 创建日期:2022/6/10 17:23
+ *
+ * @author Ryan
+ * 类说明:
+ */
+@Route(path = TCChatRouterPath.CHAT_CREATE_GROUP)
+public class CreateGroupActivity extends BaseMVPActivity<ActivityCreateGroupBinding, CreateGroupPresenter> implements CreateGroupContract.CreateGroupView, View.OnClickListener {
+    @Override
+    public void onClick(View view) {
+        if (view.getId() == R.id.tv_create) {
+            if (UiUtils.isFastClick()) {
+                return;
+            }
+            String groupName = viewBinding.etGroupName.getText().toString().trim();
+            if (TextUtils.isEmpty(groupName)) {
+                ToastUtil.getInstance().showShort("请输入粉丝群名称!");
+                return;
+            }
+            String introduction = viewBinding.etIntroduction.getText().toString().trim();
+            presenter.createGroup(groupName, introduction);
+        }
+    }
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        QMUIStatusBarHelper.setStatusBarLightMode(this);
+    }
+
+    @Override
+    protected void initView() {
+        initMidTitleToolBar(viewBinding.toolbarInclude.toolbar, "创建粉丝群");
+        viewBinding.tvCreate.setOnClickListener(this);
+    }
+
+    @Override
+    protected ActivityCreateGroupBinding getLayoutView() {
+        return ActivityCreateGroupBinding.inflate(getLayoutInflater());
+    }
+
+    @Override
+    protected CreateGroupPresenter createPresenter() {
+        return new CreateGroupPresenter();
+    }
+
+    @Override
+    public void createImGroupSuccess() {
+        ToastUtil.getInstance().showShort("创建成功");
+        finish();
+    }
+}

+ 151 - 0
chatModule/src/main/res/layout/activity_create_group.xml

@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout 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"
+    android:orientation="vertical">
+
+    <include
+        android:id="@+id/toolbar_include"
+        layout="@layout/common_toolbar_layout" />
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:layout_width="match_parent"
+        android:layout_marginLeft="@dimen/dp_14"
+        android:layout_marginTop="@dimen/dp_15"
+        android:paddingStart="12dp"
+        android:paddingEnd="12dp"
+        android:layout_marginRight="@dimen/dp_14"
+        android:background="@drawable/bg_white_10dp"
+        android:layout_height="46dp">
+
+        <TextView
+            android:id="@+id/tv_group_type"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="群类型"
+            android:textColor="@color/black"
+            android:textSize="@dimen/sp_17"
+            android:textStyle="bold"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/dp_82"
+        android:layout_marginLeft="@dimen/dp_14"
+        android:layout_marginTop="@dimen/dp_12"
+        android:layout_marginRight="@dimen/dp_14"
+        android:background="@drawable/bg_white_10dp">
+
+        <TextView
+            android:id="@+id/tv_star"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="@dimen/dp_21"
+            android:layout_marginTop="@dimen/dp_12"
+            android:text="*"
+            android:textColor="@color/color_ff4e1a"
+            android:textSize="@dimen/sp_17"
+            android:textStyle="bold"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+
+        <TextView
+            android:id="@+id/tv_group_name"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="群名称"
+            android:textColor="@color/black"
+            android:textSize="@dimen/sp_17"
+            android:textStyle="bold"
+            app:layout_constraintBottom_toBottomOf="@+id/tv_star"
+            app:layout_constraintLeft_toRightOf="@+id/tv_star"
+            app:layout_constraintTop_toTopOf="@+id/tv_star" />
+
+        <EditText
+            android:id="@+id/et_group_name"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:background="@null"
+            android:gravity="left"
+            android:hint="请输入群聊名称"
+            android:inputType="text"
+            android:lines="1"
+            android:maxLength="50"
+            android:paddingLeft="@dimen/dp_21"
+            android:paddingTop="@dimen/dp_8"
+            android:paddingRight="@dimen/dp_21"
+            android:paddingBottom="@dimen/dp_16"
+            android:textColor="@color/color_333333"
+            android:textColorHint="@color/color_ffc1c1c1"
+            android:textSize="@dimen/sp_16"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tv_group_name" />
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/dp_191"
+        android:layout_marginLeft="@dimen/dp_14"
+        android:layout_marginTop="@dimen/dp_12"
+        android:layout_marginRight="@dimen/dp_14"
+        android:background="@drawable/bg_white_10dp">
+
+        <TextView
+            android:id="@+id/tv_introduction"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="@dimen/dp_21"
+            android:layout_marginTop="@dimen/dp_12"
+            android:text="群简介"
+            android:textColor="@color/black"
+            android:textSize="@dimen/sp_17"
+            android:textStyle="bold"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <EditText
+            android:id="@+id/et_introduction"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:background="@null"
+            android:gravity="left"
+            android:hint="请输入群简介"
+            android:inputType="text"
+            android:lines="1"
+            android:maxLength="50"
+            android:paddingLeft="@dimen/dp_21"
+            android:paddingTop="@dimen/dp_8"
+            android:paddingRight="@dimen/dp_21"
+            android:paddingBottom="@dimen/dp_16"
+            android:textColor="@color/color_333333"
+            android:textColorHint="@color/color_ffc1c1c1"
+            android:textSize="@dimen/sp_16"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tv_introduction" />
+
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+
+    <TextView
+        android:id="@+id/tv_create"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/dp_44"
+        android:layout_marginLeft="@dimen/dp_28"
+        android:layout_marginTop="@dimen/dp_31"
+        android:layout_marginRight="@dimen/dp_28"
+        android:background="@drawable/shape_click_btn"
+        android:gravity="center"
+        android:text="确认创建"
+        android:textColor="@color/white"
+        android:textSize="@dimen/sp_18" />
+</LinearLayout>