package com.fxy.mine;

import android.os.Bundle;
import android.text.TextUtils;
import android.widget.EditText;

import com.elvishew.xlog.XLog;
import com.fxy.baselibrary.base.BaseActivity;
import com.fxy.baselibrary.util.AnimShakeUtil;
import com.fxy.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * 意见反馈
 */
public class FeedbackActivity extends BaseActivity {

    @BindView(R.id.et_feedback)
    EditText etFeedback;
    private Unbinder unbinder;

    @Override
    public int getContentViewResId() {
        return R.layout.activity_feedback;
    }

    @Override
    public boolean showToolBar() {
        return true;
    }

    @Override
    public boolean openEventBus() {
        return false;
    }

    @Override
    public boolean isPlayMusic() {
        return true;
    }

    @Override
    protected void getBundleExtras(Bundle extras) {

    }

    @Override
    protected void initView() {
        unbinder = ButterKnife.bind(this);
        setTitleName(getString(R.string.str_feedback));
    }

    @OnClick(R.id.btn_submit)
    public void onViewClicked() {
        if (TextUtils.isEmpty(etFeedback.getText().toString().trim())) {
            AnimShakeUtil.shake(this.etFeedback);
            showWarningToast(getString(R.string.str_feedback_nonull));
        } else {
            requestFeedback();
            etFeedback.setText("");
        }
    }

    /**
     * 意见反馈
     */
    private void requestFeedback() {
        XLog.i(etFeedback.getText().toString().trim());
        showSuccessToast("反馈成功!");
//        OkGo.<String>post(Urls.createFeedback)
//                .params("content", etFeedback.getText().toString().trim())
//                .execute(new MyDialogCallback(getApplicationContext(), true, false) {
//                    @Override
//                    public void onSuccess(com.lzy.okgo.model.Response<String> response) {
//                        super.onSuccess(response);
//                        try {
//                            ActionBean bean = JsonUtil.getObject(response.body().toString(), ActionBean.class);
//                            if (bean.code == 0) {
//                                showSuccessToast(bean.msg);
//                                finish();
//                            }
//                        } catch (Exception e) {
//                            e.printStackTrace();
//                        }
//                    }
//
//                });
    }

    @Override
    protected void onDestroy() {
        unbinder.unbind();
        super.onDestroy();
    }
}
