Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a878a9238a | ||
|
|
bd2ae6fc46 | ||
|
|
80a257273b | ||
|
|
5a846d220d | ||
|
|
01bd0e03ff | ||
|
|
3a23d2e26c | ||
|
|
5d08b77cc5 | ||
|
|
61f052b828 | ||
|
|
8194a07984 | ||
|
|
82b1413429 | ||
|
|
bad0a7fdef | ||
|
|
8b2007a11d | ||
|
|
d181d819b0 | ||
|
|
1042fbd283 | ||
|
|
f1ffdd31af | ||
|
|
3b7a77c45b | ||
|
|
7fdb48817f |
+17
-2
@@ -38,8 +38,8 @@ android {
|
||||
applicationId "com.arpa.hndahesudintocctmsdriver"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 30
|
||||
versionCode 73
|
||||
versionName "3.4.3"
|
||||
versionCode 75
|
||||
versionName "3.4.5"
|
||||
flavorDimensions "CHANNEL_VALUE"
|
||||
flavorDimensions "app_icon"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
@@ -127,6 +127,21 @@ android {
|
||||
//APP名称,可以在androidMainfest中引用
|
||||
resValue "string", "appName", "大河好运司机"
|
||||
}
|
||||
productbc {
|
||||
applicationId "com.arpa.hndahesudintocctmsdriver.bc"
|
||||
manifestPlaceholders = [CHANNEL_VALUE: "大河好运司机",
|
||||
app_icon : "@drawable/diver_logo",
|
||||
GAODEKEY : "f960bc6d14788238918bd014fa08a870",
|
||||
JPUSH_PKGNAME: applicationId,
|
||||
JPUSH_APPKEY : "fba6f55621c670d8c1fe9191", //JPush 上注册的包名对应的 Appkey.
|
||||
JPUSH_CHANNEL: "developer-default"//暂时填写默认值即可.
|
||||
]
|
||||
buildConfigField("String", "OPEN_AL_URL", "\"https://oapi.alct56.com\"")
|
||||
buildConfigField("String", "BASE_URL", "\"http://app.dahehuoyun.com/api/\"")
|
||||
buildConfigField "boolean", "isTest", "false"
|
||||
//APP名称,可以在androidMainfest中引用
|
||||
resValue "string", "appName", "大河好运司机"
|
||||
}
|
||||
|
||||
}
|
||||
// productFlavors.all { flavor ->
|
||||
|
||||
@@ -51,11 +51,11 @@
|
||||
android:required="true" />
|
||||
<uses-permission android:name="android.permission.NFC" />
|
||||
<application
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.App"
|
||||
android:name=".App"
|
||||
android:allowBackup="true"
|
||||
android:excludeFromRecents="true"
|
||||
android:icon="@mipmap/diver_logo"
|
||||
android:label="@string/appName"
|
||||
android:label="运营端"
|
||||
android:largeHeap="true"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:supportsRtl="true"
|
||||
@@ -100,7 +100,7 @@
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.auth.VehicleAuthActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.home.shangchuan.ShangChuangImgActivity"
|
||||
android:name=".ui.home.shangchuan.ShangChuangImgActivity"
|
||||
android:screenOrientation="portrait">
|
||||
|
||||
<intent-filter>
|
||||
@@ -114,7 +114,7 @@
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.home.shangchuan.ShangChuangImgActivityBC"
|
||||
android:name=".ui.home.shangchuan.ShangChuangImgActivityBC"
|
||||
android:screenOrientation="portrait">
|
||||
|
||||
<intent-filter>
|
||||
@@ -129,7 +129,7 @@
|
||||
|
||||
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.home.shangchuan.ShangChuangImgActivity2"
|
||||
android:name=".ui.home.shangchuan.ShangChuangImgActivity2"
|
||||
android:screenOrientation="portrait">
|
||||
|
||||
<intent-filter>
|
||||
@@ -142,7 +142,7 @@
|
||||
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.home.shangchuan.GetShangChuanActivity"
|
||||
android:name=".ui.home.shangchuan.GetShangChuanActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.auth.AuthQualificationActivity"
|
||||
|
||||
@@ -63,8 +63,8 @@ public class App extends Application {
|
||||
}
|
||||
//在使用SDK各组件之前初始化context信息,传入ApplicationContext
|
||||
// 路由初始化
|
||||
JVerificationInterface.setDebugMode(true);
|
||||
JVerificationInterface.init(this, 5000, (code, msg) -> Log.d("tag", "code = " + code + " msg = " + msg));
|
||||
// JVerificationInterface.setDebugMode(true);
|
||||
// JVerificationInterface.init(this, 5000, (code, msg) -> Log.d("tag", "code = " + code + " msg = " + msg));
|
||||
//友盟
|
||||
//设置非debug版本开启
|
||||
if (!isDebugVersion(con)) {
|
||||
|
||||
@@ -242,7 +242,7 @@ public class H5Activity extends AppCompatActivity {
|
||||
} catch (Exception e) {
|
||||
}
|
||||
// }else if (url.startsWith("https://agreement.dahehuoyun.com/#/1ba5c216/912f4c9587/5eb5184653/6ef9")) {
|
||||
} else if (url.startsWith("https://agreement.dahehuoyun.com/goApp")) {
|
||||
} else if (url.startsWith("https://agreement.dahehuoyun.com")) {
|
||||
Intent in = new Intent(ctx, FaceSuccActivity.class);
|
||||
startActivity(in);
|
||||
if (isGoCar) {
|
||||
@@ -271,7 +271,7 @@ public class H5Activity extends AppCompatActivity {
|
||||
Log.e("test", "要加载的地址:" + uri.getScheme() + " " + url + " ");
|
||||
if (uri.getScheme().equals("http") || uri.getScheme().equals("https")) {
|
||||
// if (url.startsWith("https://agreement.dahehuoyun.com/#/1ba5c216/912f4c9587/5eb5184653/6ef9")) {
|
||||
if (url.startsWith("https://agreement.dahehuoyun.com/goApp")) {
|
||||
if (url.startsWith("https://agreement.dahehuoyun.com")) {
|
||||
Intent in = new Intent(ctx, FaceSuccActivity.class);
|
||||
in.putExtra("isGoCar", isGoCar);
|
||||
startActivity(in);
|
||||
@@ -354,11 +354,11 @@ public class H5Activity extends AppCompatActivity {
|
||||
if (status) {
|
||||
//认证成功返回
|
||||
//认证成功返回
|
||||
new Handler().postDelayed(() -> {
|
||||
FaceEvent he = new FaceEvent("刷脸成功");
|
||||
EventBus.getDefault().post(he);
|
||||
finish();
|
||||
}, 800);
|
||||
// new Handler().postDelayed(() -> {
|
||||
// FaceEvent he = new FaceEvent("刷脸成功");
|
||||
// EventBus.getDefault().post(he);
|
||||
// finish();
|
||||
// }, 800);
|
||||
Toast.makeText(H5Activity.this, "认证成功", Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
|
||||
@@ -83,6 +83,8 @@ public class HuoYuanDelBean {
|
||||
private String vehicleTypeName;
|
||||
private int vehicleLength;
|
||||
private String vehicleLengthName;
|
||||
private String carNumber;
|
||||
private String carId;
|
||||
private String namedDrivers;
|
||||
private String requirement;
|
||||
private String totalFreight;
|
||||
@@ -97,6 +99,23 @@ public class HuoYuanDelBean {
|
||||
private Object contactName;
|
||||
private Object contactPhone;
|
||||
|
||||
|
||||
public String getCarNumber() {
|
||||
return carNumber == null ? "" : carNumber;
|
||||
}
|
||||
|
||||
public void setCarNumber(String carNumber) {
|
||||
this.carNumber = carNumber;
|
||||
}
|
||||
|
||||
public String getCarId() {
|
||||
return carId == null ? "" : carId;
|
||||
}
|
||||
|
||||
public void setCarId(String carId) {
|
||||
this.carId = carId;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -80,6 +80,12 @@ public class UserRequset {
|
||||
RequestUtil.start(1, "userdata", re, con, hd);
|
||||
}
|
||||
|
||||
//账户信息
|
||||
public void User2() {
|
||||
Request re = OkHttpUtil.posts(new OkDate(RequestConstant.getUserUrl(), ""), getToken(con), con);
|
||||
RequestUtil.start(1, "userdata2", re, con, hd);
|
||||
}
|
||||
|
||||
//司机认证信息
|
||||
public void driverAuthData() {
|
||||
String mt = "{}";
|
||||
|
||||
@@ -69,18 +69,18 @@ public class TrackService extends Service {
|
||||
con = this;
|
||||
hyr = new HuoYuanRequset(con, hd);
|
||||
Log.e("开始循环上传,等待100ms", "-----");
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
snn = SPUtil.getSP(con, "order", "ShippingNoteNumber");
|
||||
if (!snn.equals("")) {
|
||||
l = new LocationGDUtil(con, hd);
|
||||
l.onCreate();
|
||||
} else {
|
||||
onDestroy();
|
||||
}
|
||||
}
|
||||
}, 100, timeSum);
|
||||
// new Timer().schedule(new TimerTask() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// snn = SPUtil.getSP(con, "order", "ShippingNoteNumber");
|
||||
// if (!snn.equals("")) {
|
||||
// l = new LocationGDUtil(con, hd);
|
||||
// l.onCreate();
|
||||
// } else {
|
||||
// onDestroy();
|
||||
// }
|
||||
// }
|
||||
// }, 100, timeSum);
|
||||
}
|
||||
|
||||
//开始
|
||||
@@ -97,18 +97,18 @@ public class TrackService extends Service {
|
||||
}
|
||||
|
||||
public void genzong() {
|
||||
if (l == null || l.getLatitude() == 0d) {
|
||||
return;
|
||||
}
|
||||
//经度
|
||||
tib.setLatitude(l.getLatitude() + "");
|
||||
//纬度
|
||||
tib.setLongitude(l.getLongitude() + "");
|
||||
Log.e("经度", l.getLatitude() + "");
|
||||
Log.e("维度", l.getLongitude() + "");
|
||||
//单号
|
||||
tib.setShippingNoteNumber(snn);
|
||||
hyr.trackTracking(tib);
|
||||
// if (l == null || l.getLatitude() == 0d) {
|
||||
// return;
|
||||
// }
|
||||
// //经度
|
||||
// tib.setLatitude(l.getLatitude() + "");
|
||||
// //纬度
|
||||
// tib.setLongitude(l.getLongitude() + "");
|
||||
// Log.e("经度", l.getLatitude() + "");
|
||||
// Log.e("维度", l.getLongitude() + "");
|
||||
// //单号
|
||||
// tib.setShippingNoteNumber(snn);
|
||||
// hyr.trackTracking(tib);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class UiAuxiliary {
|
||||
}
|
||||
|
||||
public static void delLogin(Context con){
|
||||
JPushInterface.deleteAlias(con,0);
|
||||
// JPushInterface.deleteAlias(con,0);
|
||||
SPUtils.remove(con,"curWaybillId");
|
||||
SPUtil.insSP(con,LoginActivity.USER,LoginActivity.USER_TOKEN,"");
|
||||
SPUtil.insSP(con,LoginActivity.USER,LoginActivity.USER_UNAME,"");
|
||||
|
||||
@@ -8,11 +8,14 @@ import android.widget.Button;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.arpa.hndahesudintocctmsdriver.R;
|
||||
import com.arpa.hndahesudintocctmsdriver.event.PersonEvent;
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.MainActivity;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.statusbar.StateStyleUtil;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.view.BaseAppCompatActivity;
|
||||
import com.dahe.mylibrary.utils.ActivityUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
/**
|
||||
* @ClassName FaceSuccActivity
|
||||
* @Author john
|
||||
@@ -31,15 +34,17 @@ public class FaceSuccActivity extends BaseAppCompatActivity {
|
||||
Button btnHome = findViewById(R.id.btnHome);
|
||||
Button btnAddCar = findViewById(R.id.btnAddCar);
|
||||
boolean isGoCar = getIntent().getBooleanExtra("isGoCar", false);
|
||||
if (isGoCar){
|
||||
if (isGoCar) {
|
||||
btnHome.setText("返回首页");
|
||||
btnAddCar.setVisibility(View.VISIBLE);
|
||||
}else{
|
||||
} else {
|
||||
btnHome.setText("返回");
|
||||
btnAddCar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
btnHome.setOnClickListener(v -> finish());
|
||||
btnHome.setOnClickListener(v -> {
|
||||
finish();
|
||||
});
|
||||
btnAddCar.setOnClickListener(v -> {
|
||||
Intent in = new Intent(con, CertificatesActivity.class);
|
||||
in.putExtra("index", 2);
|
||||
@@ -48,4 +53,10 @@ public class FaceSuccActivity extends BaseAppCompatActivity {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
EventBus.getDefault().post(new PersonEvent("刷脸成功"));
|
||||
}
|
||||
}
|
||||
|
||||
+28
-6
@@ -1,5 +1,7 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.ui.auth;
|
||||
|
||||
import static com.sdk.base.framework.utils.app.AppUtils.getPackageName;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
@@ -75,15 +77,15 @@ public class PersonalAuthActivity extends BaseAppCompatActivity {
|
||||
super.msgMethod(m);
|
||||
switch (m.what) {
|
||||
case RequsetCodeConstants.SUCCESS:
|
||||
if (CacheGroup.cacheList.get("userdata") != null) {
|
||||
ub = gson.fromJson(CacheGroup.cacheList.get("userdata"), UserBean.class);
|
||||
if (CacheGroup.cacheList.get("userdata2") != null) {
|
||||
ub = gson.fromJson(CacheGroup.cacheList.get("userdata2"), UserBean.class);
|
||||
if (ub.getCode() == 200) {
|
||||
initView(ub);
|
||||
SPUtil.insSP(con, "data", "userdata", CacheGroup.cacheList.get("userdata"));
|
||||
SPUtil.insSP(con, "data", "userdata", CacheGroup.cacheList.get("userdata2"));
|
||||
} else {
|
||||
Toast.makeText(con, ub.getMsg(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
CacheGroup.cacheList.remove("userdata");
|
||||
CacheGroup.cacheList.remove("userdata2");
|
||||
}
|
||||
if (CacheGroup.cacheList.get("upload") != null) {
|
||||
upb = gson.fromJson(CacheGroup.cacheList.get("upload"), UploadBean.class);
|
||||
@@ -208,7 +210,22 @@ public class PersonalAuthActivity extends BaseAppCompatActivity {
|
||||
});
|
||||
//头像
|
||||
up_img.setOnClickListener(v -> {
|
||||
PermissionUtils.Companion.getInstance().showPermissionMessage(this, "拍摄,媒体查询权限使用说明", "用于拍照或者选择图片用于上传头像功能",
|
||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.CAMERA},
|
||||
(allGranted, grantedList, deniedList) -> {
|
||||
if (allGranted) {
|
||||
gia.showPopueWindow(this);
|
||||
} else {
|
||||
new MessageUtils().showSimCenPop(con, "缺少拍摄,媒体查询权限,将无法为您提供服务,去开启!", "取消", "确认", () -> {
|
||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
Uri uri = Uri.fromParts("package", getPackageName(), null);
|
||||
intent.setData(uri);
|
||||
startActivity(intent);
|
||||
});
|
||||
// Toast.makeText(act.getBaseContext(), "请先开启定位权限", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
up_head.setOnClickListener(v -> {
|
||||
if (ub.getData().getHeadportraitUrl() != null && !ub.getData().getHeadportraitUrl().equals("")) {
|
||||
@@ -222,10 +239,15 @@ public class PersonalAuthActivity extends BaseAppCompatActivity {
|
||||
});
|
||||
hyr = new HuoYuanRequset(con, hd);
|
||||
ur = new UserRequset(con, hd);
|
||||
ur.User();
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
ur.User2();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
@@ -249,7 +271,7 @@ public class PersonalAuthActivity extends BaseAppCompatActivity {
|
||||
public void personResult(PersonEvent home) {
|
||||
Log.e("-res-", home.getMessage());
|
||||
if (ur != null) {
|
||||
ur.User();
|
||||
ur.User2();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ import com.arpa.hndahesudintocctmsdriver.report.JTTProcess;
|
||||
import com.arpa.hndahesudintocctmsdriver.request.WalletRequest;
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.auth.CertificatesActivity;
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.home.shangchuan.ShangChuangImgActivity;
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.home.shangchuan.ShangChuangImgActivityBC;
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.news.NewActivity;
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.wallet.UpBankActivity;
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.web.WebOnlyOneActivity;
|
||||
@@ -726,14 +727,14 @@ public class HomeFragment extends BaseFragment {
|
||||
int zStatus = zData.getStatus();
|
||||
int xStatus = xData.getStatus();
|
||||
if (zStatus == 0) {//未装货
|
||||
Intent in = new Intent(con, ShangChuangImgActivity.class);
|
||||
Intent in = new Intent(con, ShangChuangImgActivityBC.class);
|
||||
in.putExtra("type", 0);
|
||||
in.putExtra("wid", zData.getId() + "");
|
||||
in.putExtra("sob", gson.toJson(sob));
|
||||
in.putExtra("keys", true);
|
||||
startActivity(in);
|
||||
} else if (zStatus == 1 && xStatus == 4) {//已装货未上传回单
|
||||
Intent in = new Intent(con, ShangChuangImgActivity.class);
|
||||
Intent in = new Intent(con, ShangChuangImgActivityBC.class);
|
||||
in.putExtra("type", 2);
|
||||
in.putExtra("wid", zData.getId() + "");
|
||||
in.putExtra("h_type", 0);
|
||||
@@ -742,7 +743,7 @@ public class HomeFragment extends BaseFragment {
|
||||
} else if (zStatus == 3 && xStatus == 4) {//已上传装货回单,未卸货
|
||||
int dis = TimeUtil.compareNowDate(TimeUtil.string2Millis(zData.getImageTakenDate(), TimeUtil.DEFAULT_FORMAT4));
|
||||
if (dis > 5) {//大于五分钟可以接单
|
||||
Intent in = new Intent(con, ShangChuangImgActivity.class);
|
||||
Intent in = new Intent(con, ShangChuangImgActivityBC.class);
|
||||
in.putExtra("type", 1);
|
||||
in.putExtra("wid", xData.getId() + "");
|
||||
in.putExtra("sob", gson.toJson(sob));
|
||||
@@ -753,7 +754,7 @@ public class HomeFragment extends BaseFragment {
|
||||
}
|
||||
|
||||
} else if (zStatus == 3 && xStatus == 2) {//已卸货,未上传卸货回单
|
||||
Intent in = new Intent(con, ShangChuangImgActivity.class);
|
||||
Intent in = new Intent(con, ShangChuangImgActivityBC.class);
|
||||
in.putExtra("type", 2);
|
||||
in.putExtra("wid", xData.getId() + "");
|
||||
in.putExtra("h_type", 1);
|
||||
@@ -869,8 +870,8 @@ public class HomeFragment extends BaseFragment {
|
||||
orderNum.setText("运单号:" + sob.getData().getShippingNoteNumber());
|
||||
order_state.setText("" + sob.getData().getWaybillStatus());
|
||||
try {
|
||||
Intent serviceIn = new Intent(con, TrackService.class);
|
||||
getActivity().startService(serviceIn);
|
||||
// Intent serviceIn = new Intent(con, TrackService.class);
|
||||
// getActivity().startService(serviceIn);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -231,8 +231,8 @@ public class HuoYuanFragmengt extends BaseFragment {
|
||||
if(sob!=null && sob.getData()!=null && sob.getData().getWayChildren().size()>0){
|
||||
SPUtil.insSP(con,"order","ShippingNoteNumber",sob.getData().getShippingNoteNumber());
|
||||
Log.e("开始轨迹上传服务","-----");
|
||||
Intent serviceIn=new Intent(con,TrackService.class);
|
||||
getActivity().startService(serviceIn);
|
||||
// Intent serviceIn=new Intent(con,TrackService.class);
|
||||
// getActivity().startService(serviceIn);
|
||||
list.add(new ManyBean(sob.getData(),R.layout.huoyuan_yundan));
|
||||
}else{
|
||||
SPUtil.insSP(con,"order","ShippingNoteNumber","");
|
||||
|
||||
@@ -315,7 +315,11 @@ public class HuoYunDelActivity extends BaseAppCompatActivity {
|
||||
});
|
||||
//
|
||||
ImageButton xuanze = v.findViewById(R.id.xuanze);
|
||||
if (clb != null && clb.getData().size() == 1) {
|
||||
|
||||
if (hyd!=null&&hyd.getData()!=null&& !TextUtils.isEmpty(hyd.getData().getCarNumber())){
|
||||
cid = hyd.getData().getCarId();
|
||||
car.setText("选择车辆:" + hyd.getData().getCarNumber());
|
||||
}else if (clb != null && clb.getData().size() == 1) {
|
||||
cid = clb.getData().get(0).getCarId();
|
||||
car.setText("选择车辆:" + clb.getData().get(0).getCarNumber());
|
||||
}
|
||||
@@ -408,6 +412,7 @@ public class HuoYunDelActivity extends BaseAppCompatActivity {
|
||||
|
||||
UiAuxiliary.homeRequest("接单");
|
||||
Intent in = new Intent(con, StartYunDanActivity.class);
|
||||
in.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
in.putExtra("id", "0");
|
||||
startActivity(in);
|
||||
finish();
|
||||
@@ -534,4 +539,9 @@ public class HuoYunDelActivity extends BaseAppCompatActivity {
|
||||
// ALProcess.verification(con, hd);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-4
@@ -41,6 +41,7 @@ import com.amap.api.services.route.DriveStep;
|
||||
import com.amap.api.services.route.RideRouteResult;
|
||||
import com.amap.api.services.route.RouteSearch;
|
||||
import com.amap.api.services.route.WalkRouteResult;
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.home.shangchuan.ShangChuangImgActivityBC;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.alert.CustomDialog;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.alert.ToastUtil;
|
||||
import com.bumptech.glide.Glide;
|
||||
@@ -385,7 +386,7 @@ public class StartYunDanActivity extends BaseActivity {
|
||||
String wid = sdw.getId() + "";
|
||||
if (sdw.getStatus() == 0) {
|
||||
if (type == 0) {
|
||||
Intent in = new Intent(con, ShangChuangImgActivity.class);
|
||||
Intent in = new Intent(con, ShangChuangImgActivityBC.class);
|
||||
in.putExtra("type", type);
|
||||
in.putExtra("wid", wid);
|
||||
in.putExtra("sob", gson.toJson(sob));
|
||||
@@ -395,14 +396,14 @@ public class StartYunDanActivity extends BaseActivity {
|
||||
Toast.makeText(con, "您还没有装货", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} else if (sdw.getStatus() == 1) {//装货回单
|
||||
Intent in = new Intent(con, ShangChuangImgActivity.class);
|
||||
Intent in = new Intent(con, ShangChuangImgActivityBC.class);
|
||||
in.putExtra("type", 2);
|
||||
in.putExtra("wid", wid);
|
||||
in.putExtra("h_type", type);
|
||||
in.putExtra("sob", gson.toJson(sob));
|
||||
startActivity(in);
|
||||
} else if (sdw.getStatus() == 2) {//上传收货单(卸货回单)
|
||||
Intent in = new Intent(con, ShangChuangImgActivity.class);
|
||||
Intent in = new Intent(con, ShangChuangImgActivityBC.class);
|
||||
in.putExtra("type", 2);
|
||||
in.putExtra("wid", wid);
|
||||
in.putExtra("h_type", type);
|
||||
@@ -421,7 +422,7 @@ public class StartYunDanActivity extends BaseActivity {
|
||||
if (zInfo.getReceiptUrl() != null && zInfo.getReceiptUrl().size() > 0) {
|
||||
int dis = TimeUtil.compareNowDate(TimeUtil.string2Millis(zInfo.getImageTakenDate(), TimeUtil.DEFAULT_FORMAT4));
|
||||
if (dis > 5) {//大于五分钟可以接单
|
||||
Intent in = new Intent(con, ShangChuangImgActivity.class);
|
||||
Intent in = new Intent(con, ShangChuangImgActivityBC.class);
|
||||
in.putExtra("type", type);
|
||||
in.putExtra("wid", wid);
|
||||
in.putExtra("sob", gson.toJson(sob));
|
||||
|
||||
+92
-28
@@ -18,6 +18,7 @@ import android.widget.Toast;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alct.mdp.MDPLocationCollectionManager;
|
||||
import com.alct.mdp.callback.OnDownloadResultListener;
|
||||
import com.alct.mdp.callback.OnResultListener;
|
||||
import com.alct.mdp.model.Goods;
|
||||
import com.alct.mdp.model.Image;
|
||||
@@ -42,6 +43,7 @@ import com.arpa.hndahesudintocctmsdriver.report.JTTProcess;
|
||||
import com.arpa.hndahesudintocctmsdriver.request.HuoYuanRequset;
|
||||
import com.arpa.hndahesudintocctmsdriver.request.OCRRequest;
|
||||
import com.arpa.hndahesudintocctmsdriver.request.bean.LUInputBean;
|
||||
import com.arpa.hndahesudintocctmsdriver.request.bean.TrackInputBean;
|
||||
import com.arpa.hndahesudintocctmsdriver.request.bean.UploadReceiptInputBean;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.BitmapUtil;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.MessageUtils;
|
||||
@@ -259,6 +261,15 @@ public class ShangChuangImgActivityBC extends BaseAppCompatActivity implements I
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (CacheGroup.cacheList.get("genzong") != null) {
|
||||
BaseBean bb = gson.fromJson(CacheGroup.cacheList.get("genzong"), BaseBean.class);
|
||||
if (bb.getCode() == 200) {
|
||||
Log.e("--轨迹上传--", "成功");
|
||||
} else {
|
||||
Log.e("--轨迹上传失败:--", bb.getMsg());
|
||||
}
|
||||
CacheGroup.cacheList.remove("genzong");
|
||||
}
|
||||
if (CacheGroup.cacheList.get("carName") != null) {
|
||||
BaseBean bb = gson.fromJson(CacheGroup.cacheList.get("carName"), BaseBean.class);
|
||||
if (bb.getCode() == 200) {
|
||||
@@ -376,14 +387,14 @@ public class ShangChuangImgActivityBC extends BaseAppCompatActivity implements I
|
||||
initView(null);
|
||||
customDialog = new CustomDialog(con, "正在定位当前位置...");
|
||||
customDialog.show();
|
||||
lgdu = new LocationGDUtil(con, hd);
|
||||
//启动定位
|
||||
lgdu.onCreate();
|
||||
// lgdu = new LocationGDUtil(con, hd);
|
||||
// //启动定位
|
||||
// lgdu.onCreate();
|
||||
tv_loaction.setOnClickListener(v -> {
|
||||
if (!locationKey) {
|
||||
customDialog.show();
|
||||
lgdu.onCreate();
|
||||
}
|
||||
// if (!locationKey) {
|
||||
// customDialog.show();
|
||||
// lgdu.onCreate();
|
||||
// }
|
||||
});
|
||||
|
||||
btnOk.setOnClickListener(v -> {
|
||||
@@ -504,7 +515,7 @@ public class ShangChuangImgActivityBC extends BaseAppCompatActivity implements I
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isFinish = false;
|
||||
public void initLocation() {
|
||||
address.setText(lgdu.getAddress());
|
||||
}
|
||||
@@ -523,17 +534,38 @@ public class ShangChuangImgActivityBC extends BaseAppCompatActivity implements I
|
||||
lub.setImageId(imgIds);
|
||||
lub.setWaybillId(wid);
|
||||
Log.e("--装货信息", gson.toJson(lub));
|
||||
if (locationKey) {//高德定位
|
||||
// if (locationKey) {//高德定位
|
||||
if (keys) {
|
||||
MDPLocationCollectionManager.getShipmentStatus(con, sob.getData().getShippingNoteNumber(), new OnDownloadResultListener() {
|
||||
@Override
|
||||
public void onSuccess(Object o) {
|
||||
|
||||
String string = o.toString();
|
||||
if (string.equals("PICKUPED")) {//安联装货,单平台未装货
|
||||
isFinish = true;
|
||||
//平台确认装货
|
||||
hyr.loading(lub);
|
||||
} else {
|
||||
nfc();
|
||||
loadInfo();
|
||||
// up_traffic_start();
|
||||
// up_image_z();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(con, "定位异常,请重新定位", Toast.LENGTH_SHORT).show();
|
||||
|
||||
upLocation(tempLoca.getLatitude()+"",tempLoca.getLongitude()+"",sob.getData().getShippingNoteNumber());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String s, String s1) {
|
||||
if (!isFinishing() && customDialog != null && customDialog.isShowing()) {
|
||||
customDialog.dismiss();
|
||||
}
|
||||
ToastUtils.showToast(con, s1);
|
||||
}
|
||||
});
|
||||
}
|
||||
// } else {
|
||||
// Toast.makeText(con, "定位异常,请重新定位", Toast.LENGTH_SHORT).show();
|
||||
// }
|
||||
|
||||
} else {
|
||||
Toast.makeText(con, "图片上传异常,请重新上传", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
@@ -548,10 +580,36 @@ public class ShangChuangImgActivityBC extends BaseAppCompatActivity implements I
|
||||
lub.setWaybillId(wid);
|
||||
lub.setRealLoadTime(tempLoca.getTime());
|
||||
Log.e("--卸货信息", gson.toJson(lub));
|
||||
if (locationKey&&!TextUtils.isEmpty(tempLoca.address)) {
|
||||
// if (locationKey&&!TextUtils.isEmpty(tempLoca.address)) {
|
||||
if (!TextUtils.isEmpty(tempLoca.address)) {
|
||||
if (keys) {
|
||||
MDPLocationCollectionManager.getShipmentStatus(con, sob.getData().getShippingNoteNumber(), new OnDownloadResultListener() {
|
||||
@Override
|
||||
public void onSuccess(Object o) {
|
||||
if (o.toString().equals("UNLOADED")) {//安联装货,单平台未装货
|
||||
//卸货状态-平台
|
||||
isFinish = true;
|
||||
hyr.dischargeCargo(lub);
|
||||
} else {
|
||||
nfc();
|
||||
uploadInfo();
|
||||
}
|
||||
upLocation(tempLoca.getLatitude()+"",tempLoca.getLongitude()+"",sob.getData().getShippingNoteNumber());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String s, String s1) {
|
||||
if (!isFinishing() && customDialog != null && customDialog.isShowing()) {
|
||||
customDialog.dismiss();
|
||||
}
|
||||
ToastUtils.showToast(con, s1);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
// nfc();
|
||||
// uploadInfo();
|
||||
|
||||
}
|
||||
|
||||
@@ -566,9 +624,9 @@ public class ShangChuangImgActivityBC extends BaseAppCompatActivity implements I
|
||||
case 2:
|
||||
if (imgIds != null && imgIds.size() > 0) {//卸货回单
|
||||
//上传回单
|
||||
urib.setLatitude(lgdu.getLatitude() + "");
|
||||
urib.setLongitude(lgdu.getLongitude() + "");
|
||||
urib.setLocationAddress(lgdu.getAddress());
|
||||
urib.setLatitude(tempLoca.getLatitude() + "");
|
||||
urib.setLongitude(tempLoca.getLongitude() + "");
|
||||
urib.setLocationAddress(tempLoca.getAddress());
|
||||
//装卸货类型
|
||||
urib.setType(h_type + 1);
|
||||
//回单id 数组
|
||||
@@ -576,16 +634,16 @@ public class ShangChuangImgActivityBC extends BaseAppCompatActivity implements I
|
||||
//子运运单ID
|
||||
urib.setWaybillId(wid);
|
||||
Log.e("--回单信息", gson.toJson(urib));
|
||||
if (locationKey) {
|
||||
// if (locationKey) {
|
||||
if (index == 2 && keys && !TextUtils.isEmpty(tempLoca.address)) {
|
||||
up_trafficSign();
|
||||
up_trafficReceipt();
|
||||
receipt_image();
|
||||
}
|
||||
hyr.receipt(urib);
|
||||
} else {
|
||||
Toast.makeText(con, "定位异常,请重新定位", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
// } else {
|
||||
// Toast.makeText(con, "定位异常,请重新定位", Toast.LENGTH_SHORT).show();
|
||||
// }
|
||||
} else {
|
||||
Toast.makeText(con, "图片上传异常,请重新上传", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
@@ -827,9 +885,9 @@ public class ShangChuangImgActivityBC extends BaseAppCompatActivity implements I
|
||||
public void onSuccess() {
|
||||
Log.e("上报安联", "装货上传成功");
|
||||
//交通厅
|
||||
if (sob.getData().getReport() == 1) {
|
||||
JTTProcess.start(con, sob, "");
|
||||
}
|
||||
// if (sob.getData().getReport() == 1) {
|
||||
// JTTProcess.start(con, sob, "");
|
||||
// }
|
||||
//装货状态
|
||||
hyr.loading(lub);
|
||||
//装货照片
|
||||
@@ -864,9 +922,9 @@ public class ShangChuangImgActivityBC extends BaseAppCompatActivity implements I
|
||||
public void onSuccess() {
|
||||
Log.e("上报安联", "卸货上传成功");
|
||||
//交通厅
|
||||
if (sob.getData().getReport() == 1) {
|
||||
JTTProcess.stop(con, sob, "");
|
||||
}
|
||||
// if (sob.getData().getReport() == 1) {
|
||||
// JTTProcess.stop(con, sob, "");
|
||||
// }
|
||||
//卸货状态-平台
|
||||
hyr.dischargeCargo4(lub);
|
||||
//卸货照片-安联
|
||||
@@ -885,5 +943,11 @@ public class ShangChuangImgActivityBC extends BaseAppCompatActivity implements I
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void upLocation(String lat,String lon,String shippingNoteNumber){
|
||||
TrackInputBean tib = new TrackInputBean();
|
||||
tib.setLatitude(lat);
|
||||
tib.setLongitude(lon);
|
||||
tib.setShippingNoteNumber(shippingNoteNumber);
|
||||
hyr.trackTracking(tib);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public class WebPDFActivity extends BaseActivity {
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
super.onPostExecute(aVoid);
|
||||
pdf_view.fromStream(input[0])
|
||||
.pages(0,1) // all pages are displayed by default
|
||||
// .pages(0,1,2,3,4,5,6,7) // all pages are displayed by default
|
||||
.enableAnnotationRendering(true)
|
||||
.load();
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class LoginActivity extends BaseActivity {
|
||||
SPUtil.insSP(con, USER, USER_UNAME, loginBean.getData().getUname());
|
||||
SPUtil.insSP(con, USER, USER_RNAME, loginBean.getData().getRname());
|
||||
SPUtil.insSP(con, USER, USER_ID, loginBean.getData().getId() + "");
|
||||
JPushInterface.setAlias(con, 0, loginBean.getData().getUname());
|
||||
// JPushInterface.setAlias(con, 0, loginBean.getData().getUname());
|
||||
appInfoBean.setStatus("0");
|
||||
appInfoBean.setUserPhone(String.valueOf(input_phone.getText()));
|
||||
ur.postAppInfo(appInfoBean, "post");
|
||||
|
||||
@@ -346,8 +346,8 @@ public class WelcomeActivity extends BaseAppCompatActivity {
|
||||
}
|
||||
//在使用SDK各组件之前初始化context信息,传入ApplicationContext
|
||||
// 路由初始化
|
||||
JVerificationInterface.setDebugMode(true);
|
||||
JVerificationInterface.init(con, 5000, (code, msg) -> Log.d("tag", "code = " + code + " msg = " + msg));
|
||||
// JVerificationInterface.setDebugMode(true);
|
||||
// JVerificationInterface.init(con, 5000, (code, msg) -> Log.d("tag", "code = " + code + " msg = " + msg));
|
||||
//友盟
|
||||
//设置非debug版本开启
|
||||
if (!isDebugVersion(con)) {
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.arpa.hndahesudintocctmsdriver.ui.business.BusinessActivity;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.PicturlUtil;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.dahe.mylibrary.utils.ImageLoader;
|
||||
import com.dahe.mylibrary.utils.ToastUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
|
||||
@@ -51,6 +52,7 @@ import com.permissionx.guolindev.PermissionX;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -344,11 +346,19 @@ public class MyFragment extends BaseFragment {
|
||||
ur.vehicleList("1");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void personResult(PersonEvent home) {
|
||||
Log.e("-res-", home.getMessage());
|
||||
if (ur != null) {
|
||||
ur.User();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (ur != null) {
|
||||
ur.User();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,9 +74,9 @@ public class SetupActivity extends BaseActivity {
|
||||
ConfigBean cb= ConfigParts.getConfigParts(con);
|
||||
if(cb!=null){
|
||||
// url1=cb.getData().getUserUrl();
|
||||
url1="http://agreement.dahehuoyun.com/rule/serviceAgreement/dist/index.html#/";
|
||||
url1="https://agreement.dahehuoyun.com/rule/serviceAgreement/dist/index.html#/";
|
||||
// url2=cb.getData().getPrivateUrl();
|
||||
url2="http://agreement.dahehuoyun.com/currency/#/";
|
||||
url2="https://agreement.dahehuoyun.com/currency/#/";
|
||||
kefu=cb.getData().getServiceMobile();
|
||||
url3=cb.getData().getSecurityUrl();
|
||||
}
|
||||
|
||||
@@ -102,8 +102,8 @@ public class BillLocationUtils {
|
||||
//order_start.setVisibility(View.VISIBLE);
|
||||
SPUtil.insSP(con, "order", "ShippingNoteNumber", sob.getData().getShippingNoteNumber());
|
||||
Log.e("开始轨迹上传服务", "-----");
|
||||
Intent serviceIn = new Intent(con, TrackService.class);
|
||||
con.startService(serviceIn);
|
||||
// Intent serviceIn = new Intent(con, TrackService.class);
|
||||
// con.startService(serviceIn);
|
||||
} else {
|
||||
SPUtil.insSP(con, "order", "ShippingNoteNumber", "");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.dahe.mylibrary.utils;
|
||||
|
||||
/**
|
||||
* @ClassName Gps
|
||||
* @Author john
|
||||
* @Date 2024/12/13 17:25
|
||||
* @Description TODO
|
||||
*/
|
||||
public class Gps {
|
||||
private double wgLon;
|
||||
private double wgLat;
|
||||
|
||||
public Gps(double wgLat,double wgLon) {
|
||||
this.wgLat = wgLat;
|
||||
this.wgLon = wgLon;
|
||||
}
|
||||
|
||||
public double getWgLon() {
|
||||
return wgLon;
|
||||
}
|
||||
|
||||
public void setWgLon(double wgLon) {
|
||||
this.wgLon = wgLon;
|
||||
}
|
||||
|
||||
public double getWgLat() {
|
||||
return wgLat;
|
||||
}
|
||||
|
||||
public void setWgLat(double wgLat) {
|
||||
this.wgLat = wgLat;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,539 @@
|
||||
package com.dahe.mylibrary.utils;
|
||||
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Address;
|
||||
import android.location.Criteria;
|
||||
import android.location.Geocoder;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.location.LocationProvider;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* @author ondear
|
||||
* time : 16/11/13
|
||||
* desc : 定位相关工具类
|
||||
*/
|
||||
public class RxLocationUtils {
|
||||
|
||||
public static double pi = 3.1415926535897932384626;
|
||||
public static double a = 6378245.0;
|
||||
public static double ee = 0.00669342162296594323;
|
||||
private static OnLocationChangeListener mListener;
|
||||
private static MyLocationListener myLocationListener;
|
||||
private static LocationManager mLocationManager;
|
||||
|
||||
/**
|
||||
* 判断Gps是否可用
|
||||
*
|
||||
* @return {@code true}: 是<br>{@code false}: 否
|
||||
*/
|
||||
public static boolean isGpsEnabled(Context context) {
|
||||
LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
return lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断定位是否可用
|
||||
*
|
||||
* @return {@code true}: 是<br>{@code false}: 否
|
||||
*/
|
||||
public static boolean isLocationEnabled(Context context) {
|
||||
LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
return lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER) || lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开Gps设置界面
|
||||
*/
|
||||
public static void openGpsSettings(Context context) {
|
||||
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册
|
||||
* <p>使用完记得调用{@link #unregister()}</p>
|
||||
* <p>需添加权限 {@code <uses-permission android:name="android.permission.INTERNET"/>}</p>
|
||||
* <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>}</p>
|
||||
* <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>}</p>
|
||||
* <p>如果{@code minDistance}为0,则通过{@code minTime}来定时更新;</p>
|
||||
* <p>{@code minDistance}不为0,则以{@code minDistance}为准;</p>
|
||||
* <p>两者都为0,则随时刷新。</p>
|
||||
*
|
||||
* @param minTime 位置信息更新周期(单位:毫秒)
|
||||
* @param minDistance 位置变化最小距离:当位置距离变化超过此值时,将更新位置信息(单位:米)
|
||||
* @param listener 位置刷新的回调接口
|
||||
* @return {@code true}: 初始化成功<br>{@code false}: 初始化失败
|
||||
*/
|
||||
public static boolean register(Context context, long minTime, long minDistance, OnLocationChangeListener listener) {
|
||||
if (listener == null) return false;
|
||||
if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
|
||||
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, 1);
|
||||
return false;
|
||||
}
|
||||
mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
mListener = listener;
|
||||
if (!isLocationEnabled(context)) {
|
||||
ToastUtils.showToast(context, "无法定位,请打开定位服务");
|
||||
return false;
|
||||
}
|
||||
String provider = mLocationManager.getBestProvider(getCriteria(), true);
|
||||
|
||||
Location location = mLocationManager.getLastKnownLocation(provider);
|
||||
if (location != null) listener.getLastKnownLocation(location);
|
||||
if (myLocationListener == null) myLocationListener = new MyLocationListener();
|
||||
mLocationManager.requestLocationUpdates(provider, minTime, minDistance, myLocationListener);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注销
|
||||
*/
|
||||
public static void unregister() {
|
||||
if (mLocationManager != null) {
|
||||
if (myLocationListener != null) {
|
||||
mLocationManager.removeUpdates(myLocationListener);
|
||||
myLocationListener = null;
|
||||
}
|
||||
mLocationManager = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置定位参数
|
||||
*
|
||||
* @return {@link Criteria}
|
||||
*/
|
||||
private static Criteria getCriteria() {
|
||||
Criteria criteria = new Criteria();
|
||||
//设置定位精确度 Criteria.ACCURACY_COARSE比较粗略,Criteria.ACCURACY_FINE则比较精细
|
||||
criteria.setAccuracy(Criteria.ACCURACY_FINE);
|
||||
//设置是否要求速度
|
||||
criteria.setSpeedRequired(false);
|
||||
// 设置是否允许运营商收费
|
||||
criteria.setCostAllowed(false);
|
||||
//设置是否需要方位信息
|
||||
criteria.setBearingRequired(false);
|
||||
//设置是否需要海拔信息
|
||||
criteria.setAltitudeRequired(false);
|
||||
// 设置对电源的需求
|
||||
criteria.setPowerRequirement(Criteria.POWER_LOW);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据经纬度获取地理位置
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param latitude 纬度
|
||||
* @param longitude 经度
|
||||
* @return {@link Address}
|
||||
*/
|
||||
public static Address getAddress(Context context, double latitude, double longitude) {
|
||||
Geocoder geocoder = new Geocoder(context, Locale.getDefault());
|
||||
try {
|
||||
List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
|
||||
if (addresses.size() > 0) return addresses.get(0);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据经纬度获取所在国家
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param latitude 纬度
|
||||
* @param longitude 经度
|
||||
* @return 所在国家
|
||||
*/
|
||||
public static String getCountryName(Context context, double latitude, double longitude) {
|
||||
Address address = getAddress(context, latitude, longitude);
|
||||
return address == null ? "unknown" : address.getCountryName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据经纬度获取所在地
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param latitude 纬度
|
||||
* @param longitude 经度
|
||||
* @return 所在地
|
||||
*/
|
||||
public static String getLocality(Context context, double latitude, double longitude) {
|
||||
Address address = getAddress(context, latitude, longitude);
|
||||
return address == null ? "unknown" : address.getLocality();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据经纬度获取所在街道
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param latitude 纬度
|
||||
* @param longitude 经度
|
||||
* @return 所在街道
|
||||
*/
|
||||
public static String getStreet(Context context, double latitude, double longitude) {
|
||||
Address address = getAddress(context, latitude, longitude);
|
||||
return address == null ? "unknown" : address.getAddressLine(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据经纬度获取详细地址
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param latitude 纬度
|
||||
* @param longitude 经度
|
||||
* @return 所在街道
|
||||
*/
|
||||
public static String getFeature(Context context, double latitude, double longitude) {
|
||||
Address address = getAddress(context, latitude, longitude);
|
||||
return address == null ? "未知地点" : address.getFeatureName();
|
||||
}
|
||||
|
||||
//------------------------------------------坐标转换工具start--------------------------------------
|
||||
|
||||
/**
|
||||
* GPS坐标 转换成 角度
|
||||
* 例如 113.202222 转换成 113°12′8″
|
||||
*
|
||||
* @param location
|
||||
* @return
|
||||
*/
|
||||
public static String gpsToDegree(double location) {
|
||||
double degree = Math.floor(location);
|
||||
double minute_temp = (location - degree) * 60;
|
||||
double minute = Math.floor(minute_temp);
|
||||
// double second = Math.floor((minute_temp - minute)*60);
|
||||
String second = new DecimalFormat("#.##").format((minute_temp - minute) * 60);
|
||||
return (int) degree + "°" + (int) minute + "′" + second + "″";
|
||||
}
|
||||
|
||||
/**
|
||||
* 国际 GPS84 坐标系
|
||||
* 转换成
|
||||
* [国测局坐标系] 火星坐标系 (GCJ-02)
|
||||
* <p>
|
||||
* World Geodetic System ==> Mars Geodetic System
|
||||
*
|
||||
* @param lon 经度
|
||||
* @param lat 纬度
|
||||
* @return GPS实体类
|
||||
*/
|
||||
public static Gps GPS84ToGCJ02(double lat, double lon) {
|
||||
if (outOfChina(lat, lon)) {
|
||||
return null;
|
||||
}
|
||||
double dLat = transformLat(lon - 105.0, lat - 35.0);
|
||||
double dLon = transformLon(lon - 105.0, lat - 35.0);
|
||||
double radLat = lat / 180.0 * pi;
|
||||
double magic = Math.sin(radLat);
|
||||
magic = 1 - ee * magic * magic;
|
||||
double sqrtMagic = Math.sqrt(magic);
|
||||
dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
|
||||
dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
|
||||
double mgLat = lat + dLat;
|
||||
double mgLon = lon + dLon;
|
||||
return new Gps(mgLat, mgLon);
|
||||
}
|
||||
|
||||
/**
|
||||
* [国测局坐标系] 火星坐标系 (GCJ-02)
|
||||
* 转换成
|
||||
* 国际 GPS84 坐标系
|
||||
*
|
||||
* @param lon 火星经度
|
||||
* @param lat 火星纬度
|
||||
*/
|
||||
public static Gps GCJ02ToGPS84(double lat, double lon) {
|
||||
Gps gps = transform(lat, lon);
|
||||
double lontitude = lon * 2 - gps.getWgLon();
|
||||
double latitude = lat * 2 - gps.getWgLat();
|
||||
return new Gps(latitude, lontitude);
|
||||
}
|
||||
|
||||
/**
|
||||
* 火星坐标系 (GCJ-02)
|
||||
* 转换成
|
||||
* 百度坐标系 (BD-09)
|
||||
*
|
||||
* @param gg_lon 经度
|
||||
* @param gg_lat 纬度
|
||||
*/
|
||||
public static Gps GCJ02ToBD09(double gg_lat, double gg_lon) {
|
||||
double x = gg_lon, y = gg_lat;
|
||||
double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * pi);
|
||||
double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * pi);
|
||||
double bd_lon = z * Math.cos(theta) + 0.0065;
|
||||
double bd_lat = z * Math.sin(theta) + 0.006;
|
||||
return new Gps(bd_lat, bd_lon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 国际 GPS84 坐标系
|
||||
* 转换成
|
||||
* 百度坐标系 (BD-09)
|
||||
*
|
||||
* @param lon 经度
|
||||
* @param lat 纬度
|
||||
*/
|
||||
public static Gps GPS84ToBD09(double lat, double lon) {
|
||||
Gps gps = GPS84ToGCJ02(lat,lon);
|
||||
if (gps == null) {
|
||||
return new Gps(lat,lon);
|
||||
}
|
||||
//GCJ-02 转 BD-09
|
||||
return GCJ02ToBD09(gps.getWgLat(), gps.getWgLon());
|
||||
}
|
||||
|
||||
/**
|
||||
* 百度坐标系 (BD-09)
|
||||
* 转换成
|
||||
* 火星坐标系 (GCJ-02)
|
||||
*
|
||||
* @param bd_lon 百度*经度
|
||||
* @param bd_lat 百度*纬度
|
||||
* @return GPS实体类
|
||||
*/
|
||||
public static Gps BD09ToGCJ02(double bd_lat, double bd_lon) {
|
||||
double x = bd_lon - 0.0065, y = bd_lat - 0.006;
|
||||
double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * pi);
|
||||
double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * pi);
|
||||
double gg_lon = z * Math.cos(theta);
|
||||
double gg_lat = z * Math.sin(theta);
|
||||
return new Gps(gg_lat, gg_lon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 百度坐标系 (BD-09)
|
||||
* 转换成
|
||||
* 国际 GPS84 坐标系
|
||||
*
|
||||
* @param bd_lon 百度*经度
|
||||
* @param bd_lat 百度*纬度
|
||||
* @return GPS实体类
|
||||
*/
|
||||
public static Gps BD09ToGPS84(double bd_lat, double bd_lon) {
|
||||
Gps gcj02 = BD09ToGCJ02(bd_lat, bd_lon);
|
||||
Gps map84 = GCJ02ToGPS84(gcj02.getWgLat(),
|
||||
gcj02.getWgLon());
|
||||
return map84;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 不在中国范围内
|
||||
*
|
||||
* @param lon 经度
|
||||
* @param lat 纬度
|
||||
* @return boolean值
|
||||
*/
|
||||
public static boolean outOfChina(double lat, double lon) {
|
||||
if (lon < 72.004 || lon > 137.8347)
|
||||
return true;
|
||||
return lat < 0.8293 || lat > 55.8271;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转化算法
|
||||
*
|
||||
* @param lon
|
||||
* @param lat
|
||||
* @return
|
||||
*/
|
||||
public static Gps transform(double lat, double lon) {
|
||||
if (outOfChina(lat, lon)) {
|
||||
return new Gps(lat, lon);
|
||||
}
|
||||
double dLat = transformLat(lon - 105.0, lat - 35.0);
|
||||
double dLon = transformLon(lon - 105.0, lat - 35.0);
|
||||
double radLat = lat / 180.0 * pi;
|
||||
double magic = Math.sin(radLat);
|
||||
magic = 1 - ee * magic * magic;
|
||||
double sqrtMagic = Math.sqrt(magic);
|
||||
dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
|
||||
dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
|
||||
double mgLat = lat + dLat;
|
||||
double mgLon = lon + dLon;
|
||||
return new Gps(mgLat, mgLon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 纬度转化算法
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @return
|
||||
*/
|
||||
public static double transformLat(double x, double y) {
|
||||
double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y
|
||||
+ 0.2 * Math.sqrt(Math.abs(x));
|
||||
ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
|
||||
ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0;
|
||||
ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 经度转化算法
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @return
|
||||
*/
|
||||
public static double transformLon(double x, double y) {
|
||||
double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1
|
||||
* Math.sqrt(Math.abs(x));
|
||||
ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
|
||||
ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0;
|
||||
ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0
|
||||
* pi)) * 2.0 / 3.0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public interface OnLocationChangeListener {
|
||||
|
||||
/**
|
||||
* 获取最后一次保留的坐标
|
||||
*
|
||||
* @param location 坐标
|
||||
*/
|
||||
void getLastKnownLocation(Location location);
|
||||
|
||||
/**
|
||||
* 当坐标改变时触发此函数,如果Provider传进相同的坐标,它就不会被触发
|
||||
*
|
||||
* @param location 坐标
|
||||
*/
|
||||
void onLocationChanged(Location location);
|
||||
|
||||
/**
|
||||
* provider的在可用、暂时不可用和无服务三个状态直接切换时触发此函数
|
||||
*
|
||||
* @param provider 提供者
|
||||
* @param status 状态
|
||||
* @param extras provider可选包
|
||||
*/
|
||||
void onStatusChanged(String provider, int status, Bundle extras);//位置状态发生改变
|
||||
|
||||
void onProviderEnabled(String provider);
|
||||
|
||||
void onProviderDisabled(String provider);
|
||||
}
|
||||
|
||||
private static class MyLocationListener
|
||||
implements LocationListener {
|
||||
/**
|
||||
* 当坐标改变时触发此函数,如果Provider传进相同的坐标,它就不会被触发
|
||||
*
|
||||
* @param location 坐标
|
||||
*/
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
if (mListener != null) {
|
||||
mListener.onLocationChanged(location);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* provider的在可用、暂时不可用和无服务三个状态直接切换时触发此函数
|
||||
*
|
||||
* @param provider 提供者
|
||||
* @param status 状态
|
||||
* @param extras provider可选包
|
||||
*/
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||
if (mListener != null) {
|
||||
mListener.onStatusChanged(provider, status, extras);
|
||||
}
|
||||
switch (status) {
|
||||
case LocationProvider.AVAILABLE:
|
||||
Log.d("onStatusChanged", "当前GPS状态为可见状态");
|
||||
break;
|
||||
case LocationProvider.OUT_OF_SERVICE:
|
||||
Log.d("onStatusChanged", "当前GPS状态为服务区外状态");
|
||||
break;
|
||||
case LocationProvider.TEMPORARILY_UNAVAILABLE:
|
||||
Log.d("onStatusChanged", "当前GPS状态为暂停服务状态");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* provider被enable时触发此函数,比如GPS被打开
|
||||
*/
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {
|
||||
if (mListener != null) {
|
||||
mListener.onProviderEnabled(provider);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* provider被disable时触发此函数,比如GPS被关闭
|
||||
*/
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {
|
||||
if (mListener != null) {
|
||||
mListener.onProviderDisabled(provider);
|
||||
}
|
||||
}
|
||||
}
|
||||
//===========================================坐标转换工具end====================================
|
||||
|
||||
|
||||
|
||||
private static final double EARTH_RADIUS = 6378137.0; //地球半径
|
||||
|
||||
|
||||
/**
|
||||
* 计算两个经纬度之间的距离
|
||||
*
|
||||
* @param longitude
|
||||
* @param latitude
|
||||
* @param longitude2
|
||||
* @param latitude2
|
||||
* @return 单位米
|
||||
*/
|
||||
public static double getDistance(double longitude, double latitude, double longitude2, double latitude2) {
|
||||
double lat1 = rad(latitude);
|
||||
double lat2 = rad(latitude2);
|
||||
double a = lat1 - lat2;
|
||||
double b = rad(longitude) - rad(longitude2);
|
||||
double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(b / 2), 2)));
|
||||
s = s * EARTH_RADIUS;
|
||||
s = Math.round(s * 10000) / 10000; //四舍五入
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* 弧度换为角度
|
||||
* @param d
|
||||
* @return
|
||||
*/
|
||||
private static double rad(double d) {
|
||||
return d * Math.PI / 180.0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user