导航菜单

页面标题

页面副标题

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

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

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


package com.mu.gymtrain.Activity;

import android.app.Dialog;
import android.content.Intent;
import android.graphics.Point;
import android.text.SpannableString;
import android.text.TextUtils;
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.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.makeramen.roundedimageview.RoundedImageView;
import com.mu.gymtrain.Activity.PersonPackage.PersonalInfoActivity;
import com.mu.gymtrain.Adapter.PersonalClazzItemAdapter;
import com.mu.gymtrain.Adapter.PersonalClazzListAdapter;
import com.mu.gymtrain.Base.BaseActivity;
import com.mu.gymtrain.Bean.AllCommentBean;
import com.mu.gymtrain.Bean.CoachDetailBeanA;
import com.mu.gymtrain.Bean.PublicCourseListBean;
import com.mu.gymtrain.Bean.PublicCourseListBeanA;
import com.mu.gymtrain.Dialog.DialogUtils;
import com.mu.gymtrain.Http.HttpHelper;
import com.mu.gymtrain.Utils.DateUtils;
import com.mu.gymtrain.Utils.DisplayUtil;
import com.mu.gymtrain.Utils.GlideUtils;
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.Iterator;
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;

public class PersonalTrainerDetailActivity extends BaseActivity {
    private PersonalClazzListAdapter adapter;

    @BindView(2131296364)
    ImageView avatar;

    @BindView(2131296365)
    ImageView avatar2;
    private RoundedImageView civ_head;

    @BindView(2131296417)
    ConstraintLayout clLayout;

    @BindView(2131296418)
    ConstraintLayout clLayout2;
    private String coachId;
    private String gymId;
    private String html;
    private ImageView imgBg;
    private ImageView imgPhoto;
    private LinearLayoutManager linearLayoutManager;
    private List<PublicCourseListBeanA> list = new ArrayList();
    private Dialog mNoInfoDialog;

    @BindView(2131296994)
    RatingBar rbContent;

    @BindView(2131296995)
    RatingBar rbContent2;
    private RecyclerView recyclerView;
    private RatingBar rtv_coach;
    private LinearLayout scrollRecylerView;
    private String time;
    private String token;
    private TextView tvAge;

    @BindView(2131297290)
    TextView tvAllComment;

    @BindView(2131297316)
    TextView tvComment;

    @BindView(2131297317)
    TextView tvComment2;
    private TextView tvLowPrice;
    private TextView tvName;

    @BindView(2131297365)
    TextView tvName1;

    @BindView(2131297366)
    TextView tvName2;
    private TextView tvPeakPrice;

    @BindView(2131297430)
    TextView tvTime;

    @BindView(2131297431)
    TextView tvTime2;
    private TextView tvValue;

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

    @Override
    public void initView() {
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
        this.adapter = new PersonalClazzListAdapter(new PersonalClazzItemAdapter.OnChildClickListener() {
            public final void onClick(String str) {
                PersonalTrainerDetailActivity.this.lambda$initView$0$PersonalTrainerDetailActivity(str);
            }
        });
        this.time = getIntent().getStringExtra("time");
        ((TextView) findViewById(2131297255)).setText("教练简介");
        this.recyclerView = (RecyclerView) findViewById(2131297022);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        this.linearLayoutManager = linearLayoutManager;
        this.recyclerView.setLayoutManager(linearLayoutManager);
        this.recyclerView.setAdapter(this.adapter);
        this.adapter.bindToRecyclerView(this.recyclerView);
        this.imgPhoto = (ImageView) findViewById(2131296644);
        this.civ_head = findViewById(2131296416);
        this.tvName = (TextView) findViewById(2131297364);
        this.tvAge = (TextView) findViewById(2131297287);
        this.tvValue = (TextView) findViewById(2131297447);
        this.rtv_coach = findViewById(2131297075);
        this.tvPeakPrice = (TextView) findViewById(2131297383);
        this.tvLowPrice = (TextView) findViewById(2131297350);
        this.imgBg = (ImageView) findViewById(2131296610);
        this.tvLowPrice = (TextView) findViewById(2131297350);
        this.scrollRecylerView = (LinearLayout) findViewById(2131297090);
        findViewById(2131297229).setOnClickListener(this);
        findViewById(2131297253).setOnClickListener(this);
        this.tvAllComment.setOnClickListener(this);
        this.rbContent.setmClickable(false);
        this.rbContent2.setmClickable(false);
        this.rtv_coach.setmClickable(false);
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        Point screenSize = DisplayUtil.getScreenSize(this);
        int measuredHeight = this.tvPeakPrice.getMeasuredHeight() + this.imgBg.getMeasuredHeight() + ((screenSize.x * 2) / 4);
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.scrollRecylerView.getLayoutParams();
        layoutParams.height = screenSize.y + measuredHeight;
        this.scrollRecylerView.setLayoutParams(layoutParams);
    }

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

    @Override
    public void initData() {
        this.coachId = getIntent().getStringExtra("id");
        this.token = PreferenceUtils.getInstance().getString("login_token", "");
        this.gymId = PreferenceUtils.getInstance().getString("currentgymid", "");
        ViewUtils.showLoading(this, "加载中...");
        requestDetail();
        requestList();
        requestCount();
        requestComment();
    }

    public void lambda$initView$0$PersonalTrainerDetailActivity(final String id) {
        ViewUtils.showLoading(this, "加载中...");
        HttpHelper.getInstance().getRetrofitService(this).getUserInfo2(getToken()).enqueue(new 1(this, id));
    }

    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();
    }

    private void requestCount() {
        HttpHelper.getInstance().getRetrofitService(this).requestCoachCommentCount(getToken(), this.coachId, 1).enqueue(new 2(this));
    }

    private void requestComment() {
        HttpHelper.getInstance().getRetrofitService(this).coachAllCommentList(getToken(), this.coachId, 1, 1, 2).enqueue(new 3(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.tvName1.setText(list.get(0).getUser_name());
        String str = "#" + list.get(0).getInfo_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);
        String comment_time = list.get(0).getComment_time();
        double currentTimeMillis = System.currentTimeMillis() - DateUtils.date2Stamp(comment_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(comment_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).getInfo_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) / 36000.0d;
            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));
        }
    }

    private void requestDetail() {
        HttpHelper.getInstance().getRetrofitService(this).requestCaachDetail(this.token, this.coachId).enqueue(new 4(this));
    }

    public void setData(CoachDetailBeanA.DataBean bean) {
        GlideUtils.withReplace("https://www.zijianshen.com/" + bean.getAvatar(), this.civ_head, this);
        Point screenSize = DisplayUtil.getScreenSize(this);
        Glide.with((FragmentActivity) this).load("https://www.zijianshen.com/" + bean.getBg_photo()).apply(new RequestOptions().override(screenSize.x, (screenSize.x * 2) / 3).placeholder(2131623942).error(2131623941)).into(this.imgPhoto);
        this.tvName.setText(bean.getName());
        this.tvAge.setText(bean.getAge() + "");
        this.tvValue.setText(bean.getRank());
        this.rtv_coach.setStar(Float.parseFloat(bean.getScore()));
        this.tvPeakPrice.setText(bean.getPrice_peak_high() + "元/小时");
        this.tvLowPrice.setText(bean.getPrice_peak_low() + "元/小时");
        this.html = bean.getDescript_file();
    }

    private void requestList() {
        HttpHelper.getInstance().getRetrofitService(this).requestPersonalList(this.token, this.gymId, this.coachId).enqueue(new 5(this));
    }

    public void box(List<PublicCourseListBean.DataBean> data) {
        int i;
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        Iterator<PublicCourseListBean.DataBean> it = data.iterator();
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            PublicCourseListBean.DataBean next = it.next();
            if (linkedHashMap.containsKey(next.getClass_date())) {
                List list = (List) linkedHashMap.get(next.getClass_date());
                list.add(0, next);
                linkedHashMap.put(next.getClass_date(), list);
            } else {
                ArrayList arrayList = new ArrayList();
                arrayList.add(next);
                linkedHashMap.put(next.getClass_date(), arrayList);
            }
        }
        for (Map.Entry entry : linkedHashMap.entrySet()) {
            PublicCourseListBeanA publicCourseListBeanA = new PublicCourseListBeanA();
            publicCourseListBeanA.setTime((String) entry.getKey());
            publicCourseListBeanA.setList((List) entry.getValue());
            this.list.add(0, publicCourseListBeanA);
        }
        this.adapter.setNewData(this.list);
        if (TextUtils.isEmpty(this.time)) {
            return;
        }
        int findFirstVisibleItemPosition = this.linearLayoutManager.findFirstVisibleItemPosition();
        int findLastVisibleItemPosition = this.linearLayoutManager.findLastVisibleItemPosition();
        if (1 <= findFirstVisibleItemPosition) {
            this.recyclerView.scrollToPosition(1);
        } else if (1 <= findLastVisibleItemPosition) {
            this.recyclerView.scrollBy(0, this.recyclerView.getChildAt(1 - findFirstVisibleItemPosition).getTop());
        } else {
            this.recyclerView.scrollToPosition(1);
        }
        for (i = 0; i < this.list.size(); i++) {
            if (this.list.get(i).getTime().equals(this.time)) {
                moveToPosition(i);
                return;
            }
        }
    }

    public void moveToPosition(int position) {
        int findFirstVisibleItemPosition = this.linearLayoutManager.findFirstVisibleItemPosition();
        int findLastVisibleItemPosition = this.linearLayoutManager.findLastVisibleItemPosition();
        if (position <= findFirstVisibleItemPosition) {
            this.recyclerView.scrollToPosition(position);
        } else if (position <= findLastVisibleItemPosition) {
            this.recyclerView.scrollBy(0, this.recyclerView.getChildAt(position - findFirstVisibleItemPosition).getTop());
        } else {
            this.recyclerView.scrollToPosition(position);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case 2131297229:
                Intent intent = new Intent(this, (Class<?>) CoachDetailHtmlActivity.class);
                intent.putExtra("html", this.html);
                startActivity(intent);
                break;
            case 2131297253:
                finish();
                break;
            case 2131297290:
                Intent intent2 = new Intent(this, (Class<?>) AllCommentActivity.class);
                intent2.putExtra("id", this.coachId);
                intent2.putExtra("from", "coach");
                startActivity(intent2);
                break;
            case 2131297339:
                this.mNoInfoDialog.dismiss();
                startActivity(new Intent(this, (Class<?>) PersonalInfoActivity.class));
                break;
        }
    }

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