正在查看: 自健身 v3.3.4 应用的 HomeActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 自健身 v3.3.4 应用的 HomeActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mu.gymtrain.Activity;
import android.R;
import android.app.Dialog;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Handler;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TabHost;
import android.widget.TextView;
import androidx.fragment.app.FragmentTabHost;
import butterknife.BindView;
import butterknife.OnClick;
import cn.jpush.android.api.JPushInterface;
import com.blankj.utilcode.util.AdaptScreenUtils;
import com.mu.gymtrain.Base.BaseActivity;
import com.mu.gymtrain.Bean.PermissionEntity;
import com.mu.gymtrain.Http.CreatMap;
import com.mu.gymtrain.Http.HttpHelper;
import com.mu.gymtrain.Http.ResponseFunc;
import com.mu.gymtrain.Utils.MessageUtils;
import com.mu.gymtrain.Utils.PermissionUtils;
import com.mu.gymtrain.Utils.PreferenceUtils;
import com.mu.gymtrain.Utils.ViewUtils;
import com.mu.gymtrain.Utils.WindowUtils;
import com.mu.gymtrain.Widget.Tabs.NavigationTabs;
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 HomeActivity extends BaseActivity implements TabHost.OnTabChangeListener, View.OnClickListener {
private static final int QUERY_DOOR_STATE = 2;
private static final int REFRESH_DOOR_QR = 1;
private static boolean isExit = false;
private Dialog dialog;
private ImageView imgDoorState;
private ImageView imgQR;
private ArrayList<TextView> list;
@BindView(2131296706)
ImageView mIv_mid;
@BindView(2131296908)
LinearLayout mPagerWrapper;
@BindView(2131297006)
FrameLayout mRealtabcontent;
@BindView(2131297054)
RelativeLayout mRl_root;
@BindView(R.id.tabhost)
FragmentTabHost mTabHost;
@BindView(R.id.tabcontent)
FrameLayout mTabcontent;
private long oldClickTime;
private DialogUtils openFailDialog;
private DialogUtils openSuccessDialog;
private WindowManager.LayoutParams params;
NavigationTabs[] tabs;
private TextView textTitle;
private ImageView textView;
private WindowManager windowManager;
private int x;
private int y;
private String lastTab = "首页";
private String inDoorTag = "-1";
private boolean flag = true;
private final PermissionEntity[] locationPermissionArr = {new PermissionEntity("android.permission.ACCESS_FINE_LOCATION", "定位权限"), new PermissionEntity("android.permission.READ_PHONE_STATE", "获取手机信息权限")};
private Handler mHandler = new 5(this);
@Override
public int getContentLayout() {
return 2131492935;
}
@Override
public void onTabChanged(String tabId) {
}
@Override
public void initData() {
getDoorStatus();
}
@Override
public void initView() {
if (!EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().register(this);
}
configBuglyAndJPush();
initDoorDialog();
this.mTabHost.setup(this, getSupportFragmentManager(), 2131297006);
this.mTabHost.getTabWidget().setShowDividers(0);
initTabs();
isHasFriend();
initSuccessDialog();
this.mTabHost.setCurrentTab(0);
this.mTabHost.setOnTabChangedListener(this);
}
private void configBuglyAndJPush() {
String stringFromSP = getStringFromSP("phone");
if (TextUtils.isEmpty(stringFromSP) || stringFromSP.length() < 5) {
stringFromSP = "15203101111";
}
JPushInterface.setAlias(this, Integer.parseInt(stringFromSP.substring(stringFromSP.length() - 5, stringFromSP.length())), stringFromSP);
}
private void initSuccessDialog() {
View inflate = LayoutInflater.from(this).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(this).setContentView(inflate).setOutCancelEnable(false).setWindoWidth(330).create();
View inflate2 = LayoutInflater.from(this).inflate(2131493012, (ViewGroup) null, false);
inflate2.findViewById(2131296577).setOnClickListener(this);
inflate2.findViewById(2131296593).setOnClickListener(this);
this.openFailDialog = new DialogUtils.Builder(this).setContentView(inflate2).setOutCancelEnable(false).setWindoWidth(330).create();
}
private void initDoorDialog() {
View inflate = LayoutInflater.from(this).inflate(2131493004, (ViewGroup) null);
this.imgQR = (ImageView) inflate.findViewById(2131296593);
inflate.findViewById(2131296623).setOnClickListener(this);
Dialog dialog = new Dialog(this, 2131886838);
this.dialog = dialog;
dialog.setContentView(inflate);
Window window = this.dialog.getWindow();
WindowManager.LayoutParams attributes = window.getAttributes();
double wIndowWidth = WindowUtils.getWIndowWidth(this);
Double.isNaN(wIndowWidth);
attributes.width = (int) (wIndowWidth * 0.8d);
attributes.height = -2;
window.setGravity(17);
this.dialog.setCancelable(true);
this.dialog.setOnDismissListener(new 1(this));
}
public void initTabs() {
this.list = new ArrayList<>();
NavigationTabs[] values = NavigationTabs.values();
this.tabs = values;
for (NavigationTabs navigationTabs : values) {
TabHost.TabSpec newTabSpec = this.mTabHost.newTabSpec(getString(navigationTabs.getNameRes()));
View inflate = LayoutInflater.from(getApplicationContext()).inflate(2131493254, (ViewGroup) null, false);
ImageView imageView = (ImageView) inflate.findViewById(2131297171);
this.list.add((TextView) inflate.findViewById(2131296650));
imageView.setImageResource(navigationTabs.getIconRes());
((TextView) inflate.findViewById(2131297172)).setText(getString(navigationTabs.getNameRes()));
newTabSpec.setIndicator(inflate);
newTabSpec.setContent((TabHost.TabContentFactory) new 2(this));
this.mTabHost.addTab(newTabSpec, navigationTabs.getClazz(), null);
}
}
@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(this).isHasFriend(PreferenceUtils.getInstance().getString("login_token", "")).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new 3(this));
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == 4) {
exit();
return false;
}
return super.onKeyDown(keyCode, event);
}
private void exit() {
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - this.oldClickTime > 2000) {
this.oldClickTime = currentTimeMillis;
MessageUtils.alertMessageCENTER("再按一次退出程序");
} else {
finish();
System.exit(0);
}
}
@OnClick({2131296706})
public void onViewClicked(View v) {
if (v.getId() != 2131296706) {
return;
}
if (TextUtils.isEmpty(getGymIdFromSP())) {
PermissionUtils.requestPermission(this, this.locationPermissionArr, new 4(this));
} else {
showQR();
}
}
public void showQR() {
if (!this.dialog.isShowing()) {
ViewUtils.showLoading(this, "加载中...");
}
HttpHelper.getInstance().getRetrofitService(this, "https://www.zijianshen.com/index.php/").getIndoorCode(new CreatMap.Builder().addParams("gym_id", getGymIdFromSP()).build().getParam()).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).subscribe(new 6(this));
}
public void getDoorStatus() {
HttpHelper.getInstance().getRetrofitService(this).getDoorStatus(new CreatMap.Builder().build().getParam()).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).map(new ResponseFunc()).subscribe(new 7(this));
}
@Override
protected void onDestroy() {
super.onDestroy();
EventBus.getDefault().unregister(this);
this.mHandler.removeMessages(1);
this.mHandler.removeMessages(2);
this.mHandler = null;
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case 2131296577:
this.openFailDialog.dismiss();
break;
case 2131296593:
this.openFailDialog.dismiss();
startActivity(new Intent(this, (Class<?>) HelperFromDoorActivity.class));
break;
case 2131296623:
this.dialog.dismiss();
break;
case 2131296627:
startActivity(new Intent(this, (Class<?>) HelperFromDoorActivity.class));
break;
case 2131297651:
this.openSuccessDialog.dismiss();
break;
}
}
@Override
public Resources getResources() {
return AdaptScreenUtils.adaptWidth(super.getResources(), 750);
}
}