package com.cooleshow.student.ui.mine;

import android.content.Intent;
import android.text.TextUtils;

import androidx.annotation.Nullable;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.cooleshow.base.router.RouterPath;
import com.cooleshow.base.ui.activity.BaseMVPActivity;
import com.cooleshow.student.bean.StudentUserInfo;
import com.cooleshow.student.contract.CheckTeachableContract;
import com.cooleshow.student.databinding.ActivityCheckTeachableBinding;
import com.cooleshow.student.presenter.mine.CheckTeachablePresenter;

/**
 * 创建日期：2022/6/5 20:16
 *
 * @author Ryan
 * 类说明：
 */
@Route(path = RouterPath.MineCenter.MINE_CHECK_TEACHABLE)
public class CheckTeachableActivity extends BaseMVPActivity<ActivityCheckTeachableBinding, CheckTeachablePresenter> implements CheckTeachableContract.CheckTeachableView {

    @Override
    protected void initView() {

    }

    @Override
    public void initData() {
        super.initData();
        presenter.queryUserInfo();
    }

    @Override
    protected ActivityCheckTeachableBinding getLayoutView() {
        return ActivityCheckTeachableBinding.inflate(getLayoutInflater());
    }

    @Override
    protected CheckTeachablePresenter createPresenter() {
        return new CheckTeachablePresenter();
    }

    @Override
    public void queryUserInfoSuccess(StudentUserInfo data) {
        //        data.subjectName
        if (TextUtils.isEmpty(data.subjectName)) {
            ARouter.getInstance().build(RouterPath.MineCenter.MINE_TEACHABLE_INSTRUMENT)
                    .navigation(this,1001);
        } else {
            goMain();
        }

    }

    @Override
    public void queryUserInfoError() {
        goMain();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode==RESULT_OK){
            if (requestCode==1001){
                goMain();
            }
        }
    }
    private void goMain(){
        ARouter.getInstance().build(RouterPath.APPCenter.PATH_HOME).navigation();
        finish();
    }
}
