导航菜单

页面标题

页面副标题

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

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

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


package com.mu.gymtrain.Fragment;

import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Parcelable;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.OnClick;
import cn.jiguang.share.android.api.JShareInterface;
import cn.jiguang.share.android.api.ShareParams;
import cn.jiguang.share.wechat.Wechat;
import cn.jpush.android.service.WakedResultReceiver;
import com.hjq.http.EasyHttp;
import com.mu.gymtrain.Activity.FriendsListActivity;
import com.mu.gymtrain.Activity.PersonPackage.ConsumeActivity;
import com.mu.gymtrain.Activity.PersonPackage.CouponActivity;
import com.mu.gymtrain.Activity.PersonPackage.MyOrderCourseActivity;
import com.mu.gymtrain.Activity.PersonPackage.PersonalAchieveActivity;
import com.mu.gymtrain.Activity.PersonPackage.PersonalInfoActivity;
import com.mu.gymtrain.Activity.PersonPackage.SuggestionActivity;
import com.mu.gymtrain.Activity.TeamActivity;
import com.mu.gymtrain.Activity.WebViewActivity;
import com.mu.gymtrain.Base.BaseFragment;
import com.mu.gymtrain.Bean.UserInfoBean;
import com.mu.gymtrain.Http.CreatMap;
import com.mu.gymtrain.Http.HttpHelper;
import com.mu.gymtrain.Http.ResponseFunc;
import com.mu.gymtrain.Http.api.UpdateUserInfoAPI;
import com.mu.gymtrain.Utils.GlideUtils;
import com.mu.gymtrain.Utils.PreferenceUtils;
import com.mu.gymtrain.Widget.CircleImageView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class MineFragment extends BaseFragment {

    @BindView(2131296416)
    CircleImageView civHead;

    @BindView(2131296638)
    TextView imgMessage;

    @BindView(2131296716)
    ImageView ivUserNext;

    @BindView(2131297253)
    ImageView titleLeft;

    @BindView(2131297255)
    TextView titleMiddle;

    @BindView(2131297476)
    TextView tvAge;

    @BindView(2131297550)
    TextView tvFrindnum;

    @BindView(2131297585)
    TextView tvLogout;

    @BindView(2131297607)
    TextView tvName;

    @BindView(2131297616)
    TextView tvPersonAbout;

    @BindView(2131297617)
    TextView tvPersonAchieve;

    @BindView(2131297618)
    TextView tvPersonAdvise;

    @BindView(2131297619)
    TextView tvPersonConsume;

    @BindView(2131297620)
    TextView tvPersonCoupon;

    @BindView(2131297621)
    TextView tvPersonCourse;

    @BindView(2131297622)
    TextView tvPersonFrinds;

    @BindView(2131297423)
    TextView tvTeamBenefits;

    @BindView(2131297659)
    TextView tvTimes;

    @BindView(2131297448)
    TextView tvVersion;
    private String userId;
    private UserInfoBean userInfoBean;

    @Override
    protected int getLayout() {
        return 2131493052;
    }

    @Override
    protected void lazyLoad() {
    }

    @Override
    public void onClick(View v) {
    }

    @Override
    protected void initView() {
        this.tvVersion.setText("67   3.3.4");
        this.userId = PreferenceUtils.getInstance().getString("userId", "");
        String stringFromSP = getStringFromSP("avatar");
        String stringFromSP2 = getStringFromSP("age");
        String stringFromSP3 = getStringFromSP("friendCount");
        String stringFromSP4 = getStringFromSP("duration");
        String stringFromSP5 = getStringFromSP("userName");
        if (!TextUtils.isEmpty(stringFromSP)) {
            GlideUtils.withReplace(stringFromSP, this.civHead, getActivity());
            this.tvAge.setText("年龄:" + stringFromSP2 + "岁");
            this.tvFrindnum.setText(stringFromSP3 + "个好友");
            this.tvTimes.setText("时长:" + stringFromSP4 + "小时");
            this.tvName.setText(stringFromSP5);
        }
        this.titleLeft.setVisibility(4);
        this.titleMiddle.setText("我的");
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
        isHasFriend();
    }

    private void isHasFriend() {
        HttpHelper.getInstance().getRetrofitService(getContext()).isHasFriend(getToken()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new 1(this));
    }

    @Override
    protected void initData() {
        getUserInfo(new 2(this));
    }

    public void updateUserInfo(String nickname, String avatarUrl, String userId) {
        EasyHttp.post(this).api(new UpdateUserInfoAPI(nickname, avatarUrl, userId)).request(new 3(this));
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(String event) {
        if (event.equals(WakedResultReceiver.WAKE_TYPE_KEY)) {
            initData();
        } else if (event.equals("6")) {
            this.imgMessage.setVisibility(8);
        } else if (event.equals("7")) {
            isHasFriend();
        }
    }

    @OnClick({2131296716, 2131297423, 2131297617, 2131297621, 2131297619, 2131297620, 2131297622, 2131297616, 2131297618, 2131297585, 2131297255, 2131296788})
    public void onViewClicked(View view) {
        int id = view.getId();
        if (id == 2131296716) {
            Intent intent = new Intent(getActivity(), (Class<?>) PersonalInfoActivity.class);
            intent.putExtra("userInfo", (Parcelable) this.userInfoBean);
            startActivity(intent);
            return;
        }
        if (id == 2131297423) {
            startActivity(new Intent(getContext(), (Class<?>) TeamActivity.class));
            return;
        }
        if (id != 2131297585) {
            switch (id) {
                case 2131297616:
                    startActivity(new Intent(getActivity(), (Class<?>) WebViewActivity.class).putExtra("url", "https://www.zijianshen.com/index.php/app/bulletin/get_about_us").putExtra("intent_common", getString(2131820836)));
                    break;
                case 2131297617:
                    startActivity(new Intent(getActivity(), (Class<?>) PersonalAchieveActivity.class));
                    break;
                case 2131297618:
                    startActivity(new Intent(getActivity(), (Class<?>) SuggestionActivity.class));
                    break;
                case 2131297619:
                    startActivity(new Intent(getActivity(), (Class<?>) ConsumeActivity.class));
                    break;
                case 2131297620:
                    startActivity(new Intent(getActivity(), (Class<?>) CouponActivity.class));
                    break;
                case 2131297621:
                    startActivity(new Intent(getActivity(), (Class<?>) MyOrderCourseActivity.class));
                    break;
                case 2131297622:
                    startActivity(new Intent(getContext(), (Class<?>) FriendsListActivity.class));
                    break;
            }
            return;
        }
        logout();
    }

    private void shareWx() {
        ShareParams shareParams = new ShareParams();
        shareParams.setTitle("自健身");
        shareParams.setText("快来健身吧\n美好一天从健身开始!");
        shareParams.setShareType(2);
        shareParams.setUrl("http://www.zijianshen.com:18080/public/appdownload4.html");
        shareParams.setImageData(BitmapFactory.decodeResource(getResources(), 2131623981));
        JShareInterface.share(Wechat.Name, shareParams, new 4(this));
    }

    private void getUserInfo(Subscriber<UserInfoBean> subscriber) {
        HttpHelper.getInstance().getRetrofitService(getActivity()).getUserInfo(new CreatMap.Builder().build().getParam()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).map(new ResponseFunc()).subscribe(subscriber);
    }

    public void logout() {
        HttpHelper.getInstance().getRetrofitService(getActivity()).logout(new CreatMap.Builder().build().getParam()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new 5(this));
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        EventBus.getDefault().unregister(this);
    }
}