kotlin转化完结
This commit is contained in:
parent
f8db723bdb
commit
da853f7bac
114
app/build.gradle
114
app/build.gradle
@ -105,19 +105,20 @@ android {
|
||||
|
||||
productFlavors {
|
||||
qa {
|
||||
manifestPlaceholders = [CHANNEL_VALUE: "大河好运司机"]
|
||||
buildConfigField("String", "OPEN_API_URL", "\"http://192.168.111.244:4009\"")
|
||||
buildConfigField("String", "BASE_URL", "\"http://app.dahehuoyun.com/api/\"")
|
||||
}
|
||||
product {
|
||||
buildConfigField("String", "OPEN_API", "\"https://oapi.alct56.com\"")
|
||||
manifestPlaceholders = [CHANNEL_VALUE: "大河好运司机"]
|
||||
buildConfigField("String", "OPEN_API_URL", "\"https://oapi.alct56.com\"")
|
||||
buildConfigField("String", "BASE_URL", "\"http://app.dahehuoyun.com/api/\"")
|
||||
}
|
||||
|
||||
}
|
||||
// productFlavors.all { flavor ->
|
||||
// flavor.manifestPlaceholders = [CHANNEL_VALUE: name]
|
||||
// }
|
||||
productFlavors.all { flavor ->
|
||||
flavor.manifestPlaceholders = [CHANNEL_VALUE: name]
|
||||
}
|
||||
|
||||
|
||||
android.applicationVariants.all { variant ->
|
||||
@ -138,33 +139,15 @@ android {
|
||||
|
||||
dependencies {
|
||||
|
||||
//implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation 'androidx.core:core-ktx:1.3.1'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'com.google.android.material:material:1.2.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
|
||||
implementation 'com.caverock:androidsvg-aar:1.3'
|
||||
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
||||
// implementation files('libs\\AMap3DMap_5.8.0_AMapNavi_5.6.0_20191014.jar')
|
||||
// implementation project(path: ':ocr_ui')
|
||||
|
||||
//implementation files('libs\\AMap3DMap_5.8.0_AMapNavi_5.6.0_20191014.jar')
|
||||
kapt 'com.android.databinding:compiler:2.3.2'
|
||||
//noinspection GradleCompatible,GradleCompatible
|
||||
//implemention 'com.android.support:design:25.3.1'
|
||||
//implementation files('libs\\BaiduLBS_Android.jar')
|
||||
//当引入的与之前引入的库有重复冲突部分的时候,使用compileOnly
|
||||
implementation files('libs\\mdp_sdk.jar')
|
||||
compileOnly files('libs\\gson-2.8.0.jar')
|
||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.2.0'
|
||||
implementation 'com.jakewharton:butterknife:10.2.1'
|
||||
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
|
||||
implementation 'id.zelory:compressor:1.0.3'
|
||||
//压缩工具
|
||||
implementation 'top.zibin:Luban:1.1.3'
|
||||
//角标
|
||||
implementation 'com.haozhang.libary:android-slanted-textview:1.2'
|
||||
//
|
||||
//刷新头部,底部样式
|
||||
implementation 'com.scwang.smart:refresh-layout-kernel:2.0.1'
|
||||
implementation 'com.scwang.smart:refresh-header-material:2.0.1'
|
||||
implementation 'com.scwang.smart:refresh-footer-ball:2.0.1' //球脉冲加载
|
||||
@ -174,45 +157,26 @@ dependencies {
|
||||
implementation 'com.github.jenly1314.AppUpdater:app-dialog:1.1.0'
|
||||
//轮播插件
|
||||
implementation 'com.github.zhpanvip:BannerViewPager:3.5.4'
|
||||
//
|
||||
implementation 'com.lxj:xpopup:2.2.8'
|
||||
//工具类
|
||||
//implementation 'cn.hutool:hutool-all:5.7.11'
|
||||
//弹出框
|
||||
// implementation 'com.lxj:xpopup:2.2.8'
|
||||
// implementation 'com.github.li-xiaojun:XPopup:2.8.15'
|
||||
//交通厅
|
||||
implementation 'com.lzy.net:okgo:3.0.4'
|
||||
implementation 'com.alibaba:fastjson:1.2.61'
|
||||
implementation 'org.bouncycastle:bcprov-jdk15on:1.55'
|
||||
//org.bouncycastle:bcprov-jdk15to18
|
||||
//compileOnly 'org.bouncycastle:bcprov-jdk15to18:1.64'
|
||||
implementation 'org.apache.commons:commons-lang3:3.5'
|
||||
implementation (name:'locationgd-androidx_2.1.0', ext:'aar')//交通厅
|
||||
// implementation 'com.amap.api:location:latest.integration'
|
||||
//implementation files('libs\\AMap_Location_V5.4.0_20210723.jar')
|
||||
//安联
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
implementation 'com.loopj.android:android-async-http:1.4.9'
|
||||
implementation 'com.j256.ormlite:ormlite-android:4.48'
|
||||
implementation 'com.j256.ormlite:ormlite-core:4.48'
|
||||
compileOnly 'com.github.hotchemi:permissionsdispatcher:2.3.1'
|
||||
annotationProcessor 'com.github.hotchemi:permissionsdispatcher-processor:2.3.1'
|
||||
implementation "org.permissionsdispatcher:permissionsdispatcher:4.6.0"
|
||||
kapt "org.permissionsdispatcher:permissionsdispatcher-processor:4.6.0"
|
||||
|
||||
//极光认证
|
||||
implementation 'cn.jiguang.sdk:jverification:2.7.1' // 此处以2.7.1 版本为例。a
|
||||
implementation 'cn.jiguang.sdk:jpush:4.2.4' // 此处以JPush 4.2.4 版本为例。
|
||||
implementation 'cn.jiguang.sdk:jcore:2.9.0' // 此处以JCore 2.9.0 版本为例。
|
||||
// 接入华为厂商
|
||||
implementation 'com.huawei.hms:push:4.0.2.300'
|
||||
implementation 'cn.jiguang.sdk.plugin:huawei:4.0.0'// 极光厂商插件版本与接入 JPush 版本保持一致,下同
|
||||
// 接入 FCM 厂商
|
||||
implementation 'com.google.firebase:firebase-messaging:21.0.1'
|
||||
implementation 'cn.jiguang.sdk.plugin:fcm:4.0.0'
|
||||
// 接入魅族厂商
|
||||
implementation 'cn.jiguang.sdk.plugin:meizu:4.0.0'
|
||||
// 接入 VIVO 厂商
|
||||
implementation 'cn.jiguang.sdk.plugin:vivo:4.0.0'
|
||||
// 接入 OPPO 厂商
|
||||
implementation 'cn.jiguang.sdk.plugin:oppo:4.0.0'
|
||||
// 接入小米厂商
|
||||
implementation 'cn.jiguang.sdk.plugin:xiaomi:4.0.0'
|
||||
//友盟
|
||||
// 下面各SDK根据宿主App是否使用相关业务按需引入。
|
||||
// 友盟统计SDK
|
||||
@ -220,61 +184,23 @@ dependencies {
|
||||
implementation 'com.umeng.umsdk:asms:1.4.1'// 必选
|
||||
implementation 'com.umeng.umsdk:apm:1.4.2' // 错误分析升级为独立SDK,看crash数据请一定集成,可选
|
||||
implementation 'com.umeng.umsdk:abtest:1.0.0'//使用U-App中ABTest能力,可选
|
||||
//动态权限获取
|
||||
implementation "org.permissionsdispatcher:permissionsdispatcher:4.6.0"
|
||||
kapt "org.permissionsdispatcher:permissionsdispatcher-processor:4.6.0"
|
||||
|
||||
//选择器
|
||||
implementation 'com.github.gzu-liyujiang.AndroidPicker:WheelPicker:3.1.1'
|
||||
//EventBus
|
||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||
//易签宝
|
||||
implementation(name:'EsignSDK', ext:'aar')
|
||||
implementation'pub.devrel:easypermissions:1.3.0'
|
||||
|
||||
implementation "com.squareup.retrofit2:retrofit:2.4.0"
|
||||
implementation "com.squareup.retrofit2:converter-gson:2.4.0"
|
||||
implementation "com.squareup.retrofit2:adapter-rxjava2:2.4.0"
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0'
|
||||
|
||||
implementation "io.reactivex.rxjava2:rxjava:2.1.5"
|
||||
implementation "io.reactivex.rxjava2:rxandroid:2.0.1"
|
||||
|
||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||
//pdf展示
|
||||
implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'
|
||||
//
|
||||
testImplementation 'junit:junit:4.+'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
//工具类
|
||||
//implementation 'cn.hutool:hutool-all:5.7.11'
|
||||
//ArcGis For Android工具库(API:100.1以上版本)
|
||||
implementation 'com.github.qingmei2:SlideBottomLayout-Android:1.2.3'
|
||||
implementation 'com.flipboard:bottomsheet-core:1.5.3'
|
||||
implementation 'com.flipboard:bottomsheet-commons:1.5.3' //可选
|
||||
implementation 'com.github.getActivity:XToast:8.2'
|
||||
//阿里云视频播放
|
||||
// implementation 'com.aliyun.sdk.android:AliyunPlayer:5.4.0-part'
|
||||
// implementation 'com.aliyun.video.android:svideostandard:3.25.+'//短视频标准版SDK必须依赖
|
||||
// implementation 'com.aliyun.video.android:core:1.2.2' //核心库必须依赖
|
||||
// implementation 'com.alivc.conan:AlivcConan:1.0.3'//核心库必须依赖
|
||||
// //AlivcFFmpeg必须依赖,且版本需要在4.3.0及以上,在以下两个版本中选择一个版本进行依赖。
|
||||
// implementation 'com.aliyun.video.android:AlivcFFmpeg:4.3.0' //短视频与播放器共用。两个SDK同时接入时,请用该版本。
|
||||
// implementation 'com.aliyun.video.android:upload:1.6.0'// 上传库,如不需要上传可不依赖
|
||||
//
|
||||
//implementation 'com.amap.api:navi-3dmap:8.1.0_3dmap8.1.0'
|
||||
//ocr
|
||||
//implementation (name:'ocrsdk.aar', ext:'aar')
|
||||
//implementation 'com.github.xuexiangjys:XVideo:1.0.2'
|
||||
|
||||
implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.2.9'
|
||||
implementation 'com.youth.banner:banner:1.4.10'
|
||||
//易签宝
|
||||
implementation(name:'EsignSDK', ext:'aar')
|
||||
|
||||
// implementation 'com.amap.api:3dmap:latest.integration'
|
||||
// implementation 'com.amap.api:search:latest.integration'
|
||||
|
||||
implementation 'com.amap.api:3dmap:8.0.0'
|
||||
implementation 'com.amap.api:location:5.5.1'
|
||||
implementation 'com.amap.api:search:7.9.0'
|
||||
//当引入的与之前引入的库有重复冲突部分的时候,使用compileOnly
|
||||
implementation files('libs\\mdp_sdk.jar')
|
||||
|
||||
implementation project(path: ':mylibrary')
|
||||
|
||||
|
Binary file not shown.
@ -17,6 +17,7 @@
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.READ_PROFILE" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<!-- Required -->
|
||||
|
@ -2,6 +2,14 @@ package com.arpa.hndahesudintocctmsdriver.request.net;
|
||||
|
||||
|
||||
import com.arpa.hndahesudintocctmsdriver.BuildConfig;
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.UserBean;
|
||||
import com.arpa.hndahesudintocctmsdriver.request.bean.LoginRegInputBean;
|
||||
import com.dahe.mylibrary.net.CommonResponseBean;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
/**
|
||||
* Created by Administrator on 2018/8/8 0008.
|
||||
@ -9,13 +17,14 @@ import com.arpa.hndahesudintocctmsdriver.BuildConfig;
|
||||
|
||||
public interface Api {
|
||||
|
||||
String BASE_URL = "BuildConfig.BASE_URL";
|
||||
String BASE_URL = BuildConfig.BASE_URL;
|
||||
|
||||
|
||||
//获取版本
|
||||
String VERSION = BASE_URL + "app/version";
|
||||
|
||||
|
||||
@POST(BASE_URL+"/common/register")
|
||||
Observable<CommonResponseBean> log(@Body LoginRegInputBean bean);
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,9 +4,9 @@ import android.content.Context;
|
||||
|
||||
import com.dahe.mylibrary.net.CommonResponseBean;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -44,7 +44,7 @@ public class DataManager {
|
||||
return api();
|
||||
}
|
||||
|
||||
public static Api api() {
|
||||
private static Api api() {
|
||||
return CommonBaseLibrary.getRetrofit().newBuilder()
|
||||
.client(new OkHttpClient.Builder()
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
|
@ -8,6 +8,8 @@ import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Window;
|
||||
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.MainActivity;
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.UiAuxiliary;
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.login.LoginActivity;
|
||||
import com.dahe.mylibrary.net.CommonResponseBean;
|
||||
import com.dahe.mylibrary.net.ResultException;
|
||||
@ -85,9 +87,9 @@ public abstract class RxHttpCallBack<T> {
|
||||
|
||||
}
|
||||
if (t.getCode() == 401) {
|
||||
// UserUtils.Companion.getInstance().loginOut(mContext);
|
||||
Intent intent = new Intent(mContext, LoginActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
UiAuxiliary.delLogin(mContext);
|
||||
Intent intent = new Intent(mContext, MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
mContext.startActivity(intent);
|
||||
ToastUtils.showToast(mContext,"您的账号再异地登录,请重新登录");
|
||||
}else{
|
||||
|
@ -20,62 +20,66 @@ import com.arpa.hndahesudintocctmsdriver.util.view.BaseAppCompatActivity
|
||||
import com.arpa.hndahesudintocctmsdriver.util.view.BottomTabUtil
|
||||
import com.arpa.hndahesudintocctmsdriver.util.view.PanDuanUtil
|
||||
import com.google.gson.Gson
|
||||
import com.luck.picture.lib.permissions.RxPermissions
|
||||
import io.reactivex.functions.Consumer
|
||||
import com.permissionx.guolindev.PermissionX
|
||||
|
||||
class MainActivity : BaseAppCompatActivity() {
|
||||
|
||||
private var ibs = arrayOf<ImageView>()
|
||||
private var title_view=arrayOf<TextView>()
|
||||
private var imgs0= intArrayOf(R.mipmap.tab1,R.mipmap.tab2,R.mipmap.xiaoxi0,R.mipmap.tab3)
|
||||
private var imgs1= intArrayOf(R.mipmap.tab1_s,R.mipmap.tab2_s,R.mipmap.xiaoxi1,R.mipmap.tab3_s)
|
||||
private var title_view = arrayOf<TextView>()
|
||||
private var imgs0 = intArrayOf(R.mipmap.tab1, R.mipmap.tab2, R.mipmap.xiaoxi0, R.mipmap.tab3)
|
||||
private var imgs1 =
|
||||
intArrayOf(R.mipmap.tab1_s, R.mipmap.tab2_s, R.mipmap.xiaoxi1, R.mipmap.tab3_s)
|
||||
private val gson = Gson()
|
||||
|
||||
override fun msgMethod(m: Message?) {
|
||||
super.msgMethod(m)
|
||||
when(m!!.what){
|
||||
1->{
|
||||
when (m!!.what) {
|
||||
1 -> {
|
||||
isExit = false;
|
||||
}
|
||||
RequsetCodeConstants.SUCCESS->{ }
|
||||
RequsetCodeConstants.SUCCESS -> {}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
StateStyleUtil.stateTextColor(this)
|
||||
setContentView(R.layout.activity_main)
|
||||
con=this
|
||||
act=this
|
||||
con = this
|
||||
act = this
|
||||
//隐藏标题栏
|
||||
val actionBar = supportActionBar
|
||||
actionBar?.hide()
|
||||
var r1=findViewById<LinearLayout>(R.id.r1)
|
||||
var r2=findViewById<LinearLayout>(R.id.r2)
|
||||
var r3=findViewById<LinearLayout>(R.id.r3)
|
||||
var r4=findViewById<LinearLayout>(R.id.r4)
|
||||
var r1 = findViewById<LinearLayout>(R.id.r1)
|
||||
var r2 = findViewById<LinearLayout>(R.id.r2)
|
||||
var r3 = findViewById<LinearLayout>(R.id.r3)
|
||||
var r4 = findViewById<LinearLayout>(R.id.r4)
|
||||
var fs = arrayOfNulls<Fragment>(4)
|
||||
fs[0] = HomeFragment()
|
||||
fs[1] = WalletFragment()
|
||||
fs[2] = NewsFragment()
|
||||
fs[3] = MyFragment()
|
||||
ibs=arrayOf(
|
||||
ibs = arrayOf(
|
||||
findViewById(R.id.huoyuan),
|
||||
findViewById(R.id.qianbao),
|
||||
findViewById(R.id.xiaoxi),
|
||||
findViewById(R.id.wode))
|
||||
title_view=arrayOf(findViewById(R.id.title1),findViewById(R.id.title2),findViewById(R.id.title3),findViewById(R.id.title4))
|
||||
title_view = arrayOf(findViewById(R.id.title1),
|
||||
findViewById(R.id.title2),
|
||||
findViewById(R.id.title3),
|
||||
findViewById(R.id.title4))
|
||||
var bt = BottomTabUtil(this, R.id.body, fs)
|
||||
bt.selectItem(fs[0])
|
||||
r1.setOnClickListener { v ->
|
||||
selectImage(bt.index,0)
|
||||
selectImage(bt.index, 0)
|
||||
bt.setDefaultFragment(fs[0])
|
||||
bt.index=0
|
||||
bt.index = 0
|
||||
}
|
||||
r2.setOnClickListener { v ->
|
||||
if (!PanDuanUtil.isLogin(con)){
|
||||
if (!PanDuanUtil.isLogin(con)) {
|
||||
jumpLogin()
|
||||
}else{
|
||||
selectImage(bt.index,1)
|
||||
} else {
|
||||
selectImage(bt.index, 1)
|
||||
if (!fs[1]!!.isAdded) {
|
||||
bt.hide(fs[bt.index])
|
||||
bt.selectItem(fs[1])
|
||||
@ -86,10 +90,10 @@ class MainActivity : BaseAppCompatActivity() {
|
||||
}
|
||||
}
|
||||
r3.setOnClickListener { v ->
|
||||
if (!PanDuanUtil.isLogin(con)){
|
||||
if (!PanDuanUtil.isLogin(con)) {
|
||||
jumpLogin()
|
||||
}else{
|
||||
selectImage(bt.index,2)
|
||||
} else {
|
||||
selectImage(bt.index, 2)
|
||||
if (!fs[2]!!.isAdded) {
|
||||
bt.hide(fs[bt.index])
|
||||
bt.selectItem(fs[2])
|
||||
@ -100,10 +104,10 @@ class MainActivity : BaseAppCompatActivity() {
|
||||
}
|
||||
}
|
||||
r4.setOnClickListener { v ->
|
||||
if (!PanDuanUtil.isLogin(con)){
|
||||
if (!PanDuanUtil.isLogin(con)) {
|
||||
jumpLogin()
|
||||
}else{
|
||||
selectImage(bt.index,3)
|
||||
} else {
|
||||
selectImage(bt.index, 3)
|
||||
if (!fs[3]!!.isAdded) {
|
||||
bt.hide(fs[bt.index])
|
||||
bt.selectItem(fs[3])
|
||||
@ -113,41 +117,35 @@ class MainActivity : BaseAppCompatActivity() {
|
||||
bt.index = 3
|
||||
}
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q){
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
getPression()
|
||||
}
|
||||
}
|
||||
|
||||
fun getPression(){
|
||||
var gpsPermissions = RxPermissions(this)
|
||||
gpsPermissions.request(
|
||||
Manifest.permission.ACCESS_FINE_LOCATION,
|
||||
Manifest.permission.ACCESS_COARSE_LOCATION,
|
||||
Manifest.permission.ACCESS_BACKGROUND_LOCATION
|
||||
).subscribe(
|
||||
Consumer { b: Boolean ->
|
||||
if (b) {
|
||||
//判断GPS模块是否开启
|
||||
fun getPression() {
|
||||
PermissionX.init(this)
|
||||
.permissions(Manifest.permission.ACCESS_FINE_LOCATION,
|
||||
Manifest.permission.ACCESS_COARSE_LOCATION,
|
||||
Manifest.permission.ACCESS_BACKGROUND_LOCATION)
|
||||
.request { allGranted, grantedList, deniedList ->
|
||||
if (allGranted) {
|
||||
|
||||
} else {
|
||||
Toast.makeText(con,"开启权限失败,请在应用设置-权限-定位-始终允许",Toast.LENGTH_SHORT).show()
|
||||
//.show("开启权限失败,请在应用设置-权限-定位-始终允许")
|
||||
Toast.makeText(con, "开启权限失败,请在应用设置-权限-定位-始终允许", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun selectImage(old:Int, new:Int){
|
||||
fun selectImage(old: Int, new: Int) {
|
||||
ibs[old].setImageResource(imgs0[old])
|
||||
ibs[new].setImageResource(imgs1[new])
|
||||
title_view[old].setTextColor(resources.getColor(R.color.tab_select_no,null))
|
||||
title_view[new].setTextColor(resources.getColor(R.color.tab_select,null))
|
||||
title_view[old].setTextColor(resources.getColor(R.color.tab_select_no, null))
|
||||
title_view[new].setTextColor(resources.getColor(R.color.tab_select, null))
|
||||
}
|
||||
|
||||
fun jumpLogin(){
|
||||
var inl=Intent(con,LoginActivity::class.java)
|
||||
fun jumpLogin() {
|
||||
var inl = Intent(con, LoginActivity::class.java)
|
||||
startActivity(inl)
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.cardview.widget.CardView;
|
||||
|
||||
|
||||
import com.lxj.xpopup.core.CenterPopupView;
|
||||
import com.arpa.hndahesudintocctmsdriver.R;
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.CarListBean;
|
||||
|
@ -11,10 +11,7 @@ import com.arpa.hndahesudintocctmsdriver.R;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.statusbar.StateStyleUtil;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.view.BaseAppCompatActivity;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import rx.Observable;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* @ClassName AddCarSuccActivity
|
||||
|
@ -12,6 +12,7 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -36,6 +37,7 @@ import com.luck.picture.lib.PictureSelector;
|
||||
import com.luck.picture.lib.config.PictureConfig;
|
||||
import com.luck.picture.lib.entity.LocalMedia;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.lxj.xpopup.core.ImageViewerPopupView;
|
||||
import com.lxj.xpopup.interfaces.XPopupImageLoader;
|
||||
import com.arpa.hndahesudintocctmsdriver.R;
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.BaseBean;
|
||||
@ -65,6 +67,7 @@ import com.arpa.hndahesudintocctmsdriver.util.http.RequsetCodeConstants;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.statusbar.StateStyleUtil;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.view.BaseAppCompatActivity;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.view.BaseRecyclerView;
|
||||
import com.lxj.xpopup.photoview.PhotoView;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -30,7 +30,6 @@ import com.arpa.hndahesudintocctmsdriver.util.view.BaseAppCompatActivity;
|
||||
import com.esign.esignsdk.EsignSdk;
|
||||
import com.esign.esignsdk.data.AuthEvent;
|
||||
import com.google.gson.Gson;
|
||||
import com.luck.picture.lib.permissions.RxPermissions;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.lxj.xpopup.core.BasePopupView;
|
||||
import com.lxj.xpopup.interfaces.OnConfirmListener;
|
||||
|
@ -19,6 +19,10 @@ import androidx.annotation.Nullable;
|
||||
import androidx.cardview.widget.CardView;
|
||||
|
||||
import com.arpa.hndahesudintocctmsdriver.parts.ConfigParts;
|
||||
import com.arpa.hndahesudintocctmsdriver.request.net.BaseObserver;
|
||||
import com.arpa.hndahesudintocctmsdriver.request.net.DataManager;
|
||||
import com.arpa.hndahesudintocctmsdriver.request.net.RxHttpCallBack;
|
||||
import com.dahe.mylibrary.net.CommonResponseBean;
|
||||
import com.google.gson.Gson;
|
||||
import com.arpa.hndahesudintocctmsdriver.R;
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.ConfigBean;
|
||||
@ -45,21 +49,21 @@ import cn.jpush.android.api.JPushInterface;
|
||||
|
||||
public class LoginActivity extends BaseActivity {
|
||||
|
||||
public static final String CODE_RESULT="code_result";
|
||||
public static final String LOGIN_RESULT="login_result";
|
||||
public static final String USER="user";
|
||||
public static final String USER_TOKEN="token";
|
||||
public static final String USER_UNAME="uname";
|
||||
public static final String USER_RNAME="rname";
|
||||
public static final String USER_ID="id";
|
||||
public static final String CODE_RESULT = "code_result";
|
||||
public static final String LOGIN_RESULT = "login_result";
|
||||
public static final String USER = "user";
|
||||
public static final String USER_TOKEN = "token";
|
||||
public static final String USER_UNAME = "uname";
|
||||
public static final String USER_RNAME = "rname";
|
||||
public static final String USER_ID = "id";
|
||||
|
||||
private Button btn_login;
|
||||
private Button auto_login;
|
||||
private EditText input_phone,input_code;
|
||||
private EditText input_phone, input_code;
|
||||
private Button getCode;
|
||||
private LoginBean loginBean;
|
||||
private TimerTask tt;
|
||||
private int timer_sum=60;
|
||||
private int timer_sum = 60;
|
||||
private ImageButton agree_btn;
|
||||
private CardView no_btn;
|
||||
private UserRequset ur;
|
||||
@ -67,38 +71,39 @@ public class LoginActivity extends BaseActivity {
|
||||
@Override
|
||||
public void msgMethod(Message m) {
|
||||
super.msgMethod(m);
|
||||
switch (m.what){
|
||||
switch (m.what) {
|
||||
case 12:
|
||||
getCode.setText(timer_sum+"s");
|
||||
if(timer_sum<=0){
|
||||
getCode.setText(timer_sum + "s");
|
||||
if (timer_sum <= 0) {
|
||||
getCode.setText("获取验证码");
|
||||
timer_sum=60;
|
||||
code_key=true;
|
||||
timer_sum = 60;
|
||||
code_key = true;
|
||||
}
|
||||
break;
|
||||
case RequsetCodeConstants.SUCCESS:
|
||||
if(CacheGroup.cacheList.get(CODE_RESULT)!=null){
|
||||
Log.e("--短信发送res--","短信发送成功");
|
||||
if (CacheGroup.cacheList.get(CODE_RESULT) != null) {
|
||||
Log.e("--短信发送res--", "短信发送成功");
|
||||
}
|
||||
if(CacheGroup.cacheList.get(LOGIN_RESULT)!=null){
|
||||
if (CacheGroup.cacheList.get(LOGIN_RESULT) != null) {
|
||||
//存储登录记录
|
||||
loginBean=new Gson().fromJson(CacheGroup.cacheList.get(LOGIN_RESULT),LoginBean.class);
|
||||
Log.e("--登录信息--",new Gson().toJson(loginBean));
|
||||
if(loginBean.getCode()==200){
|
||||
SPUtil.insSP(con,USER,USER_TOKEN,loginBean.getData().getToken());
|
||||
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());
|
||||
UiAuxiliary.homeRequest("登录成功");
|
||||
finish();
|
||||
}else{
|
||||
Toast.makeText(con,loginBean.getMsg(),Toast.LENGTH_SHORT).show();
|
||||
loginBean = new Gson().fromJson(CacheGroup.cacheList.get(LOGIN_RESULT), LoginBean.class);
|
||||
Log.e("--登录信息--", new Gson().toJson(loginBean));
|
||||
if (loginBean.getCode() == 200) {
|
||||
SPUtil.insSP(con, USER, USER_TOKEN, loginBean.getData().getToken());
|
||||
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());
|
||||
UiAuxiliary.homeRequest("登录成功");
|
||||
finish();
|
||||
} else {
|
||||
Toast.makeText(con, loginBean.getMsg(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
CacheGroup.cacheList.remove(LOGIN_RESULT);
|
||||
}
|
||||
break;
|
||||
default:break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,42 +112,43 @@ public class LoginActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
StatusBarUtil.touming(getWindow());
|
||||
setContentView(R.layout.activity_login);
|
||||
con=this;
|
||||
btn_login=findViewById(R.id.btn_login);
|
||||
auto_login=findViewById(R.id.auto_login);
|
||||
input_phone=findViewById(R.id.input_phone);
|
||||
input_code=findViewById(R.id.input_code);
|
||||
getCode=findViewById(R.id.getCode);
|
||||
agree_btn=findViewById(R.id.agree_btn);
|
||||
no_btn=findViewById(R.id.no_btn);
|
||||
ur=new UserRequset(con,hd);
|
||||
con = this;
|
||||
btn_login = findViewById(R.id.btn_login);
|
||||
auto_login = findViewById(R.id.auto_login);
|
||||
input_phone = findViewById(R.id.input_phone);
|
||||
input_code = findViewById(R.id.input_code);
|
||||
getCode = findViewById(R.id.getCode);
|
||||
agree_btn = findViewById(R.id.agree_btn);
|
||||
no_btn = findViewById(R.id.no_btn);
|
||||
ur = new UserRequset(con, hd);
|
||||
initView(null);
|
||||
}
|
||||
|
||||
boolean key=false;
|
||||
boolean code_key=true;
|
||||
private String url1="";
|
||||
private String url2="";
|
||||
boolean key = false;
|
||||
boolean code_key = true;
|
||||
private String url1 = "";
|
||||
private String url2 = "";
|
||||
|
||||
@Override
|
||||
public void initView(Object obj) {
|
||||
super.initView(obj);
|
||||
agree_btn.setOnClickListener(v -> {
|
||||
agree_btn.setVisibility(View.GONE);
|
||||
no_btn.setVisibility(View.VISIBLE);
|
||||
key=false;
|
||||
key = false;
|
||||
});
|
||||
no_btn.setOnClickListener(v -> {
|
||||
agree_btn.setVisibility(View.VISIBLE);
|
||||
no_btn.setVisibility(View.GONE);
|
||||
key=true;
|
||||
key = true;
|
||||
|
||||
});
|
||||
ConfigBean cb= ConfigParts.getConfigParts(con);
|
||||
if(cb!=null){
|
||||
url1=cb.getData().getUserUrl();
|
||||
url2="https://agreement.dahehuoyun.com/huawei/#/private";
|
||||
ConfigBean cb = ConfigParts.getConfigParts(con);
|
||||
if (cb != null) {
|
||||
url1 = cb.getData().getUserUrl();
|
||||
url2 = "https://agreement.dahehuoyun.com/huawei/#/private";
|
||||
}
|
||||
TextView tv_content=findViewById(R.id.tv_content);
|
||||
TextView tv_content = findViewById(R.id.tv_content);
|
||||
String str = "我已阅读并同意相关服务条款和隐私政策《用户服务协议》和《隐私政策》";
|
||||
SpannableStringBuilder ssb = new SpannableStringBuilder();
|
||||
ssb.append(str);
|
||||
@ -151,18 +157,19 @@ public class LoginActivity extends BaseActivity {
|
||||
ssb.setSpan(new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(View widget) {
|
||||
Log.e("-用户服务协议-",url1);
|
||||
Log.e("-用户服务协议-", url1);
|
||||
//用户服务协议点击事件
|
||||
Intent in=new Intent(con, WebActivity.class);
|
||||
in.putExtra("title","用户服务协议");
|
||||
Intent in = new Intent(con, WebActivity.class);
|
||||
in.putExtra("title", "用户服务协议");
|
||||
in.putExtra("url", url1);
|
||||
startActivity(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
//设置文件颜色
|
||||
ds.setColor(getResources().getColor(R.color.theme_color,null));
|
||||
ds.setColor(getResources().getColor(R.color.theme_color, null));
|
||||
// 去掉下划线
|
||||
ds.setUnderlineText(false);
|
||||
}
|
||||
@ -172,16 +179,17 @@ public class LoginActivity extends BaseActivity {
|
||||
@Override
|
||||
public void onClick(View widget) {
|
||||
//隐私协议点击事件
|
||||
Intent in=new Intent(con, WebActivity.class);
|
||||
in.putExtra("title","隐私政策");
|
||||
in.putExtra("url",url2);
|
||||
Intent in = new Intent(con, WebActivity.class);
|
||||
in.putExtra("title", "隐私政策");
|
||||
in.putExtra("url", url2);
|
||||
startActivity(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
//设置文件颜色
|
||||
ds.setColor(getResources().getColor(R.color.theme_color,null));
|
||||
ds.setColor(getResources().getColor(R.color.theme_color, null));
|
||||
// 去掉下划线
|
||||
ds.setUnderlineText(false);
|
||||
}
|
||||
@ -190,36 +198,37 @@ public class LoginActivity extends BaseActivity {
|
||||
tv_content.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
tv_content.setText(ssb, TextView.BufferType.SPANNABLE);
|
||||
getCode.setOnClickListener(v -> {
|
||||
String phone=String.valueOf(input_phone.getText());
|
||||
if ("".equals(phone) || phone==null){
|
||||
Log.e("点击事件","请先输入手机号");
|
||||
Toast.makeText(con,"请先输入手机号",Toast.LENGTH_SHORT).show();
|
||||
}else{
|
||||
if(11==phone.length() && phone.indexOf("1")==0){
|
||||
if(code_key){
|
||||
getCd();
|
||||
ur.getPhoneCode(phone);
|
||||
code_key=false;
|
||||
}
|
||||
}else{
|
||||
Toast.makeText(con,"手机号格式不正确",Toast.LENGTH_SHORT).show();
|
||||
String phone = String.valueOf(input_phone.getText());
|
||||
if ("".equals(phone) || phone == null) {
|
||||
Log.e("点击事件", "请先输入手机号");
|
||||
Toast.makeText(con, "请先输入手机号", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
if (11 == phone.length() && phone.indexOf("1") == 0) {
|
||||
if (code_key) {
|
||||
getCd();
|
||||
ur.getPhoneCode(phone);
|
||||
code_key = false;
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(con, "手机号格式不正确", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
btn_login.setOnClickListener(v -> {
|
||||
String phone=String.valueOf(input_phone.getText());
|
||||
String code=String.valueOf(input_code.getText());
|
||||
Log.e("--code--",code);
|
||||
if (judgeFormat(phone,code)){
|
||||
if(key){
|
||||
LoginRegInputBean lb=new LoginRegInputBean();
|
||||
String phone = String.valueOf(input_phone.getText());
|
||||
String code = String.valueOf(input_code.getText());
|
||||
Log.e("--code--", code);
|
||||
if (judgeFormat(phone, code)) {
|
||||
if (key) {
|
||||
LoginRegInputBean lb = new LoginRegInputBean();
|
||||
lb.setRoleId(4);
|
||||
lb.setUname(phone);
|
||||
lb.setSmscode(code);
|
||||
lb.setRegisterType(1);
|
||||
|
||||
ur.UserLogin(lb);
|
||||
}else{
|
||||
Toast.makeText(con,"请先同意用户协议和隐私政策",Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(con, "请先同意用户协议和隐私政策", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -238,8 +247,8 @@ public class LoginActivity extends BaseActivity {
|
||||
.setLogBtnText(LoginConstant.LOG_BTN_TEXT.getValue())
|
||||
.setLogBtnTextColor(0xffffffff)
|
||||
.setLogBtnImgPath(LoginConstant.BTN_IMG_PATH.getValue())
|
||||
.setAppPrivacyOne(LoginConstant.TIAOKUAN_ONE.getValue(),LoginConstant.TIAOKUAN_ONE_URL.getValue())
|
||||
.setAppPrivacyTwo(LoginConstant.TIAOKUAN_TWO.getValue(),LoginConstant.TIAOKUAN_TWO_URL.getValue())
|
||||
.setAppPrivacyOne(LoginConstant.TIAOKUAN_ONE.getValue(), LoginConstant.TIAOKUAN_ONE_URL.getValue())
|
||||
.setAppPrivacyTwo(LoginConstant.TIAOKUAN_TWO.getValue(), LoginConstant.TIAOKUAN_TWO_URL.getValue())
|
||||
.setUncheckedImgPath(LoginConstant.BTN_IMG_PATH.getValue())
|
||||
.setCheckedImgPath(LoginConstant.BTN_IMG_PATH.getValue())
|
||||
.setSloganTextColor(0xff999999)
|
||||
@ -263,9 +272,9 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
});//设置授权页事件监听
|
||||
JVerificationInterface.loginAuth(con, settings, (code, content, operator) -> {
|
||||
if (code == 6000){
|
||||
Log.d("授权页", "code=" + code + ", token=" + content+" ,operator="+operator);
|
||||
}else{
|
||||
if (code == 6000) {
|
||||
Log.d("授权页", "code=" + code + ", token=" + content + " ,operator=" + operator);
|
||||
} else {
|
||||
Log.d("授权页", "code=" + code + ", message=" + content);
|
||||
}
|
||||
});
|
||||
@ -273,36 +282,38 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
});
|
||||
}
|
||||
public void getCd(){
|
||||
new Thread(){
|
||||
|
||||
public void getCd() {
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (timer_sum>0) {
|
||||
while (timer_sum > 0) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
timer_sum--;
|
||||
Message msg=new Message();
|
||||
msg.what=12;
|
||||
Message msg = new Message();
|
||||
msg.what = 12;
|
||||
hd.sendMessage(msg);
|
||||
}
|
||||
interrupt();
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
//验证用户输入的是否符合格式
|
||||
public boolean judgeFormat(String phone,String code){
|
||||
public boolean judgeFormat(String phone, String code) {
|
||||
//1[0-9]{10}
|
||||
if("".equals(phone) || "".equals(code)){
|
||||
Toast.makeText(con,"手机号和验证码不得为空",Toast.LENGTH_SHORT).show();
|
||||
if ("".equals(phone) || "".equals(code)) {
|
||||
Toast.makeText(con, "手机号和验证码不得为空", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}else{
|
||||
if(11==phone.length() && phone.indexOf("1")==0){
|
||||
} else {
|
||||
if (11 == phone.length() && phone.indexOf("1") == 0) {
|
||||
return true;
|
||||
}else{
|
||||
Toast.makeText(con,"手机号格式不正确",Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(con, "手机号格式不正确", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ import com.arpa.hndahesudintocctmsdriver.util.cache.CacheGroup;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.esign.esignsdk.EsignSdk;
|
||||
import com.google.gson.Gson;
|
||||
import com.luck.picture.lib.permissions.RxPermissions;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.arpa.hndahesudintocctmsdriver.R;
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.ConfigBean;
|
||||
|
@ -23,9 +23,9 @@ import com.arpa.hndahesudintocctmsdriver.parts.ConfigParts;
|
||||
import com.arpa.hndahesudintocctmsdriver.parts.StartOrderParts;
|
||||
import com.arpa.hndahesudintocctmsdriver.parts.UserParts;
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.business.BusinessActivity;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.PicturlUtil;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.google.gson.Gson;
|
||||
import com.luck.picture.lib.permissions.RxPermissions;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
|
||||
import com.arpa.hndahesudintocctmsdriver.R;
|
||||
@ -43,6 +43,7 @@ import com.arpa.hndahesudintocctmsdriver.util.cache.CacheGroup;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.string.StringUtil;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.view.BaseFragment;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.view.BaseRecyclerView;
|
||||
import com.permissionx.guolindev.PermissionX;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -217,19 +218,17 @@ public class MyFragment extends BaseFragment {
|
||||
onAuth.setOnClickListener(v -> startActivity(new Intent(con, PersonalAuthActivity.class)));
|
||||
//司机之家
|
||||
onDriverHome.setOnClickListener(v -> {
|
||||
RxPermissions rp=new RxPermissions(getActivity());
|
||||
rp.request(
|
||||
Manifest.permission.ACCESS_BACKGROUND_LOCATION
|
||||
).subscribe(b -> {
|
||||
if (b) {
|
||||
PermissionX.init(getActivity())
|
||||
.permissions(Manifest.permission.ACCESS_BACKGROUND_LOCATION)
|
||||
.request((allGranted, grantedList, deniedList) -> {
|
||||
if (allGranted) {
|
||||
Intent in=new Intent(con, BusinessActivity.class);
|
||||
in.putExtra("type","餐饮");
|
||||
startActivity(in);
|
||||
} else {
|
||||
Toast.makeText(getContext(),"请先开启定位权限",Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
//联系我们
|
||||
onContact.setOnClickListener(v -> {
|
||||
|
@ -4,6 +4,7 @@ import android.app.Activity;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.dahe.mylibrary.weight.GlideEngine;
|
||||
import com.luck.picture.lib.PictureSelector;
|
||||
import com.luck.picture.lib.config.PictureConfig;
|
||||
import com.luck.picture.lib.entity.LocalMedia;
|
||||
@ -16,15 +17,16 @@ public class PicturlUtil {
|
||||
//(Activity) ctx 图片选择器
|
||||
PictureSelector.create(activity)
|
||||
.openGallery(PictureConfig.TYPE_IMAGE)
|
||||
.imageEngine(GlideEngine.createGlideEngine())
|
||||
.maxSelectNum(maxNum)
|
||||
.minSelectNum(1)
|
||||
.imageSpanCount(4)// 每行显示个数
|
||||
.selectionMode(PictureConfig.MULTIPLE)//多选
|
||||
.previewImage(true)//预览图片
|
||||
.compress(true)//压缩
|
||||
.isPreviewImage(true)//预览图片
|
||||
.isCompress(true)//压缩
|
||||
.isCamera(true)// 是否显示拍照按钮 true or false
|
||||
.minimumCompressSize(100)// 小于100kb的图片不压缩
|
||||
.selectionMedia(imgs)
|
||||
.selectionData(imgs)
|
||||
.forResult(PictureConfig.CHOOSE_REQUEST);//回调请求码
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.arpa.hndahesudintocctmsdriver.R;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.PicturlUtil;
|
||||
import com.luck.picture.lib.permissions.RxPermissions;
|
||||
import com.permissionx.guolindev.PermissionX;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@ -55,32 +55,27 @@ public class GetCarImageAlert {
|
||||
//请按照如图所示拍摄回单照片,回单照片必须保持清晰完整,能看清具体吨数,便于结算运费时核查,感谢配合。
|
||||
}
|
||||
btn_xiangce.setOnClickListener(v -> {
|
||||
RxPermissions rp=new RxPermissions(act);
|
||||
rp.request(
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
).subscribe(b -> {
|
||||
if (b) {
|
||||
//ImageGetUtil.AlbumGetImage(act);
|
||||
PermissionX.init(act)
|
||||
.permissions(Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
.request((allGranted, grantedList, deniedList) -> {
|
||||
if (allGranted) {
|
||||
PicturlUtil.selectPicter(act, new ArrayList<>(), 1);
|
||||
} else {
|
||||
Toast.makeText(act.getBaseContext(),"开启权限失败,请手动开启权限",Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(act.getBaseContext(), "开启权限失败,请手动开启权限", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
btn_paizhao.setOnClickListener(v -> {
|
||||
RxPermissions rp=new RxPermissions(act);
|
||||
rp.request(
|
||||
Manifest.permission.CAMERA
|
||||
).subscribe(b -> {
|
||||
if (b) {
|
||||
PermissionX.init(act)
|
||||
.permissions(Manifest.permission.CAMERA)
|
||||
.request((allGranted, grantedList, deniedList) -> {
|
||||
if (allGranted) {
|
||||
file=ImageGetUtil.createImageFile(act);
|
||||
ImageGetUtil.cameraAlbumGetImage(act,file);
|
||||
} else {
|
||||
Toast.makeText(act.getBaseContext(),"开启权限失败,请手动开启权限",Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(act.getBaseContext(), "开启权限失败,请手动开启权限", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
btn_quxiao.setOnClickListener(v -> popupWindow.dismiss());
|
||||
//popupWindow消失屏幕变为不透明
|
||||
|
@ -11,11 +11,12 @@ import android.widget.Toast;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.arpa.hndahesudintocctmsdriver.util.PicturlUtil;
|
||||
import com.luck.picture.lib.permissions.RxPermissions;
|
||||
import com.arpa.hndahesudintocctmsdriver.R;
|
||||
import com.permissionx.guolindev.PermissionX;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hlh
|
||||
@ -27,46 +28,44 @@ public class GetImageAlert {
|
||||
|
||||
File file;
|
||||
PopupWindow popupWindow;
|
||||
public void showPopueWindow(AppCompatActivity act){
|
||||
View popView = View.inflate(act, R.layout.choice_img,null);
|
||||
Button btn_xiangce =popView.findViewById(R.id.btn_xiangce);
|
||||
|
||||
public void showPopueWindow(AppCompatActivity act) {
|
||||
View popView = View.inflate(act, R.layout.choice_img, null);
|
||||
Button btn_xiangce = popView.findViewById(R.id.btn_xiangce);
|
||||
Button btn_paizhao = popView.findViewById(R.id.btn_paizhao);
|
||||
Button btn_quxiao = popView.findViewById(R.id.btn_quxiao);
|
||||
Button btn_quxiao = popView.findViewById(R.id.btn_quxiao);
|
||||
//获取屏幕宽高
|
||||
int weight =act.getResources().getDisplayMetrics().widthPixels;
|
||||
int height = act.getResources().getDisplayMetrics().heightPixels*1/3;
|
||||
popupWindow = new PopupWindow(popView,weight,height);
|
||||
int weight = act.getResources().getDisplayMetrics().widthPixels;
|
||||
int height = act.getResources().getDisplayMetrics().heightPixels * 1 / 3;
|
||||
popupWindow = new PopupWindow(popView, weight, height);
|
||||
//popupWindow.setAnimationStyle(R.style.anim_popup_dir);
|
||||
popupWindow.setFocusable(true);
|
||||
//点击外部popueWindow消失
|
||||
popupWindow.setOutsideTouchable(true);
|
||||
|
||||
btn_xiangce.setOnClickListener(v -> {
|
||||
RxPermissions rp=new RxPermissions(act);
|
||||
rp.request(
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
).subscribe(b -> {
|
||||
if (b) {
|
||||
PermissionX.init(act)
|
||||
.permissions(Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
.request((allGranted, grantedList, deniedList) -> {
|
||||
if (allGranted) {
|
||||
PicturlUtil.selectPicter(act, new ArrayList<>(), 1);
|
||||
} else {
|
||||
Toast.makeText(act.getBaseContext(),"开启权限失败,请手动开启权限",Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(act.getBaseContext(), "开启权限失败,请手动开启权限", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
btn_paizhao.setOnClickListener(v -> {
|
||||
RxPermissions rp=new RxPermissions(act);
|
||||
rp.request(
|
||||
Manifest.permission.CAMERA
|
||||
).subscribe(b -> {
|
||||
if (b) {
|
||||
file=ImageGetUtil.createImageFile(act);
|
||||
ImageGetUtil.cameraAlbumGetImage(act,file);
|
||||
|
||||
PermissionX.init(act)
|
||||
.permissions(Manifest.permission.CAMERA)
|
||||
.request((allGranted, grantedList, deniedList) -> {
|
||||
if (allGranted) {
|
||||
file = ImageGetUtil.createImageFile(act);
|
||||
ImageGetUtil.cameraAlbumGetImage(act, file);
|
||||
} else {
|
||||
Toast.makeText(act.getBaseContext(),"开启权限失败,请手动开启权限",Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(act.getBaseContext(), "开启权限失败,请手动开启权限", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
btn_quxiao.setOnClickListener(v -> popupWindow.dismiss());
|
||||
//popupWindow消失屏幕变为不透明
|
||||
@ -79,14 +78,14 @@ public class GetImageAlert {
|
||||
WindowManager.LayoutParams lp = act.getWindow().getAttributes();
|
||||
lp.alpha = 0.5f;
|
||||
act.getWindow().setAttributes(lp);
|
||||
popupWindow.showAtLocation(popView, Gravity.BOTTOM,0,50);
|
||||
popupWindow.showAtLocation(popView, Gravity.BOTTOM, 0, 50);
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void dis(){
|
||||
public void dis() {
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
}
|
||||
|
@ -76,15 +76,16 @@
|
||||
android:textColor="#ff333333"
|
||||
android:textSize="@dimen/sp_15"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_marginBottom="@dimen/dp_19"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:id="@+id/upload_img"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="@dimen/dp_19"
|
||||
android:text="点击上传图片"
|
||||
android:textColor="@color/theme_color"
|
||||
android:textSize="@dimen/sp_15"/>
|
||||
android:textSize="@dimen/sp_15" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
@ -2,7 +2,7 @@ def SupportVersion = '28.0.0'
|
||||
def ButterKnifeVersion = '10.0.0'
|
||||
def CrashActivityVersion = '2.2.0'
|
||||
def StatusBarVersion = '2.3.3'
|
||||
def GsonVersion = '2.8.5'
|
||||
def GsonVersion = '2.8.6'
|
||||
def PhotoPickerVersion = 'v2.6.1'
|
||||
//def PhotoPickerVersion = 'v2.7.2'
|
||||
def GlideVersion = '4.12.0'
|
||||
@ -24,7 +24,7 @@ def MagicIndicator = '1.7.0'
|
||||
def PickerView = '4.1.9'
|
||||
def NiceSpinner = '1.4.4'
|
||||
def Countdownview = '2.1.6'
|
||||
def Xpopup = '2.2.23'
|
||||
def Xpopup = '2.2.8'
|
||||
def CheckVersionLib = '2.4.1_androidx'
|
||||
def GooglePlayVersion = '15.0.1'
|
||||
def Streamsupport = '1.7.3'
|
||||
@ -53,7 +53,7 @@ project.ext {
|
||||
"customactivityoncrash": "cat.ereza:customactivityoncrash:${CrashActivityVersion}",
|
||||
"gson" : "com.google.code.gson:gson:${GsonVersion}",
|
||||
"PhotoPicker" : "com.github.LuckSiege.PictureSelector:picture_library:${PhotoPickerVersion}",
|
||||
// "PhotoPicker" : "io.github.lucksiege:pictureselector:${PhotoPickerVersion}",
|
||||
"PhotoPicker" : "io.github.lucksiege:pictureselector:${PhotoPickerVersion}",
|
||||
"agentweb" : "com.github.Justson.AgentWeb:agentweb-core:${AgentWebVersion}",
|
||||
"statusbaruitl" : "com.github.niorgai:StatusBarCompat:${StatusBarVersion}",
|
||||
"glide" : "com.github.bumptech.glide:glide:${GlideVersion}",
|
||||
@ -83,6 +83,10 @@ project.ext {
|
||||
"CheckVersionLib" :"com.github.AlexLiuSheng:CheckVersionLib:${CheckVersionLib}",
|
||||
"Bugly" :"com.tencent.bugly:crashreport:${BuglyVersion}",
|
||||
"Streamsupport" :"net.sourceforge.streamsupport:streamsupport:${Streamsupport}",
|
||||
"PickerView" :"com.contrarywind:Android-PickerView:${PickerView}"
|
||||
"PickerView" :"com.contrarywind:Android-PickerView:${PickerView}",
|
||||
"Permissionx" :'com.guolindev.permissionx:permissionx:1.6.4',
|
||||
"3Dmap" :'com.amap.api:3dmap:8.0.0',
|
||||
"Location" :'com.amap.api:location:5.5.1',
|
||||
"Search" :'com.amap.api:search:7.9.0'
|
||||
]
|
||||
}
|
||||
|
@ -39,13 +39,11 @@ dependencies {
|
||||
implementation 'androidx.core:core-ktx:1.3.1'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'com.google.android.material:material:1.2.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
|
||||
testImplementation 'junit:junit:4.+'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
|
||||
|
||||
// api rootProject.ext.dependencies["butterknife"]
|
||||
// annotationProcessor rootProject.ext.dependencies["butterknife-compiler"]
|
||||
api rootProject.ext.dependencies["gson"]
|
||||
api rootProject.ext.dependencies["glide"]
|
||||
annotationProcessor rootProject.ext.dependencies["glide-compiler"]
|
||||
@ -67,15 +65,19 @@ dependencies {
|
||||
api rootProject.ext.dependencies["PickerView"]
|
||||
api rootProject.ext.dependencies["Xpopup"]
|
||||
api rootProject.ext.dependencies["Countdownview"]
|
||||
api rootProject.ext.dependencies["CheckVersionLib"]
|
||||
api rootProject.ext.dependencies["Bugly"]
|
||||
api rootProject.ext.dependencies["Zxing"]
|
||||
// api rootProject.ext.dependencies["CheckVersionLib"]
|
||||
// api rootProject.ext.dependencies["Bugly"]
|
||||
// api rootProject.ext.dependencies["Zxing"]
|
||||
api rootProject.ext.dependencies["Multidex"]
|
||||
api rootProject.ext.dependencies["FlycoTabLayout"]
|
||||
// api rootProject.ext.dependencies["FlycoTabLayout"]
|
||||
api rootProject.ext.dependencies["NiceDialog"]
|
||||
api rootProject.ext.dependencies["MagicIndicator"]
|
||||
// api rootProject.ext.dependencies["MagicIndicator"]
|
||||
api rootProject.ext.dependencies["glide-okhttps"]
|
||||
api 'pub.devrel:easypermissions:3.0.0'
|
||||
api rootProject.ext.dependencies["Permissionx"]
|
||||
api rootProject.ext.dependencies["3Dmap"]
|
||||
api rootProject.ext.dependencies["Location"]
|
||||
api rootProject.ext.dependencies["Search"]
|
||||
|
||||
|
||||
//友盟基础库(必须)
|
||||
// api 'com.umeng.umsdk:common:9.4.4'
|
||||
|
@ -15,11 +15,8 @@ import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.listener.OnItemClickListener;
|
||||
import com.dahe.mylibrary.R;
|
||||
import com.dahe.mylibrary.adapter.CarAdapter;
|
||||
import com.dahe.mylibrary.adapter.NodeAdapter;
|
||||
import com.dahe.mylibrary.bean.CarBean;
|
||||
import com.dahe.mylibrary.bean.NodeBean;
|
||||
import com.dahe.mylibrary.net.JsonUtils;
|
||||
import com.dahe.mylibrary.utils.ToastUtils;
|
||||
import com.lxj.xpopup.core.CenterPopupView;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -14,7 +14,6 @@ import com.chad.library.adapter.base.listener.OnItemClickListener;
|
||||
import com.dahe.mylibrary.R;
|
||||
import com.dahe.mylibrary.adapter.CenterSimAdapter;
|
||||
import com.dahe.mylibrary.bean.StateBean;
|
||||
import com.dahe.mylibrary.wapper.SelectSimAdapter;
|
||||
import com.luck.picture.lib.decoration.GridSpacingItemDecoration;
|
||||
import com.lxj.xpopup.impl.PartShadowPopupView;
|
||||
|
||||
|
@ -1,90 +0,0 @@
|
||||
package com.dahe.mylibrary.cuspop;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.listener.OnItemClickListener;
|
||||
import com.dahe.mylibrary.R;
|
||||
import com.dahe.mylibrary.adapter.SelectDicAdapter;
|
||||
import com.dahe.mylibrary.bean.DictBean;
|
||||
import com.dahe.mylibrary.bean.StateBean;
|
||||
import com.lxj.xpopup.core.AttachPopupView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description: 自定义局部阴影弹窗
|
||||
* Create by dance, at 2018/12/21
|
||||
*/
|
||||
public class CustomDicPopView extends AttachPopupView {
|
||||
private Context ctx;
|
||||
private RecyclerView recyclerView;
|
||||
private List<StateBean> wordList;
|
||||
private SelectDicAdapter adapter;
|
||||
private int selectPos;
|
||||
|
||||
public CustomDicPopView(@NonNull Context context, List<StateBean> wordList, int selectPos) {
|
||||
super(context);
|
||||
this.ctx = context;
|
||||
this.wordList= wordList;
|
||||
this.selectPos = selectPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getImplLayoutId() {
|
||||
return R.layout.custom_dic_popup;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
super.onCreate();
|
||||
recyclerView = findViewById(R.id.recyclerView);
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(ctx, RecyclerView.VERTICAL, false);
|
||||
// recyclerView.addItemDecoration(new RecycleViewDivider(ctx,RecyclerView.VERTICAL));
|
||||
recyclerView.setLayoutManager(linearLayoutManager);
|
||||
adapter = new SelectDicAdapter(-1, wordList,selectPos);
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
adapter.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(@NonNull BaseQuickAdapter adapter, @NonNull View view, int position) {
|
||||
if (listener!=null){
|
||||
listener.selectChange(wordList.get(position),position);
|
||||
}
|
||||
((SelectDicAdapter)adapter).setSelect(position);
|
||||
adapter.notifyDataSetChanged();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onShow() {
|
||||
super.onShow();
|
||||
Log.e("tag", "CustomPartShadowPopupView onShow");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDismiss() {
|
||||
super.onDismiss();
|
||||
Log.e("tag", "CustomPartShadowPopupView onDismiss");
|
||||
}
|
||||
|
||||
|
||||
private OnSelectChangeListener listener;
|
||||
public CustomDicPopView setOnSelectChangeListener(OnSelectChangeListener listener){
|
||||
this.listener = listener;
|
||||
return this;
|
||||
}
|
||||
public interface OnSelectChangeListener{
|
||||
void selectChange(StateBean item ,int postion);
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
package com.dahe.mylibrary.cuspop;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.listener.OnItemClickListener;
|
||||
import com.dahe.mylibrary.R;
|
||||
import com.dahe.mylibrary.wapper.SelectSimAdapter;
|
||||
import com.luck.picture.lib.decoration.GridSpacingItemDecoration;
|
||||
import com.lxj.xpopup.impl.PartShadowPopupView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description: 自定义局部阴影弹窗
|
||||
* Create by dance, at 2018/12/21
|
||||
*/
|
||||
public class CustomPartShadowPopupView extends PartShadowPopupView {
|
||||
private Context ctx;
|
||||
private RecyclerView recyclerView;
|
||||
private List<String> wordList;
|
||||
private SelectSimAdapter adapter;
|
||||
private String selectString;
|
||||
|
||||
public CustomPartShadowPopupView(@NonNull Activity context, List<String> wordList, String selectString) {
|
||||
super(context);
|
||||
this.wordList= wordList;
|
||||
this.selectString = selectString;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getImplLayoutId() {
|
||||
return R.layout.custom_part_shadow_popup;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
super.onCreate();
|
||||
recyclerView = findViewById(R.id.recyclerView);
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(ctx, 4);
|
||||
recyclerView.addItemDecoration(new GridSpacingItemDecoration(4, 20, false));
|
||||
recyclerView.setLayoutManager(gridLayoutManager);
|
||||
adapter = new SelectSimAdapter(-1, wordList,selectString);
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
adapter.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(@NonNull BaseQuickAdapter adapter, @NonNull View view, int position) {
|
||||
if (listener!=null){
|
||||
listener.selectChange(wordList.get(position),position);
|
||||
}
|
||||
((SelectSimAdapter)adapter).setSelect(wordList.get(position));
|
||||
adapter.notifyDataSetChanged();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onShow() {
|
||||
super.onShow();
|
||||
Log.e("tag", "CustomPartShadowPopupView onShow");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDismiss() {
|
||||
super.onDismiss();
|
||||
Log.e("tag", "CustomPartShadowPopupView onDismiss");
|
||||
}
|
||||
|
||||
|
||||
private OnSelectChangeListener listener;
|
||||
public CustomPartShadowPopupView setOnSelectChangeListener(OnSelectChangeListener listener){
|
||||
this.listener = listener;
|
||||
return this;
|
||||
}
|
||||
public interface OnSelectChangeListener{
|
||||
void selectChange(String item ,int postion);
|
||||
}
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
package com.dahe.mylibrary.cuspop;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.dahe.mylibrary.R;
|
||||
import com.dahe.mylibrary.utils.ToastUtils;
|
||||
import com.lxj.xpopup.core.CenterPopupView;
|
||||
import com.lxj.xpopup.util.KeyboardUtils;
|
||||
|
||||
/**
|
||||
* Description: 自定义局部阴影弹窗
|
||||
* Create by dance, at 2018/12/21
|
||||
*/
|
||||
public class InputPopupView extends CenterPopupView {
|
||||
private Context ctx;
|
||||
|
||||
|
||||
public InputPopupView(@NonNull Context context) {
|
||||
super(context);
|
||||
this.ctx = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getImplLayoutId() {
|
||||
return R.layout.my_confim_popup_input;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
super.onCreate();
|
||||
EditText etInput = findViewById(R.id.et_input);
|
||||
TextView tvCancel = findViewById(R.id.tv_cancel);
|
||||
TextView tvConfirm = findViewById(R.id.tv_confirm);
|
||||
if (listener != null) {
|
||||
tvConfirm.setOnClickListener(view -> {
|
||||
if (TextUtils.isEmpty(etInput.getText().toString().trim())){
|
||||
KeyboardUtils.hideSoftInput(tvConfirm);
|
||||
ToastUtils.showToast(ctx,"请填写取消原因");
|
||||
return;
|
||||
}
|
||||
listener.okClick(etInput.getText().toString());
|
||||
dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
tvCancel.setOnClickListener(v -> dismiss());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onShow() {
|
||||
super.onShow();
|
||||
Log.e("tag", "CustomPartShadowPopupView onShow");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDismiss() {
|
||||
super.onDismiss();
|
||||
Log.e("tag", "CustomPartShadowPopupView onDismiss");
|
||||
}
|
||||
|
||||
|
||||
private OnOkListener listener;
|
||||
|
||||
public InputPopupView setOnOkListener(OnOkListener listener) {
|
||||
this.listener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface OnOkListener {
|
||||
void okClick(String item);
|
||||
}
|
||||
}
|
@ -1,107 +0,0 @@
|
||||
package com.dahe.mylibrary.cuspop;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.listener.OnItemClickListener;
|
||||
import com.dahe.mylibrary.R;
|
||||
import com.dahe.mylibrary.adapter.NodeAdapter;
|
||||
import com.dahe.mylibrary.bean.NodeBean;
|
||||
import com.dahe.mylibrary.net.JsonUtils;
|
||||
import com.dahe.mylibrary.utils.ToastUtils;
|
||||
import com.lxj.xpopup.core.CenterPopupView;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class NodePopupView extends CenterPopupView {
|
||||
|
||||
|
||||
private Context context;
|
||||
private List<NodeBean> data;
|
||||
public NodePopupView(Context context,String data) {
|
||||
super(context);
|
||||
this.context = context;
|
||||
ArrayList<NodeBean> nodeBeans = JsonUtils.getInstance().jsonToList(data, NodeBean.class);
|
||||
this.data = nodeBeans;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getImplLayoutId() {
|
||||
return R.layout.view_node;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
super.onCreate();
|
||||
TextView tvTitle = (TextView) findViewById(R.id.tvTitle);
|
||||
ImageView ivCha = (ImageView) findViewById(R.id.ivCha);
|
||||
LinearLayout llCha = (LinearLayout) findViewById(R.id.llCha);
|
||||
Button btnOK = (Button) findViewById(R.id.btnOK);
|
||||
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(context,RecyclerView.VERTICAL,false));
|
||||
recyclerView.setHasFixedSize(true);
|
||||
NodeAdapter nodeAdapter = new NodeAdapter(-1,data);
|
||||
recyclerView.setAdapter(nodeAdapter);
|
||||
|
||||
|
||||
nodeAdapter.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(@NonNull @NotNull BaseQuickAdapter<?, ?> adapter, @NonNull @NotNull View view, int position) {
|
||||
NodeBean nodeSelectBean = data.get(position);
|
||||
if (!"0".equals(nodeSelectBean.getState())){
|
||||
ToastUtils.showToast(context,"该节点不可操作");
|
||||
return;
|
||||
}
|
||||
nodeSelectBean.setSelect("1".equals(nodeSelectBean.isSelect())?"0":"1");
|
||||
nodeAdapter.notifyItemChanged(position);
|
||||
}
|
||||
});
|
||||
|
||||
btnOK.setOnClickListener(v -> {
|
||||
if (listener!=null){
|
||||
ArrayList<NodeBean> temp = new ArrayList<>();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
NodeBean nodeSelectBean = data.get(i);
|
||||
if ("1".equals(nodeSelectBean.isSelect())){
|
||||
temp.add(nodeSelectBean);
|
||||
}
|
||||
|
||||
}
|
||||
if (temp.size()<=0){
|
||||
ToastUtils.showToast(context,"至少存在一个节点");
|
||||
return;
|
||||
}
|
||||
listener.okClick(JsonUtils.getInstance().toJson(data));
|
||||
temp = null;
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
llCha.setOnClickListener(v -> {
|
||||
dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private OnOkListener listener;
|
||||
|
||||
public NodePopupView setOnOkListener(OnOkListener listener) {
|
||||
this.listener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface OnOkListener {
|
||||
void okClick(String data);
|
||||
}
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
package com.dahe.mylibrary.cuspop;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.dahe.mylibrary.R;
|
||||
import com.dahe.mylibrary.bean.TipsBean;
|
||||
import com.lxj.xpopup.core.CenterPopupView;
|
||||
|
||||
/**
|
||||
* Description: 自定义局部阴影弹窗
|
||||
* Create by dance, at 2018/12/21
|
||||
*/
|
||||
public class TextPopupTipsView extends CenterPopupView {
|
||||
private TipsBean data;
|
||||
private Context ctx;
|
||||
|
||||
|
||||
public TextPopupTipsView(@NonNull Context context, TipsBean data) {
|
||||
super(context);
|
||||
this.data = data;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getImplLayoutId() {
|
||||
return R.layout.my_confim_popup_tip;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
super.onCreate();
|
||||
TextView etInput = findViewById(R.id.tv_input);
|
||||
TextView tvTitle = findViewById(R.id.tv_title);
|
||||
TextView tvCancel = findViewById(R.id.tv_cancel);
|
||||
TextView tvConfirm = findViewById(R.id.tv_confirm);
|
||||
tvTitle.setText(data.getTitle());
|
||||
etInput.setText(data.getContent());
|
||||
if (listener != null) {
|
||||
tvConfirm.setOnClickListener(view -> {
|
||||
listener.okClick();
|
||||
dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
tvCancel.setOnClickListener(v -> dismiss());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onShow() {
|
||||
super.onShow();
|
||||
Log.e("tag", "CustomPartShadowPopupView onShow");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDismiss() {
|
||||
super.onDismiss();
|
||||
Log.e("tag", "CustomPartShadowPopupView onDismiss");
|
||||
}
|
||||
|
||||
|
||||
private OnOkListener listener;
|
||||
|
||||
public TextPopupTipsView setOnOkListener(OnOkListener listener) {
|
||||
this.listener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface OnOkListener {
|
||||
void okClick();
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
package com.dahe.mylibrary.cuspop;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.dahe.mylibrary.R;
|
||||
import com.lxj.xpopup.core.CenterPopupView;
|
||||
|
||||
/**
|
||||
* Description: 自定义局部阴影弹窗
|
||||
* Create by dance, at 2018/12/21
|
||||
*/
|
||||
public class TextPopupView extends CenterPopupView {
|
||||
private String data;
|
||||
private Context ctx;
|
||||
|
||||
|
||||
public TextPopupView(@NonNull Context context,String data) {
|
||||
super(context);
|
||||
this.data = data;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getImplLayoutId() {
|
||||
return R.layout.my_confim_popup_unus;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
super.onCreate();
|
||||
TextView etInput = findViewById(R.id.tv_input);
|
||||
TextView tvCancel = findViewById(R.id.tv_cancel);
|
||||
TextView tvConfirm = findViewById(R.id.tv_confirm);
|
||||
etInput.setText(data);
|
||||
if (listener != null) {
|
||||
tvConfirm.setOnClickListener(view -> {
|
||||
listener.okClick(etInput.getText().toString());
|
||||
dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
tvCancel.setOnClickListener(v -> dismiss());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onShow() {
|
||||
super.onShow();
|
||||
Log.e("tag", "CustomPartShadowPopupView onShow");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDismiss() {
|
||||
super.onDismiss();
|
||||
Log.e("tag", "CustomPartShadowPopupView onDismiss");
|
||||
}
|
||||
|
||||
|
||||
private OnOkListener listener;
|
||||
|
||||
public TextPopupView setOnOkListener(OnOkListener listener) {
|
||||
this.listener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface OnOkListener {
|
||||
void okClick(String item);
|
||||
}
|
||||
}
|
@ -2,11 +2,6 @@ package com.dahe.mylibrary.net;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
import com.google.zxing.common.StringUtils;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -1,325 +0,0 @@
|
||||
package com.dahe.mylibrary.utils;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Address;
|
||||
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.util.Log;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.Nullable;
|
||||
import pub.devrel.easypermissions.EasyPermissions;
|
||||
|
||||
public class LocationUtil {
|
||||
private static OnResponseListener responseListener;
|
||||
private static LocationUtil locationUtil;
|
||||
|
||||
private LocationManager locationManager;
|
||||
private Location currentBestLocation;
|
||||
private NetworkListener networkListener;
|
||||
private GPSLocationListener gpsListener;
|
||||
|
||||
private LocationUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 定位模式
|
||||
*/
|
||||
public enum Mode {
|
||||
NETWORK, //网络定位
|
||||
GPS, //GPS定位
|
||||
AUTO //自动定位,使用网络或GPS定位
|
||||
}
|
||||
|
||||
|
||||
public static final int NO_PERMISSION = 1; //没权限
|
||||
public static final int GPS_CLOSE = 2; //GPS是关闭的
|
||||
public static final int UNAVAILABLE = 3; //不可用
|
||||
|
||||
/**
|
||||
* 请求定位
|
||||
*/
|
||||
public static void requestLocation(Context context, Mode mode, OnResponseListener onResponseListener) {
|
||||
LocationUtil.responseListener = onResponseListener;
|
||||
if (EasyPermissions.hasPermissions(context, Manifest.permission.ACCESS_FINE_LOCATION,
|
||||
Manifest.permission.ACCESS_COARSE_LOCATION)) {
|
||||
Log.i("lj", "获取定位权限,开始定位");
|
||||
//开始定位
|
||||
locationUtil = new LocationUtil();
|
||||
locationUtil.startLocation(context, mode);
|
||||
} else {
|
||||
Log.i("lj", "没有定位权限,定位失败");
|
||||
String provider = mode == Mode.GPS ? LocationManager.GPS_PROVIDER : LocationManager.NETWORK_PROVIDER;
|
||||
onResponseListener.onErrorResponse(provider, NO_PERMISSION);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始定位
|
||||
*/
|
||||
private void startLocation(Context context, Mode mode) {
|
||||
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
|
||||
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
|
||||
switch (mode) {
|
||||
case NETWORK:
|
||||
if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
|
||||
Log.i("lj", "网络定位");
|
||||
networkListener = new NetworkListener();
|
||||
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 500, 0.1f, networkListener);
|
||||
} else {
|
||||
responseListener.onErrorResponse(LocationManager.NETWORK_PROVIDER, UNAVAILABLE);
|
||||
}
|
||||
break;
|
||||
case GPS:
|
||||
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||
Log.i("lj","GPS定位");
|
||||
gpsListener = new GPSLocationListener();
|
||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000 * 2, 0.1f, gpsListener);
|
||||
} else {
|
||||
responseListener.onErrorResponse(LocationManager.GPS_PROVIDER, GPS_CLOSE);
|
||||
}
|
||||
|
||||
break;
|
||||
case AUTO:
|
||||
if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
|
||||
Log.i("lj","自动定位选择网络定位");
|
||||
networkListener = new NetworkListener();
|
||||
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 500, 0.1f, networkListener);
|
||||
} else if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||
Log.i("lj","自动定位选择gps");
|
||||
gpsListener = new GPSLocationListener();
|
||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000 * 2, 0.1f, gpsListener);
|
||||
} else {
|
||||
responseListener.onErrorResponse(LocationManager.NETWORK_PROVIDER, UNAVAILABLE);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
Log.i("lj","无权限");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止定位
|
||||
*/
|
||||
public static void stopLocation() {
|
||||
if (locationUtil == null) {
|
||||
Log.i("lj","locationUtil is null");
|
||||
return;
|
||||
}
|
||||
if (locationUtil.networkListener != null) {
|
||||
locationUtil.locationManager.removeUpdates(locationUtil.networkListener);
|
||||
}
|
||||
if (locationUtil.gpsListener != null) {
|
||||
locationUtil.locationManager.removeUpdates(locationUtil.gpsListener);
|
||||
}
|
||||
// L.i("停止定位");
|
||||
}
|
||||
|
||||
private class GPSLocationListener implements LocationListener {
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
// L.i("onLocationChanged");
|
||||
if (location != null) {
|
||||
// L.i("GPS定位成功");
|
||||
// L.i("GPS定位耗时:" + ((System.currentTimeMillis() - l) / 1000) + "秒");
|
||||
boolean isBetter = isBetterLocation(location, currentBestLocation);
|
||||
if (isBetter) {
|
||||
currentBestLocation = location;
|
||||
}
|
||||
double latitude = currentBestLocation.getLatitude(); //纬度
|
||||
double longitude = currentBestLocation.getLongitude(); //经度
|
||||
responseListener.onSuccessResponse(latitude, longitude);
|
||||
} else {
|
||||
// L.i("location is null");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||
// L.i("onStatusChanged:" + status);
|
||||
if (status == LocationProvider.OUT_OF_SERVICE || status == LocationProvider.TEMPORARILY_UNAVAILABLE) {
|
||||
// L.i("GPS定位失败");
|
||||
//如果之前没有开启过网络定位,自动切换到网络定位
|
||||
if (networkListener == null) {
|
||||
//开启网络定位
|
||||
networkListener = new NetworkListener();
|
||||
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, networkListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {
|
||||
// L.i("onProviderEnabled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {
|
||||
// L.i("onProviderDisabled");
|
||||
}
|
||||
}
|
||||
|
||||
private class NetworkListener implements LocationListener {
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
if (location != null) {
|
||||
// L.i("网络定位成功");
|
||||
|
||||
boolean isBetter = isBetterLocation(location, currentBestLocation);
|
||||
if (isBetter) {
|
||||
currentBestLocation = location;
|
||||
}
|
||||
double latitude = currentBestLocation.getLatitude(); //纬度
|
||||
double longitude = currentBestLocation.getLongitude(); //经度
|
||||
responseListener.onSuccessResponse(latitude, longitude);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||
if (status == LocationProvider.OUT_OF_SERVICE || status == LocationProvider.TEMPORARILY_UNAVAILABLE) {
|
||||
// Log.i("网络定位失败");
|
||||
responseListener.onErrorResponse(LocationManager.NETWORK_PROVIDER, UNAVAILABLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {
|
||||
// L.e("可用");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {
|
||||
// L.e("不可用");
|
||||
}
|
||||
}
|
||||
|
||||
private static final int TWO_MINUTES = 1000 * 60 * 2;
|
||||
|
||||
/**
|
||||
* 比较最新获取到的位置是否比当前最好的位置更好
|
||||
*
|
||||
* @param location 最新获得的位置
|
||||
* @param currentBestLocation 当前获取到的最好的位置
|
||||
* @return 最新获取的位置比当前最好的位置更好则返回true
|
||||
*/
|
||||
private boolean isBetterLocation(Location location, Location currentBestLocation) {
|
||||
if (currentBestLocation == null) {
|
||||
// A new locationUtil is always better than no locationUtil
|
||||
return true;
|
||||
}
|
||||
|
||||
//实时性
|
||||
// Check whether the new locationUtil fix is newer or older
|
||||
long timeDelta = location.getTime() - currentBestLocation.getTime();
|
||||
boolean isSignificantlyNewer = timeDelta > TWO_MINUTES; //最新位置比当前位置晚两分钟定位
|
||||
boolean isSignificantlyOlder = timeDelta < -TWO_MINUTES;//最新位置比当前位置早两分钟定位
|
||||
boolean isNewer = timeDelta > 0;
|
||||
|
||||
// If it's been more than two minutes since the current locationUtil, use the new locationUtil
|
||||
// because the user has likely moved
|
||||
if (isSignificantlyNewer) {
|
||||
return true;
|
||||
// If the new locationUtil is more than two minutes older, it must be worse
|
||||
} else if (isSignificantlyOlder) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//精确性
|
||||
// Check whether the new locationUtil fix is more or less accurate
|
||||
//locationUtil.getAccuracy()值越小越精确
|
||||
int accuracyDelta = (int) (location.getAccuracy() - currentBestLocation.getAccuracy());
|
||||
boolean isLessAccurate = accuracyDelta > 0; //最新的位置不如当前的精确
|
||||
boolean isMoreAccurate = accuracyDelta < 0; //最新的位置比当前的精确
|
||||
//最新的位置不如当前的精确,但是相差在一定范围之内
|
||||
boolean isSignificantlyLessAccurate = accuracyDelta > 200;
|
||||
|
||||
// Check if the old and new locationUtil are from the same provider
|
||||
boolean isFromSameProvider = isSameProvider(location.getProvider(),
|
||||
currentBestLocation.getProvider());
|
||||
|
||||
// Determine locationUtil quality using a combination of timeliness and accuracy
|
||||
if (isMoreAccurate) {
|
||||
return true;
|
||||
} else if (isNewer && !isLessAccurate) {
|
||||
return true;
|
||||
} else if (isNewer && !isSignificantlyLessAccurate && isFromSameProvider) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether two providers are the same
|
||||
*/
|
||||
private boolean isSameProvider(String provider1, String provider2) {
|
||||
if (provider1 == null) {
|
||||
return provider2 == null;
|
||||
}
|
||||
return provider1.equals(provider2);
|
||||
}
|
||||
|
||||
public interface OnResponseListener {
|
||||
/**
|
||||
* 定位成功
|
||||
*
|
||||
* @param latitude 纬度
|
||||
* @param longitude 经度
|
||||
*/
|
||||
void onSuccessResponse(double latitude, double longitude);
|
||||
|
||||
/**
|
||||
* 定位失败
|
||||
*
|
||||
* @param provider provider
|
||||
* @param status 失败码
|
||||
*/
|
||||
void onErrorResponse(String provider, int status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取地址
|
||||
*
|
||||
* @param context Context
|
||||
* @param latitude 纬度
|
||||
* @param longitude 经度
|
||||
* @return Address
|
||||
*/
|
||||
public static @Nullable
|
||||
Address getAddress(Context context, double latitude, double longitude) {
|
||||
Geocoder geocoder = new Geocoder(context);
|
||||
try {
|
||||
List<Address> list = geocoder.getFromLocation(latitude, longitude, 3);
|
||||
if (list.size() > 0) {
|
||||
Address address = list.get(0);
|
||||
// Log.i("省:" + address.getAdminArea());
|
||||
// Log.i("市:" + address.getLocality());
|
||||
// Log.i("县/区:" + address.getSubLocality());
|
||||
return address;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,181 +0,0 @@
|
||||
package com.dahe.mylibrary.utils;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.allenliu.versionchecklib.core.http.HttpParams;
|
||||
import com.allenliu.versionchecklib.core.http.HttpRequestMethod;
|
||||
import com.allenliu.versionchecklib.v2.AllenVersionChecker;
|
||||
import com.allenliu.versionchecklib.v2.builder.DownloadBuilder;
|
||||
import com.allenliu.versionchecklib.v2.builder.RequestVersionBuilder;
|
||||
import com.allenliu.versionchecklib.v2.builder.UIData;
|
||||
import com.allenliu.versionchecklib.v2.callback.CustomDownloadingDialogListener;
|
||||
import com.allenliu.versionchecklib.v2.callback.CustomVersionDialogListener;
|
||||
import com.allenliu.versionchecklib.v2.callback.RequestVersionListener;
|
||||
import com.dahe.mylibrary.R;
|
||||
import com.dahe.mylibrary.bean.VersionBean;
|
||||
import com.dahe.mylibrary.dialog.VersionDialog;
|
||||
import com.dahe.mylibrary.net.CommonResponseBean;
|
||||
import com.dahe.mylibrary.net.JsonUtils;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class VersionUtils {
|
||||
|
||||
|
||||
private static class SingletonHolder {
|
||||
private static final VersionUtils INSTANCE = new VersionUtils();
|
||||
}
|
||||
|
||||
private VersionUtils() {
|
||||
}
|
||||
|
||||
public static final VersionUtils getInstance() {
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
public void checkVersion(Context ctx, String api,boolean isShow) {
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("appType", "1");
|
||||
DownloadBuilder request = AllenVersionChecker
|
||||
.getInstance()
|
||||
.requestVersion()
|
||||
.setRequestMethod(HttpRequestMethod.GET)
|
||||
.setRequestUrl(api)
|
||||
.setRequestParams(httpParams)
|
||||
.request(new RequestVersionListener() {
|
||||
@Nullable
|
||||
@org.jetbrains.annotations.Nullable
|
||||
@Override
|
||||
public UIData onRequestVersionSuccess(DownloadBuilder downloadBuilder, String result) {
|
||||
try {
|
||||
if (StringUtils.isEmpty(result))
|
||||
return null;
|
||||
Type type = new TypeToken<CommonResponseBean<VersionBean>>() {
|
||||
}.getType();
|
||||
CommonResponseBean<VersionBean> o = JsonUtils.getInstance().fromJson(result, type);
|
||||
VersionBean.ParamsDao data = o.getData().getData();
|
||||
if ("1".equals(data.getUpdateType())) {
|
||||
downloadBuilder.setForceRedownload(true);
|
||||
}else{
|
||||
downloadBuilder.setForceRedownload(false);
|
||||
}
|
||||
if (AppUtils.getAppVersionCode() < data.getVersion()) {
|
||||
UIData uiData = UIData.create();
|
||||
uiData.setTitle(data.getVersionName());
|
||||
uiData.setDownloadUrl(data.getApkUrl());
|
||||
uiData.setContent(data.getIntroduce());
|
||||
return uiData;
|
||||
}
|
||||
if (isShow){
|
||||
ToastUtils.showToast(ctx,"当前已是最新版本啊!");
|
||||
}
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestVersionFailure(String message) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
request.setCustomVersionDialogListener(createCustomDialogTwo(request));
|
||||
request.setCustomDownloadingDialogListener(createCustomDownloadingDialog(ctx)).executeMission(ctx);
|
||||
}
|
||||
|
||||
private CustomVersionDialogListener createCustomDialogTwo(DownloadBuilder request) {
|
||||
return (context, versionBundle) -> {
|
||||
VersionDialog baseDialog = new VersionDialog(context, R.style.BaseDialog, R.layout.custom_dialog_two_layout2);
|
||||
TextView textView = baseDialog.findViewById(R.id.tv_msg);
|
||||
TextView tvVersion = baseDialog.findViewById(R.id.tvVersion);
|
||||
tvVersion.setText(request.getVersionBundle().getTitle()+" 版本更新");
|
||||
textView.setMovementMethod(ScrollingMovementMethod.getInstance());
|
||||
RequestVersionBuilder requestVersionBuilder = request.getRequestVersionBuilder();
|
||||
// TextView tvTitle = baseDialog.findViewById(R.id.tv_title);
|
||||
baseDialog.findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean forceRedownload = request.isForceRedownload();
|
||||
if (forceRedownload){
|
||||
ToastUtils.showToast(context,"请更新版本");
|
||||
}else{
|
||||
baseDialog.cancel();
|
||||
baseDialog.dismiss();
|
||||
AllenVersionChecker.getInstance().cancelAllMission();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
// textView.setText(versionBundle.getContent());
|
||||
textView.setText(versionBundle.getContent());
|
||||
baseDialog.setCanceledOnTouchOutside(request.isForceRedownload()?false:true);
|
||||
baseDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
||||
if (KeyEvent.KEYCODE_BACK==event.getKeyCode()&&request.isForceRedownload()){
|
||||
ToastUtils.showToast(context,"请更新版本");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
baseDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
|
||||
}
|
||||
});
|
||||
return baseDialog;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自定义下载中对话框,下载中会连续回调此方法 updateUI
|
||||
* 务必用库传回来的context 实例化你的dialog
|
||||
*
|
||||
* @param ctx
|
||||
* @return
|
||||
*/
|
||||
private CustomDownloadingDialogListener createCustomDownloadingDialog(Context ctx) {
|
||||
return new CustomDownloadingDialogListener() {
|
||||
@Override
|
||||
public Dialog getCustomDownloadingDialog(Context context, int progress, UIData versionBundle) {
|
||||
VersionDialog baseDialog = new VersionDialog(context, R.style.BaseDialog, R.layout.dialog_download_layout);
|
||||
return baseDialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUI(Dialog dialog, int progress, UIData versionBundle) {
|
||||
TextView tvProgress = dialog.findViewById(R.id.tv_progress);
|
||||
ProgressBar progressBar = dialog.findViewById(R.id.pb);
|
||||
progressBar.setProgress(progress);
|
||||
tvProgress.setText(ctx.getString(R.string.versionchecklib_progress, progress));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// private NotificationBuilder createCustomNotification(Context ctx) {
|
||||
// return NotificationBuilder.create()
|
||||
// .setRingtone(true)
|
||||
// .setIcon(R.mipmap.)
|
||||
// .setTicker("custom_ticker")
|
||||
// .setContentTitle("custom title")
|
||||
// .setContentText(ctx.getString(R.string.custom_content_text));
|
||||
// }
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="381dp"
|
||||
android:background="@drawable/version_top_bg"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/tv_msg"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="50dp"
|
||||
android:layout_marginTop="200dp"
|
||||
android:layout_marginRight="50dp"
|
||||
android:nestedScrollingEnabled="true"
|
||||
android:scrollbars="vertical"
|
||||
android:text="SL会计法士大夫撒离开尽量快点撒发了喀什角SL会计法士大夫撒离开尽量快点撒发了喀什角SL会计法士大夫撒离开尽量快点撒发了喀什角SL会计法士大夫撒离开尽量快点撒发了喀什角动量反馈阿斯利康大家分厘卡士大夫刻录机阿斯利康的飞机流口水克拉斯JFK垃圾啊收到了开发"
|
||||
android:textColor="@color/colorBlack0"
|
||||
android:textSize="@dimen/text_14sp" />
|
||||
|
||||
<Button
|
||||
android:id="@id/versionchecklib_version_dialog_commit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginRight="30dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@drawable/shape_bind_phone_background"
|
||||
android:text="立即更新"
|
||||
android:textColor="@android:color/white" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/close"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="26dp"
|
||||
android:background="@drawable/error" />
|
||||
|
||||
|
||||
</LinearLayout>
|
@ -1,75 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="217dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/update_head"
|
||||
></ImageView>
|
||||
<TextView
|
||||
android:id="@+id/tvVersion"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="版本号"
|
||||
android:gravity="center"
|
||||
android:textSize="18dp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/black"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="10dp"
|
||||
></TextView>
|
||||
<ImageView
|
||||
android:id="@+id/close"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginTop="48dp"
|
||||
android:layout_marginRight="14dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/diss"
|
||||
></ImageView>
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="120dp"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="30dp"
|
||||
android:paddingRight="30dp"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/shape_bottom_bgw16">
|
||||
<TextView
|
||||
android:gravity="center_vertical"
|
||||
android:id="@+id/tv_msg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="120dp"
|
||||
android:maxHeight="220dp"
|
||||
android:text=""
|
||||
android:textColor="@color/colorBlack6"
|
||||
android:textSize="@dimen/text_14sp"
|
||||
></TextView>
|
||||
<Button
|
||||
android:id="@id/versionchecklib_version_dialog_commit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginRight="30dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@drawable/shape_log_btn_bg22"
|
||||
android:text="立即更新"
|
||||
android:textColor="@android:color/white" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="20dp">
|
||||
|
||||
<androidx.core.widget.ContentLoadingProgressBar
|
||||
android:id="@+id/pb"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="15dp"
|
||||
android:max="100"
|
||||
android:progress="0"
|
||||
|
||||
android:progressDrawable="@drawable/progressbar_horizontal" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/versionchecklib_downloading"
|
||||
android:textColor="@color/versionchecklib_theme_color"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:text="@string/versionchecklib_progress"
|
||||
android:textColor="@color/versionchecklib_theme_color"
|
||||
android:textSize="15sp" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user