package com.common.im.ui.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.common.im_ui.R;
import com.common.im_ui.databinding.ActivityCreateGroupBinding;
import com.common.im.contract.CreateGroupContract;
import com.common.im.presenter.CreateGroupPresenter;
import com.cooleshow.base.router.RouterPath;
import com.cooleshow.base.ui.activity.BaseMVPActivity;
import com.cooleshow.base.utils.ToastUtil;
import com.cooleshow.base.utils.ToastUtils;
import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;

import androidx.annotation.Nullable;

/**
 * 创建日期：2022/6/10 17:23
 *
 * @author Ryan
 * 类说明：
 */
@Route(path = RouterPath.ChatCenter.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) {
            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();
    }
}
