正在查看: 自健身 v3.3.4 应用的 AroundGymActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 自健身 v3.3.4 应用的 AroundGymActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mu.gymtrain.Activity.MainPackage;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.lifecycle.Observer;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.OnClick;
import com.baidu.location.BDAbstractLocationListener;
import com.baidu.location.BDLocation;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.blankj.utilcode.util.LogUtils;
import com.github.mikephil.charting.utils.Utils;
import com.mu.gymtrain.Adapter.AroundGymAdapter;
import com.mu.gymtrain.Base.BaseActivity;
import com.mu.gymtrain.Base.BaseRecyclerView;
import com.mu.gymtrain.Bean.AroundGymBean;
import com.mu.gymtrain.Bean.GPSEntity;
import com.mu.gymtrain.Http.CreatMap;
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.GPSObserver;
import com.mu.gymtrain.Utils.UrlConfig;
import com.mu.gymtrain.Utils.ViewUtils;
import java.util.ArrayList;
import java.util.List;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
public class AroundGymActivity extends BaseActivity implements BaseRecyclerView.OnItemClickListener {
private double lat;
private LocationClient locationClient;
private double lon;
AroundGymAdapter mAdapter;
List<AroundGymBean> mList = new ArrayList();
@BindView(R.id.recy_gym)
RecyclerView recyGym;
@BindView(R.id.title_left)
ImageView titleLeft;
@BindView(R.id.title_middle)
TextView titleMiddle;
@BindView(R.id.tv_allgym)
TextView tvAllgym;
@BindView(R.id.tv_gymname)
TextView tvGymname;
public int getContentLayout() {
return R.layout.activity_around;
}
public void initData() {
GPSObserver.getInstance(this).observe(this, new Observer<GPSEntity>() {
public void onChanged(GPSEntity gpsEntity) {
if (!gpsEntity.isOpen || AroundGymActivity.this.lat > Utils.DOUBLE_EPSILON) {
return;
}
AroundGymActivity.this.getLocation();
}
});
}
public void initView() {
this.titleMiddle.setText(getString(R.string.around));
this.tvGymname.setText(getIntent().getStringExtra(FinalTools.INTENT_TITLE));
this.recyGym.setLayoutManager(new LinearLayoutManager(this));
AroundGymAdapter aroundGymAdapter = new AroundGymAdapter(this.mList, this);
this.mAdapter = aroundGymAdapter;
aroundGymAdapter.setOnItemClickListener(this);
this.recyGym.setAdapter(this.mAdapter);
getLocation();
}
public 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.start();
this.locationClient.requestLocation();
this.locationClient.registerLocationListener(new BDAbstractLocationListener() {
public void onReceiveLocation(BDLocation location) {
if (location == null) {
return;
}
AroundGymActivity.this.lat = location.getLatitude();
AroundGymActivity.this.lon = location.getLongitude();
if ((AroundGymActivity.this.lat + "").contains("E")) {
AroundGymActivity.this.lat = 39.76594d;
AroundGymActivity.this.lon = 116.204987d;
}
AroundGymActivity.this.requestGym();
}
});
this.locationClient.start();
}
@OnClick({R.id.title_left})
public void onViewClicked(View view) {
if (view.getId() != 2131297253) {
return;
}
finish();
}
@Override
public void onItemClick(RecyclerView recyclerView, View view, int position, Object o) {
String gym_id = this.mList.get(position).getGym_id();
if (gym_id.equals(getGymIdFromSP())) {
return;
}
Intent intent = new Intent();
intent.putExtra(FinalTools.INTENT_COMMON, this.mList.get(position).getGym_name());
intent.putExtra(FinalTools.INTENT_COMMON2, gym_id);
setResult(FinalTools.INTENT_RESULT_CODE_SUCCESS, intent);
finish();
}
void requestGym() {
ViewUtils.showLoading(this, "加载中...");
HttpHelper.getInstance().getRetrofitService(this).getAroundGYM(new CreatMap.Builder().addParams(UrlConfig.Params.LNG, this.lon + "").addParams(UrlConfig.Params.LAT, this.lat + "").build().getParam()).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).map(new ResponseFunc()).subscribe(new Subscriber<List<AroundGymBean>>() {
public void onCompleted() {
}
public void onError(Throwable throwable) {
ViewUtils.hideLoading();
LogUtils.i(new Object[]{throwable.getMessage()});
}
public void onNext(List<AroundGymBean> aroundGymBeen) {
ViewUtils.hideLoading();
AroundGymActivity.this.mList.clear();
AroundGymActivity.this.mList.addAll(aroundGymBeen);
AroundGymActivity.this.mAdapter.notifyDataSetChanged();
AroundGymActivity.this.tvAllgym.setText("共" + AroundGymActivity.this.mList.size() + "家");
}
});
}
}