正在查看: 自健身 v3.3.4 应用的 ChargeActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 自健身 v3.3.4 应用的 ChargeActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mu.gymtrain.Activity.MainPackage;
import android.content.Intent;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import butterknife.OnClick;
import com.baidu.location.BDAbstractLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.blankj.utilcode.util.LogUtils;
import com.mu.gymtrain.Activity.WebViewActivity;
import com.mu.gymtrain.Adapter.PriceAdapter;
import com.mu.gymtrain.Base.BaseActivity;
import com.mu.gymtrain.Bean.AroundGymBean;
import com.mu.gymtrain.Bean.WXPayBean;
import com.mu.gymtrain.Dialog.RechargeDialog;
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.PayResult;
import com.mu.gymtrain.Utils.PreferenceUtils;
import com.mu.gymtrain.Utils.ViewUtils;
import com.mu.gymtrain.view.DialogUtils;
import com.mu.gymtrain.view.SimpleViewpagerIndicator;
import com.tencent.mm.opensdk.modelpay.PayReq;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import java.util.ArrayList;
import java.util.List;
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 ChargeActivity extends BaseActivity {
private static final int SDK_PAY_FLAG = 1;
IWXAPI api;
@BindView(2131296498)
TextView etChargeMoney;
private ImageView imgBg;
private SimpleViewpagerIndicator indicator;
@BindView(2131296681)
ImageView ivAlipay;
@BindView(2131296717)
ImageView ivWx;
private String lat;
private LocationClient locationClient;
private String lon;
PriceAdapter mAdapter;
private DialogUtils mDialog;
@BindView(2131297253)
ImageView titleLeft;
@BindView(2131297255)
TextView titleMiddle;
@BindView(2131297489)
TextView tvChargeNow;
@BindView(2131297491)
TextView tvExplain;
private TextView tvSuccess;
private ViewPager viewPager;
private int mChargeWay = 0;
List<AroundGymBean> gymsList = new ArrayList();
@Override
public int getContentLayout() {
return 2131492906;
}
@Override
public void initData() {
}
@Override
public void initView() {
EventBus.getDefault().register(this);
this.titleMiddle.setText(PreferenceUtils.getInstance().getString("currentgym", ""));
getLocation();
initTab();
}
private void getLocation() {
this.locationClient = new LocationClient(this);
LocationClientOption locationClientOption = new LocationClientOption();
locationClientOption.setOpenGps(true);
locationClientOption.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
this.locationClient.setLocOption(locationClientOption);
this.locationClient.registerLocationListener((BDAbstractLocationListener) new 1(this));
this.locationClient.start();
}
private void initDialog() {
View inflate = LayoutInflater.from(this).inflate(2131493016, (ViewGroup) null, false);
this.mDialog = new DialogUtils.Builder(this).setGravity(17).setOutCancelEnable(false).setContentView(inflate).create();
inflate.findViewById(2131296624).setOnClickListener(this);
inflate.findViewById(2131297337).setVisibility(4);
this.imgBg = (ImageView) inflate.findViewById(2131296610);
this.tvSuccess = (TextView) inflate.findViewById(2131297420);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(String wxPay) {
wxPay.hashCode();
switch (wxPay) {
case "0":
this.imgBg.setBackgroundResource(2131230989);
this.tvSuccess.setText(getString(2131820835));
this.mDialog.show();
break;
case "-1":
this.imgBg.setBackgroundResource(2131231226);
this.tvSuccess.setText(getString(2131820832));
this.mDialog.show();
break;
case "-2":
this.imgBg.setBackgroundResource(2131231226);
this.tvSuccess.setText(getString(2131820829));
this.mDialog.show();
break;
}
}
public void requestGym() {
ViewUtils.showLoading(this, "加载中...");
HttpHelper.getInstance().getRetrofitService(this).getAroundGYM(new CreatMap.Builder().addParams("longitude", this.lon + "").addParams("latitude", this.lat + "").build().getParam()).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).map(new ResponseFunc()).subscribe(new 2(this));
}
private void initTab() {
this.indicator = findViewById(2131296674);
this.viewPager = (ViewPager) findViewById(2131297702);
}
@OnClick({2131297253, 2131296681, 2131297235, 2131297236, 2131296717, 2131297489, 2131297491})
public void onViewClicked(View view) {
switch (view.getId()) {
case 2131296681:
case 2131297235:
changeChargeWay(0);
break;
case 2131296717:
case 2131297236:
changeChargeWay(1);
break;
case 2131297253:
finish();
break;
case 2131297489:
if (TextUtils.isEmpty(this.etChargeMoney.getText().toString())) {
MessageUtils.alertMessageCENTER(getString(2131820834));
break;
} else {
new RechargeDialog(this, new RechargeDialog.OnListener() {
public final void onClick() {
ChargeActivity.this.lambda$onViewClicked$0$ChargeActivity();
}
}).show();
break;
}
case 2131297491:
startActivity(new Intent(this, (Class<?>) WebViewActivity.class).putExtra("url", "https://www.zijianshen.com/index.php/app/bulletin/get_recharge_instruction").putExtra("intent_common", getString(2131820619)));
break;
}
}
public void lambda$onViewClicked$0$ChargeActivity() {
if (this.mChargeWay == 0) {
chargeAli();
} else {
chargeWx();
}
initDialog();
}
@Override
public void onClick(View v) {
super.onClick(v);
if (v.getId() == 2131296624) {
this.mDialog.dismiss();
}
}
private void changeChargeWay(int type) {
this.mChargeWay = type;
this.ivAlipay.setImageResource(type == 0 ? 2131230939 : 2131230992);
this.ivWx.setImageResource(type != 1 ? 2131230992 : 2131230939);
}
public void chargeAli() {
ViewUtils.showLoading(this, "加载中...");
HttpHelper.getInstance().getRetrofitService(this, "https://www.zijianshen.com/index.php/").getAliPay(new CreatMap.Builder().addParams("money", this.etChargeMoney.getText().toString()).build().getParam()).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).subscribe(new 3(this));
}
public void chargeWx() {
ViewUtils.showLoading(this, "加载中...");
HttpHelper.getInstance().getRetrofitService(this, "https://www.zijianshen.com/index.php/").getWXPay(new CreatMap.Builder().addParams("money", this.etChargeMoney.getText().toString()).build().getParam()).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).map(new ResponseFunc()).subscribe(new 4(this));
}
public void payByWx(WXPayBean wx) {
try {
PayReq payReq = new PayReq();
IWXAPI createWXAPI = WXAPIFactory.createWXAPI(getApplicationContext(), wx.getAppid());
this.api = createWXAPI;
createWXAPI.registerApp(wx.getAppid());
payReq.appId = wx.getAppid();
payReq.partnerId = wx.getMch_id();
payReq.prepayId = wx.getPrepay_id();
payReq.nonceStr = wx.getNonce_str();
payReq.timeStamp = wx.getTimes() + "";
payReq.packageValue = "Sign=WXPay";
payReq.sign = wx.getSign();
this.api.sendReq(payReq);
} catch (Exception e) {
e.printStackTrace();
}
}
public void payByAli(final String str) {
new Thread((Runnable) new 5(this, str)).start();
}
public void alipayResult(String result) {
String resultStatus = new PayResult(result).getResultStatus();
LogUtils.i(result);
if (TextUtils.equals(resultStatus, "9000")) {
this.imgBg.setBackgroundResource(2131230989);
this.tvSuccess.setText(getString(2131820835));
} else {
this.imgBg.setBackgroundResource(2131231226);
this.tvSuccess.setText(getString(2131820832));
}
this.mDialog.show();
}
@Override
protected void onDestroy() {
super.onDestroy();
EventBus.getDefault().unregister(this);
}
}