正在查看: 自健身 v3.3.4 应用的 MainPublicAppointmentClassActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 自健身 v3.3.4 应用的 MainPublicAppointmentClassActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mu.gymtrain.Activity;
import android.content.Context;
import android.content.Intent;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import butterknife.BindView;
import com.blankj.utilcode.util.LogUtils;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.mu.gymtrain.Activity.MainPackage.PayOrderActivity;
import com.mu.gymtrain.Base.BaseActivity;
import com.mu.gymtrain.Bean.AllCommentBean;
import com.mu.gymtrain.Bean.PriveClassisSubBean;
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.DateUtils;
import com.mu.gymtrain.Utils.FinalTools;
import com.mu.gymtrain.Utils.JsonUtil;
import com.mu.gymtrain.Utils.PreferenceUtils;
import com.mu.gymtrain.Utils.UrlConfig;
import com.mu.gymtrain.Utils.ViewUtils;
import com.mu.gymtrain.Widget.RatingBar;
import com.mu.gymtrain.Widget.RightEditView;
import java.io.IOException;
import java.util.List;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
public class MainPublicAppointmentClassActivity extends BaseActivity {
@BindView(R.id.avatar)
ImageView avatar;
@BindView(R.id.avatar2)
ImageView avatar2;
@BindView(R.id.bt_suretime)
Button bt_suretime;
@BindView(R.id.clLayout)
ConstraintLayout clLayout;
@BindView(R.id.clLayout2)
ConstraintLayout clLayout2;
private String classId;
private String classInfoId;
@BindView(R.id.rbContent)
RatingBar rbContent;
@BindView(R.id.rbContent2)
RatingBar rbContent2;
@BindView(R.id.reShopName)
RightEditView reShopName;
@BindView(R.id.rev_line1)
RightEditView revLine1;
@BindView(R.id.rev_line2)
RightEditView revLine2;
@BindView(R.id.rev_line3)
RightEditView revLine3;
@BindView(R.id.rev_line4)
RightEditView revLine4;
@BindView(R.id.rev_line5)
RightEditView revLine5;
@BindView(R.id.rev_line6)
RightEditView revLine6;
@BindView(R.id.title_left)
ImageView titleLeft;
@BindView(R.id.title_middle)
TextView titleMiddle;
@BindView(R.id.tvAllComment)
TextView tvAllComment;
@BindView(R.id.tvComment)
TextView tvComment;
@BindView(R.id.tvComment2)
TextView tvComment2;
@BindView(R.id.tvName)
TextView tvName;
@BindView(R.id.tvName2)
TextView tvName2;
@BindView(R.id.tvTime)
TextView tvTime;
@BindView(R.id.tvTime2)
TextView tvTime2;
public int getContentLayout() {
return R.layout.activity_appointment_main_public_class_layout;
}
public void initView() {
String stringExtra = getIntent().getStringExtra(UrlConfig.Params.NAME);
this.classInfoId = getIntent().getStringExtra("classInfoId");
this.titleMiddle.setText(stringExtra);
this.titleLeft.setOnClickListener(this);
this.bt_suretime.setOnClickListener(this);
this.tvAllComment.setOnClickListener(this);
this.reShopName.setRightText(PreferenceUtils.getInstance().getString("currentgym", ""));
}
public void onClick(View v) {
super.onClick(v);
int id = v.getId();
if (id == 2131296389) {
startActivity(new Intent((Context) this, (Class<?>) PayOrderActivity.class).putExtra(FinalTools.INTENT_COMMON, this.classId));
finish();
} else if (id == 2131297253) {
finish();
} else {
if (id != 2131297290) {
return;
}
Intent intent = new Intent((Context) this, (Class<?>) AllCommentActivity.class);
intent.putExtra("id", this.classInfoId);
intent.putExtra("from", "class");
startActivity(intent);
}
}
public void initData() {
requestCount();
requestComment();
this.classId = getIntent().getStringExtra("classId");
ViewUtils.showLoading(this, "加载中...");
HttpHelper.getInstance().getRetrofitService(this).getOrderPage(new CreatMap.Builder().addParams("class_id", this.classId).build().getParam()).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).map(new ResponseFunc()).subscribe(new Subscriber<PriveClassisSubBean>() {
public void onCompleted() {
}
public void onError(Throwable e) {
ViewUtils.hideLoading();
LogUtils.i(new Object[]{e.getMessage()});
}
public void onNext(PriveClassisSubBean o) {
ViewUtils.hideLoading();
MainPublicAppointmentClassActivity.this.revLine1.setRightText(o.getClass_name());
MainPublicAppointmentClassActivity.this.revLine2.setRightText(o.getClass_date());
MainPublicAppointmentClassActivity.this.revLine3.setRightText(o.getStart_time() + " - " + o.getEnd_time());
if (o.getHall_name() != null) {
MainPublicAppointmentClassActivity.this.revLine4.setRightText(o.getHall_name());
}
MainPublicAppointmentClassActivity.this.revLine5.setRightText(o.getClass_min_count() + MainPublicAppointmentClassActivity.this.getString(R.string.unit_man));
MainPublicAppointmentClassActivity.this.revLine6.setRightText(o.getClass_appoint_count() + "/" + o.getClass_max_count() + MainPublicAppointmentClassActivity.this.getString(R.string.unit_man));
}
});
}
private void requestCount() {
HttpHelper.getInstance().getRetrofitService(this).requestClassCommentCount(getToken(), this.classInfoId, 1).enqueue(new Callback<ResponseBody>() {
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
}
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
if (response.body() == null) {
return;
}
try {
SucessBean sucessBean = (SucessBean) JsonUtil.json2Bean(((ResponseBody) response.body()).string(), SucessBean.class);
if (sucessBean.code == 10000) {
MainPublicAppointmentClassActivity.this.tvAllComment.setText("全部评论 (" + sucessBean.data + ")");
}
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
private void requestComment() {
HttpHelper.getInstance().getRetrofitService(this).classAllCommentList(getToken(), this.classInfoId, 1, 1, 2).enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
ViewUtils.hideLoading();
try {
String string = ((ResponseBody) response.body()).string();
LogUtils.i(new Object[]{string});
AllCommentBean allCommentBean = (AllCommentBean) JsonUtil.json2Bean(string, AllCommentBean.class);
List<AllCommentBean.DataBean> data = allCommentBean.getData();
if (allCommentBean.getCode() != 10000 || data == null || data.size() <= 0) {
return;
}
LogUtils.i(new Object[]{Integer.valueOf(allCommentBean.getCode())});
MainPublicAppointmentClassActivity.this.setComments(data);
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
ViewUtils.hideLoading();
}
});
}
public void setComments(List<AllCommentBean.DataBean> list) {
this.clLayout.setVisibility(0);
Glide.with(this).load(UrlConfig.Path.IMG_URL + 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(R.color.orange)), 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(this).load(UrlConfig.Path.IMG_URL + 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(R.color.orange)), 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;
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));
}
}
}