package com.taikor.investment.modules.user;

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 android.widget.TextView;

import com.taikor.investment.R;
import com.taikor.investment.base.BaseActivity;
import com.taikor.investment.utils.ToastUtils;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 意见反馈
 * Created by Any on 2017/5/3.
 */
public class FeedBackActivity extends BaseActivity implements TextWatcher {
    
    @BindView(R.id.tv_bar_title)
    TextView tvBarTitle;
    @BindView(R.id.et_feedback)
    EditText etFeedback;
    @BindView(R.id.bt_submit)
    Button btSubmit;

    @Override
    public int getContentViewId() {
        return R.layout.activity_user_feedback;
    }

    @Override
    public void initView() {
        tvBarTitle.setText(getString(R.string.feedback));
        btSubmit.getBackground().setAlpha(125);
        etFeedback.addTextChangedListener(this);
    }
    
    @OnClick({R.id.tv_bar_back, R.id.bt_submit})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_bar_back:
                finish();
                break;
            case R.id.bt_submit:
                String feedback = etFeedback.getText().toString();
                if (!TextUtils.isEmpty(feedback)){
                    //上传到服务器
                    ToastUtils.showShort(this, feedback);
                    etFeedback.setText("");
                }
                break;
        }
    }

    @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) {
        btSubmit.getBackground().setAlpha(255);
    }
}
