正在查看: 自健身 v3.3.4 应用的 FriendInfoActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 自健身 v3.3.4 应用的 FriendInfoActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mu.gymtrain.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
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 butterknife.BindView;
import butterknife.OnClick;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.mu.gymtrain.Base.BaseActivity;
import com.mu.gymtrain.Base.BaseModel;
import com.mu.gymtrain.Bean.FriendDetail;
import com.mu.gymtrain.Http.HttpHelper;
import com.mu.gymtrain.R;
import com.mu.gymtrain.Utils.FinalTools;
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 org.greenrobot.eventbus.EventBus;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
public class FriendInfoActivity extends BaseActivity {
private int isFriend;
@BindView(R.id.avatar)
ImageView mAvatar;
private Dialog mNoInfoDialog;
@BindView(R.id.title_middle)
TextView mTitleMiddle;
@BindView(R.id.tvAge)
TextView mTvAge;
@BindView(R.id.tvCK)
TextView mTvCK;
@BindView(R.id.tvHeight)
TextView mTvHeight;
@BindView(R.id.tvJob)
TextView mTvJob;
@BindView(R.id.tvName)
TextView mTvName;
@BindView(R.id.tvSK)
TextView mTvSK;
@BindView(R.id.tvSubmit)
TextView mTvSubmit;
@BindView(R.id.tvWeight)
TextView mTvWeight;
private String userId;
private String userName;
public int getContentLayout() {
return R.layout.activity_friend_info_layout;
}
public void initView() {
this.mTitleMiddle.setText("好友信息");
}
public void initData() {
ViewUtils.showLoading(this, "加载中...");
this.userId = getIntent().getStringExtra(FinalTools.USER_ID);
HttpHelper.getInstance().getRetrofitService(this).getFriendDetial(getToken(), this.userId).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<FriendDetail>() {
public void onCompleted() {
}
public void onError(Throwable e) {
ViewUtils.hideLoading();
ToastUtils.show(FriendInfoActivity.this, e.getMessage());
}
public void onNext(FriendDetail friendsEntity) {
ViewUtils.hideLoading();
FriendInfoActivity.this.isFriend = friendsEntity.data.is_friend;
if (FriendInfoActivity.this.isFriend != 0) {
FriendInfoActivity.this.mTvSubmit.setText("删除好友");
}
FriendInfoActivity.this.mTvSubmit.setVisibility(0);
FriendInfoActivity.this.mTvHeight.setText(friendsEntity.data.height + "CM");
FriendInfoActivity.this.mTvWeight.setText(friendsEntity.data.weight + "公斤");
FriendInfoActivity.this.mTvJob.setText(friendsEntity.data.professional);
FriendInfoActivity.this.mTvCK.setText(friendsEntity.data.ck_count + "");
FriendInfoActivity.this.mTvSK.setText(friendsEntity.data.sk_count + "");
FriendInfoActivity.this.userName = friendsEntity.data.user_name;
FriendInfoActivity.this.mTvName.setText(FriendInfoActivity.this.userName);
FriendInfoActivity.this.mTvAge.setText(friendsEntity.data.age + "周岁 " + friendsEntity.data.gender);
Glide.with(FriendInfoActivity.this).load(UrlConfig.Path.IMG_URL + friendsEntity.data.avatar).apply(new RequestOptions().circleCrop().placeholder(R.mipmap.ic_defalut_head)).into(FriendInfoActivity.this.mAvatar);
}
});
}
@OnClick({R.id.title_left, R.id.tvCK, R.id.tvSK, R.id.right1, R.id.right2, R.id.tvSubmit})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.right1:
case R.id.tvCK:
Intent intent = new Intent((Context) this, (Class<?>) FriendCourseDetailActivity.class);
intent.putExtra("title", "操课课程");
intent.putExtra(FinalTools.USER_ID, this.userId);
startActivity(intent);
break;
case R.id.right2:
case R.id.tvSK:
Intent intent2 = new Intent((Context) this, (Class<?>) FriendCourseDetailActivity.class);
intent2.putExtra("title", "私教课程");
intent2.putExtra(FinalTools.USER_ID, this.userId);
startActivity(intent2);
break;
case R.id.title_left:
finish();
break;
case R.id.tvSubmit:
showDialog();
break;
}
}
private void showDialog() {
View inflate = LayoutInflater.from(this).inflate(R.layout.dialog_friend, (ViewGroup) null, false);
TextView textView = (TextView) inflate.findViewById(R.id.textTitle);
TextView textView2 = (TextView) inflate.findViewById(2131297190);
ImageView imageView = (ImageView) inflate.findViewById(R.id.iv_close);
if (this.isFriend == 0) {
textView.setText("确定添加 " + this.userName + " 为好友吗?");
} else {
textView.setText("确定删除 " + this.userName + " 好友吗?");
}
final Dialog dialog = new Dialog(this, R.style.progress_dialog);
dialog.setContentView(inflate);
Window window = 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);
dialog.setCancelable(true);
dialog.show();
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
textView2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
if (FriendInfoActivity.this.isFriend == 0) {
FriendInfoActivity.this.addFriend();
} else {
FriendInfoActivity.this.deleteFriend();
}
}
});
}
public void addFriend() {
ViewUtils.showLoading(this, "加载中...");
HttpHelper.getInstance().getRetrofitService(this).addFriend(getToken(), this.userId).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<BaseModel<Integer>>() {
public void onCompleted() {
}
public void onError(Throwable e) {
ViewUtils.hideLoading();
ToastUtils.show(FriendInfoActivity.this, e.getMessage());
}
public void onNext(BaseModel<Integer> integerBaseModel) {
ViewUtils.hideLoading();
ToastUtils.show(FriendInfoActivity.this, "请求发送成功,等待对方确认");
EventBus.getDefault().post("8");
FriendInfoActivity.this.finish();
}
});
}
public void deleteFriend() {
ViewUtils.showLoading(this, "加载中...");
HttpHelper.getInstance().getRetrofitService(this).deleteFriend(getToken(), this.userId).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<BaseModel<Integer>>() {
public void onCompleted() {
}
public void onError(Throwable e) {
ViewUtils.hideLoading();
ToastUtils.show(FriendInfoActivity.this, e.getMessage());
}
public void onNext(BaseModel<Integer> integerBaseModel) {
ViewUtils.hideLoading();
ToastUtils.show(FriendInfoActivity.this, "删除成功");
EventBus.getDefault().post("3");
FriendInfoActivity.this.finish();
}
});
}
}