package com.bc_chat.contacts.ui.report

import android.app.Activity
import android.content.Intent
import android.view.Menu
import android.view.MenuItem
import com.alibaba.android.arouter.facade.annotation.Route
import com.bc_chat.bc_base.config.RouteConfig
import com.bc_chat.contacts.R
import com.bc_chat.contacts.databinding.ActivityReportOtherBinding
import com.zhaohaoting.framework.abs.BaseActivity
import com.zhaohaoting.framework.abs.contract.BaseContract
import com.zhaohaoting.framework.utils.SimpleTextWatcher

/**
 * author：Created by zhaohaoting on 2019/3/7
 * email：526309416@qq.com
 * desc：举报描述
 */
@Route(path = RouteConfig.REPORT_OTHER_ACTIVITY)
class ReportOtherActivity : BaseActivity<BaseContract.BasePresenter>() {

    private val binding by lazy {
        rootDataBinding as ActivityReportOtherBinding
    }

    override fun getLayoutResId(): Int {
        return R.layout.activity_report_other
    }

    override fun initialize() {
        binding.etReport.addTextChangedListener(object : SimpleTextWatcher() {
            override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
                binding.etCount.text = (100 - s.length).toString()
            }
        })
    }

    override fun onCreateOptionsMenu(menu: Menu?): Boolean {
        menu?.add("完成")!!.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS)
        return super.onCreateOptionsMenu(menu)
    }

    override fun onOptionsItemSelected(item: MenuItem?): Boolean {
        setResult(Activity.RESULT_OK, Intent().putExtra("report_content", binding.etReport.text.trim().toString()))
        finish()
        return true
    }

    override fun initPresenter(): BaseContract.BasePresenter? {
        return null
    }
}
