package com.ycgis.macall.personalcenter.v.activity;

import android.os.Bundle;
import android.text.Html;

import com.rs.macall.androidx.basemodel.base.BaseViewBindActivity;
import com.rs.macall.androidx.basemodel.utils.StringUtil;
import com.rs.macall.androidx.basemodel.utils.ToastUtil;
import com.ycgis.macall.personalcenter.R;
import com.ycgis.macall.personalcenter.databinding.ActivitySuggestionsDetailsBinding;
import com.ycgis.macall.personalcenter.m.adapterbean.FeedbackBean;
import com.ycgis.macall.personalcenter.p.app.AppCache;

/**
 * 意见反馈详情
 */
public class SuggestionsDetailsActivity extends BaseViewBindActivity<ActivitySuggestionsDetailsBinding> {
    private FeedbackBean bean;

    @Override
    protected ActivitySuggestionsDetailsBinding getViewBinding() {
        return ActivitySuggestionsDetailsBinding.inflate(getLayoutInflater());
    }

    @Override
    protected void init() {

    }

    @Override
    protected boolean isImmersiveStatusBar() {
        return true;
    }

    @Override
    protected void readInstanceState(Bundle savedInstanceState) {
        bean = (FeedbackBean) getIntent().getSerializableExtra("dataModel");
    }

    @Override
    protected void start() {
        viewBinding.include2.contentTitle.setText("反馈详情");
        viewBinding.include2.leftImage.setImageDrawable(getDrawables(R.drawable.back_cliener));
        viewBinding.include2.titleleft.setOnClickListener(v->finish());
        if (bean == null){
            ToastUtil.centered(getContext(),"未知错误！");
            return;
        }
        viewBinding.suggestionsTvTitle.setText(bean.getTitleStr());
        viewBinding.suggestionsContent.setText(bean.getContentStr());
        viewBinding.suggestionsTvTime.setText(bean.getCreateTime());
        viewBinding.suggestionsTvType.setText(bean.getTypeStr());

        if (StringUtil.isNullOrEmpty(bean.getApplicationName())){
            goneView(viewBinding.suggestionsBqAppName);
        }else {
            visibleView(viewBinding.suggestionsBqAppName);
            viewBinding.suggestionsBqAppName.setText(bean.getApplicationName());
        }
        if (bean.getReplyStatus() == 1){
            visibleView(viewBinding.suggestionsReply);
            StringBuffer str = new StringBuffer();
        str.append("<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><body><p style=\"word-break:break-all; padding:12px;\">")
                .append(bean.getReplyContent().replace("/prod-api/profile", AppCache.BASE_IMAGE_URL+"profile"))
                .append("</p></body></html>");
            viewBinding.replyContent.loadDataWithBaseURL("", str.toString(), "text/html","UTF-8", "");

//            viewBinding.replyContent.loadUrl(bean.getReplyContent());
//            viewBinding.replyContent.setText(Html.fromHtml(bean.getReplyContent()));
            viewBinding.replyTime.setText(bean.getUpdateTime());
            viewBinding.replyUser.setText(bean.getReplier());
            viewBinding.suggestionsTvReply.setText("已回复");
            viewBinding.suggestionsTvReply.setBackground(getDrawables(R.drawable.bk_ls));
            viewBinding.suggestionsTvReply.setTextColor(getColors(R.color.colorGreen6));
        }else {
            goneView(viewBinding.suggestionsReply);
            viewBinding.suggestionsTvReply.setText("未回复");
            viewBinding.suggestionsTvReply.setBackground(getDrawables(R.drawable.bk_gray));
            viewBinding.suggestionsTvReply.setTextColor(getColors(R.color.colorGrey6));
        }
    }



}