导航菜单

页面标题

页面副标题

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

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

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


package com.mu.gymtrain.Activity.MainPackage;

import android.app.Dialog;
import android.content.Intent;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import com.blankj.utilcode.util.LogUtils;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.mu.gymtrain.Activity.AllCommentActivity;
import com.mu.gymtrain.Activity.CoachDetailHtmlActivity;
import com.mu.gymtrain.Activity.PersonPackage.PersonalInfoActivity;
import com.mu.gymtrain.Activity.WebViewActivity;
import com.mu.gymtrain.Adapter.CoachCKDetailAdapter;
import com.mu.gymtrain.Adapter.MainPubClassisAdapter;
import com.mu.gymtrain.Adapter.PublicCKClazzListAdapter;
import com.mu.gymtrain.Adapter.PublicCKClazzListAdapter$OnChildClickListener;
import com.mu.gymtrain.Adapter.WeekAdapter;
import com.mu.gymtrain.Base.BaseActivity;
import com.mu.gymtrain.Bean.AllCommentBean;
import com.mu.gymtrain.Bean.CKCoachitemBean;
import com.mu.gymtrain.Bean.PublicCourseBeanBox1;
import com.mu.gymtrain.Bean.PublicCourseListBean;
import com.mu.gymtrain.Bean.WeekBean;
import com.mu.gymtrain.Dialog.DialogUtils;
import com.mu.gymtrain.Http.CreatMap;
import com.mu.gymtrain.Http.HttpHelper;
import com.mu.gymtrain.Http.ResponseFunc;
import com.mu.gymtrain.Utils.DateUtils;
import com.mu.gymtrain.Utils.DisplayUtil;
import com.mu.gymtrain.Utils.PreferenceUtils;
import com.mu.gymtrain.Utils.ViewUtils;
import com.mu.gymtrain.Widget.RatingBar;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class CKDetailActivity extends BaseActivity implements BaseQuickAdapter.OnItemClickListener, PublicCKClazzListAdapter$OnChildClickListener {
    private PublicCKClazzListAdapter adapter;
    private int age;

    @BindView(2131296364)
    ImageView avatar;

    @BindView(2131296365)
    ImageView avatar2;

    @BindView(2131296417)
    ConstraintLayout clLayout;

    @BindView(2131296418)
    ConstraintLayout clLayout2;
    private boolean hasInfo;
    private double height;

    @BindView(2131296628)
    ImageView imgDown;

    @BindView(2131296629)
    ImageView imgDownCoach;
    ImageView ivCkbg;

    @BindView(2131296770)
    LinearLayout llCoach;

    @BindView(2131296772)
    LinearLayout llContent;

    @BindView(2131296774)
    LinearLayout llImgTextDetail;
    WeekAdapter mAdapter;
    MainPubClassisAdapter mAdapterCK;
    private String mClassName;
    CoachCKDetailAdapter mCoachAdapter;
    private Dialog mNoInfoDialog;

    @BindView(2131296994)
    RatingBar rbContent;

    @BindView(2131296995)
    RatingBar rbContent2;

    @BindView(2131297009)
    RecyclerView recyClazz;

    @BindView(2131297022)
    RecyclerView recyclerView;

    @BindView(2131297253)
    ImageView titleLeft;

    @BindView(2131297255)
    TextView titleMiddle;

    @BindView(2131297290)
    TextView tvAllComment;
    TextView tvClazzinfo;
    TextView tvClazzname;
    TextView tvClazzname2;
    TextView tvCoachtime;

    @BindView(2131297316)
    TextView tvComment;

    @BindView(2131297317)
    TextView tvComment2;

    @BindView(2131297364)
    TextView tvName;

    @BindView(2131297366)
    TextView tvName2;

    @BindView(2131297430)
    TextView tvTime;

    @BindView(2131297431)
    TextView tvTime2;
    private String userName;
    String infoid = "";
    String gymid = "";
    List<WeekBean> mList = new ArrayList();
    List<CKCoachitemBean> mCoachList = new ArrayList();
    private String currentDay = "";
    List<PublicCourseBeanBox1> mListCK_box = new ArrayList();
    List<PublicCourseListBean.DataBean> mListCK = new ArrayList();

    @Override
    public int getContentLayout() {
        return 2131492909;
    }

    @Override
    public void initData() {
        ViewUtils.showLoading(this, "加载中...");
        HttpHelper.getInstance().getRetrofitService(this).getCKDetailPage(new CreatMap.Builder().addParams("info_id", this.infoid).build().getParam()).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).map(new ResponseFunc()).subscribe(new 1(this));
        HttpHelper.getInstance().getRetrofitService(this).getCKDetailCoach(new CreatMap.Builder().addParams("info_id", this.infoid).addParams("gym_id", this.gymid).build().getParam()).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).map(new ResponseFunc()).subscribe(new 2(this));
        requestCount();
        requestComment();
        getClazz();
    }

    private void getUserInfo(final String id) {
        ViewUtils.showLoading(this, "加载中...");
        HttpHelper.getInstance().getRetrofitService(this).getUserInfo(new CreatMap.Builder().build().getParam()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).map(new ResponseFunc()).subscribe(new 3(this, id));
    }

    @Override
    public void initView() {
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
        this.ivCkbg = (ImageView) findViewById(2131296686);
        this.tvClazzname = (TextView) findViewById(2131297499);
        this.tvCoachtime = (TextView) findViewById(2131297506);
        this.tvClazzname2 = (TextView) findViewById(2131297500);
        this.tvClazzinfo = (TextView) findViewById(2131297498);
        this.llContent.setOnClickListener(this);
        this.llCoach.setOnClickListener(this);
        this.llImgTextDetail.setOnClickListener(this);
        this.infoid = getIntent().getStringExtra("intent_common");
        this.gymid = getIntent().getStringExtra("intent_common2");
        this.titleLeft.setOnClickListener(new 4(this));
        this.tvAllComment.setOnClickListener(this);
        this.recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
        RecyclerView.Adapter coachCKDetailAdapter = new CoachCKDetailAdapter(DisplayUtil.getScreenSize(this));
        this.mCoachAdapter = coachCKDetailAdapter;
        this.recyclerView.setAdapter(coachCKDetailAdapter);
        this.mCoachAdapter.setOnItemClickListener(this);
        this.recyClazz.setLayoutManager(new LinearLayoutManager(this));
        this.recyClazz.setFocusableInTouchMode(false);
        RecyclerView.Adapter publicCKClazzListAdapter = new PublicCKClazzListAdapter(this);
        this.adapter = publicCKClazzListAdapter;
        this.recyClazz.setAdapter(publicCKClazzListAdapter);
    }

    private void requestCount() {
        HttpHelper.getInstance().getRetrofitService(this).requestClassCommentCount(getToken(), this.infoid, 1).enqueue(new 5(this));
    }

    private void requestComment() {
        HttpHelper.getInstance().getRetrofitService(this).classAllCommentList(getToken(), this.infoid, 1, 1, 2).enqueue(new 6(this));
    }

    public void setComments(List<AllCommentBean.DataBean> list) {
        this.clLayout.setVisibility(0);
        Glide.with((FragmentActivity) this).load("https://www.zijianshen.com/" + list.get(0).getUser_avatar()).apply(new RequestOptions().circleCrop()).into(this.avatar);
        this.tvName.setText(list.get(0).getUser_name());
        String str = "#" + list.get(0).getCoach_name() + "教练#  ";
        SpannableString spannableString = new SpannableString(str + list.get(0).getComment());
        spannableString.setSpan(new ForegroundColorSpan(getResources().getColor(2131099865)), 0, str.length(), 33);
        this.tvComment.setText(spannableString);
        this.rbContent.setStar((float) list.get(0).getScore());
        this.rbContent.setmClickable(false);
        double currentTimeMillis = System.currentTimeMillis() - DateUtils.date2Stamp(list.get(0).getComment_time(), "yyyy-MM-dd hh:mm:ss");
        Double.isNaN(currentTimeMillis);
        double d = (currentTimeMillis / 1000.0d) / 3600.0d;
        if (d <= 1.0d) {
            this.tvTime.setText("刚刚");
        } else if (d > 1.0d && d <= 24.0d) {
            this.tvTime.setText(Math.round(d) + "小时前");
        } else {
            this.tvTime.setText(list.get(0).getComment_time().substring(0, 10));
        }
        if (list.size() >= 2) {
            this.clLayout2.setVisibility(0);
            Glide.with((FragmentActivity) this).load("https://www.zijianshen.com/" + list.get(1).getUser_avatar()).apply(new RequestOptions().circleCrop()).into(this.avatar2);
            this.tvName2.setText(list.get(1).getUser_name());
            String str2 = "#" + list.get(1).getCoach_name() + "教练#  ";
            SpannableString spannableString2 = new SpannableString(str2 + list.get(1).getComment());
            spannableString2.setSpan(new ForegroundColorSpan(getResources().getColor(2131099865)), 0, str2.length(), 33);
            this.tvComment2.setText(spannableString2);
            this.rbContent2.setStar((float) list.get(1).getScore());
            this.rbContent2.setmClickable(false);
            double currentTimeMillis2 = System.currentTimeMillis() - DateUtils.date2Stamp(list.get(1).getComment_time(), "yyyy-MM-dd hh:mm:ss");
            Double.isNaN(currentTimeMillis2);
            double d2 = (currentTimeMillis2 / 1000.0d) / 3600.0d;
            LogUtils.i(list.get(1).getComment_time());
            if (d2 <= 1.0d) {
                this.tvTime2.setText("刚刚");
                return;
            }
            if (d2 > 1.0d && d2 <= 24.0d) {
                this.tvTime2.setText(Math.round(d2) + "小时前");
                return;
            }
            this.tvTime2.setText(list.get(1).getComment_time().substring(0, 10));
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(String event) {
        if (event.equals("5")) {
            getClazz();
        }
    }

    public void creatWeek() {
        ArrayList fetureDays = DateUtils.getFetureDays(7);
        ArrayList fetureDaysofWeek = DateUtils.getFetureDaysofWeek(7);
        int i = 0;
        while (i < fetureDays.size()) {
            this.mList.add(new WeekBean((String) fetureDaysofWeek.get(i), (String) fetureDays.get(i), i == 0));
            i++;
        }
    }

    private void getClazz() {
        HttpHelper.getInstance().getRetrofitService(this).getCKDetailClazz1(PreferenceUtils.getInstance().getString("login_token", ""), this.gymid, this.infoid).enqueue(new 7(this));
    }

    public void changData(List<PublicCourseListBean.DataBean> data) {
        this.mListCK.addAll(data);
        boxCK();
    }

    private void boxCK() {
        this.mListCK_box.clear();
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        for (PublicCourseListBean.DataBean dataBean : this.mListCK) {
            if (linkedHashMap.containsKey(dataBean.getClass_date())) {
                ((List) linkedHashMap.get(dataBean.getClass_date())).add(dataBean);
            } else {
                ArrayList arrayList = new ArrayList();
                arrayList.add(dataBean);
                linkedHashMap.put(dataBean.getClass_date(), arrayList);
            }
        }
        for (Map.Entry entry : linkedHashMap.entrySet()) {
            PublicCourseBeanBox1 publicCourseBeanBox1 = new PublicCourseBeanBox1();
            publicCourseBeanBox1.setTime((String) entry.getKey());
            publicCourseBeanBox1.setPublicCourseBean((List) entry.getValue());
            this.mListCK_box.add(publicCourseBeanBox1);
        }
        this.adapter.setNewData(this.mListCK_box);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case 2131296770:
                if (this.recyclerView.getVisibility() == 8) {
                    this.imgDownCoach.setRotation(180.0f);
                    this.recyclerView.setVisibility(0);
                    break;
                } else {
                    this.imgDownCoach.setRotation(0.0f);
                    this.recyclerView.setVisibility(8);
                    break;
                }
            case 2131296772:
                if (this.tvClazzinfo.getVisibility() == 8) {
                    this.imgDown.setRotation(180.0f);
                    this.tvClazzinfo.setVisibility(0);
                    break;
                } else {
                    this.imgDown.setRotation(0.0f);
                    this.tvClazzinfo.setVisibility(8);
                    break;
                }
            case 2131296774:
                Intent intent = new Intent(this, (Class<?>) WebViewActivity.class);
                intent.putExtra("url", "https://www.zijianshen.com/index.php/app/classes/get_class_info_detail/" + this.infoid);
                intent.putExtra("title", this.mClassName);
                startActivity(intent);
                break;
            case 2131297290:
                Intent intent2 = new Intent(this, (Class<?>) AllCommentActivity.class);
                intent2.putExtra("id", this.infoid);
                intent2.putExtra("from", "class");
                startActivity(intent2);
                break;
            case 2131297339:
                this.mNoInfoDialog.dismiss();
                startActivity(new Intent(this, (Class<?>) PersonalInfoActivity.class));
                break;
        }
    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        CKCoachitemBean cKCoachitemBean = (CKCoachitemBean) adapter.getData().get(position);
        Intent intent = new Intent(this, (Class<?>) CoachDetailHtmlActivity.class);
        intent.putExtra("id", cKCoachitemBean.getCoach_id());
        startActivity(intent);
    }

    public void noInfoDialog() {
        View inflate = View.inflate(this, 2131493026, null);
        ((TextView) inflate.findViewById(2131297190)).setText("请正确填写您的个人资料  有助于教练为您制定更合理的训练计划。");
        this.mNoInfoDialog = DialogUtils.createDialog(this, inflate);
        inflate.findViewById(2131297339).setOnClickListener(this);
        this.mNoInfoDialog.setCanceledOnTouchOutside(true);
        this.mNoInfoDialog.show();
    }

    @Override
    public void onClick(String id) {
        getUserInfo(id);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}