导航菜单

页面标题

页面副标题

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

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

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


package com.mu.gymtrain.Activity;

import android.view.View;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import com.mu.gymtrain.Adapter.CommentPagerAdapter;
import com.mu.gymtrain.Base.BaseActivity;
import com.mu.gymtrain.Bean.CommentCountBean;
import com.mu.gymtrain.Fragment.CommentListFragment;
import com.mu.gymtrain.Http.HttpHelper;
import com.mu.gymtrain.R;
import com.mu.gymtrain.Utils.FinalTools;
import com.mu.gymtrain.Utils.JsonUtil;
import com.mu.gymtrain.Utils.PreferenceUtils;
import java.io.IOException;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class AllCommentActivity extends BaseActivity implements RadioGroup.OnCheckedChangeListener, ViewPager.OnPageChangeListener {
    private String from;
    private String id;

    @BindView(R.id.radioGroup)
    RadioGroup radioGroup;

    @BindView(R.id.rbAgree)
    RadioButton rbAgree;

    @BindView(R.id.rbAll)
    RadioButton rbAll;

    @BindView(R.id.rbBad)
    RadioButton rbBad;

    @BindView(R.id.rbGood)
    RadioButton rbGood;

    @BindView(R.id.rbHasPhoto)
    RadioButton rbHasPhoto;

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

    @BindView(R.id.title_middle)
    TextView titleMiddle;
    private String url;

    @BindView(R.id.viewPager)
    ViewPager viewPager;

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

    public void onPageScrollStateChanged(int state) {
    }

    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    }

    public void initView() {
        this.radioGroup.setOnCheckedChangeListener(this);
        this.titleMiddle.setText("全部评论");
        this.id = getIntent().getStringExtra("id");
        this.from = getIntent().getStringExtra("from");
        this.titleLeft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AllCommentActivity.this.finish();
            }
        });
        this.viewPager.setAdapter(new CommentPagerAdapter(getSupportFragmentManager(), new Fragment[]{CommentListFragment.instance(0, this.id, this.from), CommentListFragment.instance(5, this.id, this.from), CommentListFragment.instance(2, this.id, this.from), CommentListFragment.instance(3, this.id, this.from)}));
        this.viewPager.addOnPageChangeListener(this);
        this.viewPager.setOffscreenPageLimit(3);
        this.rbAll.setChecked(true);
    }

    public void initData() {
        Call<ResponseBody> commentClassCount;
        String string = PreferenceUtils.getInstance().getString(FinalTools.TOKEN, "");
        if (this.from.equals("coach")) {
            this.url = "https://www.zijianshen.com/index.php/app/classes/get_comment_counts_of_coach";
            commentClassCount = HttpHelper.getInstance().getRetrofitService(this).commentCoachCount(this.url, string, this.id);
        } else {
            this.url = "https://www.zijianshen.com/index.php/app/classes/get_comment_counts_of_class";
            commentClassCount = HttpHelper.getInstance().getRetrofitService(this).commentClassCount(this.url, string, this.id);
        }
        commentClassCount.enqueue(new Callback<ResponseBody>() {
            @Override
            public void onFailure(Call<ResponseBody> call, Throwable t) {
            }

            @Override
            public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                try {
                    CommentCountBean commentCountBean = (CommentCountBean) JsonUtil.json2Bean(((ResponseBody) response.body()).string(), CommentCountBean.class);
                    if (commentCountBean == null || commentCountBean.getCode() != 10000) {
                        return;
                    }
                    int all = commentCountBean.getData().getAll();
                    int praised = commentCountBean.getData().getPraised();
                    int good = commentCountBean.getData().getGood();
                    int bad = commentCountBean.getData().getBad();
                    if (all >= 10000) {
                        AllCommentActivity.this.rbAll.setText("全部 999+");
                    } else {
                        AllCommentActivity.this.rbAll.setText("全部 " + commentCountBean.getData().getAll());
                    }
                    if (praised >= 10000) {
                        AllCommentActivity.this.rbAgree.setText("点赞 999+");
                    } else {
                        AllCommentActivity.this.rbAgree.setText("点赞" + commentCountBean.getData().getPraised());
                    }
                    if (good >= 10000) {
                        AllCommentActivity.this.rbGood.setText("好评 999+");
                    } else {
                        AllCommentActivity.this.rbGood.setText("好评 " + commentCountBean.getData().getGood());
                    }
                    if (bad >= 10000) {
                        AllCommentActivity.this.rbBad.setText("差评 999");
                        return;
                    }
                    AllCommentActivity.this.rbBad.setText("差评 " + commentCountBean.getData().getBad());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        if (checkedId != 2131296997) {
            switch (checkedId) {
                case R.id.rbAgree:
                    this.viewPager.setCurrentItem(1);
                    break;
                case R.id.rbAll:
                    this.viewPager.setCurrentItem(0);
                    break;
                case R.id.rbBad:
                    this.viewPager.setCurrentItem(3);
                    break;
            }
        }
        this.viewPager.setCurrentItem(2);
    }

    public void onPageSelected(int position) {
        if (position == 0) {
            this.rbAll.setChecked(true);
            return;
        }
        if (position == 1) {
            this.rbAgree.setChecked(true);
        } else if (position == 2) {
            this.rbGood.setChecked(true);
        } else {
            if (position != 3) {
                return;
            }
            this.rbBad.setChecked(true);
        }
    }
}