导航菜单

页面标题

页面副标题

爱心e站 v1.0.0 - ActivityRehabilitationCommentAdd.java 源代码

正在查看: 爱心e站 v1.0.0 应用的 ActivityRehabilitationCommentAdd.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.newheyd.JZKFcanjiren.Activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RatingBar;
import android.widget.TextView;
import com.igexin.assist.sdk.AssistPushConsts;
import com.newheyd.JZKFcanjiren.BaseActivity;
import com.newheyd.JZKFcanjiren.Bean.MessageEvent;
import com.newheyd.JZKFcanjiren.Bean.RehabilitationServiceBean;
import com.newheyd.JZKFcanjiren.R;
import com.newheyd.JZKFcanjiren.Utils.DataUtil;
import com.newheyd.JZKFcanjiren.Utils.SharedPreferencedUtils;
import com.newheyd.JZKFcanjiren.Utils.StastisticUtil;
import com.newheyd.JZKFcanjiren.Utils.ToastUtils;
import com.newheyd.JZKFcanjiren.Utils.locationUtil.LocationAddrUtil;
import com.newheyd.JZKFcanjiren.View.DateTimePickDialogPlus;
import com.newheyd.JZKFcanjiren.View.TitleView;
import com.newheyd.JZKFcanjiren.config.NewHYConfig;
import com.newheyd.JZKFcanjiren.model.BaseResult;
import com.newheyd.JZKFcanjiren.model.DataParser;
import com.newheyd.JZKFcanjiren.net.CommonDataListTask;
import com.newheyd.JZKFcanjiren.net.CommonTask;
import com.newheyd.JZKFcanjiren.net.NewHYTask;
import com.newheyd.JZKFcanjiren.net.RequestServiceList;
import java.util.HashMap;
import org.greenrobot.eventbus.EventBus;

public class ActivityRehabilitationCommentAdd extends BaseActivity implements View.OnClickListener {
    private String citizenId;
    private String environmentFacility;
    private String evaluateContent;
    private String id;
    private Button mBtSave;
    private EditText mEtReply;
    private EditText mEtReplyName;
    private TitleView mTitleView;
    private TextView mTvDate;
    private TextView mTvIdCard;
    private TextView mTvName;
    private String name;
    private String professionalSkill;
    private String rateDate;
    private String rateName;
    private RatingBar ratingBarEnvironment;
    private RatingBar ratingBarService;
    private RatingBar ratingBarSkill;
    private String serviceAttitude;
    private DateTimePickDialogPlus dateTimePickDialogPlus = null;
    private RehabilitationServiceBean rehabilitationCommentBean = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_rehabilitation_comment_add);
        super.onCreate(savedInstanceState);
        getRehibilitationCommentView();
        goStatistics();
    }

    public void goStatistics() {
        HashMap<String, String> map = LocationAddrUtil.getInstance().getLocationParam(this.mContext);
        StastisticUtil.getInstance().onEvent(this.mContext, "ActivityRehabilitationCommentAdd", map);
    }

    public void getRehibilitationCommentView() {
        HashMap<String, String> params = new HashMap<>();
        params.put("service", this.id);
        params.put(AssistPushConsts.MSG_TYPE_TOKEN, SharedPreferencedUtils.getInstance(this.mContext).getString(AssistPushConsts.MSG_TYPE_TOKEN));
        NewHYTask task = new CommonDataListTask(RequestServiceList.COMMENT_PREADDDETAIL, params, RehabilitationServiceBean.class);
        executeRequest(task);
    }

    public void freshData() {
        float score;
        float score2;
        float score3;
        this.mTvName.setText(this.rehabilitationCommentBean.getName());
        this.mTvIdCard.setText(this.rehabilitationCommentBean.getCitizenId());
        this.mEtReplyName.setText(isNull(this.rehabilitationCommentBean.getRateName()) ? this.rehabilitationCommentBean.getName() : this.rehabilitationCommentBean.getRateName());
        this.mEtReplyName.requestFocus();
        if (!isNull(this.mEtReplyName.getText().toString())) {
            this.mEtReplyName.setSelection(this.mEtReplyName.getText().toString().length());
        }
        this.mTvDate.setText(DataUtil.formatDateOther(this.rehabilitationCommentBean.getRateDate()));
        try {
            score = Float.parseFloat(this.rehabilitationCommentBean.getServiceAttitude());
        } catch (Exception e) {
            score = 0.0f;
        }
        this.ratingBarService.setRating(score);
        try {
            score2 = Float.parseFloat(this.rehabilitationCommentBean.getEnvironmentFacility());
        } catch (Exception e2) {
            score2 = 0.0f;
        }
        this.ratingBarEnvironment.setRating(score2);
        try {
            score3 = Float.parseFloat(this.rehabilitationCommentBean.getProfessionalSkill());
        } catch (Exception e3) {
            score3 = 0.0f;
        }
        this.ratingBarSkill.setRating(score3);
        this.mEtReply.setText(this.rehabilitationCommentBean.getEvaluateContent());
    }

    @Override
    public void onResponseBefore(NewHYTask task) {
        switch (task.getService()) {
            case COMMENT_PREADDDETAIL:
            case COMMENT_ADDDETAIL:
                showProgress(NewHYConfig.LOADING_HINT, false);
                break;
        }
    }

    @Override
    public void onResponseAfter(NewHYTask task) {
        switch (task.getService()) {
            case COMMENT_PREADDDETAIL:
            case COMMENT_ADDDETAIL:
                cancleProgress();
                break;
        }
    }

    @Override
    public void onResponseSuccessful(NewHYTask task, BaseResult object) {
        switch (task.getService()) {
            case COMMENT_PREADDDETAIL:
                DataParser<RehabilitationServiceBean> mResult = (DataParser) object;
                if (mResult.getObjects().size() != 0) {
                    this.rehabilitationCommentBean = mResult.getObjects().get(0);
                    freshData();
                    break;
                }
                break;
            case COMMENT_ADDDETAIL:
                ToastUtils.showShortToast(this.mContext, "评价成功");
                MessageEvent event = new MessageEvent("评价成功", 2);
                EventBus.getDefault().post(event);
                this.mTitleView.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        ActivityRehabilitationCommentAdd.this.finish();
                    }
                }, 300L);
                break;
        }
    }

    @Override
    public void onResponseError(NewHYTask task, BaseResult object) {
        switch (task.getService()) {
            case COMMENT_PREADDDETAIL:
            case COMMENT_ADDDETAIL:
                ToastUtils.showShortToast(this.mContext, object.getMsg());
                break;
        }
    }

    @Override
    public void onServerError(NewHYTask task, int failedType) {
        switch (task.getService()) {
            case COMMENT_PREADDDETAIL:
            case COMMENT_ADDDETAIL:
                onResultShow(failedType);
                break;
        }
    }

    @Override
    public void getExtraParam() {
        this.id = getIntent().getStringExtra("id");
        this.name = getIntent().getStringExtra("name");
        this.citizenId = getIntent().getStringExtra("citizenId");
    }

    @Override
    public void initViews() {
        this.mTitleView = (TitleView) findViewById(R.id.titleview);
        this.mTvName = (TextView) findViewById(R.id.tv_name);
        this.mTvIdCard = (TextView) findViewById(R.id.tv_idcard);
        this.mEtReplyName = (EditText) findViewById(R.id.et_reply_name);
        this.mTvDate = (TextView) findViewById(R.id.tv_date);
        this.ratingBarService = (RatingBar) findViewById(R.id.ratingBar_service);
        this.ratingBarEnvironment = (RatingBar) findViewById(R.id.ratingBar_environment);
        this.ratingBarSkill = (RatingBar) findViewById(R.id.ratingBar_skill);
        this.mEtReply = (EditText) findViewById(R.id.et_reply);
        this.mBtSave = (Button) findViewById(R.id.bt_save);
    }

    @Override
    public void setListener() {
        this.mTitleView.setOnTitleClik(new TitleView.BackListenner() {
            @Override
            public void BackSet() {
                ActivityRehabilitationCommentAdd.this.finish();
            }
        }, null);
        this.mTvDate.setOnClickListener(this);
        this.mBtSave.setOnClickListener(this);
    }

    public void rehabilitationCommentSave() {
        HashMap<String, String> params = new HashMap<>();
        params.put(AssistPushConsts.MSG_TYPE_TOKEN, SharedPreferencedUtils.getInstance(this.mContext).getString(AssistPushConsts.MSG_TYPE_TOKEN));
        params.put("service", this.id);
        params.put("name", this.name);
        params.put("citizenId", this.citizenId);
        params.put("rateName", this.rateName);
        params.put("rateDate", this.rateDate + " 00:00:00");
        params.put("serviceAttitude", this.serviceAttitude);
        params.put("environmentFacility", this.environmentFacility);
        params.put("professionalSkill", this.professionalSkill);
        params.put("evaluateContent", this.evaluateContent);
        NewHYTask task = new CommonTask(RequestServiceList.COMMENT_ADDDETAIL, params);
        executeRequest(task);
    }

    public void rehabilitationCommentPre() {
        this.name = this.mTvName.getText().toString();
        this.citizenId = this.mTvIdCard.getText().toString();
        this.rateDate = this.mTvDate.getText().toString();
        this.rateName = this.mEtReplyName.getText().toString();
        this.serviceAttitude = String.valueOf((int) this.ratingBarService.getRating());
        this.environmentFacility = String.valueOf((int) this.ratingBarEnvironment.getRating());
        this.professionalSkill = String.valueOf((int) this.ratingBarSkill.getRating());
        this.evaluateContent = this.mEtReply.getText().toString();
        if (isNull(this.rateName)) {
            ToastUtils.showShortToast(this.mContext, "请输入评估人");
            return;
        }
        if (isNull(this.rateDate)) {
            ToastUtils.showShortToast(this.mContext, "请输入评价时间");
        } else if (isNull(this.evaluateContent)) {
            ToastUtils.showShortToast(this.mContext, "请输入评论内容");
        } else {
            rehabilitationCommentSave();
        }
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_date:
                this.dateTimePickDialogPlus = new DateTimePickDialogPlus(this.mContext, "yyyy-MM-dd");
                this.dateTimePickDialogPlus.dateTimePicKDialog(this.mTvDate, new DateTimePickDialogPlus.OnDateTimeListener() {
                    @Override
                    public void onDateChange(String dateTime) {
                        ActivityRehabilitationCommentAdd.this.mTvDate.setText(dateTime);
                    }
                }).show();
                break;
            case R.id.bt_save:
                rehabilitationCommentPre();
                break;
        }
    }
}