导航菜单

页面标题

页面副标题

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

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

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


package com.mu.gymtrain.Activity.PersonPackage;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import butterknife.OnClick;
import com.github.mikephil.charting.utils.Utils;
import com.google.android.material.tabs.TabLayout;
import com.mu.gymtrain.Activity.MainPackage.ChargeActivity;
import com.mu.gymtrain.Activity.PersonPackage.ConsumeActivity;
import com.mu.gymtrain.Activity.RegistActivity;
import com.mu.gymtrain.Adapter.ConsumeTabsAdapter;
import com.mu.gymtrain.Base.BaseActivity;
import com.mu.gymtrain.Base.BaseViewPagerAdapter;
import com.mu.gymtrain.Bean.SucessBean;
import com.mu.gymtrain.Bean.UserInfoBean;
import com.mu.gymtrain.Dialog.LogOffDialogHolder;
import com.mu.gymtrain.Dialog.ZhuXiaoDialog;
import com.mu.gymtrain.Dialog.ZhuXiaoSuccessDialog;
import com.mu.gymtrain.Http.CreatMap;
import com.mu.gymtrain.Http.HttpCallBack;
import com.mu.gymtrain.Http.HttpHelper;
import com.mu.gymtrain.Http.ResponseFunc;
import com.mu.gymtrain.R;
import com.mu.gymtrain.Utils.FinalTools;
import com.mu.gymtrain.Utils.GPSUtils;
import com.mu.gymtrain.Utils.GlideUtils;
import com.mu.gymtrain.Utils.PreferenceUtils;
import com.mu.gymtrain.Utils.ToastUtils;
import com.mu.gymtrain.Utils.UrlConfig;
import com.mu.gymtrain.Widget.CircleImageView;
import com.tencent.connect.common.Constants;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class ConsumeActivity extends BaseActivity {

    @BindView(R.id.civ_head)
    CircleImageView civHead;
    private BaseViewPagerAdapter mAdapter;
    private double money = -1.0d;

    @BindView(R.id.tab_consume_layout)
    TabLayout tabConsumeLayout;

    @BindView(R.id.title_left)
    ImageView titleLeft;

    @BindView(R.id.title_middle)
    TextView titleMiddle;

    @BindView(R.id.title_righttext)
    TextView titleRighttext;

    @BindView(R.id.tv_charge)
    TextView tvCharge;

    @BindView(R.id.tv_logoff)
    TextView tvLogoff;

    @BindView(R.id.tv_money)
    TextView tvMoney;

    @BindView(R.id.vp_content_consume)
    ViewPager vpContentConsume;

    public int getContentLayout() {
        return R.layout.activity_consume;
    }

    public void initData() {
        this.titleMiddle.setText(getString(R.string.person_consume));
        this.titleRighttext.setText(getString(R.string.person_consume_chargelist));
        showProgress();
        getUserInfo(new Subscriber<UserInfoBean>() {
            public void onCompleted() {
            }

            public void onError(Throwable e) {
                ConsumeActivity.this.dismissProgress();
            }

            public void onNext(UserInfoBean userInfoBean) {
                ConsumeActivity.this.dismissProgress();
                ConsumeActivity.this.money = Double.parseDouble(userInfoBean.getMoney_remain());
                ConsumeActivity.this.tvMoney.setText(userInfoBean.getMoney_remain());
            }
        });
    }

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

    public void initView() {
        if (this.mAdapter == null) {
            this.mAdapter = new ConsumeTabsAdapter(getSupportFragmentManager());
        }
        this.vpContentConsume.setAdapter(this.mAdapter);
        this.vpContentConsume.setOffscreenPageLimit(this.mAdapter.getCount());
        this.vpContentConsume.setCurrentItem(0);
        this.tabConsumeLayout.setupWithViewPager(this.vpContentConsume);
        GlideUtils.withReplace(UrlConfig.Path.IMG_URL + PreferenceUtils.getInstance().getString("useravter", ""), this.civHead, this);
    }

    @OnClick({R.id.title_left, R.id.title_righttext, R.id.tv_charge, R.id.tv_logoff})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.title_left:
                finish();
                break;
            case R.id.title_righttext:
                startActivity(new Intent((Context) this, (Class<?>) ChargeRecordActivity.class));
                break;
            case R.id.tv_charge:
                if (GPSUtils.isOPen(this)) {
                    startActivity(new Intent((Context) this, (Class<?>) ChargeActivity.class));
                    break;
                } else {
                    ToastUtils.show(this, "请打开GSPS定位服务");
                    break;
                }
            case R.id.tv_logoff:
                if (this.money == -1.0d) {
                    showToast("网络错误,请重新进入该页面");
                    break;
                } else {
                    new ZhuXiaoDialog(this).show(new ZhuXiaoDialog.OnClickListener() {
                        @Override
                        public final void onOk() {
                            ConsumeActivity.this.lambda$onViewClicked$0$ConsumeActivity();
                        }
                    });
                    break;
                }
        }
    }

    public void lambda$onViewClicked$0$ConsumeActivity() {
        if (this.money > Utils.DOUBLE_EPSILON) {
            showDialog();
        } else {
            zhuxiao();
        }
    }

    private void zhuxiao() {
        showProgress();
        HttpHelper.getInstance().getRetrofitService(this).zhuXiao(getToken(), Constants.VIA_REPORT_TYPE_SHARE_TO_QZONE).enqueue(new AnonymousClass2());
    }

    class AnonymousClass2 extends HttpCallBack<SucessBean> {
        AnonymousClass2() {
        }

        @Override
        public void onSuccess(SucessBean sucessBean, String json) {
            ConsumeActivity.this.dismissProgress();
            if (sucessBean.code == 10000) {
                new ZhuXiaoSuccessDialog(ConsumeActivity.this).show(new ZhuXiaoSuccessDialog.OnClickListener() {
                    @Override
                    public final void onOk() {
                        ConsumeActivity.AnonymousClass2.this.lambda$onSuccess$0$ConsumeActivity$2();
                    }
                });
            } else {
                ConsumeActivity.this.showToast(sucessBean.message);
            }
        }

        public void lambda$onSuccess$0$ConsumeActivity$2() {
            PreferenceUtils.getInstance().saveString(FinalTools.TOKEN, "");
            ConsumeActivity.this.startActivity(new Intent((Context) ConsumeActivity.this, (Class<?>) RegistActivity.class));
            ConsumeActivity.this.finish();
        }

        @Override
        public void onFail(String str) {
            ConsumeActivity.this.dismissProgress();
            ConsumeActivity.this.showToast(str);
        }
    }

    private void showDialog() {
        final LogOffDialogHolder logOffDialogHolder = new LogOffDialogHolder(this);
        logOffDialogHolder.mIvClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                LogOffDialogHolder.this.mDialog.dismiss();
            }
        });
        logOffDialogHolder.mDialog.setCanceledOnTouchOutside(true);
        logOffDialogHolder.mDialog.show();
    }
}