导航菜单

页面标题

页面副标题

自健身 v3.3.4 - LookCommentActivity.java 源代码

正在查看: 自健身 v3.3.4 应用的 LookCommentActivity.java JAVA 源代码文件

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


package com.mu.gymtrain.Activity;

import android.app.Dialog;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.constraintlayout.widget.Group;
import butterknife.BindView;
import butterknife.OnClick;
import com.blankj.utilcode.util.LogUtils;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.mu.gymtrain.Base.BaseActivity;
import com.mu.gymtrain.Bean.JudgePageBean;
import com.mu.gymtrain.Bean.LookCommentBean;
import com.mu.gymtrain.Bean.SucessBean;
import com.mu.gymtrain.Http.CreatMap;
import com.mu.gymtrain.Http.HttpHelper;
import com.mu.gymtrain.Http.ResponseFunc;
import com.mu.gymtrain.R;
import com.mu.gymtrain.Utils.GlideUtils;
import com.mu.gymtrain.Utils.JsonUtil;
import com.mu.gymtrain.Utils.PreferenceUtils;
import com.mu.gymtrain.Utils.ToastUtils;
import com.mu.gymtrain.Utils.UrlConfig;
import com.mu.gymtrain.Utils.ViewUtils;
import com.mu.gymtrain.Utils.WindowUtils;
import com.mu.gymtrain.Widget.RatingBar;
import com.mu.gymtrain.view.CollapsibleTextView;
import java.io.IOException;
import okhttp3.ResponseBody;
import org.greenrobot.eventbus.EventBus;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class LookCommentActivity extends BaseActivity {
    private String classId;
    private String className;
    private String coachName;
    private Dialog dialog;
    private String from;

    @BindView(R.id.group)
    Group group;

    @BindView(R.id.imgAvatar)
    ImageView imgAvatar;

    @BindView(R.id.imgIcon)
    ImageView mImgIcon;

    @BindView(R.id.imgIconCoach)
    ImageView mImgIconCoach;
    private int mRbClasCount;

    @BindView(R.id.rbClass)
    RatingBar mRbClass;
    private int mRbCoachCount;

    @BindView(R.id.rtv_coach)
    RatingBar mRtvCoach;

    @BindView(R.id.title1)
    TextView mTitle1;

    @BindView(R.id.title_left)
    ImageView mTitleLeft;

    @BindView(R.id.title_middle)
    TextView mTitleMiddle;

    @BindView(R.id.title_righttext)
    TextView mTitleRighttext;

    @BindView(R.id.tvClassName)
    TextView mTvClassName;

    @BindView(R.id.tvClassComment)
    CollapsibleTextView tvClassComment;

    @BindView(R.id.tvClassLevel)
    TextView tvClassLevel;

    @BindView(R.id.tvCoachComment)
    CollapsibleTextView tvCoachComment;

    @BindView(R.id.tvCoachLevel)
    TextView tvCoachLevel;

    @BindView(R.id.tvCoachName)
    TextView tvCoachName;

    @BindView(R.id.tvDelete)
    TextView tvDelete;

    @BindView(R.id.tvName)
    TextView tvName;

    @BindView(R.id.tvTime)
    TextView tvTime;

    public int getContentLayout() {
        return R.layout.activity_look_comment_layout;
    }

    public void initView() {
        this.mTitleMiddle.setText("评价");
        this.classId = getIntent().getStringExtra("classId");
        this.className = getIntent().getStringExtra("className");
        this.coachName = getIntent().getStringExtra("coachName");
        this.mTvClassName.setText(this.className);
        this.tvCoachName.setText(this.coachName);
        String stringExtra = getIntent().getStringExtra("from");
        this.from = stringExtra;
        if (!TextUtils.isEmpty(stringExtra)) {
            this.group.setVisibility(0);
        }
        this.mRtvCoach.setmClickable(false);
        this.mRbClass.setmClickable(false);
        String string = PreferenceUtils.getInstance().getString(UrlConfig.Params.AVATAR, "");
        String string2 = PreferenceUtils.getInstance().getString("userName", "");
        GlideUtils.withReplace(string, this.imgAvatar, this.mActivity);
        Glide.with(this).load(string).apply(new RequestOptions().circleCrop()).into(this.imgAvatar);
        this.tvName.setText(string2);
    }

    public void initData() {
        ViewUtils.showLoading(this, "加载中...");
        HttpHelper.getInstance().getRetrofitService(this).lookComment(getToken(), this.classId).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).subscribe(new Subscriber<LookCommentBean>() {
            public void onCompleted() {
            }

            public void onError(Throwable e) {
                ViewUtils.hideLoading();
            }

            public void onNext(LookCommentBean bean) {
                ViewUtils.hideLoading();
                if (bean.getCode() == 10000) {
                    LookCommentActivity.this.setData(bean);
                } else {
                    ToastUtils.show(LookCommentActivity.this, bean.getMessage());
                }
            }
        });
        HttpHelper.getInstance().getRetrofitService(this).getJudgePage(new CreatMap.Builder().addParams("class_id", this.classId).build().getParam()).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).map(new ResponseFunc()).subscribe(new Subscriber<JudgePageBean>() {
            public void onCompleted() {
            }

            public void onError(Throwable throwable) {
                ViewUtils.hideLoading();
            }

            public void onNext(JudgePageBean adBeen) {
                ViewUtils.hideLoading();
                GlideUtils.withReplace(UrlConfig.Path.IMG_URL + adBeen.getCoach_avatar(), LookCommentActivity.this.mImgIconCoach, LookCommentActivity.this.mActivity);
                LookCommentActivity.this.tvCoachName.setText(adBeen.getCoach_name());
                GlideUtils.withReplace(UrlConfig.Path.IMG_URL + adBeen.getClass_photo(), LookCommentActivity.this.mImgIcon, LookCommentActivity.this.mActivity);
                LookCommentActivity.this.mTvClassName.setText(adBeen.getClass_name());
            }
        });
    }

    public void setData(LookCommentBean bean) {
        this.tvTime.setText(bean.getData().getCoach_comment().getScore_time());
        if (!TextUtils.isEmpty(this.from)) {
            int score = bean.getData().getClass_comment().getScore();
            if (score > 0 && score <= 2) {
                this.tvClassLevel.setText("差");
            } else if (score == 3) {
                this.tvClassLevel.setText("中");
            } else if (score > 3) {
                this.tvClassLevel.setText("好");
            }
            this.mRbClass.setStar(score);
            String comment = bean.getData().getClass_comment().getComment();
            if (!TextUtils.isEmpty(comment)) {
                this.tvClassComment.setFullString("#" + this.className + "#  " + comment, this.className.length() + 2);
            }
        }
        int score2 = bean.getData().getCoach_comment().getScore();
        if (score2 > 0 && score2 <= 2) {
            this.tvCoachLevel.setText("差");
        } else if (score2 == 3) {
            this.tvCoachLevel.setText("中");
        } else if (score2 > 3) {
            this.tvCoachLevel.setText("好");
        }
        this.mRtvCoach.setStar(score2);
        if (!TextUtils.isEmpty(bean.getData().getCoach_comment().getComment())) {
            this.tvCoachComment.setFullString("#" + this.coachName + "#  " + bean.getData().getCoach_comment().getComment(), this.coachName.length() + 2);
        }
        if (TextUtils.isEmpty(bean.getData().getClass_comment().getComment()) && TextUtils.isEmpty(bean.getData().getCoach_comment().getComment())) {
            return;
        }
        this.tvDelete.setVisibility(0);
    }

    @OnClick({R.id.title_left, R.id.tvDelete})
    public void onViewClicked(View view) {
        int id = view.getId();
        if (id == 2131297253) {
            finish();
        } else {
            if (id != 2131297327) {
                return;
            }
            deleteDialog();
        }
    }

    public void onClick(View v) {
        super.onClick(v);
        int id = v.getId();
        if (id == 2131296688) {
            this.dialog.dismiss();
        } else {
            if (id != 2131297190) {
                return;
            }
            this.dialog.dismiss();
            delete();
        }
    }

    private void deleteDialog() {
        View inflate = LayoutInflater.from(this).inflate(R.layout.normal_dialog_view, (ViewGroup) null, false);
        ((TextView) inflate.findViewById(R.id.textTitle)).setText("是否删除此条评论");
        TextView textView = (TextView) inflate.findViewById(2131297190);
        textView.setText("确认删除");
        ((ImageView) inflate.findViewById(R.id.iv_close)).setOnClickListener(this);
        textView.setOnClickListener(this);
        Dialog dialog = new Dialog(this, R.style.progress_dialog);
        this.dialog = dialog;
        dialog.setContentView(inflate);
        Window window = this.dialog.getWindow();
        WindowManager.LayoutParams attributes = window.getAttributes();
        double wIndowWidth = WindowUtils.getWIndowWidth(this);
        Double.isNaN(wIndowWidth);
        attributes.width = (int) (wIndowWidth * 0.6d);
        attributes.height = -2;
        window.setGravity(17);
        this.dialog.setCancelable(true);
        this.dialog.show();
    }

    private void delete() {
        ViewUtils.showLoading(this, "加载中...");
        HttpHelper.getInstance().getRetrofitService(this).deleteComment(getToken(), this.classId).enqueue(new Callback<ResponseBody>() {
            @Override
            public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                ViewUtils.hideLoading();
                if (response.body() != null) {
                    try {
                        String string = ((ResponseBody) response.body()).string();
                        LogUtils.i(new Object[]{string});
                        if (((SucessBean) JsonUtil.json2Bean(string, SucessBean.class)).code == 10000) {
                            EventBus.getDefault().post("7");
                            ToastUtils.show(LookCommentActivity.this, "删除成功");
                            LookCommentActivity.this.finish();
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }

            @Override
            public void onFailure(Call<ResponseBody> call, Throwable t) {
                ViewUtils.hideLoading();
                ToastUtils.show(LookCommentActivity.this, t.getMessage());
            }
        });
    }
}