导航菜单

页面标题

页面副标题

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

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

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


package com.mu.gymtrain.Fragment;

import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Handler;
import android.text.TextUtils;
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.RadioButton;
import android.widget.TextView;
import butterknife.BindView;
import cn.jpush.android.api.JPushInterface;
import com.blankj.utilcode.util.ScreenUtils;
import com.mu.gymtrain.Activity.HelperFromDoorActivity;
import com.mu.gymtrain.Base.BaseFragment;
import com.mu.gymtrain.Bean.PermissionEntity;
import com.mu.gymtrain.Fragment.PermissionFragment;
import com.mu.gymtrain.Http.CreatMap;
import com.mu.gymtrain.Http.HttpHelper;
import com.mu.gymtrain.Http.ResponseFunc;
import com.mu.gymtrain.Utils.DisplayUtil;
import com.mu.gymtrain.Utils.PermissionUtils;
import com.mu.gymtrain.Utils.PreferenceUtils;
import com.mu.gymtrain.view.DialogUtils;
import java.util.ArrayList;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class RootFragment extends BaseFragment {
    private static final int QUERY_DOOR_STATE = 2;
    private static final int REFRESH_DOOR_QR = 1;
    private CouponFragment couponFragment;
    private ImageView imgDoorState;
    private ImageView imgQR;
    private ArrayList<TextView> list;

    @BindView(2131296706)
    ImageView mIv_mid;
    private MainFragment mainFragment;
    private MineFragment mineFragment;
    private DialogUtils openFailDialog;
    private DialogUtils openSuccessDialog;
    private Dialog qrDialog;

    @BindView(2131296996)
    RadioButton rbCoupon;

    @BindView(2131296999)
    RadioButton rbHome;

    @BindView(2131297000)
    RadioButton rbMy;

    @BindView(2131297002)
    RadioButton rbZone;
    private TextView textTitle;
    private TextView tvShopName;
    private ZoneFragment zoneFragment;
    private String inDoorTag = "-1";
    private final PermissionEntity[] locationPermissionArr = {new PermissionEntity("android.permission.ACCESS_FINE_LOCATION", "定位权限"), new PermissionEntity("android.permission.READ_PHONE_STATE", "获取手机信息权限")};
    private Handler mHandler = new 2(this);

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

    @Override
    protected void lazyLoad() {
    }

    @Override
    protected void initView() {
        this.rbHome.setOnClickListener(this);
        this.rbCoupon.setOnClickListener(this);
        this.rbZone.setOnClickListener(this);
        this.rbMy.setOnClickListener(this);
        this.mIv_mid.setOnClickListener(this);
        this.mainFragment = new MainFragment();
        this.couponFragment = new CouponFragment();
        this.zoneFragment = new ZoneFragment();
        MineFragment mineFragment = new MineFragment();
        this.mineFragment = mineFragment;
        loadMultipleRootFragment(2131296542, 0, this.mainFragment, this.couponFragment, this.zoneFragment, mineFragment);
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
        configBuglyAndJPush();
        initDoorDialog();
        isHasFriend();
        initSuccessDialog();
    }

    @Override
    protected void initData() {
        getDoorStatus();
    }

    private void configBuglyAndJPush() {
        String stringFromSP = getStringFromSP("phone");
        if (TextUtils.isEmpty(stringFromSP) || stringFromSP.length() < 5) {
            stringFromSP = "15203101111";
        }
        JPushInterface.setAlias(getContext(), Integer.parseInt(stringFromSP.substring(stringFromSP.length() - 5, stringFromSP.length())), stringFromSP);
    }

    private void initSuccessDialog() {
        View inflate = LayoutInflater.from(getContext()).inflate(2131493013, (ViewGroup) null, false);
        this.textTitle = (TextView) inflate.findViewById(2131297207);
        ImageView imageView = (ImageView) inflate.findViewById(2131296627);
        this.imgDoorState = imageView;
        imageView.setOnClickListener(this);
        inflate.findViewById(2131297651).setOnClickListener(this);
        this.openSuccessDialog = new DialogUtils.Builder(getContext()).setContentView(inflate).setOutCancelEnable(false).setWindoWidth(330).create();
        View inflate2 = LayoutInflater.from(getContext()).inflate(2131493012, (ViewGroup) null, false);
        inflate2.findViewById(2131296577).setOnClickListener(this);
        inflate2.findViewById(2131296593).setOnClickListener(this);
        this.openFailDialog = new DialogUtils.Builder(getContext()).setContentView(inflate2).setOutCancelEnable(false).setWindoWidth(330).create();
    }

    private void initDoorDialog() {
        View inflate = LayoutInflater.from(getContext()).inflate(2131493004, (ViewGroup) null);
        this.imgQR = (ImageView) inflate.findViewById(2131296593);
        inflate.findViewById(2131296623).setOnClickListener(this);
        this.tvShopName = (TextView) inflate.findViewById(2131297413);
        Dialog dialog = new Dialog(getContext(), 2131886838);
        this.qrDialog = dialog;
        dialog.setContentView(inflate);
        Window window = this.qrDialog.getWindow();
        WindowManager.LayoutParams attributes = window.getAttributes();
        DisplayUtil.dipToPix(getContext(), 230);
        double screenWidth = ScreenUtils.getScreenWidth();
        Double.isNaN(screenWidth);
        attributes.width = (int) (screenWidth * 0.6d);
        attributes.height = -2;
        window.setGravity(17);
        this.qrDialog.setCancelable(true);
        this.qrDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public final void onDismiss(DialogInterface dialogInterface) {
                RootFragment.this.lambda$initDoorDialog$0$RootFragment(dialogInterface);
            }
        });
        this.inDoorTag = getStringFromSP("doorstatus");
    }

    public void lambda$initDoorDialog$0$RootFragment(DialogInterface dialogInterface) {
        DisplayUtil.cancelScreenMaxBrightness(getActivity());
        this.mHandler.removeMessages(1);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(String event) {
        if (event.equals("6")) {
            this.list.get(4).setVisibility(8);
        } else if (event.equals("7")) {
            isHasFriend();
        }
    }

    private void isHasFriend() {
        HttpHelper.getInstance().getRetrofitService(getContext()).isHasFriend(PreferenceUtils.getInstance().getString("login_token", "")).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new 1(this));
    }

    private void midClick() {
        if (TextUtils.isEmpty(getGymIdFromSP())) {
            PermissionUtils.requestPermission(this, this.locationPermissionArr, new PermissionFragment.IPermissionListener() {
                public final void granted() {
                    RootFragment.this.lambda$midClick$1$RootFragment();
                }
            });
        } else {
            lambda$midClick$1$RootFragment();
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case 2131296577:
                this.openFailDialog.dismiss();
                break;
            case 2131296593:
                this.openFailDialog.dismiss();
                startActivity(new Intent(getContext(), (Class<?>) HelperFromDoorActivity.class));
                break;
            case 2131296623:
                this.qrDialog.dismiss();
                break;
            case 2131296627:
                startActivity(new Intent(getContext(), (Class<?>) HelperFromDoorActivity.class));
                break;
            case 2131296706:
                midClick();
                break;
            case 2131296996:
                showHideFragment(this.couponFragment);
                break;
            case 2131296999:
                showHideFragment(this.mainFragment);
                break;
            case 2131297000:
                showHideFragment(this.mineFragment);
                break;
            case 2131297002:
                showHideFragment(this.zoneFragment);
                break;
            case 2131297651:
                this.openSuccessDialog.dismiss();
                break;
        }
    }

    public void lambda$midClick$1$RootFragment() {
        if (!this.qrDialog.isShowing()) {
            showProgress();
        }
        HttpHelper.getInstance().getRetrofitService(getContext(), "https://www.zijianshen.com/index.php/").getIndoorCode(new CreatMap.Builder().addParams("gym_id", getGymIdFromSP()).build().getParam()).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).subscribe(new 3(this));
    }

    public void getDoorStatus() {
        HttpHelper.getInstance().getRetrofitService(getContext()).getDoorStatus(new CreatMap.Builder().build().getParam()).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).map(new ResponseFunc()).subscribe(new 4(this));
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        EventBus.getDefault().unregister(this);
        this.mHandler.removeMessages(1);
        this.mHandler.removeMessages(2);
        this.mHandler = null;
    }
}