首次提交
commit
3bd8794363
|
|
@ -0,0 +1 @@
|
|||
/build
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
plugins {
|
||||
id 'com.android.application'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.ycgis.macall.personalcenter"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 30
|
||||
versionCode 2401171
|
||||
versionName "3.0.20240117"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
debug{
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
dataBinding true
|
||||
}
|
||||
packagingOptions {
|
||||
exclude 'META-INF/XXX'
|
||||
exclude 'META-INF/proguard/androidx-annotations.pro'
|
||||
exclude 'META-INF/DEPENDENCIES.txt'
|
||||
exclude 'META-INF/LICENSE.txt'
|
||||
exclude 'META-INF/NOTICE.txt'
|
||||
exclude 'META-INF/NOTICE'
|
||||
exclude 'META-INF/LICENSE'
|
||||
exclude 'META-INF/DEPENDENCIES'
|
||||
exclude 'META-INF/notice.txt'
|
||||
exclude 'META-INF/license.txt'
|
||||
exclude 'META-INF/dependencies.txt'
|
||||
exclude 'META-INF/LGPL2.1'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
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'
|
||||
|
||||
// tableLayout
|
||||
implementation 'io.github.h07000223:flycoTabLayout:3.0.0'
|
||||
//选择组件
|
||||
implementation 'com.contrarywind:Android-PickerView:4.1.9'
|
||||
//轮播图
|
||||
implementation 'io.github.youth5201314:banner:2.2.2'
|
||||
//加载动画
|
||||
implementation 'com.wang.avi:library:2.1.3'
|
||||
//视频播放器 饺子视频播放器
|
||||
implementation 'cn.jzvd:jiaozivideoplayer:7.7.0'
|
||||
|
||||
implementation 'com.github.Justson.AgentWeb:agentweb-core:v5.0.6-androidx' // (必选)
|
||||
implementation 'com.github.Justson.AgentWeb:agentweb-filechooser:v5.0.6-androidx' // (可选)
|
||||
implementation 'com.github.Justson:Downloader:v5.0.4-androidx'
|
||||
|
||||
//rxJava + retrofit
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.4'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.6.1'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
|
||||
implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.6.1'
|
||||
|
||||
// Glide 设置 OkHttp 请求的注解 依赖
|
||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
||||
|
||||
implementation 'com.google.android.material:material:1.5.0-alpha02'
|
||||
//viewModel
|
||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation files('libs/com.code.base.jar')
|
||||
implementation files('libs/AuthSDK_v3.0.0.aar')
|
||||
implementation files('libs/MarketSDK_v3.0.16.11.aar')
|
||||
implementation files('libs/unifyservemoduleSDK_V1.5.231221.aar')
|
||||
implementation files('libs/libfriapkrecord-r1.0.1.aar')
|
||||
implementation project(':BaseModel')
|
||||
//Zxing 二维码识别
|
||||
implementation 'com.github.jenly1314:zxing-lite:2.1.1'
|
||||
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,281 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
|
||||
#统一认证
|
||||
-dontwarn com.anhui.police.auth.**
|
||||
-keep class com.anhui.police.auth.** { *; }
|
||||
#应用中心
|
||||
-dontwarn com.anhui.police.market.sdk.**
|
||||
-keep class com.anhui.police.market.** { *; }
|
||||
#统一服务组件
|
||||
-dontwarn com.ruansee.macall.unifyservemodulesdk.**
|
||||
-keep class com.ruansee.macall.unifyservemodulesdk.** { *; }
|
||||
|
||||
#基类
|
||||
-dontwarn com.rs.macall.androidx.basemodel.**
|
||||
-keep class com.rs.macall.androidx.basemodel.** { *; }
|
||||
|
||||
#加载动画
|
||||
-dontwarn com.wang.avi.**
|
||||
-keep class com.wang.avi.** { *; }
|
||||
|
||||
-keep public class * extends androidx.fragment.app.FragmentActivity
|
||||
-keep public class * extends android.app.Application
|
||||
-keep public class * extends androidx.core.content.FileProvider
|
||||
-keep public class * extends android.app.Service
|
||||
-keep public class * extends android.app.Activity
|
||||
-keep public class * extends android.content.BroadcastReceiver
|
||||
-keep public class * extends android.content.ContentProvider
|
||||
|
||||
-keep public class * extends android.app.backup.BackupAgentHelper
|
||||
-keep public class * extends android.preference.Preference
|
||||
-keep public class * extends android.view.View
|
||||
-keep class android.support.** {*;}
|
||||
|
||||
-dontwarn java.util.concurrent.Flow*
|
||||
|
||||
-keep public class com.ycgis.macall.personalcenter.p.app.CrashHandler{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.p.app.RuanseeApplication{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.p.app.UserData{*;}
|
||||
#-keep public class com.ycgis.macall.personalcenter.p.app.AppCache{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.p.callback.BaseRequestCallback{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.p.callback.RequestCallback{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.p.callback.WebActivityCallback{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.p.presenter.**{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.p.request.interceptors.**{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.p.request.ApiModel{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.p.request.HttpErrorHandler{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.p.request.RetrofitApi{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.p.request.RetrofitService{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.p.request.UploadProgressResponsBody{*;}
|
||||
|
||||
-keep public class com.ycgis.macall.personalcenter.m.adapterbean.**{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.m.event.MessageEvent{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.m.enumbean.**{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.m.provider.**{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.m.requestbean.**{*;}
|
||||
|
||||
-keep public class com.ycgis.macall.personalcenter.v.activity.**{
|
||||
public *;}
|
||||
-keep public class com.ycgis.macall.personalcenter.v.adapter.**{
|
||||
public *;}
|
||||
-keep public class com.ycgis.macall.personalcenter.v.fragment.**{
|
||||
public *;}
|
||||
-keep public class com.ycgis.macall.personalcenter.v.custom.**{
|
||||
public *;}
|
||||
-keep public class com.ycgis.macall.personalcenter.v.photoview.**{*;}
|
||||
|
||||
-keep public class com.ycgis.macall.personalcenter.util.ReadDeviceInfo{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.util.FileUtils{
|
||||
public *;}
|
||||
-keep public class com.ycgis.macall.personalcenter.util.IdcardUtils{
|
||||
public *;}
|
||||
-keep public class com.ycgis.macall.personalcenter.util.JiaMi{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.util.ImageOptimizationUtil{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.util.IPAddressUtils{*;}
|
||||
-keep public class com.ycgis.macall.personalcenter.util.LocationGPSManage{
|
||||
public *;}
|
||||
-keep public class com.ycgis.macall.personalcenter.util.NotificationUtils{
|
||||
public *;}
|
||||
-keep public class com.ycgis.macall.personalcenter.util.ToThirdPartyAppUtils{
|
||||
public *;}
|
||||
-keep public class com.ycgis.macall.personalcenter.util.UriUtils{
|
||||
public *;}
|
||||
-keep public class com.ycgis.macall.personalcenter.util.PhoneValidateUtils{*;}
|
||||
|
||||
#-keep public class com.ycgis.macall.personalcenter.v.**{
|
||||
# public *;
|
||||
#}
|
||||
|
||||
-keepclassmembers class com.ycgis.macall.personalcenter.v.activity.OpenAppActivity$AndroidMethodInterface{ *; }
|
||||
|
||||
-keepclassmembers class * extends androidx.fragment.app.FragmentActivity{
|
||||
public void *(android.view.View);
|
||||
}
|
||||
|
||||
-keepclassmembers enum * { *; }
|
||||
|
||||
-keep public class * extends android.view.View{
|
||||
*** get*();
|
||||
void set*(***);
|
||||
public <init>(android.content.Context);
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
}
|
||||
-keepclasseswithmembers class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
}
|
||||
-keep class **.R$* {
|
||||
*;
|
||||
}
|
||||
|
||||
-keepclassmembers class * {
|
||||
void *(**On*Event);
|
||||
}
|
||||
|
||||
#OkHttp
|
||||
-dontwarn okhttp3.**
|
||||
-keep class okhttp3.**{*;}
|
||||
-keep interface okhttp3.**{*;}
|
||||
|
||||
#gson
|
||||
-dontwarn com.google.gson.**
|
||||
-keep class com.google.gson.** { *;}
|
||||
|
||||
#fastjson
|
||||
#-keep class com.alibaba.fastjson.** { *; }
|
||||
#-keep class com.alibaba.fastjson.support.** { *; }
|
||||
|
||||
#EVENT
|
||||
-keep class org.greenrobot.eventbus.** { *; }
|
||||
|
||||
#luban压缩
|
||||
-keep class top.zibin.luban.**{*;}
|
||||
|
||||
#RxJava
|
||||
-dontwarn sun.misc.**
|
||||
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
|
||||
long producerIndex;
|
||||
long consumerIndex;
|
||||
}
|
||||
|
||||
-dontwarn io.reactivex.android.**
|
||||
-keepclassmembers class io.reactivex.internal.util.unsafe.*ArrayQueue*Field* {
|
||||
long producerIndex;
|
||||
long consumerIndex;
|
||||
}
|
||||
|
||||
-dontwarn java.lang.invoke.*
|
||||
|
||||
#retrofit
|
||||
-dontwarn retrofit2.**
|
||||
-keep class retrofit2.** { *; }
|
||||
-keepattributes Signature
|
||||
-keepattributes Exceptions
|
||||
|
||||
-dontwarn com.squareup.**
|
||||
-dontwarn okio.**
|
||||
-keep public class org.codehaus.* { *; }
|
||||
-keep public class java.nio.* { *; }
|
||||
|
||||
-dontwarn butterknife.internal.**
|
||||
-keep class **$$ViewInjector { *; }
|
||||
|
||||
|
||||
#Glide
|
||||
-keep public class * implements com.bumptech.glide.module.GlideModule
|
||||
-keep public class * implements com.bumptech.glide.module.AppGlideModule
|
||||
-keep public class * implements com.bumptech.glide.load.ImageHeaderParser
|
||||
-keep public enum com.bumptech.glide.load.ImageHeaderParser$*{
|
||||
**[] $VALUES;
|
||||
public *;
|
||||
}
|
||||
|
||||
|
||||
-dontwarn com.bumptech.glide.load.resource.bitmap.VideoDecoder
|
||||
-dontwarn me.iwf.photopicker.adapter.**
|
||||
|
||||
-keep public class cn.jzvd.JZMediaSystem {*; }
|
||||
|
||||
-keep class tv.danmaku.ijk.media.player.** {*; }
|
||||
-dontwarn tv.danmaku.ijk.media.player.*
|
||||
-keep interface tv.danmaku.ijk.media.player.** { *; }
|
||||
|
||||
#Agentweb
|
||||
-keep class com.just.agentweb.** {*;}
|
||||
-keep class com.download.** {*;}
|
||||
-dontwarn com.just.agentweb.**
|
||||
|
||||
-keepclassmembers class **.R$* {
|
||||
public static <fields>;
|
||||
public static final int *;
|
||||
}
|
||||
-keepclasseswithmembernames class * { # 保持 native 方法不被混淆
|
||||
native <methods>;
|
||||
}
|
||||
-keepclasseswithmembers class * { # 保持自定义控件类不被混淆
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
}
|
||||
-keepclasseswithmembers class * {# 保持自定义控件类不被混淆
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
}
|
||||
-keepclassmembers class * extends android.app.Activity { # 保持自定义控件类不被混淆
|
||||
public void *(android.view.View);
|
||||
}
|
||||
-keepclassmembers enum * { # 保持枚举 enum 类不被混淆
|
||||
public static **[] values();
|
||||
public static ** valueOf(java.lang.String);
|
||||
}
|
||||
-keep class * implements android.os.Parcelable { # 保持 Parcelable 不被混淆
|
||||
public static final android.os.Parcelable$Creator *;
|
||||
}
|
||||
-keep public class * extends android.view.View {
|
||||
public <init>(android.content.Context);
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
public void set*(...);
|
||||
}
|
||||
-keepclassmembers public class * extends android.view.View {
|
||||
void set*(***);
|
||||
*** get*();
|
||||
}
|
||||
|
||||
#Rxjava RxAndroid
|
||||
-dontwarn rx.*
|
||||
-dontwarn sun.misc.**
|
||||
-keepclassmembers class rx.internal.util.unsafe.*ArrayQuene*Field*{
|
||||
long producerIndex;
|
||||
long consumerIndex;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#忽略警告
|
||||
-ignorewarnings
|
||||
-keep class javax.ws.rs.** { *; }
|
||||
-dontwarn com.alibaba.fastjson.**
|
||||
-keep class com.alibaba.fastjson.** { *; }
|
||||
|
||||
#apk 包内所有 class 的内部结构
|
||||
#-dump class_files.txt
|
||||
#未混淆的类和成员
|
||||
#-printseeds seeds.txt
|
||||
#列出从 apk 中删除的代码
|
||||
#-printusage unused.txt
|
||||
#混淆前后的映射
|
||||
#-printmapping mapping.txt
|
||||
|
||||
#fastjson 可以混淆也可以不混淆
|
||||
#-keep class javax.ws.rs.** { *; }
|
||||
#-dontwarn com.alibaba.fastjson.**
|
||||
#-keep class com.alibaba.fastjson.** { *; }
|
||||
-keepclassmembers class * implements java.io.Serializable {
|
||||
static final long serialVersionUID;
|
||||
private static final java.io.ObjectStreamField[] serialPersistentFields;
|
||||
private void writeObject(java.io.ObjectOutputStream);
|
||||
private void readObject(java.io.ObjectInputStream);
|
||||
java.lang.Object writeReplace();
|
||||
java.lang.Object readResolve();
|
||||
public <fields>;
|
||||
}
|
||||
-keepattributes Signature
|
||||
Binary file not shown.
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"version": 2,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "com.ruansee.macall.testwebview",
|
||||
"variantName": "release",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"versionCode": 5,
|
||||
"versionName": "2.5",
|
||||
"outputFile": "testwebview-release.apk"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.ycgis.macall.personalcenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.ycgis.macall.personalcenter", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,204 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.ycgis.macall.personalcenter">
|
||||
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
tools:ignore="ScopedStorage" />
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission
|
||||
android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||
tools:ignore="QueryAllPackagesPermission" /> <!-- Android 10及以上版本 要声明此权限 才能在应用内根据包名打开 第三方应用 -->
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_SETTINGS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
<uses-permission android:name="com.android.rsgps.provider.READ_PERMISSION" />
|
||||
<uses-permission android:name="com.android.peter.provider.WRITE_PERMISSION" />
|
||||
<uses-permission android:name="android.permission.NFC" />
|
||||
|
||||
<application
|
||||
android:name=".p.app.RuanseeApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/icon_applogin"
|
||||
android:label="@string/app_name"
|
||||
android:networkSecurityConfig="@xml/network_config"
|
||||
android:roundIcon="@mipmap/icon_applogin"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.NewPersonalCenter"
|
||||
tools:targetApi="n">
|
||||
|
||||
<activity
|
||||
android:name=".v.activity.ScanCodeActivity"
|
||||
android:theme="@style/Theme.NewPersonalCenter.NoActionBar" />
|
||||
<activity
|
||||
android:name=".v.activity.SuggestionsDetailsActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.UpdateDeptActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.AboutActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.WorkbenchCenterActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.UpdatePasswordActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.PlayVideosActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.AppGuideDetailsActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.ApplicationGuideActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.MySuggestionsListActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.travel.TravelDetailsActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.SelectAppActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.AuthenticationActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.travel.TravelAssistantActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.FrequentlyQuestionsActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.MyDetailsActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.OpenAppActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.applyfo.ToBeReviewedActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.applyfo.ApplyDetailsActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.applyfo.MyApplyForActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.applyfo.SelectSystemActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.applyfo.InitiateApplyForActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.applyfo.ApplyProcessActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.applyfo.ApplyForMainActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.OpinionsSuggestionsActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.MsgDetailsActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".v.activity.StartActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".v.activity.MainActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustUnspecified|stateHidden|stateAlwaysHidden|adjustPan" />
|
||||
|
||||
<service
|
||||
android:name=".p.service.GetMessageService"
|
||||
android:permission="android.permission.BIND_JOB_SERVICE"
|
||||
android:enabled="true"
|
||||
android:exported="true"/>
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="com.ycgis.macall.personalcenter.m.provider.MyFileProvider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
[
|
||||
{
|
||||
"title": "应用安装登录问题",
|
||||
"data": [
|
||||
{
|
||||
"problem": "1、应用中心下载后安装失败?",
|
||||
"reply": "如果安装包已经下载且点击安装后安装不了的,返回应用中心’首页‘,切换到‘应用管理’,至’安装包管理‘,找到并删除已下载的安装包,然后返回’首页‘重新下载安装应用。\n\t\t如果此操作还是安装不了,建议电话联系应用中心运维人员反馈",
|
||||
"extend": "查找应用中心运维人员联系方式",
|
||||
"guidance": "ic_tyrzyw"
|
||||
},
|
||||
{
|
||||
"problem": "2、登录应用提示设备未绑定?",
|
||||
"reply": "提示设备未绑定的,如果跳转到了登录页,就在登录页输入警号和密码后进行绑定。\n\t\t未跳转登录页的,先打开’应用中心‘查看是否能正常打开’应用中心‘,如果正常打开,就在应用中心搜索该应用,找到运维人员联系方式进行反馈。\n\t\t未正常打开且不跳转登录页的,请联系市局科信(下发设备的)反馈设备问题。",
|
||||
"extend": "",
|
||||
"guidance": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "个人信息问题",
|
||||
"data": [
|
||||
{
|
||||
"problem": "1、登录应用后显示的用户信息不是本人信息?",
|
||||
"reply": "有以下几种情况:\n\t\t\t\t1、设备绑定信息问题:即设备绑定的信息是其他民警的,需联系'统一认证'运维人员解绑该设备,然后重新打开'应用中心'登录自己的警号即可。\n\t\t\t\t2、警员库问题:警号是自己的,姓名和身份证号等信息是别人的,这种情况是警员库没有及时更新导致的,需联系'统一认证'运维人员修改信息。\n\t\t\t\t3、警员库问题:警号是自己的、姓名或者身份证号有错误,如身份证号正确,姓名录入错别字的,也需要联系'统一认证'运维人员修改信息。",
|
||||
"extend": "查找统一认证运维人员联系方式",
|
||||
"guidance": "ic_tyrzyw"
|
||||
},
|
||||
{
|
||||
"problem": "2、登录后显示单位不是当前单位?",
|
||||
"reply": "单位显示的不是当前单位,到我的页面点击上方个人信息,跳转页面后,点击单位名称,跳转后找到当前单位,然后申请调整单位。",
|
||||
"extend": "",
|
||||
"guidance": ""
|
||||
},
|
||||
{
|
||||
"problem": "3、关于个人信息修改",
|
||||
"reply": "警员信息统一由警综维护,个人中心目前只支持修改联系电话,如果是显示的警号信息和个人信息不符合的参考第1条解决方案。",
|
||||
"extend": "",
|
||||
"guidance": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "应用使用相关",
|
||||
"data": [
|
||||
{
|
||||
"problem": "1、关于自定义应用",
|
||||
"reply": "自定义应用为了方便快速找到自己想要使用的移动警务应用,实现在’人中心中‘快速开展工作。\n\t\t在首次使用时,点击列表内的+号图标,会读取本机已经安装的移动警务应用列表,民警根据自己需求添加或者移除应用,添加后将在列表中展示该应用,\n\t\t点击已经添加的应用将打开并跳转到该应用。",
|
||||
"extend": "",
|
||||
"guidance": ""
|
||||
},
|
||||
{
|
||||
"problem": "2、关于意见反馈?",
|
||||
"reply": "民警在使用本应用和应用内的第三方应用时,发现的问题和意见建议都可以在本模块提交。",
|
||||
"extend": "",
|
||||
"guidance": ""
|
||||
},
|
||||
{
|
||||
"problem": "3、关于认证管理",
|
||||
"reply": "该模块是修改手机上的‘统一认证’的登录方式,目前支持警号密码登录和手势图形登。",
|
||||
"extend": "",
|
||||
"guidance": ""
|
||||
},
|
||||
{
|
||||
"problem": "4、关于应用指南",
|
||||
"reply": "该模块是展示第三方应用的应用信息、运维信息及上传的操作手册、操作视频、图片等应用相关资料,方便民警快速掌握应用的使用熟悉各应用的使用方法。",
|
||||
"extend": "",
|
||||
"guidance": ""
|
||||
},
|
||||
{
|
||||
"problem": "5、关于应用内第三方应用使用问题",
|
||||
"reply": "请至'应用指南'中查找到该应用信息,然后联系相关运维人员进行反馈。",
|
||||
"extend": "",
|
||||
"guidance": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
Binary file not shown.
|
|
@ -0,0 +1,104 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/5/31 10:50
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class ActionBean extends BaseBean{
|
||||
private int iconId;
|
||||
private String name;
|
||||
private int count;
|
||||
|
||||
private Class aClass;
|
||||
|
||||
private Map<String,Object> param;
|
||||
|
||||
public void addParam(String key,Object value){
|
||||
if (param == null)param = new HashMap<>();
|
||||
param.put(key,value);
|
||||
}
|
||||
|
||||
public Map<String, Object> getParam() {
|
||||
return param;
|
||||
}
|
||||
|
||||
public int getIconId() {
|
||||
return iconId;
|
||||
}
|
||||
|
||||
public void setIconId(int iconId) {
|
||||
this.iconId = iconId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public Class getaClass() {
|
||||
return aClass;
|
||||
}
|
||||
|
||||
public void setaClass(Class aClass) {
|
||||
this.aClass = aClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置跳转参数
|
||||
* @param intent intent 意向
|
||||
* @return intent 意向
|
||||
*/
|
||||
public Intent setIntentParam(Intent intent){
|
||||
if (param!=null&&!param.isEmpty()){
|
||||
Set<String> strings = param.keySet();
|
||||
for (String key :strings) {
|
||||
Object o = param.get(key);
|
||||
if (o instanceof Integer) {
|
||||
intent.putExtra(key, (int) o);
|
||||
} else if (o instanceof String) {
|
||||
intent.putExtra(key, o.toString());
|
||||
} else if (o instanceof Boolean) {
|
||||
intent.putExtra(key, (boolean) o);
|
||||
} else if (o instanceof Long) {
|
||||
intent.putExtra(key, (long) o);
|
||||
} else if (o instanceof Bundle) {
|
||||
intent.putExtra(key, (Bundle) o);
|
||||
} else if (o instanceof Byte) {
|
||||
intent.putExtra(key, (byte) o);
|
||||
}else if (o instanceof byte[]) {
|
||||
intent.putExtra(key, (byte[]) o);
|
||||
}else if (o instanceof Short) {
|
||||
intent.putExtra(key, (short) o);
|
||||
}else if (o instanceof Character) {
|
||||
intent.putExtra(key, (char) o);
|
||||
}else if (o instanceof String[]) {
|
||||
intent.putExtra(key, (String[]) o);
|
||||
}else if (o instanceof Serializable) {
|
||||
intent.putExtra(key, (Serializable) o);
|
||||
}
|
||||
}
|
||||
}
|
||||
return intent;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,200 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.base.BaseViewBindActivity;
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2022/11/7 17:26
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class AppBean extends BaseBean{
|
||||
private String id;
|
||||
//省厅应用地市应用
|
||||
private String appType;
|
||||
//治安类、社区类、
|
||||
private String classification;
|
||||
//二类应用、三类应用
|
||||
private String networkType;
|
||||
private String appName;
|
||||
|
||||
private boolean isNew = false;
|
||||
private int icon;
|
||||
private Drawable iconDrawable;
|
||||
|
||||
private String iconUrl;
|
||||
|
||||
private String linkUrl;
|
||||
|
||||
private String cityNumber;
|
||||
private String company;
|
||||
private String operationName;
|
||||
private String operationPhone;
|
||||
|
||||
private String time;
|
||||
|
||||
private String clientId;
|
||||
private String clientSecret;
|
||||
|
||||
private Class activityClass;
|
||||
|
||||
//应用介绍
|
||||
private String appIntroduction;
|
||||
|
||||
public Class getActivityClass() {
|
||||
return activityClass;
|
||||
}
|
||||
|
||||
public void setActivityClass(Class activityClass) {
|
||||
this.activityClass = activityClass;
|
||||
}
|
||||
|
||||
public Drawable getIconDrawable() {
|
||||
return iconDrawable;
|
||||
}
|
||||
|
||||
public void setIconDrawable(Drawable iconDrawable) {
|
||||
this.iconDrawable = iconDrawable;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return StringUtil.isNullOrEmpty(id)?"":id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCityNumber() {
|
||||
return cityNumber;
|
||||
}
|
||||
|
||||
public void setCityNumber(String cityNumber) {
|
||||
this.cityNumber = cityNumber;
|
||||
}
|
||||
|
||||
public boolean isNew() {
|
||||
return isNew;
|
||||
}
|
||||
|
||||
public void setNew(boolean aNew) {
|
||||
isNew = aNew;
|
||||
}
|
||||
|
||||
public String getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void setClientId(String clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public String getClientSecret() {
|
||||
return clientSecret;
|
||||
}
|
||||
|
||||
public void setClientSecret(String clientSecret) {
|
||||
this.clientSecret = clientSecret;
|
||||
}
|
||||
|
||||
|
||||
public String getLinkUrl() {
|
||||
return linkUrl;
|
||||
}
|
||||
|
||||
public void setLinkUrl(String linkUrl) {
|
||||
this.linkUrl = linkUrl;
|
||||
}
|
||||
|
||||
public String getAppType() {
|
||||
return appType;
|
||||
}
|
||||
|
||||
public void setAppType(String appType) {
|
||||
this.appType = appType;
|
||||
}
|
||||
|
||||
public String getClassification() {
|
||||
return classification;
|
||||
}
|
||||
|
||||
public void setClassification(String classification) {
|
||||
this.classification = classification;
|
||||
}
|
||||
|
||||
public String getNetworkType() {
|
||||
return networkType;
|
||||
}
|
||||
|
||||
public void setNetworkType(String networkType) {
|
||||
this.networkType = networkType;
|
||||
}
|
||||
|
||||
public String getAppName() {
|
||||
return appName;
|
||||
}
|
||||
|
||||
public void setAppName(String appName) {
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
public int getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(int icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public String getIconUrl() {
|
||||
return iconUrl;
|
||||
}
|
||||
|
||||
public void setIconUrl(String iconUrl) {
|
||||
this.iconUrl = iconUrl;
|
||||
}
|
||||
|
||||
public String getCompany() {
|
||||
return company;
|
||||
}
|
||||
|
||||
public void setCompany(String company) {
|
||||
this.company = company;
|
||||
}
|
||||
|
||||
public String getOperationName() {
|
||||
return operationName;
|
||||
}
|
||||
|
||||
public void setOperationName(String operationName) {
|
||||
this.operationName = operationName;
|
||||
}
|
||||
|
||||
public String getOperationPhone() {
|
||||
return operationPhone;
|
||||
}
|
||||
|
||||
public void setOperationPhone(String operationPhone) {
|
||||
this.operationPhone = operationPhone;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getAppIntroduction() {
|
||||
return appIntroduction;
|
||||
}
|
||||
|
||||
public void setAppIntroduction(String appIntroduction) {
|
||||
this.appIntroduction = appIntroduction;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2022/11/18 14:23
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class AppGuideDetailsBean extends BaseBean implements Serializable {
|
||||
|
||||
/**
|
||||
* id : 11
|
||||
* applicationId : 26
|
||||
* applicationName : 一标三实
|
||||
* filePath : /profile/upload/2022/11/18/车辆档案结果界面_20221118094523A002.jpg
|
||||
* type : 1
|
||||
* createTime : 2022-11-18 09:45:24
|
||||
* updateTime : 2022-11-18 09:45:24
|
||||
* remark : null
|
||||
*/
|
||||
|
||||
@SerializedName("id")
|
||||
private Integer id;
|
||||
@SerializedName("applicationId")
|
||||
private Integer applicationId;
|
||||
@SerializedName("applicationName")
|
||||
private String applicationName;
|
||||
@SerializedName("filePath")
|
||||
private String filePath;
|
||||
@SerializedName("type")
|
||||
private Integer type;
|
||||
@SerializedName("remark")
|
||||
private String remark;
|
||||
|
||||
public static AppGuideDetailsBean objectFromData(String str) {
|
||||
|
||||
return new Gson().fromJson(str, AppGuideDetailsBean.class);
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getApplicationId() {
|
||||
return applicationId;
|
||||
}
|
||||
|
||||
public void setApplicationId(Integer applicationId) {
|
||||
this.applicationId = applicationId;
|
||||
}
|
||||
|
||||
public String getApplicationName() {
|
||||
return applicationName;
|
||||
}
|
||||
|
||||
public void setApplicationName(String applicationName) {
|
||||
this.applicationName = applicationName;
|
||||
}
|
||||
|
||||
public String getFilePath() {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public void setFilePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,255 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
import com.ycgis.macall.personalcenter.p.app.AppCache;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/11/14 17:19
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class AppInfoBean extends BaseBean{
|
||||
/**
|
||||
* id : 21
|
||||
* name : 皖警云核查
|
||||
* icon : /profile/upload/2023/01/02/icon_云核查_20230102194657A007.png
|
||||
* link : null
|
||||
* packageName : com.ycgis.macall.provinceproject
|
||||
* effectiveness : 1
|
||||
* level : 3
|
||||
* classification : null
|
||||
* type : 1
|
||||
* sort : 1
|
||||
* cityNumber : null
|
||||
* serviceProvider : 安徽软思信息技术有限公司
|
||||
* operationPerson : 陈乐
|
||||
* phoneNumber : 15655166626
|
||||
* clientId : 6772242211161756101
|
||||
* clientSecret : 82I8I280VX3PCqNqV886y739S2u86i5B
|
||||
* state : 1
|
||||
* remark : null
|
||||
* applicant : 管理员
|
||||
* alarmSignal : admin
|
||||
* department : 安徽省公安厅
|
||||
* applicationTime : 2022-11-16 17:56:23
|
||||
* policeDirector : 沙海峰
|
||||
* policeDirectorSignal : 006856
|
||||
* policePhoneNumber : 15566551515
|
||||
* operationGuide : null
|
||||
* approvalTime : 2022-11-16 17:56:37
|
||||
* rejectReason : null
|
||||
* approver : null
|
||||
* isRecommend : 0
|
||||
* clickCount : 7
|
||||
* label : null
|
||||
* attribution : 0
|
||||
*/
|
||||
|
||||
//是否被选中
|
||||
private boolean isSelect;
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
private String icon;
|
||||
private String link;
|
||||
private String packageName;
|
||||
private int effectiveness;
|
||||
//应用级别(1 省厅应用 2 地市应用 3 公共应用)
|
||||
private int level;
|
||||
//应用分类(1 行业管理 2 社区警务 3 治安管理)
|
||||
// private String classification;
|
||||
//应用类型(1 Ⅱ类应用 2 Ⅲ类应用)
|
||||
private int type;
|
||||
//所属省市编号
|
||||
private String cityNumber;
|
||||
//服务厂商
|
||||
private String serviceProvider;
|
||||
//运维人员
|
||||
private String operationPerson;
|
||||
//运维人员联系电话
|
||||
private String phoneNumber;
|
||||
private String clientId;
|
||||
private String clientSecret;
|
||||
private String state;
|
||||
//备注
|
||||
private String remark;
|
||||
//操作指南
|
||||
private String operationGuide;
|
||||
private int isRecommend;
|
||||
//应用标签(1 人 2 车 3 其它)
|
||||
private String label;
|
||||
//0 个人中心应用 1 应用中心 2 共有
|
||||
private int attribution;
|
||||
|
||||
public boolean isSelect() {
|
||||
return isSelect;
|
||||
}
|
||||
|
||||
public void setSelect(boolean select) {
|
||||
isSelect = select;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public String getIconUrl() {
|
||||
return AppCache.BASE_IMAGE_URL+icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public String getLink() {
|
||||
return link;
|
||||
}
|
||||
|
||||
public void setLink(String link) {
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public int getEffectiveness() {
|
||||
return effectiveness;
|
||||
}
|
||||
|
||||
public void setEffectiveness(int effectiveness) {
|
||||
this.effectiveness = effectiveness;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getCityNumber() {
|
||||
return cityNumber;
|
||||
}
|
||||
|
||||
public void setCityNumber(String cityNumber) {
|
||||
this.cityNumber = cityNumber;
|
||||
}
|
||||
|
||||
public String getServiceProvider() {
|
||||
return serviceProvider;
|
||||
}
|
||||
|
||||
public void setServiceProvider(String serviceProvider) {
|
||||
this.serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public String getOperationPerson() {
|
||||
return operationPerson;
|
||||
}
|
||||
|
||||
public void setOperationPerson(String operationPerson) {
|
||||
this.operationPerson = operationPerson;
|
||||
}
|
||||
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public void setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
|
||||
public String getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void setClientId(String clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public String getClientSecret() {
|
||||
return clientSecret;
|
||||
}
|
||||
|
||||
public void setClientSecret(String clientSecret) {
|
||||
this.clientSecret = clientSecret;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getOperationGuide() {
|
||||
return operationGuide;
|
||||
}
|
||||
|
||||
public void setOperationGuide(String operationGuide) {
|
||||
this.operationGuide = operationGuide;
|
||||
}
|
||||
|
||||
public int getIsRecommend() {
|
||||
return isRecommend;
|
||||
}
|
||||
|
||||
public void setIsRecommend(int isRecommend) {
|
||||
this.isRecommend = isRecommend;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public int getAttribution() {
|
||||
return attribution;
|
||||
}
|
||||
|
||||
public void setAttribution(int attribution) {
|
||||
this.attribution = attribution;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,216 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
import com.ycgis.macall.personalcenter.v.activity.applyfo.ApplyForMainActivity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/6/3 17:52
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class ApplyAppBean implements Serializable {
|
||||
|
||||
/**
|
||||
* msg : 操作成功
|
||||
* code : 200
|
||||
* data : [{"createBy":null,"createTime":"2023-06-02 12:11:26","updateBy":null,"updateTime":"2023-06-03 11:30:27","remark":"是的","id":6,"name":"2121","icon":"/profile/upload/2023/06/02/logo_20230602121120A001.png","category":"1","deptId":340100000000,"deptName":"合肥市公安局","status":1,"createUserId":null,"createDeptId":null,"createUserName":null,"createDeptName":null,"roles":[{"createBy":null,"createTime":null,"updateBy":null,"updateTime":null,"remark":null,"id":9,"appId":6,"roleName":"超级管理员"},{"createBy":null,"createTime":null,"updateBy":null,"updateTime":null,"remark":null,"id":10,"appId":6,"roleName":"地市"}]},{"createBy":null,"createTime":"2023-06-02 10:21:31","updateBy":null,"updateTime":"2023-06-03 11:30:27","remark":"这是一个治安应用2023年6月2日10:21:31","id":1,"name":"皖治通","icon":"/profile/upload/2023/06/02/logo_20230602102112A002.png","category":"1","deptId":340100000000,"deptName":"合肥市公安局","status":1,"createUserId":null,"createDeptId":null,"createUserName":null,"createDeptName":null,"roles":[{"createBy":null,"createTime":null,"updateBy":null,"updateTime":null,"remark":null,"id":11,"appId":1,"roleName":"普通用户"},{"createBy":null,"createTime":null,"updateBy":null,"updateTime":null,"remark":null,"id":12,"appId":1,"roleName":"管理员1"}]},{"createBy":null,"createTime":"2023-06-02 11:58:39","updateBy":null,"updateTime":"2023-06-03 11:30:27","remark":"是否","id":5,"name":"11111","icon":"/profile/upload/2023/06/02/logo_20230602115827A002.png","category":"1","deptId":340000000000,"deptName":"安徽省公安厅","status":1,"createUserId":null,"createDeptId":null,"createUserName":null,"createDeptName":null,"roles":[{"createBy":null,"createTime":null,"updateBy":null,"updateTime":null,"remark":null,"id":13,"appId":5,"roleName":"12"}]},{"createBy":null,"createTime":"2023-06-02 10:56:43","updateBy":null,"updateTime":"2023-06-03 11:30:27","remark":"1","id":3,"name":"云搜索","icon":"/profile/upload/2023/06/02/btn_record_20230602105626A002.png","category":"1","deptId":800701750001,"deptName":"安徽省","status":1,"createUserId":null,"createDeptId":null,"createUserName":null,"createDeptName":null,"roles":[{"createBy":null,"createTime":null,"updateBy":null,"updateTime":null,"remark":null,"id":14,"appId":3,"roleName":"23"}]}]
|
||||
*/
|
||||
|
||||
private String msg;
|
||||
private int code;
|
||||
private List<DataBean> data;
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public List<DataBean> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(List<DataBean> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public boolean isSuccess(){
|
||||
return code == 200;
|
||||
}
|
||||
|
||||
public static class DataBean extends BaseBean implements Serializable {
|
||||
/**
|
||||
* createBy : null
|
||||
* createTime : 2023-06-02 12:11:26
|
||||
* updateBy : null
|
||||
* updateTime : 2023-06-03 11:30:27
|
||||
* remark : 是的
|
||||
* id : 6
|
||||
* name : 2121
|
||||
* icon : /profile/upload/2023/06/02/logo_20230602121120A001.png
|
||||
* category : 1
|
||||
* deptId : 340100000000
|
||||
* deptName : 合肥市公安局
|
||||
* status : 1
|
||||
* createUserId : null
|
||||
* createDeptId : null
|
||||
* createUserName : null
|
||||
* createDeptName : null
|
||||
* roles : [{"createBy":null,"createTime":null,"updateBy":null,"updateTime":null,"remark":null,"id":9,"appId":6,"roleName":"超级管理员"},{"createBy":null,"createTime":null,"updateBy":null,"updateTime":null,"remark":null,"id":10,"appId":6,"roleName":"地市"}]
|
||||
*/
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
private String icon;
|
||||
private String category;
|
||||
private long deptId;
|
||||
private String deptName;
|
||||
private int status;
|
||||
private List<RolesBean> roles;
|
||||
private boolean isSelect;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public long getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId(long deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
public String getDeptName() {
|
||||
return deptName;
|
||||
}
|
||||
|
||||
public void setDeptName(String deptName) {
|
||||
this.deptName = deptName;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public List<RolesBean> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(List<RolesBean> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public boolean isSelect() {
|
||||
return isSelect;
|
||||
}
|
||||
|
||||
public void setSelect(boolean select) {
|
||||
isSelect = select;
|
||||
}
|
||||
|
||||
public String getIconUrl(){
|
||||
return ApplyForMainActivity.BASE_PHOTO_URL+icon;
|
||||
}
|
||||
|
||||
public static class RolesBean extends BaseBean implements Serializable {
|
||||
/**
|
||||
* createBy : null
|
||||
* createTime : null
|
||||
* updateBy : null
|
||||
* updateTime : null
|
||||
* remark : null
|
||||
* id : 9
|
||||
* appId : 6
|
||||
* roleName : 超级管理员
|
||||
*/
|
||||
|
||||
private int id;
|
||||
private int appId;
|
||||
private String roleName;
|
||||
private boolean isSelect;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setAppId(int appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public boolean isSelect() {
|
||||
return isSelect;
|
||||
}
|
||||
|
||||
public void setSelect(boolean select) {
|
||||
isSelect = select;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return roleName ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
import com.ycgis.macall.personalcenter.R;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/6/3 11:00
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class ApplyAuditBean extends BaseBean {
|
||||
private String id;
|
||||
//姓名
|
||||
private String auditNickName;
|
||||
|
||||
//警号
|
||||
private String auditUserName;
|
||||
//机构
|
||||
private String auditDeptName;
|
||||
// 2 所在单位 3 所在地市 6 省厅 1 运维
|
||||
private String auditUserType;
|
||||
|
||||
//结果
|
||||
private String result;
|
||||
|
||||
//0不通过 1 通过
|
||||
private int auditStatus;
|
||||
|
||||
//审核意见
|
||||
private String opinion;
|
||||
private String auditTime;
|
||||
|
||||
private String sealStatus;
|
||||
private String sealDeptId;
|
||||
|
||||
public String getSealStatus() {
|
||||
return sealStatus;
|
||||
}
|
||||
|
||||
public void setSealStatus(String sealStatus) {
|
||||
this.sealStatus = sealStatus;
|
||||
}
|
||||
|
||||
public String getSealDeptId() {
|
||||
return sealDeptId;
|
||||
}
|
||||
|
||||
public void setSealDeptId(String sealDeptId) {
|
||||
this.sealDeptId = sealDeptId;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getReviewedBy() {
|
||||
return String.format("%s(%s)",getAuditNickName(),getAuditUserName());
|
||||
}
|
||||
|
||||
public int stateBG(){
|
||||
if (auditStatus == 0 )return R.drawable.bk_read;
|
||||
return R.drawable.bk_ls;
|
||||
}
|
||||
|
||||
public int stateColor(){
|
||||
if (auditStatus == 0 )return R.color.colorRed7;
|
||||
return R.color.colorGreen7;
|
||||
}
|
||||
|
||||
//1 审核通过 0 待审核 2 分局审核通过 3 市局审核通过 -1 不通过
|
||||
public String getStateStr() {
|
||||
if (auditStatus == 0 )return "不通过";
|
||||
return "通过";
|
||||
}
|
||||
|
||||
public int getAuditStatus() {
|
||||
return auditStatus;
|
||||
}
|
||||
|
||||
public void setAuditStatus(int auditStatus) {
|
||||
this.auditStatus = auditStatus;
|
||||
}
|
||||
|
||||
public String getTimeStr() {
|
||||
return "审批时间:"+getAuditTime();
|
||||
}
|
||||
|
||||
public String getAuditNickName() {
|
||||
return StringUtil.get(auditNickName,"暂无");
|
||||
}
|
||||
|
||||
public void setAuditNickName(String auditNickName) {
|
||||
this.auditNickName = auditNickName;
|
||||
}
|
||||
|
||||
public String getAuditUserName() {
|
||||
return StringUtil.get(auditUserName,"暂无");
|
||||
}
|
||||
|
||||
public void setAuditUserName(String auditUserName) {
|
||||
this.auditUserName = auditUserName;
|
||||
}
|
||||
|
||||
public String getAuditDeptNameStr() {
|
||||
return "所属部门:"+getAuditDeptName();
|
||||
}
|
||||
|
||||
|
||||
public String getAuditDeptName() {
|
||||
return StringUtil.get(auditDeptName,"暂无");
|
||||
}
|
||||
|
||||
public void setAuditDeptName(String auditDeptName) {
|
||||
this.auditDeptName = auditDeptName;
|
||||
}
|
||||
|
||||
public String getResult() {
|
||||
return StringUtil.get(result,"暂无");
|
||||
}
|
||||
|
||||
public void setResult(String result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public String getOpinionStr() {
|
||||
return "审核意见:"+StringUtil.get(opinion,"暂无");
|
||||
}
|
||||
public String getOpinion() {
|
||||
return StringUtil.get(opinion,"暂无审核意见");
|
||||
}
|
||||
|
||||
public void setOpinion(String opinion) {
|
||||
this.opinion = opinion;
|
||||
}
|
||||
|
||||
public String getAuditTime() {
|
||||
return StringUtil.get(auditTime,"暂无");
|
||||
}
|
||||
|
||||
public void setAuditTime(String auditTime) {
|
||||
this.auditTime = auditTime;
|
||||
}
|
||||
|
||||
public String getAuditUserTypeStr() {
|
||||
if (auditUserType == null) return "暂无:";
|
||||
switch (auditUserType){
|
||||
case "2":
|
||||
return "所在单位意见:";
|
||||
case "3":
|
||||
return "所在地市意见:";
|
||||
case "6":
|
||||
return "省厅意见:";
|
||||
default:
|
||||
return "运维单位:";
|
||||
}
|
||||
}
|
||||
|
||||
public String getAuditUserType() {
|
||||
return auditUserType;
|
||||
}
|
||||
|
||||
public void setAuditUserType(String auditUserType) {
|
||||
this.auditUserType = auditUserType;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,318 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
import com.ycgis.macall.personalcenter.R;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/6/2 11:07
|
||||
* copyright: @ruansee.com
|
||||
* Describe: 应用申请
|
||||
*/
|
||||
public class ApplyBean extends BaseBean {
|
||||
private String id;
|
||||
private String name;
|
||||
private String code;
|
||||
private String userId;
|
||||
private String sysName;
|
||||
private String sysId;
|
||||
private String roleName;
|
||||
private int type;
|
||||
private String time;
|
||||
private String phone;
|
||||
private String applyReason;
|
||||
|
||||
private String reviewComments;
|
||||
|
||||
private String node;
|
||||
|
||||
private boolean isSel = false;
|
||||
//多选
|
||||
private boolean isMore = false;
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
* 10 默认普通新增未审核 11 单位审核通过 12 单位审核不通过
|
||||
* 20 市局直属新增未审核 21 市局审核通过 22 市局审核不通过
|
||||
* 30 省厅直属新增未审核 31 省厅审核通过 32 省厅审核不通过
|
||||
* 1 完成
|
||||
* 0 删除
|
||||
*/
|
||||
private int state;
|
||||
private String deptCode;
|
||||
private String deptName;
|
||||
private String idCordNum;
|
||||
|
||||
public String getSysId() {
|
||||
return sysId;
|
||||
}
|
||||
|
||||
public void setSysId(String sysId) {
|
||||
this.sysId = sysId;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getApplyReason() {
|
||||
return StringUtil.get(applyReason,"暂无");
|
||||
}
|
||||
|
||||
public void setApplyReason(String applyReason) {
|
||||
this.applyReason = applyReason;
|
||||
}
|
||||
|
||||
public String getReviewComments() {
|
||||
return reviewComments;
|
||||
}
|
||||
|
||||
public void setReviewComments(String reviewComments) {
|
||||
this.reviewComments = reviewComments;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getNameStr() {
|
||||
return String.format(" 申 请 人:%s(%s)", name, code);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getSysName() {
|
||||
return sysName;
|
||||
}
|
||||
|
||||
public String getSysNameStr() {
|
||||
return "系统名称:" + sysName;
|
||||
}
|
||||
|
||||
public void setSysName(String sysName) {
|
||||
this.sysName = sysName;
|
||||
}
|
||||
|
||||
public String getRoleNameStr() {
|
||||
return "角色名称:" + roleName;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public String getTypeStr() {
|
||||
String s = type == 1 ? "申请" : "撤销";
|
||||
return "操作类型:" + s;
|
||||
}
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getTypeStr2() {
|
||||
return type == 1 ? "申请" : "撤销";
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getTimeStr() {
|
||||
return "申请时间:" + time;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public boolean isSel() {
|
||||
return isSel;
|
||||
}
|
||||
|
||||
public void setSel(boolean sel) {
|
||||
isSel = sel;
|
||||
}
|
||||
|
||||
public boolean isMore() {
|
||||
return isMore;
|
||||
}
|
||||
|
||||
public void setMore(boolean more) {
|
||||
isMore = more;
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
* 10 默认普通新增未审核 11 单位审核通过 12 单位审核不通过
|
||||
* 20 市局直属新增未审核 21 市局审核通过 22 市局审核不通过
|
||||
* 30 省厅直属新增未审核 31 省厅审核通过 32 省厅审核不通过
|
||||
* 1 完成
|
||||
* 0 删除
|
||||
*/
|
||||
public int stateBG() {
|
||||
switch (state) {
|
||||
case 1:
|
||||
return R.drawable.bk_ls;
|
||||
case 10:
|
||||
case 20:
|
||||
case 30:
|
||||
case 11:
|
||||
case 21:
|
||||
case 31:
|
||||
default:
|
||||
return R.drawable.bk_hs;
|
||||
case 22:
|
||||
case 32:
|
||||
case 12:
|
||||
case 0:
|
||||
return R.drawable.bk_read;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
* 10 默认普通新增未审核 11 单位审核通过 12 单位审核不通过
|
||||
* 20 市局直属新增未审核 21 市局审核通过 22 市局审核不通过
|
||||
* 30 省厅直属新增未审核 31 省厅审核通过 32 省厅审核不通过
|
||||
* 1 完成
|
||||
* 0 删除
|
||||
*/
|
||||
public int stateColor() {
|
||||
switch (state) {
|
||||
case 1:
|
||||
return R.color.colorGreen7;
|
||||
case 10:
|
||||
case 20:
|
||||
case 30:
|
||||
case 11:
|
||||
case 21:
|
||||
case 31:
|
||||
default:
|
||||
return R.color.colorYellow7;
|
||||
case 22:
|
||||
case 32:
|
||||
case 12:
|
||||
case 0:
|
||||
return R.color.colorRed7;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
* 10 默认普通新增未审核 11 单位审核通过 12 单位审核不通过
|
||||
* 20 市局直属新增未审核 21 市局审核通过 22 市局审核不通过
|
||||
* 30 省厅直属新增未审核 31 省厅审核通过 32 省厅审核不通过
|
||||
* 1 完成
|
||||
* 0 删除
|
||||
*/
|
||||
public String getStateStr() {
|
||||
switch (state) {
|
||||
case 0:
|
||||
return "删除";
|
||||
case 1:
|
||||
return "完成";
|
||||
case 10:
|
||||
case 20:
|
||||
case 30:
|
||||
case 11:
|
||||
case 21:
|
||||
case 31:
|
||||
default:
|
||||
return "待审核";
|
||||
case 22:
|
||||
case 32:
|
||||
case 12:
|
||||
return "不通过";
|
||||
}
|
||||
}
|
||||
|
||||
public int getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(int state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getDeptCode() {
|
||||
return deptCode;
|
||||
}
|
||||
|
||||
public void setDeptCode(String deptCode) {
|
||||
this.deptCode = deptCode;
|
||||
}
|
||||
|
||||
public String getDeptNameStr() {
|
||||
return "所属单位:" + deptName;
|
||||
}
|
||||
|
||||
public String getDeptName() {
|
||||
return deptName;
|
||||
}
|
||||
|
||||
public void setDeptName(String deptName) {
|
||||
this.deptName = deptName;
|
||||
}
|
||||
|
||||
public String getIdCordNumStr() {
|
||||
return "身份证号:" + idCordNum;
|
||||
}
|
||||
|
||||
public String getIdCordNum() {
|
||||
return idCordNum;
|
||||
}
|
||||
|
||||
public void setIdCordNum(String idCordNum) {
|
||||
this.idCordNum = idCordNum;
|
||||
}
|
||||
|
||||
public String getNodeStr() {
|
||||
return "当前节点:" + node;
|
||||
}
|
||||
|
||||
public String getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
public void setNode(String node) {
|
||||
this.node = node;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
import com.anhui.police.auth.sdk.AuthType;
|
||||
|
||||
public class AuthManageItem extends BaseBean {
|
||||
|
||||
private String name;
|
||||
// 模式是否绑定
|
||||
private boolean autheType;
|
||||
|
||||
// 是否支持修改
|
||||
private boolean isUpdate = false;
|
||||
|
||||
//是否开通
|
||||
private boolean isActivate = false;
|
||||
|
||||
private AuthType authType;
|
||||
|
||||
//该模式是否被选中
|
||||
private boolean isSelect = false;
|
||||
|
||||
// 2 修改密码
|
||||
private int type = 1;
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean isActivate() {
|
||||
return isActivate;
|
||||
}
|
||||
|
||||
public void setActivate(boolean activate) {
|
||||
isActivate = activate;
|
||||
}
|
||||
|
||||
public AuthManageItem(String name, boolean autheType, boolean isUpdate, AuthType authType) {
|
||||
this.name = name;
|
||||
this.autheType = autheType;
|
||||
this.isUpdate = isUpdate;
|
||||
this.authType = authType;
|
||||
}
|
||||
|
||||
public AuthType getAuthType() {
|
||||
return authType;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isAutheType() {
|
||||
return autheType;
|
||||
}
|
||||
|
||||
public void setAutheType(boolean autheType) {
|
||||
this.autheType = autheType;
|
||||
}
|
||||
|
||||
public boolean isUpdate() {
|
||||
return isUpdate;
|
||||
}
|
||||
|
||||
public void setUpdate(boolean update) {
|
||||
isUpdate = update;
|
||||
}
|
||||
|
||||
public boolean isSelect() {
|
||||
return isSelect;
|
||||
}
|
||||
|
||||
public void setSelect(boolean select) {
|
||||
isSelect = select;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2022/11/7 17:27
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public abstract class BaseBean {
|
||||
protected int baseType;
|
||||
protected String baseMessage;
|
||||
|
||||
|
||||
public int getBaseType() {
|
||||
return baseType;
|
||||
}
|
||||
|
||||
public void setBaseType(int baseType) {
|
||||
this.baseType = baseType;
|
||||
}
|
||||
|
||||
public String getBaseMessage() {
|
||||
return baseMessage;
|
||||
}
|
||||
|
||||
public void setBaseMessage(String baseMessage) {
|
||||
this.baseMessage = baseMessage;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/11/16 15:29
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class FeedbackBean extends BaseBean implements Serializable {
|
||||
|
||||
/**
|
||||
* id : 5
|
||||
* applicationId : 23
|
||||
* alarmSignal : 064922
|
||||
* alarmName : 陈乐
|
||||
* type : 1
|
||||
* createTime : 2023-11-16 14:49:54
|
||||
* title : APP测试
|
||||
* content : 看看效果
|
||||
* applicationName : 聆听通讯
|
||||
* updateTime : null
|
||||
*/
|
||||
|
||||
private int id;
|
||||
private int type;
|
||||
private String createTime;
|
||||
private String title;
|
||||
private String content;
|
||||
private String applicationName;
|
||||
private int replyStatus;
|
||||
private String replyContent;
|
||||
private String replier;
|
||||
private String updateTime;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getTypeStr() {
|
||||
switch (type) {
|
||||
case 1:
|
||||
return "个人建议";
|
||||
case 2:
|
||||
return "软件问题";
|
||||
case 3:
|
||||
return "硬件问题";
|
||||
default:
|
||||
case 4:
|
||||
return "其它";
|
||||
}
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public String getCreateTimeStr() {
|
||||
return StringUtil.get(createTime, "暂无");
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public int getReplyStatus() {
|
||||
return replyStatus;
|
||||
}
|
||||
|
||||
public String getReplyStatusStr() {
|
||||
return replyStatus == 0?"未回复":"已回复";
|
||||
}
|
||||
|
||||
public void setReplyStatus(int replyStatus) {
|
||||
this.replyStatus = replyStatus;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getTitleStr() {
|
||||
return StringUtil.get(title, "暂无");
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public String getContentStr() {
|
||||
return StringUtil.get(content, "暂无");
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getApplicationName() {
|
||||
return applicationName;
|
||||
}
|
||||
|
||||
public void setApplicationName(String applicationName) {
|
||||
this.applicationName = applicationName;
|
||||
}
|
||||
|
||||
public String getReplyContent() {
|
||||
return StringUtil.get(replyContent,"暂无");
|
||||
}
|
||||
|
||||
public void setReplyContent(String replyContent) {
|
||||
this.replyContent = replyContent;
|
||||
}
|
||||
|
||||
public String getReplier() {
|
||||
return StringUtil.get(replier,"暂无");
|
||||
}
|
||||
|
||||
public void setReplier(String replier) {
|
||||
this.replier = replier;
|
||||
}
|
||||
|
||||
public String getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(String updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/11/7 14:48
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class FrequentlyItemBean extends BaseBean implements Serializable {
|
||||
/**
|
||||
* problem : 1、应用中心下载后安装失败?
|
||||
* reply : 如果安装包已经下载且点击安装后安装不了的,返回应用中心’首页‘,切换到‘应用管理’,至’安装包管理‘,找到并删除已下载的安装包,然后返回’首页‘重新下载安装应用。如果此操作还是安装不了,建议电话联系应用中心运维人员反馈
|
||||
* extend : 查找应用中心运维人员联系方式
|
||||
*/
|
||||
private String problem;
|
||||
private String reply;
|
||||
private String extend;
|
||||
private String guidance;
|
||||
|
||||
public String getProblem() {
|
||||
return problem;
|
||||
}
|
||||
|
||||
public void setProblem(String problem) {
|
||||
this.problem = problem;
|
||||
}
|
||||
|
||||
public String getReply() {
|
||||
return StringUtil.get("\t\t"+reply.replace("\\n","\n").replace("\\t","\t"),"暂无");
|
||||
}
|
||||
|
||||
public void setReply(String reply) {
|
||||
this.reply = reply;
|
||||
}
|
||||
|
||||
public String getExtend() {
|
||||
return extend;
|
||||
}
|
||||
|
||||
public void setExtend(String extend) {
|
||||
this.extend = extend;
|
||||
}
|
||||
|
||||
public String getGuidance() {
|
||||
return guidance;
|
||||
}
|
||||
|
||||
public void setGuidance(String guidance) {
|
||||
this.guidance = guidance;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/11/10 10:26
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class HomeMessageBean {
|
||||
private int count;
|
||||
private String title;
|
||||
private List<MessageBean> messageBeanList;
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public List<MessageBean> getMessageBeanList() {
|
||||
return messageBeanList;
|
||||
}
|
||||
|
||||
public void setMessageBeanList(List<MessageBean> messageBeanList) {
|
||||
this.messageBeanList = messageBeanList;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,191 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2022/11/11 17:17
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class MessageBean extends BaseBean implements Serializable {
|
||||
private String id;
|
||||
private String msgId;
|
||||
// private String title;
|
||||
private String appName;
|
||||
// private String time;
|
||||
// private String content;
|
||||
// private String clientId;
|
||||
private String msgType;
|
||||
// private String clientSecret;
|
||||
private String appIcon;
|
||||
private String state;
|
||||
|
||||
|
||||
/**
|
||||
* 是否在个人中心APP内展示:
|
||||
* 0 :跳转第三方应用内展示
|
||||
* 1 : 直接在个人中心展示
|
||||
* 默认值0
|
||||
*/
|
||||
private int appExhibition = 0;
|
||||
|
||||
|
||||
/**
|
||||
* ture 已读 false 未读
|
||||
*/
|
||||
private boolean isRead = false;
|
||||
// private String appLinkUrl;
|
||||
|
||||
private int drawable;
|
||||
|
||||
private String applicationId;
|
||||
/**
|
||||
* msgTitle : 危险性评估到期
|
||||
* msgContent : 您有一条关于刘双胜(340823198612214011)危险性评估任务即将到期,请及时进行危估
|
||||
* userId : 999013
|
||||
* state : 0
|
||||
* appId : 9450172311301425102
|
||||
* appSecret : B5479QP8p2I216B3M9gNpL363Z77dM8S
|
||||
* sendingTime : 2023-01-05 17:40:38
|
||||
* readingTime : null
|
||||
* appUrl : cbh
|
||||
*/
|
||||
|
||||
private String msgTitle;
|
||||
private String msgContent;
|
||||
private String appId;
|
||||
private String appSecret;
|
||||
private String sendingTime;
|
||||
private String appUrl;
|
||||
|
||||
public int getAppExhibition() {
|
||||
return appExhibition;
|
||||
}
|
||||
|
||||
public void setAppExhibition(int appExhibition) {
|
||||
this.appExhibition = appExhibition;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getAppIcon() {
|
||||
return appIcon;
|
||||
}
|
||||
|
||||
public void setAppIcon(String appIcon) {
|
||||
this.appIcon = appIcon;
|
||||
}
|
||||
|
||||
public int getDrawable() {
|
||||
return drawable;
|
||||
}
|
||||
|
||||
public void setDrawable(int drawable) {
|
||||
this.drawable = drawable;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMsgId() {
|
||||
return msgId;
|
||||
}
|
||||
|
||||
public void setMsgId(String msgId) {
|
||||
this.msgId = msgId;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return msgTitle;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.msgTitle = title;
|
||||
}
|
||||
|
||||
public String getAppName() {
|
||||
return appName;
|
||||
}
|
||||
|
||||
public void setAppName(String appName) {
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return sendingTime;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.sendingTime = time;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return "\t" + StringUtil.get(msgContent, "暂无");
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.msgContent = content;
|
||||
}
|
||||
|
||||
public boolean isRead() {
|
||||
return isRead;
|
||||
}
|
||||
|
||||
public void setRead(boolean read) {
|
||||
isRead = read;
|
||||
}
|
||||
|
||||
public String getAppLinkUrl() {
|
||||
return appUrl;
|
||||
}
|
||||
|
||||
public void setAppLinkUrl(String appLinkUrl) {
|
||||
this.appUrl = appLinkUrl;
|
||||
}
|
||||
|
||||
public String getClientId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setClientId(String clientId) {
|
||||
this.appId = clientId;
|
||||
}
|
||||
|
||||
public String getClientSecret() {
|
||||
return appSecret;
|
||||
}
|
||||
|
||||
public void setClientSecret(String clientSecret) {
|
||||
this.appSecret = clientSecret;
|
||||
}
|
||||
|
||||
public String getMsgType() {
|
||||
return msgType;
|
||||
}
|
||||
|
||||
public void setMsgType(String msgType) {
|
||||
this.msgType = msgType;
|
||||
}
|
||||
|
||||
public String getApplicationId() {
|
||||
return applicationId;
|
||||
}
|
||||
|
||||
public void setApplicationId(String applicationId) {
|
||||
this.applicationId = applicationId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.base.BaseViewBindActivity;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2022/11/10 10:28
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class MyItem<T extends BaseViewBindActivity> extends BaseBean {
|
||||
private String title;
|
||||
private int icon;
|
||||
private Class<T> activityClass;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public int getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(int icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public Class<T> getActivityClass() {
|
||||
return activityClass;
|
||||
}
|
||||
|
||||
public void setActivityClass(Class<T> activityClass) {
|
||||
this.activityClass = activityClass;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
public class OrgBean extends BaseBean{
|
||||
private String deptName;
|
||||
private String deptId;
|
||||
|
||||
private int type = 1; // 1 列表 -1 错误 -2 未查询到结果
|
||||
|
||||
private boolean isSelect = false;
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getOrgName() {
|
||||
return deptName;
|
||||
}
|
||||
|
||||
public void setOrgName(String orgName) {
|
||||
this.deptName = orgName;
|
||||
}
|
||||
|
||||
public String getOrgCode() {
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setOrgCode(String orgCode) {
|
||||
this.deptId = orgCode;
|
||||
}
|
||||
|
||||
public boolean isSelect() {
|
||||
return isSelect;
|
||||
}
|
||||
|
||||
public void setSelect(boolean select) {
|
||||
isSelect = select;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2022/11/14 18:20
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class SelectAddressBean {
|
||||
private String name;
|
||||
private String code;
|
||||
private boolean isSelect;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isSelect() {
|
||||
return isSelect;
|
||||
}
|
||||
|
||||
public void setSelect(boolean select) {
|
||||
isSelect = select;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2022/11/19 15:58
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class SelectAppBean extends BaseBean{
|
||||
private String id;
|
||||
|
||||
private String appName;
|
||||
|
||||
private boolean isSelect = false;
|
||||
|
||||
private Integer icon;
|
||||
|
||||
private String iconUrl;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(Integer icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public String getAppName() {
|
||||
return appName;
|
||||
}
|
||||
|
||||
public void setAppName(String appName) {
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
public boolean isSelect() {
|
||||
return isSelect;
|
||||
}
|
||||
|
||||
public void setSelect(boolean select) {
|
||||
isSelect = select;
|
||||
}
|
||||
|
||||
public String getIconUrl() {
|
||||
return iconUrl;
|
||||
}
|
||||
|
||||
public void setIconUrl(String iconUrl) {
|
||||
this.iconUrl = iconUrl;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/6/1 16:41
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class SelectRoleBean extends BaseBean{
|
||||
private String id;
|
||||
private String appId;
|
||||
private String appName;
|
||||
private String name;
|
||||
private String label;
|
||||
private boolean isSelect = false;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public boolean isSelect() {
|
||||
return isSelect;
|
||||
}
|
||||
|
||||
public void setSelect(boolean select) {
|
||||
isSelect = select;
|
||||
}
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getAppName() {
|
||||
return appName;
|
||||
}
|
||||
|
||||
public void setAppName(String appName) {
|
||||
this.appName = appName;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/11/13 10:30
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class TravelCityBean extends BaseBean{
|
||||
private String id;
|
||||
private String name;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
package com.ycgis.macall.personalcenter.m.adapterbean;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/11/2 17:38
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class WorkAppBean extends BaseBean{
|
||||
|
||||
private String appName;
|
||||
private String iconUrl;
|
||||
private int icon;
|
||||
private String packageName;
|
||||
private Drawable applicationIcon;
|
||||
|
||||
private boolean isAdd = false;
|
||||
|
||||
public int isAddStatus(){
|
||||
if (!isAdd){
|
||||
return View.VISIBLE;
|
||||
}else {
|
||||
return View.GONE;
|
||||
}
|
||||
}
|
||||
|
||||
public int isDeleteStatus(){
|
||||
if (isAdd){
|
||||
return View.VISIBLE;
|
||||
}else {
|
||||
return View.GONE;
|
||||
}
|
||||
}
|
||||
|
||||
public Drawable getApplicationIcon() {
|
||||
return applicationIcon;
|
||||
}
|
||||
|
||||
public void setApplicationIcon(Drawable applicationIcon) {
|
||||
this.applicationIcon = applicationIcon;
|
||||
}
|
||||
|
||||
public String getAppName() {
|
||||
return appName;
|
||||
}
|
||||
|
||||
public void setAppName(String appName) {
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
public String getIconUrl() {
|
||||
return iconUrl;
|
||||
}
|
||||
|
||||
public void setIconUrl(String iconUrl) {
|
||||
this.iconUrl = iconUrl;
|
||||
}
|
||||
|
||||
public int getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(int icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public boolean isAdd() {
|
||||
return isAdd;
|
||||
}
|
||||
|
||||
public void setAdd(boolean add) {
|
||||
isAdd = add;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.ycgis.macall.personalcenter.m.enumbean;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/1/30 15:35
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public enum AppOpenType {
|
||||
LOGIN("登录"),READ_MESSAGE("查看消息"),SEARCH("搜索内容");
|
||||
|
||||
private String name;
|
||||
|
||||
AppOpenType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.ycgis.macall.personalcenter.m.event;
|
||||
|
||||
import com.ycgis.macall.personalcenter.m.adapterbean.MessageBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/12/6 15:07
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class MessageEvent {
|
||||
private int count;
|
||||
private String msg;
|
||||
private List<MessageBean> messageBeanList;
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public List<MessageBean> getMessageBeanList() {
|
||||
return messageBeanList;
|
||||
}
|
||||
|
||||
public void setMessageBeanList(List<MessageBean> messageBeanList) {
|
||||
this.messageBeanList = messageBeanList;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
package com.ycgis.macall.personalcenter.m.model;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2022/11/21 18:16
|
||||
* copyright: @ruansee.com
|
||||
* Describe: H5文件选择配置
|
||||
*/
|
||||
public class SelectFileOptions {
|
||||
/*是否支持相机拍照*/
|
||||
private boolean isCamera;
|
||||
/*是否支持相册选择*/
|
||||
private boolean isDCIM;
|
||||
/*是否支持文件选择*/
|
||||
private boolean isFileSelection;
|
||||
/*是否由H5自己实现*/
|
||||
private boolean selfRealization;
|
||||
|
||||
public SelectFileOptions(boolean isCamera) {
|
||||
this.isCamera = isCamera;
|
||||
}
|
||||
|
||||
public SelectFileOptions(boolean isDCIM, boolean isFileSelection) {
|
||||
this.isDCIM = isDCIM;
|
||||
this.isFileSelection = isFileSelection;
|
||||
}
|
||||
|
||||
public SelectFileOptions(boolean selfRealization, boolean isCamera, boolean isDCIM, boolean isFileSelection) {
|
||||
this.selfRealization = selfRealization;
|
||||
this.isCamera = isCamera;
|
||||
this.isDCIM = isDCIM;
|
||||
this.isFileSelection = isFileSelection;
|
||||
}
|
||||
public void configureOptions(boolean selfRealization,boolean isCamera, boolean isDCIM, boolean isFileSelection) {
|
||||
this.selfRealization = selfRealization;
|
||||
this.isCamera = isCamera;
|
||||
this.isDCIM = isDCIM;
|
||||
this.isFileSelection = isFileSelection;
|
||||
}
|
||||
|
||||
public boolean isCamera() {
|
||||
return isCamera;
|
||||
}
|
||||
|
||||
public void setCamera(boolean camera) {
|
||||
isCamera = camera;
|
||||
}
|
||||
|
||||
public boolean isDCIM() {
|
||||
return isDCIM;
|
||||
}
|
||||
|
||||
public void setDCIM(boolean DCIM) {
|
||||
isDCIM = DCIM;
|
||||
}
|
||||
|
||||
public boolean isFileSelection() {
|
||||
return isFileSelection;
|
||||
}
|
||||
|
||||
public void setFileSelection(boolean fileSelection) {
|
||||
isFileSelection = fileSelection;
|
||||
}
|
||||
|
||||
public boolean isSelfRealization() {
|
||||
return selfRealization;
|
||||
}
|
||||
|
||||
public void setSelfRealization(boolean selfRealization) {
|
||||
this.selfRealization = selfRealization;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否只配置了一个选项
|
||||
* @return true 只配置了一个选项
|
||||
* false 配置了多个选项
|
||||
*/
|
||||
public boolean onlyOneItemIsSelected(){
|
||||
int count = 0;
|
||||
if (isCamera){
|
||||
count++;
|
||||
}
|
||||
if (isDCIM){
|
||||
count++;
|
||||
}
|
||||
if (isFileSelection){
|
||||
count++;
|
||||
}
|
||||
return count==1;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.ycgis.macall.personalcenter.m.provider;
|
||||
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
public class MyFileProvider extends FileProvider {
|
||||
}
|
||||
|
|
@ -0,0 +1,261 @@
|
|||
package com.ycgis.macall.personalcenter.m.provider;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.utils.LogUtils;
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
import com.ycgis.macall.personalcenter.m.adapterbean.WorkAppBean;
|
||||
import com.ycgis.macall.personalcenter.p.app.RuanseeApplication;
|
||||
import com.ycgis.macall.personalcenter.p.callback.BaseRequestCallback;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/11/3 9:31
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class NativeAppProvider {
|
||||
private static final String CUSTOM_CACHE_APP_LIST = "cacheCustomAppList";
|
||||
/**
|
||||
* 需要过滤的应用名称
|
||||
*/
|
||||
private static final String FILTER_APP_NAME = "陌生号码识别Print Service音频播放phoneservice桌面资源MyOS主题资源基本互动屏保Gestural Navigation BarFileBrowserCell Broadcast Service" +
|
||||
"系统配置更新计算器CameraExtensionsProxy系统 WLAN 资源Call Log Backup/Restore运营商默认应用软件包安装程序指纹服务System Resources Package图片编辑Live Wallpaper Picker" +
|
||||
"系统桌面电话服务主题管理服务急救信息SecCamService存储空间管理器系统跟踪配置拨号器关机闹钟LTE Broadcast ManagerGestural Navigation BarQCC-AUTHMGRzpub.resalsCaptivePortalLoginBluetooth MIDI Service" +
|
||||
"扫一扫双卡管理用户词典智能识屏录音机华为杂志锁屏系统切换系统通话管理通话设置相机ConfigUpdaterFIDO UAF ASMHwIndexSearchObserverService下载内容iConnect隐私空间androidhwext屏幕录制下载管理器" +
|
||||
"MmsServiceCompanion Device Manager外部存储设备HTML 查看器Huawei Secure IMEHwIntelligentRecSystem打印处理服务默认打印服务图库SmartcardService媒体存储设备HwChrServiceHwNearby" +
|
||||
"悬浮导航华为服务框架文件管理器通过蓝牙导入HwSynergyhiview设置建议电话和短信日历存储设置存储时钟拨号联系人存储短信浏览器华为手机助手手机管家中兴手机助手华为桌面手机管理主题系统界面通话/信息存储UEInfoCheck";
|
||||
|
||||
private Context context;
|
||||
private List<String> selectPackageAppList;
|
||||
|
||||
public NativeAppProvider(Context context, List<String> selectPackageAppList) {
|
||||
this.context = context;
|
||||
this.selectPackageAppList = selectPackageAppList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取本地全部应用列表
|
||||
*
|
||||
* @return List<WorkAppBean>
|
||||
*/
|
||||
public List<WorkAppBean> checkInstallApps() {
|
||||
List<WorkAppBean> launcherIconPackageList = new ArrayList<>();
|
||||
PackageManager pm = context.getPackageManager();
|
||||
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
|
||||
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
try {
|
||||
List<PackageInfo> packageInfos = pm.getInstalledPackages(0);
|
||||
for (int i = 0; i < packageInfos.size(); i++) {
|
||||
PackageInfo pkgInfo = packageInfos.get(i);
|
||||
ApplicationInfo appInfo = pkgInfo.applicationInfo;
|
||||
if (TextUtils.equals(context.getPackageName(), pkgInfo.packageName)) continue;
|
||||
String appName = appInfo.loadLabel(pm).toString();
|
||||
if (appName.startsWith("com")) continue;
|
||||
if (appName.startsWith("org")) continue;
|
||||
if (appName.startsWith("vendor")) continue;
|
||||
if (appName.startsWith("framework")) continue;
|
||||
if (appName.startsWith("huawei.android")) continue;
|
||||
if (appName.endsWith("中兴版")) continue;
|
||||
if (appName.endsWith("华为版")) continue;
|
||||
if (appName.startsWith("Android")) continue;
|
||||
if (appName.contains("游戏")) continue;
|
||||
if (appName.contains("Huawei")) continue;
|
||||
if (appName.contains("浏览器")) continue;
|
||||
if (appName.contains("音乐")) continue;
|
||||
if (appName.contains("视频")) continue;
|
||||
if (FILTER_APP_NAME.contains(appName)) continue;
|
||||
Drawable applicationIcon = pm.getApplicationIcon(appInfo);
|
||||
WorkAppBean bean = new WorkAppBean();
|
||||
bean.setBaseType(1);
|
||||
bean.setApplicationIcon(applicationIcon);
|
||||
bean.setIcon(appInfo.icon);
|
||||
bean.setPackageName(pkgInfo.packageName);
|
||||
bean.setAppName(appName);
|
||||
LogUtils.w("本机应用名称",bean.getAppName());
|
||||
if (selectPackageAppList != null && !selectPackageAppList.isEmpty()) {
|
||||
if (selectPackageAppList.contains(bean.getPackageName())) {
|
||||
bean.setAdd(true);
|
||||
}
|
||||
}
|
||||
launcherIconPackageList.add(bean);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
//
|
||||
}
|
||||
return launcherIconPackageList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取本地全部应用列表
|
||||
*
|
||||
* @param callback 异步回调
|
||||
*/
|
||||
public void asyncCheckInstallApps(BaseRequestCallback<List<WorkAppBean>> callback) {
|
||||
Observable.create(new ObservableOnSubscribe<List<WorkAppBean>>() {
|
||||
@Override
|
||||
public void subscribe(@NotNull ObservableEmitter<List<WorkAppBean>> emitter) throws Exception {
|
||||
List<WorkAppBean> launcherIconPackageList = checkInstallApps();
|
||||
emitter.onNext(launcherIconPackageList);
|
||||
emitter.onComplete();
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
//获得的数据返回主线程去更新界面
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<List<WorkAppBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NotNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull List<WorkAppBean> packageInfo) {
|
||||
callback.onRequestSuccess(packageInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NotNull Throwable e) {
|
||||
callback.onRequestFailure(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static Intent getLaunchIntent(PackageManager pm, String pkg) {
|
||||
Intent intent = pm.getLaunchIntentForPackage(pkg);
|
||||
if (intent != null) {
|
||||
return intent;
|
||||
} else {
|
||||
intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
intent.setPackage(pkg);
|
||||
List<ResolveInfo> apps = pm.queryIntentActivities(intent, 0);
|
||||
if (apps == null || apps.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
ResolveInfo ri = apps.iterator().next();
|
||||
if (ri == null) {
|
||||
return null;
|
||||
}
|
||||
intent.setComponent(new ComponentName(pkg, ri.activityInfo.name));
|
||||
return intent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取本地全部应用列表
|
||||
*
|
||||
* @param callback 异步回调
|
||||
*/
|
||||
public void getSelCustomAppList(BaseRequestCallback<List<WorkAppBean>> callback) {
|
||||
Observable.create((ObservableOnSubscribe<List<WorkAppBean>>) emitter -> {
|
||||
List<WorkAppBean> launcherIconPackageList = getSelCustomAppList();
|
||||
emitter.onNext(launcherIconPackageList);
|
||||
emitter.onComplete();
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
//获得的数据返回主线程去更新界面
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<List<WorkAppBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NotNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull List<WorkAppBean> packageInfos) {
|
||||
callback.onRequestSuccess(packageInfos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NotNull Throwable e) {
|
||||
callback.onRequestFailure(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取本地全部应用列表
|
||||
*
|
||||
* @return List<WorkAppBean>
|
||||
*/
|
||||
public List<WorkAppBean> getSelCustomAppList() {
|
||||
List<WorkAppBean> launcherIconPackageList = new ArrayList<>();
|
||||
PackageManager pm = context.getPackageManager();
|
||||
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
|
||||
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
try {
|
||||
List<PackageInfo> packageInfos = pm.getInstalledPackages(0);
|
||||
String cacheCustomAppList = RuanseeApplication.getStringValue(CUSTOM_CACHE_APP_LIST);
|
||||
if (StringUtil.isNullOrEmpty(cacheCustomAppList)) return launcherIconPackageList;
|
||||
for (int i = 0; i < packageInfos.size(); i++) {
|
||||
PackageInfo pkgInfo = packageInfos.get(i);
|
||||
ApplicationInfo appInfo = pkgInfo.applicationInfo;
|
||||
if (TextUtils.equals(context.getPackageName(), pkgInfo.packageName)) continue;
|
||||
if (cacheCustomAppList.contains(pkgInfo.packageName)) {
|
||||
Drawable applicationIcon = pm.getApplicationIcon(appInfo);
|
||||
WorkAppBean bean = new WorkAppBean();
|
||||
bean.setBaseType(1);
|
||||
bean.setApplicationIcon(applicationIcon);
|
||||
bean.setIcon(appInfo.icon);
|
||||
bean.setPackageName(pkgInfo.packageName);
|
||||
bean.setAppName(appInfo.loadLabel(pm).toString());
|
||||
launcherIconPackageList.add(bean);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
//
|
||||
}
|
||||
return launcherIconPackageList;
|
||||
}
|
||||
|
||||
public static void cacheCustomAppList(boolean isAdd, String packageName) {
|
||||
String cacheCustomAppList = RuanseeApplication.getStringValue(CUSTOM_CACHE_APP_LIST);
|
||||
if (isAdd) {
|
||||
if (StringUtil.isNullOrEmpty(cacheCustomAppList)) {
|
||||
cacheCustomAppList = packageName;
|
||||
} else {
|
||||
if (cacheCustomAppList.contains(packageName)) return;
|
||||
cacheCustomAppList += ";" + packageName;
|
||||
}
|
||||
} else {
|
||||
cacheCustomAppList = cacheCustomAppList.replace(";" + packageName, "").replace(packageName + ";", "");
|
||||
}
|
||||
RuanseeApplication.saveData(CUSTOM_CACHE_APP_LIST, cacheCustomAppList);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.ycgis.macall.personalcenter.m.provider;/*
|
||||
* 项目名:xayss
|
||||
* 作者:马超
|
||||
* 类目:SPCheckKey.java
|
||||
* 包名:com.ruansee.sx.xayss.m.provider.SPCheckKey
|
||||
* 当前修改时间:2023年06月16日 11:35:22
|
||||
* 上次修改时间:2023年06月16日 11:35:22
|
||||
* Copyright©:2023 安徽软思信息技术有限公司
|
||||
* 功能描述:
|
||||
*/
|
||||
|
||||
public final class SPCheckKey {
|
||||
public static final String CHECK_ARCHIVE_CAR_DATA = "checkArchiveCarData";
|
||||
public static final String CACHE_ARCHIVE_CAR_DATA_TIME = "cacheArchiveCarDataTime";
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
package com.ycgis.macall.personalcenter.m.requestbean;
|
||||
|
||||
import com.ycgis.macall.personalcenter.m.adapterbean.AppInfoBean;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/11/14 17:00
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class AppInfoModel implements Serializable {
|
||||
|
||||
/**
|
||||
* counts : 7
|
||||
* pagesize : 20
|
||||
* pages : 1
|
||||
* page : 1
|
||||
* items : [{"id":21,"name":"皖警云核查","icon":"/profile/upload/2023/01/02/icon_云核查_20230102194657A007.png","link":null,"packageName":"com.ycgis.macall.provinceproject","effectiveness":1,"level":3,"classification":null,"type":1,"sort":1,"cityNumber":null,"serviceProvider":"安徽软思信息技术有限公司","operationPerson":"陈乐","phoneNumber":"15655166626","clientId":"6772242211161756101","clientSecret":"82I8I280VX3PCqNqV886y739S2u86i5B","state":"1","remark":null,"applicant":"管理员","alarmSignal":"admin","department":"安徽省公安厅","applicationTime":"2022-11-16 17:56:23","policeDirector":"沙海峰","policeDirectorSignal":"006856","policePhoneNumber":"15566551515","operationGuide":null,"approvalTime":"2022-11-16 17:56:37","rejectReason":null,"approver":null,"isRecommend":0,"clickCount":7,"label":null,"attribution":0}]
|
||||
*/
|
||||
|
||||
private int counts;
|
||||
private int pagesize;
|
||||
private int pages;
|
||||
private int page;
|
||||
private List<AppInfoBean> items;
|
||||
|
||||
public int getCounts() {
|
||||
return counts;
|
||||
}
|
||||
|
||||
public void setCounts(int counts) {
|
||||
this.counts = counts;
|
||||
}
|
||||
|
||||
public int getPagesize() {
|
||||
return pagesize;
|
||||
}
|
||||
|
||||
public void setPagesize(int pagesize) {
|
||||
this.pagesize = pagesize;
|
||||
}
|
||||
|
||||
public int getPages() {
|
||||
return pages;
|
||||
}
|
||||
|
||||
public void setPages(int pages) {
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(int page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public List<AppInfoBean> getItems() {
|
||||
return items == null?new ArrayList<>():items;
|
||||
}
|
||||
|
||||
public void setItems(List<AppInfoBean> items) {
|
||||
this.items = items;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.ycgis.macall.personalcenter.m.requestbean;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2022/10/27 16:56
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class BaseRequestModel<T> {
|
||||
private int code;
|
||||
private String msg;
|
||||
private int total;
|
||||
// private int counts;
|
||||
private T data;
|
||||
|
||||
// public int getCounts() {
|
||||
// return counts;
|
||||
// }
|
||||
//
|
||||
// public void setCounts(int counts) {
|
||||
// this.counts = counts;
|
||||
// }
|
||||
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(int totalCount) {
|
||||
this.total = totalCount;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new Gson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.ycgis.macall.personalcenter.m.requestbean;
|
||||
|
||||
import com.ycgis.macall.personalcenter.m.adapterbean.BaseBean;
|
||||
import com.ycgis.macall.personalcenter.m.adapterbean.FrequentlyItemBean;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/11/7 14:48
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class FrequentlyBean extends BaseBean implements Serializable {
|
||||
|
||||
/**
|
||||
* title : 应用安装登录问题
|
||||
* data : [{"problem":"1、应用中心下载后安装失败?","reply":"如果安装包已经下载且点击安装后安装不了的,返回应用中心\u2019首页\u2018,切换到\u2018应用管理\u2019,至\u2019安装包管理\u2018,找到并删除已下载的安装包,然后返回\u2019首页\u2018重新下载安装应用。如果此操作还是安装不了,建议电话联系应用中心运维人员反馈","extend":"查找应用中心运维人员联系方式"},{"problem":"2、登录应用提示设备未绑定?","reply":"提示设备未绑定的,如果跳转到了登录页,就在登录页输入警号和密码后进行绑定。未跳转登录页的,先打开\u2019应用中心\u2018查看是否能正常打开\u2019应用中心\u2018,如果正常打开,就在应用中心搜索该应用,找到运维人员联系方式进行反馈,未正常打开且不跳转登录页的联系市局科信(下发设备的)反馈设备问题。","extend":""}]
|
||||
*/
|
||||
|
||||
private List<FrequentlyItemBean> data;
|
||||
|
||||
|
||||
private String title;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public List<FrequentlyItemBean> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(List<FrequentlyItemBean> data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.ycgis.macall.personalcenter.m.requestbean;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/6/19 15:09
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class GetDeptNameResult {
|
||||
private String police_role;
|
||||
|
||||
public String getPolice_role() {
|
||||
return StringUtil.get(police_role,"");
|
||||
}
|
||||
|
||||
public void setPolice_role(String police_role) {
|
||||
this.police_role = police_role;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package com.ycgis.macall.personalcenter.m.requestbean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/11/9 11:51
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class HomeBannerBean implements Serializable, Comparable<HomeBannerBean> {
|
||||
|
||||
/**
|
||||
* id : 5
|
||||
* url : /profile/upload/2023/01/02/icon_banner1.png
|
||||
* sort : 1
|
||||
* effectiveness : 1
|
||||
* link : null
|
||||
* remark : null
|
||||
*/
|
||||
|
||||
private int id;
|
||||
private String url;
|
||||
private int sort;
|
||||
|
||||
public HomeBannerBean(int id, String url, int sort) {
|
||||
this.id = id;
|
||||
this.url = url;
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public int getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(int sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(HomeBannerBean o) {
|
||||
return sort-o.getSort()>0?1:-1;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.ycgis.macall.personalcenter.m.requestbean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/11/16 15:28
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class PagingModel<T> {
|
||||
private int counts;
|
||||
|
||||
private List<T> items;
|
||||
|
||||
public int getCounts() {
|
||||
return counts;
|
||||
}
|
||||
|
||||
public void setCounts(int counts) {
|
||||
this.counts = counts;
|
||||
}
|
||||
|
||||
public List<T> getItems() {
|
||||
return items == null?new ArrayList<>():items;
|
||||
}
|
||||
|
||||
public void setItems(List<T> items) {
|
||||
this.items = items;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.ycgis.macall.personalcenter.m.requestbean;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/12/5 14:11
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class WorkbenchModel {
|
||||
private AppInfoModel commonApplications;
|
||||
|
||||
private AppInfoModel newestApplications;
|
||||
|
||||
public AppInfoModel getCommonApplications() {
|
||||
return commonApplications;
|
||||
}
|
||||
|
||||
public void setCommonApplications(AppInfoModel commonApplications) {
|
||||
this.commonApplications = commonApplications;
|
||||
}
|
||||
|
||||
public AppInfoModel getNewestApplications() {
|
||||
return newestApplications;
|
||||
}
|
||||
|
||||
public void setNewestApplications(AppInfoModel newestApplications) {
|
||||
this.newestApplications = newestApplications;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,223 @@
|
|||
package com.ycgis.macall.personalcenter.p.app;
|
||||
|
||||
import com.anhui.police.auth.sdk.AuthType;
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
import com.ycgis.macall.personalcenter.util.IPAddressUtils;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/10/27 15:07
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class AppCache {
|
||||
|
||||
private static AppCache appCache;
|
||||
private String BASE_URL = "";
|
||||
//http://192.168.0.233/dev-api/profile/upload/2023/01/02/icon_banner1.png
|
||||
public static final String BASE_IMAGE_URL = "http://20.90.2.2/pcenter_img_out";
|
||||
// public static final String BASE_IMAGE_URL = "http://192.168.43.98:3000/prod-api/";
|
||||
|
||||
private AuthType authType;
|
||||
private String appToke;
|
||||
|
||||
private String ip;
|
||||
private String port;
|
||||
|
||||
private String localIp;
|
||||
|
||||
//系统Token
|
||||
private String system_token;
|
||||
|
||||
//服务总线token
|
||||
private String access_token;
|
||||
//应用申请token
|
||||
private String apply_token;
|
||||
|
||||
//统一认证token
|
||||
private String token;
|
||||
|
||||
private String userInfo;
|
||||
|
||||
private String imei,imsi;
|
||||
|
||||
|
||||
private AppCache() {
|
||||
|
||||
}
|
||||
|
||||
public synchronized static AppCache getAppCacheData() {
|
||||
if (appCache == null){
|
||||
synchronized (AppCache.class){
|
||||
if (appCache == null) appCache = new AppCache();
|
||||
}
|
||||
}
|
||||
return appCache;
|
||||
}
|
||||
|
||||
|
||||
public void setIpAndPort(String ip,String port){
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getBaseUrlPath() {
|
||||
if (StringUtil.isNullOrEmpty(BASE_URL)){
|
||||
BASE_URL = String.format("http://%s:%s/pcenter_app_out/",ip,port);
|
||||
// BASE_URL = String.format("http://%s:%s/wzt/",ip,port);
|
||||
}
|
||||
return BASE_URL;
|
||||
}
|
||||
|
||||
public String getLocalIp() {
|
||||
if (StringUtil.isNullOrEmpty(localIp)){
|
||||
localIp = IPAddressUtils.getLocalIpAddress();
|
||||
}
|
||||
return localIp;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public String getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(String port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getSystem_token() {
|
||||
return system_token;
|
||||
}
|
||||
|
||||
public void setSystem_token(String system_token) {
|
||||
this.system_token = system_token;
|
||||
}
|
||||
|
||||
public String getAccess_token() {
|
||||
return access_token;
|
||||
}
|
||||
|
||||
public void setAccess_token(String access_token) {
|
||||
this.access_token = access_token;
|
||||
}
|
||||
|
||||
public String getApply_token() {
|
||||
return apply_token;
|
||||
}
|
||||
|
||||
public void setApply_token(String apply_token) {
|
||||
this.apply_token = apply_token;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return StringUtil.get(token,"");
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getUserInfo() {
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
public void setUserInfo(String userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
}
|
||||
|
||||
public String getImei() {
|
||||
return imei;
|
||||
}
|
||||
|
||||
public void setImei(String imei) {
|
||||
this.imei = imei;
|
||||
}
|
||||
|
||||
public String getImsi() {
|
||||
return imsi;
|
||||
}
|
||||
|
||||
public void setImsi(String imsi) {
|
||||
this.imsi = imsi;
|
||||
}
|
||||
|
||||
public String getSysmCode() {
|
||||
return "11e8f9a0948a43d78f68c6af41c12242";
|
||||
}
|
||||
|
||||
public void setAuthType(AuthType authType) {
|
||||
if (authType == AuthType.PWD){
|
||||
RuanseeApplication.saveData("authType",0);
|
||||
} else if (authType == AuthType.DIGITAL_CERTIFICATE) {
|
||||
RuanseeApplication.saveData("authType",1);
|
||||
}else if (authType == AuthType.GESTURE){
|
||||
RuanseeApplication.saveData("authType",2);
|
||||
}else if (authType == AuthType.FACE){
|
||||
RuanseeApplication.saveData("authType",3);
|
||||
}else if (authType == AuthType.VOICE){
|
||||
RuanseeApplication.saveData("authType",4);
|
||||
}else {
|
||||
RuanseeApplication.saveData("authType",0);
|
||||
}
|
||||
this.authType = authType;
|
||||
RuanseeApplication.saveData("isUpdateAuthType",true);
|
||||
}
|
||||
/**
|
||||
* 0 : 密码 1 数字证书 2:手势 3 : 人脸 4 :语音
|
||||
* @param authType 认证方式
|
||||
*/
|
||||
public void setAuthType(int authType) {
|
||||
RuanseeApplication.saveData("authType",authType);
|
||||
switch (authType) {
|
||||
case 0:
|
||||
this.authType = AuthType.PWD;
|
||||
break;
|
||||
case 1:
|
||||
this.authType = AuthType.DIGITAL_CERTIFICATE;
|
||||
break;
|
||||
case 2:
|
||||
this.authType = AuthType.GESTURE;
|
||||
break;
|
||||
case 3:
|
||||
this.authType = AuthType.FACE;
|
||||
break;
|
||||
case 4:
|
||||
this.authType = AuthType.VOICE;
|
||||
break;
|
||||
default:
|
||||
this.authType = AuthType.PWD;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public AuthType getAuthType() {
|
||||
if (authType == null) {
|
||||
int i = RuanseeApplication.getIntegerValue("authType");
|
||||
switch (i) {
|
||||
case 1:
|
||||
authType = AuthType.DIGITAL_CERTIFICATE;
|
||||
break;
|
||||
case 2:
|
||||
authType = AuthType.GESTURE;
|
||||
break;
|
||||
case 3:
|
||||
authType = AuthType.FACE;
|
||||
break;
|
||||
case 4:
|
||||
authType = AuthType.VOICE;
|
||||
break;
|
||||
default:
|
||||
authType = AuthType.PWD;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return authType;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,216 @@
|
|||
package com.ycgis.macall.personalcenter.p.app;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.ycgis.macall.personalcenter.util.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CrashHandler implements UncaughtExceptionHandler {
|
||||
|
||||
public static final String TAG = "CrashHandler";
|
||||
public static String LOG_DIR = FileUtils.FILE_DIR + "cache/log";
|
||||
private UncaughtExceptionHandler mDefaultHandler;
|
||||
|
||||
private static CrashHandler INSTANCE = new CrashHandler();
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private Map<String, String> infos = new HashMap<String, String>();
|
||||
|
||||
// private DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
|
||||
|
||||
private CrashHandler() {
|
||||
}
|
||||
|
||||
public synchronized static CrashHandler getInstance() {
|
||||
if (INSTANCE == null){
|
||||
synchronized (CrashHandler.class){
|
||||
if (INSTANCE == null){
|
||||
INSTANCE = new CrashHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public void init(Context context,String LOG_DIR) {
|
||||
mContext = context;
|
||||
mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
|
||||
this.LOG_DIR = LOG_DIR;
|
||||
Thread.setDefaultUncaughtExceptionHandler(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable ex) {
|
||||
if (!handleException(ex) && mDefaultHandler != null) {
|
||||
mDefaultHandler.uncaughtException(thread, ex);
|
||||
} else {
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
Log.e(TAG, "error : ", e);
|
||||
}
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleException(Throwable ex) {
|
||||
if (ex == null) {
|
||||
return false;
|
||||
}
|
||||
final Throwable _ex = ex;
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
Looper.prepare();
|
||||
Toast.makeText(mContext, "很抱歉,程序出现异常,即将退出" + _ex.getMessage(), Toast.LENGTH_LONG)
|
||||
.show();
|
||||
// TwitterApplication.LogOut(mContext);
|
||||
Looper.loop();
|
||||
}
|
||||
}.start();
|
||||
|
||||
// 收集设备参数信息
|
||||
collectDeviceInfo(mContext);
|
||||
// 保存日志文件
|
||||
saveCrashInfo2File(ex);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 收集设备参数信息
|
||||
*
|
||||
* @param ctx
|
||||
*/
|
||||
public void collectDeviceInfo(Context ctx) {
|
||||
try {
|
||||
PackageManager pm = ctx.getPackageManager();
|
||||
PackageInfo pi = pm.getPackageInfo(ctx.getPackageName(),
|
||||
PackageManager.GET_ACTIVITIES);
|
||||
if (pi != null) {
|
||||
String versionName = pi.versionName == null ? "null"
|
||||
: pi.versionName;
|
||||
String versionCode = pi.versionCode + "";
|
||||
infos.put("versionName", versionName);
|
||||
infos.put("versionCode", versionCode);
|
||||
}
|
||||
} catch (NameNotFoundException e) {
|
||||
Log.e(TAG, "an error occured when collect package info", e);
|
||||
infos.put("Exception1:", "收集系统参数报错");
|
||||
}
|
||||
Field[] fields = Build.class.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
try {
|
||||
field.setAccessible(true);
|
||||
infos.put(field.getName(), field.get(null).toString());
|
||||
Log.d(TAG, field.getName() + " : " + field.get(null));
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "an error occured when collect crash info", e);
|
||||
infos.put("Exception2:", "收集系统参数报错");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveCrashInfo2File(Throwable ex) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("================ 系统信息 ===================" + "\n");
|
||||
for (Map.Entry<String, String> entry : infos.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
sb.append(key + "=" + value + "\n");
|
||||
}
|
||||
sb.append("================ 系统信息 /===================" + "\n");
|
||||
sb.append("================ 报错信息 ===================" + "\n");
|
||||
Writer writer = new StringWriter();
|
||||
PrintWriter printWriter = new PrintWriter(writer);
|
||||
ex.printStackTrace(printWriter);
|
||||
Throwable cause = ex.getCause();
|
||||
while (cause != null) {
|
||||
cause.printStackTrace(printWriter);
|
||||
cause = cause.getCause();
|
||||
}
|
||||
printWriter.close();
|
||||
String result = writer.toString();
|
||||
sb.append(result);
|
||||
sb.append("================ 报错信息 ===================" + "\n");
|
||||
sendErrorLog(sb.toString());
|
||||
try {
|
||||
long timestamp = System.currentTimeMillis() % 100000;
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
|
||||
String time = sdf.format(new Date());
|
||||
// String time = formatter.from(new Date());
|
||||
String fileName = "WZT_" + time + "-" + timestamp + ".log";
|
||||
if (Environment.getExternalStorageState().equals(
|
||||
Environment.MEDIA_MOUNTED)) {
|
||||
String path = LOG_DIR;
|
||||
File dir = new File(path);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
FileOutputStream fos = new FileOutputStream(path + "/" + fileName);
|
||||
fos.write(sb.toString().getBytes());
|
||||
fos.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "an error occured while writing file...", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendErrorLog(String errorText) {
|
||||
// RequestModel.uploadOperationLog("5","2",errorText);
|
||||
//// String url = "http://192.168.43.202:8081/ypc/phone/error/saveError";
|
||||
// String url = YcgisApplication.getAppCacheData().getApiBaseUrl()+"error/saveError";
|
||||
// YcgisApplication
|
||||
// .componet()
|
||||
// .environment()
|
||||
// .apiClient()
|
||||
// .saveErrorLog(url, YcgisApplication.getAppCacheData().getUserCode(), errorText)
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .observeOn(Schedulers.io())
|
||||
// .subscribe(new Observer<JsonObject>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// Log.w(TAG, "onSubscribe " + d.toString());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(JsonObject s) {
|
||||
// Log.w(TAG, s.toString());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(Throwable e) {
|
||||
// Log.e(TAG, "onError " + e.getMessage());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// Log.w(TAG, "onComplete ");
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package com.ycgis.macall.personalcenter.p.app;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.GlideBuilder;
|
||||
import com.bumptech.glide.Registry;
|
||||
import com.bumptech.glide.annotation.GlideModule;
|
||||
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader;
|
||||
import com.bumptech.glide.load.DecodeFormat;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory;
|
||||
import com.bumptech.glide.load.engine.cache.LruResourceCache;
|
||||
import com.bumptech.glide.load.model.GlideUrl;
|
||||
import com.bumptech.glide.module.AppGlideModule;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.rs.macall.androidx.basemodel.request.OkHttpUtils;
|
||||
import com.ycgis.macall.personalcenter.R;
|
||||
import com.ycgis.macall.personalcenter.util.FileUtils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @Author macall
|
||||
* @Create 2019/12/18 0018
|
||||
* @Describe
|
||||
*/
|
||||
@GlideModule
|
||||
public class MyAppGlideModule extends AppGlideModule {
|
||||
|
||||
@Override
|
||||
public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {
|
||||
OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(OkHttpUtils.getClient(30,40,60));
|
||||
registry.replace(GlideUrl.class, InputStream.class, factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyOptions(Context context, GlideBuilder builder) {
|
||||
// 设置缓存大小为20mb
|
||||
int memoryCacheSizeBytes = 1024 * 1024 * 50; // 50mb
|
||||
// 设置内存缓存大小
|
||||
builder.setMemoryCache(new LruResourceCache(1024 * 1024*20));
|
||||
// 根据SD卡是否可用选择是在内部缓存还是SD卡缓存
|
||||
builder.setDiskCache(new DiskLruCacheFactory(FileUtils.IMAGE_DIR,"cache_glide",memoryCacheSizeBytes));
|
||||
builder.setDefaultRequestOptions(new Glide.RequestOptionsFactory() {
|
||||
@NonNull
|
||||
@NotNull
|
||||
@Override
|
||||
public RequestOptions build() {
|
||||
return new RequestOptions()
|
||||
.placeholder(R.drawable.icon_not_data)
|
||||
.error(R.drawable.ic_load_imag_eerror)
|
||||
.centerCrop()
|
||||
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
|
||||
.format(DecodeFormat.DEFAULT)
|
||||
.encodeQuality(90);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 针对V4用户可以提升速度
|
||||
@Override
|
||||
public boolean isManifestParsingEnabled() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
package com.ycgis.macall.personalcenter.p.app;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.anhui.police.auth.sdk.AuthConfig;
|
||||
import com.anhui.police.auth.sdk.AuthSDK;
|
||||
import com.anhui.police.auth.sdk.AuthType;
|
||||
import com.anhui.police.market.sdk.MarketConfigure;
|
||||
import com.rs.macall.androidx.basemodel.base.BaseApplication;
|
||||
import com.rs.macall.androidx.basemodel.utils.LogUtils;
|
||||
import com.ruansee.macall.unifyservemodulesdk.USMConfigure;
|
||||
import com.ycgis.macall.personalcenter.R;
|
||||
import com.ycgis.macall.personalcenter.util.FileUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/10/25 15:00
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class RuanseeApplication extends BaseApplication {
|
||||
public static final boolean isPrintLog = true;
|
||||
public static final boolean isHFVersion = false;
|
||||
private static AppCache appCache;
|
||||
private static UserData userData;
|
||||
public static boolean isShowIIIAppTitle = false;
|
||||
|
||||
// public static final int RefreshMessageTime = 20000;
|
||||
public static final int RefreshMessageTime = 2 * 60 * 1000;
|
||||
|
||||
/**
|
||||
* 查询消息的时间间隔
|
||||
*/
|
||||
public static final int REFRESH_MESSAGE_TIME = 2*1000*60;
|
||||
|
||||
static {
|
||||
CACHE_FILE_NAME = "newPersonalCenterSP";
|
||||
isShowWatermark = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
appCache = AppCache.getAppCacheData();
|
||||
userData = UserData.getUserData();
|
||||
|
||||
FileUtils.initFilePath(getApplication());
|
||||
new LogUtils.Builder(FileUtils.LOG_DIR)
|
||||
.setBorderSwitch(isPrintLog)
|
||||
.setLogSwitch(isPrintLog)
|
||||
.setLog2FileSwitch(false);
|
||||
|
||||
//统一服务组件
|
||||
USMConfigure.getDefault().init("11811535", "grzx_test_app");
|
||||
|
||||
List<AuthType> types = new ArrayList<>();
|
||||
types.add(appCache.getAuthType());
|
||||
AuthConfig config = AuthConfig.builder();
|
||||
config.setThemeColor(ContextCompat.getColor(getApplicationContext(), R.color.colorAccent));
|
||||
config.setAuthTypes(types);
|
||||
AuthSDK.init("55b161aefd464849b48986a1073d5622", this, config);
|
||||
// AuthMarkManager.setShowAuthMark(true);
|
||||
//应用中心检测更新
|
||||
MarketConfigure.init(this, "442eab382e6a49649e3402115bd8837f", MarketConfigure.MarketDeviceType.DEVICE_TYPE_PHONE);
|
||||
MarketConfigure.setUseMarketDownloadHelper(true);
|
||||
CrashHandler.getInstance().init(getApplication(),FileUtils.LOG_DIR);
|
||||
}
|
||||
|
||||
public static AppCache getAppCache() {
|
||||
return appCache;
|
||||
}
|
||||
|
||||
public static void setAppCache(AppCache appCache) {
|
||||
RuanseeApplication.appCache = appCache;
|
||||
}
|
||||
|
||||
public static UserData getUserData() {
|
||||
return userData;
|
||||
}
|
||||
|
||||
public static void setUserData(UserData userData) {
|
||||
RuanseeApplication.userData = userData;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,234 @@
|
|||
package com.ycgis.macall.personalcenter.p.app;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
import com.ycgis.macall.personalcenter.R;
|
||||
import com.ycgis.macall.personalcenter.util.IdcardUtils;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/10/27 15:40
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class UserData {
|
||||
private static UserData userData;
|
||||
|
||||
private String photo;
|
||||
//角色
|
||||
private String police_role;
|
||||
//职务
|
||||
private String police_post;
|
||||
|
||||
//警号姓名
|
||||
private String userId;
|
||||
|
||||
//警号姓名
|
||||
@Expose(serialize = true)
|
||||
private String userCode;
|
||||
|
||||
@Expose(serialize = true)
|
||||
private String userName;
|
||||
|
||||
@Expose(serialize = true)
|
||||
private String idCardNum;
|
||||
|
||||
//用户所属机构
|
||||
@Expose(serialize = true)
|
||||
private String deptCode;
|
||||
@Expose(serialize = true)
|
||||
private String deptName;
|
||||
|
||||
@Expose(serialize = true)
|
||||
private String ip;
|
||||
|
||||
//所在地市代码
|
||||
@Expose(serialize = true)
|
||||
private String departmentCode;
|
||||
//所在地市名称
|
||||
@Expose(serialize = true)
|
||||
private String departmentName;
|
||||
|
||||
private String phone1;
|
||||
private String phone2;
|
||||
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
//是否是省厅用户 true == 是省厅用户 || false == 地市用户
|
||||
private boolean isStUser;
|
||||
|
||||
public void setPhoto(String photo) {
|
||||
this.photo = photo;
|
||||
}
|
||||
|
||||
public String getPhoto() {
|
||||
return photo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户是否有效
|
||||
* 警号、身份号、组织机构代码 不能为空,否则返回 false
|
||||
* @return true : false
|
||||
*/
|
||||
public boolean isValidOrNot() {
|
||||
if (StringUtil.isNullOrEmpty(userCode)) return false;
|
||||
if (StringUtil.isNullOrEmpty(deptCode)) return false;
|
||||
if (StringUtil.isNullOrEmpty(idCardNum)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getPhone1() {
|
||||
return StringUtil.get(phone1,"暂无");
|
||||
}
|
||||
|
||||
public void setPhone1(String phone1) {
|
||||
this.phone1 = phone1;
|
||||
}
|
||||
|
||||
public String getPhone2() {
|
||||
return StringUtil.get(phone2,"暂无");
|
||||
}
|
||||
|
||||
public void setPhone2(String phone2) {
|
||||
this.phone2 = phone2;
|
||||
}
|
||||
|
||||
public String getPolice_post() {
|
||||
return StringUtil.get(police_post,"暂无");
|
||||
}
|
||||
|
||||
public void setPolice_post(String police_post) {
|
||||
this.police_post = police_post;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public synchronized static UserData getUserData() {
|
||||
if (userData == null) {
|
||||
synchronized (UserData.class) {
|
||||
if (userData == null) userData = new UserData();
|
||||
}
|
||||
}
|
||||
return userData;
|
||||
}
|
||||
|
||||
public static void setUserData(UserData userData) {
|
||||
UserData.userData = userData;
|
||||
}
|
||||
|
||||
public String getPolice_role() {
|
||||
return StringUtil.get(police_role,"暂无");
|
||||
}
|
||||
|
||||
public void setPolice_role(String police_role) {
|
||||
this.police_role = police_role;
|
||||
}
|
||||
|
||||
public String getUserCode() {
|
||||
return userCode;
|
||||
}
|
||||
|
||||
public void setUserCode(String userCode) {
|
||||
this.userCode = userCode;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return StringUtil.get(userName,"暂无");
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getDeptCode() {
|
||||
return deptCode;
|
||||
}
|
||||
|
||||
public void setDeptCode(String deptCode) {
|
||||
this.deptCode = deptCode;
|
||||
initStUser();
|
||||
}
|
||||
|
||||
public String getDeptName() {
|
||||
return StringUtil.get(deptName,"暂无");
|
||||
}
|
||||
|
||||
public void setDeptName(String deptName) {
|
||||
this.deptName = deptName;
|
||||
}
|
||||
|
||||
public String getDepartmentCode() {
|
||||
return departmentCode;
|
||||
}
|
||||
|
||||
public void setDepartmentCode(String departmentCode) {
|
||||
this.departmentCode = departmentCode;
|
||||
}
|
||||
|
||||
public String getDepartmentName() {
|
||||
return departmentName;
|
||||
}
|
||||
|
||||
public void setDepartmentName(String departmentName) {
|
||||
this.departmentName = departmentName;
|
||||
}
|
||||
|
||||
public String getIdCardNum() {
|
||||
return StringUtil.get(idCardNum,"暂无");
|
||||
}
|
||||
|
||||
public void setIdCardNum(String idCardNum) {
|
||||
this.idCardNum = idCardNum;
|
||||
}
|
||||
|
||||
public boolean isStUser() {
|
||||
return isStUser;
|
||||
}
|
||||
|
||||
public void setStUser(boolean stUser) {
|
||||
isStUser = stUser;
|
||||
}
|
||||
|
||||
public void initStUser() {
|
||||
if (StringUtil.hasContent(deptCode)) {
|
||||
if (deptCode.startsWith("3400")) {
|
||||
isStUser = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
Gson gson = new GsonBuilder()
|
||||
.excludeFieldsWithoutExposeAnnotation()
|
||||
.create();
|
||||
return gson.toJson(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取错误的头像照片
|
||||
* 297548
|
||||
*/
|
||||
public int getErrorPhotoByIdCardNum(){
|
||||
if (StringUtil.isNullOrEmpty(idCardNum)) return R.drawable.ic_load_imag_eerror;
|
||||
String genderByIdCard = IdcardUtils.getGenderByIdCard(idCardNum);
|
||||
if ("M".equals(genderByIdCard))return R.drawable.icon_police_man;
|
||||
if ("F".equals(genderByIdCard))return R.drawable.icon_police_woman;
|
||||
return R.drawable.ic_load_imag_eerror;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package com.ycgis.macall.personalcenter.p.callback;
|
||||
|
||||
|
||||
import com.ycgis.macall.personalcenter.p.request.HttpErrorHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author macall
|
||||
* @Create 2020/1/7 0007
|
||||
* @Describe
|
||||
*/
|
||||
public abstract class BaseRequestCallback<T> implements RequestCallback<T> {
|
||||
/*========================= HttpException 异常 code ==========================*/
|
||||
|
||||
private List<Object> payloads;
|
||||
|
||||
public BaseRequestCallback() {
|
||||
}
|
||||
|
||||
public BaseRequestCallback(List<Object> payloads) {
|
||||
this.payloads = payloads;
|
||||
}
|
||||
|
||||
public BaseRequestCallback<T> addPayload(Object o){
|
||||
if (payloads==null){
|
||||
payloads = new ArrayList<>();
|
||||
}
|
||||
payloads.add(o);
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<Object> getPayloads() {
|
||||
return payloads;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestFailure(Throwable e) {
|
||||
onRequestFailure(HttpErrorHandler.requestHandle(e));
|
||||
}
|
||||
|
||||
public abstract void onRequestFailure(String msg);
|
||||
|
||||
@Override
|
||||
public void onStartRequest() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.ycgis.macall.personalcenter.p.callback;
|
||||
|
||||
/*
|
||||
* 项目名:xayss
|
||||
* 作者:马超
|
||||
* 类目:FramgmentCallback.java
|
||||
* 包名:com.ruansee.sx.xayss.p.callback.FramgmentCallback
|
||||
* 当前修改时间:2023年08月17日 08:31:16
|
||||
* 上次修改时间:2023年08月17日 08:31:16
|
||||
* Copyright©:2023 安徽软思信息技术有限公司
|
||||
* 功能描述:
|
||||
*/
|
||||
public interface CarFragmentCallback {
|
||||
|
||||
String[] getTimePeriod();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.ycgis.macall.personalcenter.p.callback;/*
|
||||
* 项目名:xayss
|
||||
* 作者:马超
|
||||
* 类目:DataModelCallback.java
|
||||
* 包名:com.ruansee.sx.xayss.p.callback.DataModelCallback
|
||||
* 当前修改时间:2023年05月22日 15:34:38
|
||||
* 上次修改时间:2023年05月22日 15:34:38
|
||||
* Copyright©:2023 安徽软思信息技术有限公司
|
||||
* 功能描述:
|
||||
*/
|
||||
|
||||
public interface DataModelCallback {
|
||||
|
||||
void onUpdate(int what,int org,Object obg);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.ycgis.macall.personalcenter.p.callback;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.ycgis.macall.personalcenter.m.adapterbean.BaseBean;
|
||||
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/3/27 16:50
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public interface DerivativeCallback {
|
||||
void onItemClick(View view, BaseBean baseBean, int position);
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.ycgis.macall.personalcenter.p.callback;/*
|
||||
* 项目名:xayss
|
||||
* 作者:马超
|
||||
* 类目:EditTextWatcherListener.java
|
||||
* 包名:com.ruansee.sx.xayss.p.callback.EditTextWatcherListener
|
||||
* 当前修改时间:2023年05月08日 14:26:02
|
||||
* 上次修改时间:2023年05月08日 14:26:02
|
||||
* Copyright©:2023 安徽软思信息技术有限公司
|
||||
* 功能描述:
|
||||
*/
|
||||
|
||||
import android.text.Editable;
|
||||
import android.text.Spannable;
|
||||
import android.text.TextWatcher;
|
||||
|
||||
public abstract class EditTextWatcherListener implements TextWatcher {
|
||||
/**
|
||||
* This method is called to notify you that, within <code>s</code>,
|
||||
* the <code>count</code> characters beginning at <code>start</code>
|
||||
* are about to be replaced by new text with length <code>after</code>.
|
||||
* It is an error to attempt to make changes to <code>s</code> from
|
||||
* this callback.
|
||||
*/
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called to notify you that, within <code>s</code>,
|
||||
* the <code>count</code> characters beginning at <code>start</code>
|
||||
* have just replaced old text that had length <code>before</code>.
|
||||
* It is an error to attempt to make changes to <code>s</code> from
|
||||
* this callback.
|
||||
*/
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called to notify you that, somewhere within
|
||||
* <code>s</code>, the text has been changed.
|
||||
* It is legitimate to make further changes to <code>s</code> from
|
||||
* this callback, but be careful not to get yourself into an infinite
|
||||
* loop, because any changes you make will cause this method to be
|
||||
* called again recursively.
|
||||
* (You are not told where the change took place because other
|
||||
* afterTextChanged() methods may already have made other changes
|
||||
* and invalidated the offsets. But if you need to know here,
|
||||
* you can use {@link Spannable#setSpan} in {@link #onTextChanged}
|
||||
* to mark your place and then look up from here where the span
|
||||
* ended up.
|
||||
*/
|
||||
public void afterTextChanged(Editable s){
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.ycgis.macall.personalcenter.p.callback;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.utils.GpsUtil;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/3/28 9:40
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class GPSListener extends GpsUtil {
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package com.ycgis.macall.personalcenter.p.callback;
|
||||
|
||||
import android.location.Location;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/3/28 9:38
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public abstract class GPSLocationListener {
|
||||
|
||||
/**
|
||||
* 位置发生改变
|
||||
* @param location
|
||||
*/
|
||||
public abstract void onLocationChanged(Location location);
|
||||
|
||||
public void stopLocation(){}
|
||||
|
||||
public void onScanSatellite(int totalCount,int bduCount,int locationCount){}
|
||||
|
||||
// /**
|
||||
// * 定位状态发生改变
|
||||
// * @param provider
|
||||
// * @param status
|
||||
// * @param extras
|
||||
// */
|
||||
// @Override
|
||||
// public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 启用 定位模式
|
||||
// * @param provider
|
||||
// */
|
||||
// @Override
|
||||
// public void onProviderEnabled(String provider) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 定位模式 被禁用
|
||||
// * @param provider
|
||||
// */
|
||||
// @Override
|
||||
// public void onProviderDisabled(String provider) {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.ycgis.macall.personalcenter.p.callback;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.widget.ImageView;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/11/16 9:46
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public interface ImageCallBack {
|
||||
public void imageLoad(ImageView imageView, Bitmap bitmap);
|
||||
|
||||
public void imageLoadError(ImageView imageView, String message);
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.ycgis.macall.personalcenter.p.callback;
|
||||
|
||||
import com.ycgis.macall.personalcenter.p.request.HttpErrorHandler;
|
||||
|
||||
/*
|
||||
* 项目名:xayss
|
||||
* 作者:马超
|
||||
* 类目:MainSearchRequestCallback.java
|
||||
* 包名:com.ruansee.sx.xayss.p.callback.MainSearchRequestCallback
|
||||
* 当前修改时间:2023年07月28日 15:30:09
|
||||
* 上次修改时间:2023年07月28日 15:30:09
|
||||
* Copyright©:2023 安徽软思信息技术有限公司
|
||||
* 功能描述:
|
||||
*/
|
||||
public abstract class MainSearchRequestCallback <T> extends BaseRequestCallback<T> {
|
||||
/*========================= HttpException 异常 code ==========================*/
|
||||
private String paramKey;
|
||||
private Class eClass;
|
||||
|
||||
public MainSearchRequestCallback(String paramKey, Class eClass) {
|
||||
this.paramKey = paramKey;
|
||||
this.eClass = eClass;
|
||||
}
|
||||
|
||||
abstract public void onRequestSuccess(T result,String paramKey,Class eClass);
|
||||
|
||||
@Override
|
||||
public void onRequestSuccess(T result) {
|
||||
onRequestSuccess(result,paramKey,eClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestFailure(Throwable e) {
|
||||
onRequestFailure(HttpErrorHandler.requestHandle(e));
|
||||
}
|
||||
|
||||
public abstract void onRequestFailure(String msg);
|
||||
|
||||
@Override
|
||||
public void onStartRequest() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.ycgis.macall.personalcenter.p.callback;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/10/13 16:30
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
abstract public class OnAdapterLongClickListener<E> implements View.OnLongClickListener {
|
||||
|
||||
private E data;
|
||||
private int position;
|
||||
|
||||
public OnAdapterLongClickListener(E data, int position) {
|
||||
this.data = data;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
|
||||
public void setParam(E data, int position) {
|
||||
this.data = data;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
onLongClick(v,data,position);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract void onLongClick(View v, E data, int position);
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.ycgis.macall.personalcenter.p.callback;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface OnFragmentOnClickListener {
|
||||
|
||||
@NotNull
|
||||
void onClickListener(View view,@NotNull Object obj);
|
||||
|
||||
@NotNull
|
||||
void ovReturnData(String json);
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package com.ycgis.macall.personalcenter.p.callback;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/8/23 10:05
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class OnGlobalLayoutListenerByEllipsize implements ViewTreeObserver.OnGlobalLayoutListener {
|
||||
|
||||
private TextView mTextView;
|
||||
private int mMaxLines; //最大行数
|
||||
|
||||
public OnGlobalLayoutListenerByEllipsize(TextView textView, int maxLines){
|
||||
if(maxLines <= 0)
|
||||
throw new IllegalArgumentException("maxLines不能小于等于0");
|
||||
this.mTextView = textView;
|
||||
this.mMaxLines = maxLines;
|
||||
this.mTextView.setMaxLines(mMaxLines+1);
|
||||
this.mTextView.setSingleLine(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
if(mTextView.getLineCount() > mMaxLines){
|
||||
int line = mTextView.getLayout().getLineEnd(mMaxLines-1);
|
||||
CharSequence truncate = "...";//定义成CharSequence类型,是为了兼容emoji表情,如果使用String类型则会造成emoji无法显示
|
||||
CharSequence text = mTextView.getText();
|
||||
try {
|
||||
text = text.subSequence(0, line - 3);
|
||||
}catch (Exception e){
|
||||
truncate = "";
|
||||
text = mTextView.getText();
|
||||
}
|
||||
TextUtils.TruncateAt at = mTextView.getEllipsize();
|
||||
if(at == TextUtils.TruncateAt.START) {
|
||||
mTextView.setText(truncate);
|
||||
mTextView.append(text);
|
||||
}else if(at == TextUtils.TruncateAt.MIDDLE){
|
||||
mTextView.setText(text.subSequence(0,text.length()/2));
|
||||
mTextView.append(truncate);
|
||||
mTextView.append(text.subSequence(text.length()/2,text.length()));
|
||||
}else {
|
||||
mTextView.setText(text);
|
||||
mTextView.append(truncate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.ycgis.macall.personalcenter.p.callback;
|
||||
|
||||
/**
|
||||
* @Author macall
|
||||
* @Create 2020/1/7 0007
|
||||
* @Describe
|
||||
*/
|
||||
public interface RequestCallback<T> {
|
||||
void onStartRequest();
|
||||
|
||||
/*成功*/
|
||||
void onRequestSuccess(T result);
|
||||
|
||||
/*失败*/
|
||||
void onRequestFailure(Throwable e);
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.ycgis.macall.personalcenter.p.callback;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2022/11/15 15:40
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public interface SelectReturnCallback<T> {
|
||||
|
||||
void returnMsg(T message);
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.ycgis.macall.personalcenter.p.callback;
|
||||
|
||||
/**
|
||||
* Created by macall on 2018-06-06.
|
||||
* copyright:ycgis
|
||||
*/
|
||||
|
||||
public interface UploadProgressListener {
|
||||
void onUploadProgress(long totalBytes, long remainingBytes, boolean done);
|
||||
|
||||
/**
|
||||
* 完成状态
|
||||
*
|
||||
* @param totalSize
|
||||
*/
|
||||
public void onUploadDone(long totalSize);
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.ycgis.macall.personalcenter.p.callback;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.callback.BasePresenterCallback;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2022/11/21 17:30
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public interface WebActivityCallback extends BasePresenterCallback {
|
||||
|
||||
void onShowOperationSelectDialog( String[] split ,int whit);
|
||||
|
||||
void onFinish();
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.ycgis.macall.personalcenter.p.callback;
|
||||
|
||||
import com.ycgis.macall.personalcenter.m.adapterbean.WorkAppBean;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/11/3 11:12
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public interface WorkManageCallback {
|
||||
void onAdd(WorkAppBean appBean);
|
||||
void onRemove(WorkAppBean appBean);
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.ycgis.macall.personalcenter.p.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.callback.BasePresenterCallback;
|
||||
import com.rs.macall.androidx.basemodel.utils.ProgressDialogUtils;
|
||||
|
||||
|
||||
/**
|
||||
* @Author macall
|
||||
* @Create 2019/12/4 0004
|
||||
* @Describe
|
||||
*/
|
||||
public abstract class BasePresenter<T extends BasePresenterCallback> {
|
||||
protected static String TAG = "";
|
||||
protected Context context;
|
||||
protected T callBack;
|
||||
|
||||
private ProgressDialogUtils dialogUtils;
|
||||
|
||||
public BasePresenter(Context context, T callback){
|
||||
this.context = context;
|
||||
this.callBack = callback;
|
||||
TAG = getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public void baseShowDialog(String mess) {
|
||||
baseShowDialog("提示信息", mess);
|
||||
}
|
||||
|
||||
public void baseShowDialog(String title, String mess) {
|
||||
if (dialogUtils == null) dialogUtils = new ProgressDialogUtils(context);
|
||||
else dialogUtils.dismiss();
|
||||
dialogUtils.show(title, mess);
|
||||
}
|
||||
|
||||
public void baseShowFaseDialong(String title, String mess) {
|
||||
if (dialogUtils == null) dialogUtils = new ProgressDialogUtils(context);
|
||||
else dialogUtils.dismiss();
|
||||
dialogUtils.showFase(title, mess);
|
||||
}
|
||||
|
||||
public void baseDialogUpdateMessage(String mess) {
|
||||
if (dialogUtils == null) {
|
||||
baseShowDialog(mess);
|
||||
} else {
|
||||
dialogUtils.setMessage(mess);
|
||||
}
|
||||
}
|
||||
|
||||
public void baseDismissDialog() {
|
||||
if (dialogUtils != null) dialogUtils.dismiss();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,493 @@
|
|||
package com.ycgis.macall.personalcenter.p.presenter;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DownloadManager;
|
||||
import android.content.ClipData;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.net.http.SslError;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.webkit.JsResult;
|
||||
import android.webkit.SslErrorHandler;
|
||||
import android.webkit.URLUtil;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebResourceError;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebResourceResponse;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.just.agentweb.WebChromeClient;
|
||||
import com.just.agentweb.WebViewClient;
|
||||
import com.rs.macall.androidx.basemodel.callback.CustomClickListener;
|
||||
import com.rs.macall.androidx.basemodel.utils.BitMapUtils;
|
||||
import com.rs.macall.androidx.basemodel.utils.LogUtils;
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
import com.ycgis.macall.personalcenter.R;
|
||||
import com.ycgis.macall.personalcenter.m.model.SelectFileOptions;
|
||||
import com.ycgis.macall.personalcenter.p.callback.WebActivityCallback;
|
||||
import com.ycgis.macall.personalcenter.p.request.DownloadUtil;
|
||||
import com.ycgis.macall.personalcenter.util.FileUtils;
|
||||
import com.ycgis.macall.personalcenter.util.UriUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import top.zibin.luban.OnCompressListener;
|
||||
|
||||
import static android.content.Context.DOWNLOAD_SERVICE;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2022/11/21 17:26
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class WebViewPresenter extends BasePresenter<WebActivityCallback> {
|
||||
public File photoFile;
|
||||
public final static int RESULT_CODE = 10000;
|
||||
public final static int SELECT_IMG_CODE = 10001;
|
||||
public final static int SELECT_FILE_CODE = 10002;
|
||||
public SelectFileOptions selectFileOptions;
|
||||
private String fileTypes;
|
||||
private Dialog selectItems;
|
||||
private boolean isLogin = false;
|
||||
public String ywryName = "", ywryPhone = "";
|
||||
|
||||
public String intoUrl = "http://20.90.1.150:8888/";
|
||||
// public Map<String, SelectFileOptions> selectFileOptionsMap;
|
||||
|
||||
public ValueCallback<Uri[]> mFilePathCallback;
|
||||
|
||||
public WebViewPresenter(Context context, WebActivityCallback callback) {
|
||||
super(context, callback);
|
||||
// selectFileOptionsMap = new HashMap<>();
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 相机拍照
|
||||
*
|
||||
* @param activity 当前活动
|
||||
*/
|
||||
private void skipPickPhoto(Activity activity) {
|
||||
if (photoFile != null && photoFile.exists()) {
|
||||
photoFile.delete();
|
||||
}
|
||||
photoFile = new File(FileUtils.IMAGE_DIR, FileUtils.getPhotoName());
|
||||
Intent photoIntent = UriUtils.getPhotoIntent(context, photoFile);
|
||||
activity.startActivityForResult(photoIntent, RESULT_CODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件选择配置 实现选择弹框
|
||||
*/
|
||||
private void showSelectUploadDialog() {
|
||||
if (selectFileOptions.onlyOneItemIsSelected()) {
|
||||
if (selectFileOptions.isCamera()) {
|
||||
callBack.onShowOperationSelectDialog(new String[]{"相机"}, 0);
|
||||
return;
|
||||
}
|
||||
if (selectFileOptions.isDCIM()) {
|
||||
callBack.onShowOperationSelectDialog(new String[]{"相册"}, 1);
|
||||
return;
|
||||
}
|
||||
if (selectFileOptions.isFileSelection()) {
|
||||
callBack.onShowOperationSelectDialog(new String[]{"文件选择"}, 2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
int a = View.GONE, b = View.GONE, c = View.GONE;
|
||||
if (selectFileOptions.isCamera()) {
|
||||
a = View.VISIBLE;
|
||||
}
|
||||
if (selectFileOptions.isDCIM()) {
|
||||
b = View.VISIBLE;
|
||||
}
|
||||
if (selectFileOptions.isFileSelection()) {
|
||||
c = View.VISIBLE;
|
||||
}
|
||||
if (selectItems == null) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.dialog_select_items, null, false);
|
||||
selectItems = new AlertDialog.Builder(context)
|
||||
.setView(view)
|
||||
.setOnCancelListener(dialog -> {
|
||||
mFilePathCallback.onReceiveValue(null);
|
||||
mFilePathCallback = null;
|
||||
})
|
||||
.create();
|
||||
}
|
||||
selectItems.show();
|
||||
TextView tv_title = selectItems.findViewById(R.id.tv_title);
|
||||
tv_title.setText("选择操作方式");
|
||||
View tv_xj = selectItems.findViewById(R.id.tv_xj);
|
||||
tv_xj.setVisibility(a);
|
||||
View tv_xc = selectItems.findViewById(R.id.tv_xc);
|
||||
tv_xc.setVisibility(b);
|
||||
View tv_wjxz = selectItems.findViewById(R.id.tv_wjxz);
|
||||
tv_wjxz.setVisibility(c);
|
||||
tv_xj.setOnClickListener(new CustomClickListener() {
|
||||
@Override
|
||||
public void onSingleClick(View v) {
|
||||
selectItems.dismiss();
|
||||
callBack.onShowOperationSelectDialog(new String[]{"相机"}, 0);
|
||||
}
|
||||
});
|
||||
tv_xc.setOnClickListener(new CustomClickListener() {
|
||||
@Override
|
||||
public void onSingleClick(View v) {
|
||||
selectItems.dismiss();
|
||||
callBack.onShowOperationSelectDialog(new String[]{"相册"}, 1);
|
||||
}
|
||||
});
|
||||
tv_wjxz.setOnClickListener(new CustomClickListener() {
|
||||
@Override
|
||||
public void onSingleClick(View v) {
|
||||
selectItems.dismiss();
|
||||
callBack.onShowOperationSelectDialog(new String[]{"文件选择"}, 2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示选择文件弹框
|
||||
*
|
||||
* @param whit 可操作的项
|
||||
* 1表示 只能相机拍照,将直接打开系统相机
|
||||
* 2表示 提供相机拍照、相册选取两个选项
|
||||
* 3表示 文件选取
|
||||
*/
|
||||
public void onShowOperationSelectDialog(Activity activity, int whit, String[] split) {
|
||||
switch (whit) {
|
||||
case 0:
|
||||
skipPickPhoto(activity);
|
||||
break;
|
||||
case 1:
|
||||
Intent intent = new Intent(Intent.ACTION_PICK, null);
|
||||
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, fileTypes);
|
||||
intent.setType(fileTypes);
|
||||
activity.startActivityForResult(intent, SELECT_IMG_CODE);
|
||||
break;
|
||||
case 2:
|
||||
intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intent.setType(fileTypes);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
activity.startActivityForResult(intent, SELECT_FILE_CODE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*
|
||||
* @param url 文件URL
|
||||
* @param fileName 文件名称
|
||||
* @param downloadListener 下载监听
|
||||
*/
|
||||
public void downloadFile(String url, String fileName, DownloadUtil.OnDownloadListener downloadListener) {
|
||||
// ApiModel.request(RetrofitService.getBaseInstance().downFile(url), new BaseRequestCallback<ResponseBody>() {
|
||||
// @Override
|
||||
// public void onRequestFailure(String msg) {
|
||||
// // 下载失败
|
||||
// downloadListener.onDownloadFailed(msg);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onRequestSuccess(ResponseBody result) {
|
||||
// try {
|
||||
// DownloadUtil.get().handDownFile(url,FileUtils.DOWNLOADS_DIR,result,fileName,downloadListener);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// // 下载失败
|
||||
// downloadListener.onDownloadFailed(e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
DownloadUtil.get().download(url, FileUtils.DOWNLOADS_DIR, fileName, downloadListener);
|
||||
}
|
||||
|
||||
public WebViewClient mWebViewClient = new WebViewClient() {
|
||||
@Override
|
||||
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
||||
//do you work
|
||||
LogUtils.w(String.format("onPageStarted : url=%s", url));
|
||||
if (url.startsWith(intoUrl) || url.startsWith("http://localhost")) {
|
||||
if (isLogin) {
|
||||
callBack.onFinish();
|
||||
}
|
||||
isLogin = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadResource(WebView view, String url) {
|
||||
super.onLoadResource(view, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
|
||||
super.onReceivedError(view, request, error);
|
||||
//net::ERR_NAME_NOT_RESOLVED -2 网页超时加载 执行这个回调
|
||||
// showLoadWebError("应用加载超时,请联系管理员排查系统。",ywryName,ywryPhone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
|
||||
//内部系统 沒有用用户
|
||||
// errorResponse.getStatusCode() == 404;
|
||||
// if(errorResponse.getStatusCode() == 404){
|
||||
// showLoadWebError("应用加载失败,用户没有权限,请联系管理添加权限。",ywryName,ywryPhone);
|
||||
// }else {
|
||||
super.onReceivedHttpError(view, request, errorResponse);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
|
||||
super.onReceivedSslError(view, handler, error);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
view.getSettings().setBlockNetworkImage(false);
|
||||
super.onPageFinished(view, url);
|
||||
}
|
||||
};
|
||||
|
||||
public WebChromeClient mWebChromeClient = new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
//do you work
|
||||
super.onProgressChanged(view, newProgress);
|
||||
if (newProgress>=100){
|
||||
view.getSettings().setBlockNetworkImage(false);
|
||||
}
|
||||
LogUtils.w(TAG, String.format("onProgressChanged : newProgress=%s", newProgress));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
|
||||
//设置弹窗
|
||||
AlertDialog.Builder b = new AlertDialog.Builder(context);
|
||||
b.setTitle("Alert");
|
||||
b.setMessage(message);
|
||||
b.setPositiveButton(android.R.string.ok, (dialog, which) -> result.confirm());
|
||||
b.setCancelable(true);
|
||||
b.create().show();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
|
||||
mFilePathCallback = filePathCallback;
|
||||
if (fileChooserParams != null) {
|
||||
if (fileChooserParams.getAcceptTypes() != null
|
||||
&& fileChooserParams.getAcceptTypes().length > 0) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String sp = "";
|
||||
for (int i = 0; i < fileChooserParams.getAcceptTypes().length; i++) {
|
||||
builder.append(sp);
|
||||
builder.append(fileChooserParams.getAcceptTypes()[0]);
|
||||
sp = ";";
|
||||
}
|
||||
fileTypes = builder.toString();
|
||||
}
|
||||
}
|
||||
if (StringUtil.isNullOrEmpty(fileTypes)) {
|
||||
fileTypes = "*/*";
|
||||
}
|
||||
if (selectFileOptions == null) {
|
||||
selectFileOptions = new SelectFileOptions(false, true, true, true);
|
||||
}
|
||||
if (selectFileOptions.isSelfRealization()) {
|
||||
return super.onShowFileChooser(webView, filePathCallback, fileChooserParams);
|
||||
}
|
||||
showSelectUploadDialog();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public void showLoadWebError(String titleStr, String msg, String lxryName, String lxryPhone) {
|
||||
if (StringUtil.isNullOrEmpty(titleStr)){
|
||||
titleStr = "温馨提示";
|
||||
}
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.dialog_h5_error, null, false);
|
||||
Dialog insertTips = new AlertDialog.Builder(context)
|
||||
.setView(view)
|
||||
.create();
|
||||
insertTips.show();
|
||||
TextView title = insertTips.findViewById(R.id.textView2);
|
||||
title.setText(titleStr);
|
||||
TextView tvMsg = insertTips.findViewById(R.id.tv_msg);
|
||||
TextView tvYwry = insertTips.findViewById(R.id.tv_wery);
|
||||
TextView tvPhone = insertTips.findViewById(R.id.tv_ywrydh);
|
||||
tvMsg.setText(msg);
|
||||
String name = "暂无";
|
||||
String lxdh ="暂无";
|
||||
if (StringUtil.isNullOrEmpty(lxryName)) {
|
||||
if (StringUtil.hasContent(ywryName)) {
|
||||
name =ywryName;
|
||||
if (StringUtil.hasContent(ywryPhone)){
|
||||
lxdh = ywryPhone;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
name = lxryName;
|
||||
lxdh= StringUtil.isNullOrEmpty(lxryPhone)?"暂无":lxryPhone;
|
||||
}
|
||||
tvYwry.setText(name+":");
|
||||
tvPhone.setText(lxdh);
|
||||
insertTips.findViewById(R.id.btn_determine).setOnClickListener(new CustomClickListener() {
|
||||
@Override
|
||||
public void onSingleClick(View v) {
|
||||
insertTips.dismiss();
|
||||
callBack.onFinish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理选择相册和选择文件
|
||||
*
|
||||
* @param requestCode
|
||||
* @param resultCode
|
||||
* @param intent
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public void onActivityResultAboveL(int requestCode, int resultCode, Intent intent) {
|
||||
Uri[] results = null;
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (intent != null) {
|
||||
String dataString = intent.getDataString();
|
||||
ClipData clipData = intent.getClipData();
|
||||
if (clipData != null) {
|
||||
results = new Uri[clipData.getItemCount()];
|
||||
for (int i = 0; i < clipData.getItemCount(); i++) {
|
||||
ClipData.Item item = clipData.getItemAt(i);
|
||||
results[i] = item.getUri();
|
||||
}
|
||||
}
|
||||
if (dataString != null)
|
||||
results = new Uri[]{Uri.parse(dataString)};
|
||||
}
|
||||
mFilePathCallback.onReceiveValue(results);
|
||||
mFilePathCallback = null;
|
||||
} else {
|
||||
mFilePathCallback.onReceiveValue(null);
|
||||
mFilePathCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 压缩图片
|
||||
*/
|
||||
public void ysBitmap() {
|
||||
BitMapUtils.lubanCompress(context, photoFile, FileUtils.IMAGE_DIR, new OnCompressListener() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
if (!file.getAbsolutePath().equals(photoFile.getAbsolutePath())) {
|
||||
photoFile.delete();
|
||||
photoFile = file;
|
||||
}
|
||||
Uri ph = UriUtils.getUri(context, file);
|
||||
Uri[] uris = new Uri[]{ph};
|
||||
mFilePathCallback.onReceiveValue(uris);
|
||||
mFilePathCallback = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
mFilePathCallback.onReceiveValue(null);
|
||||
mFilePathCallback = null;
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 浏览器下载
|
||||
*
|
||||
* @param url
|
||||
*/
|
||||
private void downloadByBrowser(String url) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||
intent.setData(Uri.parse(url));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统下载服务下载
|
||||
*
|
||||
* @param url
|
||||
* @param contentDisposition
|
||||
* @param mimeType
|
||||
*/
|
||||
public void downloadBySystem(String url, String contentDisposition, String mimeType) {
|
||||
// 指定下载地址
|
||||
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
|
||||
// 允许媒体扫描,根据下载的文件类型被加入相册、音乐等媒体库
|
||||
request.allowScanningByMediaScanner();
|
||||
// 设置通知的显示类型,下载进行时和完成后显示通知
|
||||
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
||||
// 设置通知栏的标题,如果不设置,默认使用文件名
|
||||
// request.setTitle("This is title");
|
||||
// 设置通知栏的描述
|
||||
// request.setDescription("This is description");
|
||||
// 允许在计费流量下下载
|
||||
request.setAllowedOverMetered(false);
|
||||
// 允许该记录在下载管理界面可见
|
||||
request.setVisibleInDownloadsUi(false);
|
||||
// 允许漫游时下载
|
||||
request.setAllowedOverRoaming(true);
|
||||
// 允许下载的网路类型
|
||||
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);
|
||||
// 设置下载文件保存的路径和文件名
|
||||
String fileName = URLUtil.guessFileName(url, contentDisposition, mimeType);
|
||||
LogUtils.d("fileName:{}", fileName);
|
||||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
|
||||
// 另外可选一下方法,自定义下载路径
|
||||
// request.setDestinationUri()
|
||||
// request.setDestinationInExternalFilesDir()
|
||||
final DownloadManager downloadManager = (DownloadManager) context.getSystemService(DOWNLOAD_SERVICE);
|
||||
// 添加一个下载任务
|
||||
long downloadId = downloadManager.enqueue(request);
|
||||
LogUtils.d("downloadId:{}", downloadId + "");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 打开GPS
|
||||
*/
|
||||
// private void openGPSSettings() {
|
||||
// LocationManager alm = (LocationManager) context
|
||||
// .getSystemService(Context.LOCATION_SERVICE);
|
||||
// if (alm.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) {
|
||||
// Toast.makeText(context, "GPS模块正常", Toast.LENGTH_SHORT).show();
|
||||
//// baiDuMapManager.startLocation();
|
||||
// return;
|
||||
// } else {
|
||||
// Toast.makeText(context, "请开启GPS!", Toast.LENGTH_SHORT).show();
|
||||
// Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
|
||||
// startActivityForResult(intent, 0); // 此为设置完成后返回到获取界面
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
@ -0,0 +1,633 @@
|
|||
package com.ycgis.macall.personalcenter.p.request;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.rs.macall.androidx.basemodel.utils.LogUtils;
|
||||
import com.ycgis.macall.personalcenter.p.app.RuanseeApplication;
|
||||
import com.ycgis.macall.personalcenter.p.callback.RequestCallback;
|
||||
import com.ycgis.macall.personalcenter.p.rxjava.ResultObserver;
|
||||
import com.ycgis.macall.personalcenter.util.ParamMap;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableSource;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
/**
|
||||
* @Author macall
|
||||
* @Create 2020/6/23 0023
|
||||
* @Describe 接口封装类
|
||||
*/
|
||||
public class ApiModel {
|
||||
private static final String TAG = "ApiModel";
|
||||
|
||||
// /**
|
||||
// * 下载文件
|
||||
// *
|
||||
// * @param url 下载链接
|
||||
// * @param fileName 下载后文件名
|
||||
// * @param downloadInfo 需要更新的实体
|
||||
// * @param pointer 需要更新的指针
|
||||
// * @param callBack 回调监听
|
||||
// */
|
||||
/* public static void download(Resources resources, String url, final String fileName, final DownloadOV downloadInfo, final int pointer, final DownloadCallBack callBack) {
|
||||
RetrofitService.getBaseInstance()
|
||||
.downloadFile(url)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.unsubscribeOn(Schedulers.io())
|
||||
.flatMap(new Function<ResponseBody, ObservableSource<DownloadOV>>() {
|
||||
|
||||
@Override
|
||||
public ObservableSource<DownloadOV> apply(final ResponseBody responseBody) throws Exception {
|
||||
return Observable.create(new ObservableOnSubscribe<DownloadOV>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<DownloadOV> emitter) throws Exception {
|
||||
InputStream inputStream = null;
|
||||
long total = 0;
|
||||
long responseLength = 0;
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
byte[] buf = new byte[2048];
|
||||
int len = 0;
|
||||
responseLength = responseBody.contentLength();
|
||||
inputStream = responseBody.byteStream();
|
||||
String fileDir = "";
|
||||
// if (downloadInfo.getType() == 1) {
|
||||
// fileDir = FileUtil.getTxlPath();
|
||||
// } else if (downloadInfo.getType() == 2) {
|
||||
// String extension = FileUtil.getFileExtension(fileName);
|
||||
// fileDir = ResDrawableIdHelp.getFileDir(extension);
|
||||
// }
|
||||
final File file = new File(fileDir, fileName);
|
||||
downloadInfo.setFile(file);
|
||||
downloadInfo.setFileSize(responseLength);
|
||||
fos = new FileOutputStream(file);
|
||||
int progress = 0;
|
||||
int lastProgress = 0;
|
||||
long startTime = System.currentTimeMillis(); // 开始下载时获取开始时间
|
||||
while ((len = inputStream.read(buf)) != -1) {
|
||||
fos.write(buf, 0, len);
|
||||
total += len;
|
||||
lastProgress = progress;
|
||||
progress = (int) (total * 100 / responseLength);
|
||||
long curTime = System.currentTimeMillis();
|
||||
long usedTime = (curTime - startTime) / 1000;
|
||||
if (usedTime == 0) {
|
||||
usedTime = 1;
|
||||
}
|
||||
long speed = (total / usedTime); // 平均每秒下载速度
|
||||
// 如果进度与之前进度相等,则不更新,如果更新太频繁,则会造成界面卡顿
|
||||
if (progress > 0 && progress != lastProgress) {
|
||||
downloadInfo.setSpeed(speed);
|
||||
downloadInfo.setProgress(progress);
|
||||
downloadInfo.setCurrentSize(total);
|
||||
emitter.onNext(downloadInfo);
|
||||
}
|
||||
}
|
||||
fos.flush();
|
||||
downloadInfo.setFile(file);
|
||||
emitter.onComplete();
|
||||
} catch (Exception e) {
|
||||
downloadInfo.setErrorMsg(e);
|
||||
emitter.onError(e);
|
||||
} finally {
|
||||
try {
|
||||
if (fos != null) {
|
||||
fos.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if (inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<DownloadOV>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(DownloadOV downloadInfo) {
|
||||
callBack.onProgress(downloadInfo.getProgress(), downloadInfo.getFileSize(), downloadInfo.getSpeed());
|
||||
callBack.onProgress(downloadInfo, pointer);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
callBack.onError(e, pointer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
LogUtils.e(TAG, "完成");
|
||||
downloadInfo.setDownload(1);
|
||||
callBack.onCompleted(downloadInfo, pointer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
*//*上传文件*//*
|
||||
public static void uploadFile(int pointer, File file, FileItem item, String fileType, final UploadCallBack<JsonObject> callback) {
|
||||
//设置文件设置图片的格式
|
||||
RequestBody requestBody = RequestBody.create(getMediaType(file.getName()), file);
|
||||
String str = file.getName();
|
||||
try {
|
||||
str = URLEncoder.encode(file.getName(), "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
str = System.currentTimeMillis() + str.substring(str.lastIndexOf("."));
|
||||
}
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("files", file.getName());
|
||||
map.put("fileType", fileType);
|
||||
|
||||
//设置一个file文件
|
||||
MultipartBody.Part body = MultipartBody.Part.createFormData("files", str, requestBody);
|
||||
// RetrofitService.getBaseInstance()
|
||||
// .uploadFile(RuanSiApplication.getAppCacheData().getUserCode()
|
||||
// , RuanSiApplication.getAppCacheData().getSfzh(), RuanSiApplication.getAppCacheData().getUserName(), RuanSiApplication.getAppCacheData().getZzjgDm(), body, fileType)
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .doOnSubscribe(new Consumer<Disposable>() {
|
||||
// @Override
|
||||
// public void accept(@io.reactivex.annotations.NonNull Disposable disposable) throws Exception {
|
||||
// callback.onStartRequest();
|
||||
// }
|
||||
// })
|
||||
// //获得的数据返回主线程去更新界面
|
||||
// .observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(new Observer<JsonObject>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
//// LogUtils.w(TAG, "onSubscribe " + d.toString());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(JsonObject s) {
|
||||
//// mode.setStatus(0).setJsonResult(s.toString()).sendLog();
|
||||
//// callback.onRequestSuccess(pointer, item, s);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(Throwable e) {
|
||||
//// callback.onRequestFailure(pointer, item, e);
|
||||
//// LogUtils.w(TAG, "onError " + e.getMessage());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// }
|
||||
// });
|
||||
}*/
|
||||
/**
|
||||
* 发起请求
|
||||
*
|
||||
* @param requestKey {@link CommonCompositeManage#addDisposable(String, Disposable)} 接口请求标识 用来管理 请求
|
||||
* @param observable 请求体
|
||||
* @param callback 接口回调
|
||||
* @param <T> 返回类型
|
||||
*/
|
||||
public static <T> void requestRetry( String requestKey, Observable<T> observable, final RequestCallback<T> callback) {
|
||||
requestRetry( observable, new Observer<T>() {
|
||||
@Override
|
||||
public void onSubscribe(@NotNull Disposable d) {
|
||||
CommonCompositeManage.getInstance().addDisposable(requestKey, d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull T t) {
|
||||
CommonCompositeManage.getInstance().unDisposable(requestKey);
|
||||
callback.onRequestSuccess(t);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NotNull Throwable e) {
|
||||
CommonCompositeManage.getInstance().unDisposable(requestKey);
|
||||
callback.onRequestFailure(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
CommonCompositeManage.getInstance().unDisposable(requestKey);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
/**
|
||||
* 请求发生IO(time out) 异常时重新请求(重复3次)
|
||||
* @param observable 被观察者(请求对象)
|
||||
* @param observer 观察者(响应对象)
|
||||
* @param <T> 返回数据类型
|
||||
*/
|
||||
public static <T> void requestRetry(Observable<T> observable, Observer<T> observer) {
|
||||
observable.retryWhen(new MyFunction<Observable<Throwable>, ObservableSource<?>>() {
|
||||
@Override
|
||||
public ObservableSource<?> apply(@NotNull Observable<Throwable> throwableObservable) throws Exception {
|
||||
return throwableObservable.flatMap(new MyFunction<Throwable, ObservableSource<?>>() {
|
||||
@Override
|
||||
public Observable<?> apply(@NotNull Throwable throwable) throws Exception {
|
||||
// 输出异常信息
|
||||
LogUtils.d(TAG, "发生异常 = " + throwable.toString());
|
||||
/**
|
||||
* 需求1:根据异常类型选择是否重试
|
||||
* 即,当发生的异常 = 网络异常 = IO异常 才选择重试
|
||||
*/
|
||||
if (throwable instanceof IOException) {
|
||||
LogUtils.d(TAG, "属于IO异常,需重试");
|
||||
/**
|
||||
* 需求2:限制重试次数
|
||||
* 即,当已重试次数 < 设置的重试次数,才选择重试
|
||||
*/
|
||||
if (currentRetryCount < maxConnectCount) {
|
||||
// 记录重试次数
|
||||
currentRetryCount++;
|
||||
LogUtils.d(TAG, "重试次数 = " + currentRetryCount);
|
||||
/**
|
||||
* 需求2:实现重试
|
||||
* 通过返回的Observable发送的事件 = Next事件,从而使得retryWhen()重订阅,最终实现重试功能
|
||||
*
|
||||
* 需求3:延迟1段时间再重试
|
||||
* 采用delay操作符 = 延迟一段时间发送,以实现重试间隔设置
|
||||
*
|
||||
* 需求4:遇到的异常越多,时间越长
|
||||
* 在delay操作符的等待时间内设置 = 每重试1次,增多延迟重试时间1s
|
||||
*/
|
||||
// 设置等待时间
|
||||
waitRetryTime = currentRetryCount * 500;
|
||||
LogUtils.d(TAG, "等待时间 =" + waitRetryTime);
|
||||
return Observable.just(1).delay(waitRetryTime, TimeUnit.MILLISECONDS);
|
||||
} else {
|
||||
// 若重试次数已 > 设置重试次数,则不重试
|
||||
// 通过发送error来停止重试(可在观察者的onError()中获取信息)
|
||||
return Observable.error(new Throwable("接口请求超时,请重试!"));
|
||||
}
|
||||
}
|
||||
// 若发生的异常不属于I/O异常,则不重试
|
||||
// 通过返回的Observable发送的事件 = Error事件 实现(可在观察者的onError()中获取信息)
|
||||
else {
|
||||
return Observable.error(throwable);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.doOnSubscribe(new Consumer<Disposable>() {
|
||||
@Override
|
||||
public void accept(Disposable disposable) throws Exception {
|
||||
}
|
||||
})
|
||||
//获得的数据返回主线程去更新界面
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(observer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起请求
|
||||
*
|
||||
* @param requestKey {@link CommonCompositeManage#addDisposable(String, Disposable)} 接口请求标识 用来管理 请求
|
||||
* @param observable 请求体
|
||||
* @param callback 接口回调
|
||||
* @param <T> 返回类型
|
||||
*/
|
||||
public static <T> void request(final String requestKey, Observable<T> observable, final RequestCallback<T> callback) {
|
||||
request(observable, new ResultObserver<T>(requestKey) {
|
||||
@Override
|
||||
protected void onNext(String identifierKey, @NotNull T data) {
|
||||
if (callback!=null){
|
||||
callback.onRequestSuccess(data);
|
||||
}
|
||||
CommonCompositeManage.getInstance().unDisposable(identifierKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribe(String identifierKey, @NotNull Disposable d) {
|
||||
CommonCompositeManage.getInstance().addDisposable(identifierKey, d);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onError(String identifierKey, @NotNull Throwable e) {
|
||||
LogUtils.w(TAG, "onError " + e.getMessage());
|
||||
if (callback!=null){
|
||||
callback.onRequestFailure(e);
|
||||
}
|
||||
CommonCompositeManage.getInstance().unDisposable(identifierKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(String identifierKey) {
|
||||
CommonCompositeManage.getInstance().unDisposable(identifierKey);
|
||||
}
|
||||
}, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起请求
|
||||
*
|
||||
* @param observable 请求体
|
||||
* @param callback 接口回调
|
||||
* @param <T> 返回类型
|
||||
*/
|
||||
public static <T> void request(Observable<T> observable, final RequestCallback<T> callback) {
|
||||
request(observable, new Observer<T>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
// LogUtils.w(TAG, "onSubscribe " + d.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(T s) {
|
||||
LogUtils.w(TAG, "onSubscribe " + s.toString());
|
||||
callback.onRequestSuccess(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
callback.onRequestFailure(e);
|
||||
LogUtils.w(TAG, "onError " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
LogUtils.w(TAG, "onComplete ");
|
||||
}
|
||||
}, callback);
|
||||
}
|
||||
|
||||
// public static <T> void request(Observable<T> observable, Observer<T> observer, final RequestCallback<T> callback) {
|
||||
// observable
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .doOnSubscribe(new Consumer<Disposable>() {
|
||||
// @Override
|
||||
// public void accept(@io.reactivex.annotations.NonNull Disposable disposable) throws Exception {
|
||||
// if (callback != null) {
|
||||
// callback.onStartRequest();
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// //获得的数据返回主线程去更新界面
|
||||
// .observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(observer);
|
||||
// }
|
||||
//
|
||||
public static <T> void request(Observable<T> observable, Observer<T> observer, final RequestCallback<T> callback) {
|
||||
observable.retryWhen(new MyFunction<Observable<Throwable>, ObservableSource<?>>() {
|
||||
@Override
|
||||
public ObservableSource<?> apply(@NotNull Observable<Throwable> throwableObservable) throws Exception {
|
||||
return throwableObservable.flatMap(new MyFunction<Throwable, ObservableSource<?>>() {
|
||||
@Override
|
||||
public Observable<?> apply(@NotNull Throwable throwable) throws Exception {
|
||||
// 输出异常信息
|
||||
LogUtils.d(TAG, "发生异常 = " + throwable.toString());
|
||||
/**
|
||||
* 需求1:根据异常类型选择是否重试
|
||||
* 即,当发生的异常 = 网络异常 = IO异常 才选择重试
|
||||
*/
|
||||
|
||||
if (throwable instanceof IOException || throwable instanceof TimeoutException) {
|
||||
LogUtils.d(TAG, "属于IO异常,需重试");
|
||||
/**
|
||||
* 需求2:限制重试次数
|
||||
* 即,当已重试次数 < 设置的重试次数,才选择重试
|
||||
*/
|
||||
if (currentRetryCount < maxConnectCount) {
|
||||
// 记录重试次数
|
||||
currentRetryCount++;
|
||||
LogUtils.d(TAG, "重试次数 = " + currentRetryCount);
|
||||
/**
|
||||
* 需求2:实现重试
|
||||
* 通过返回的Observable发送的事件 = Next事件,从而使得retryWhen()重订阅,最终实现重试功能
|
||||
*
|
||||
* 需求3:延迟1段时间再重试
|
||||
* 采用delay操作符 = 延迟一段时间发送,以实现重试间隔设置
|
||||
*
|
||||
* 需求4:遇到的异常越多,时间越长
|
||||
* 在delay操作符的等待时间内设置 = 每重试1次,增多延迟重试时间1s
|
||||
*/
|
||||
// 设置等待时间
|
||||
waitRetryTime = currentRetryCount * 500;
|
||||
LogUtils.d(TAG, "等待时间 =" + waitRetryTime);
|
||||
return Observable.just(1).delay(waitRetryTime, TimeUnit.MILLISECONDS);
|
||||
} else {
|
||||
// 若重试次数已 > 设置重试次数,则不重试
|
||||
// 通过发送error来停止重试(可在观察者的onError()中获取信息)
|
||||
return Observable.error(new Throwable("接口请求超时,请重试!"));
|
||||
}
|
||||
}
|
||||
// 若发生的异常不属于I/O异常,则不重试
|
||||
// 通过返回的Observable发送的事件 = Error事件 实现(可在观察者的onError()中获取信息)
|
||||
else {
|
||||
return Observable.error(throwable);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.doOnSubscribe(new Consumer<Disposable>() {
|
||||
@Override
|
||||
public void accept(@io.reactivex.annotations.NonNull Disposable disposable) throws Exception {
|
||||
if (callback != null) {
|
||||
callback.onStartRequest();
|
||||
}
|
||||
}
|
||||
})
|
||||
//获得的数据返回主线程去更新界面
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(observer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 全部在IO线程执行,不需要切换至UI线程
|
||||
*
|
||||
* @param observable 接口
|
||||
* @param callback 接收返回结果的监听接口
|
||||
* @param <T> 返回参数泛型
|
||||
*/
|
||||
public static <T> void requestIO(final String requestKey, Observable<T> observable, final RequestCallback<T> callback) {
|
||||
requestIO(observable, new ResultObserver<T>(requestKey) {
|
||||
@Override
|
||||
protected void onSubscribe(String identifierKey, @NotNull Disposable d) {
|
||||
CommonCompositeManage.getInstance().addDisposable(identifierKey,d);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNext(String identifierKey, @NotNull T data) {
|
||||
CommonCompositeManage.getInstance().unDisposable(identifierKey);
|
||||
if (callback!=null){
|
||||
callback.onRequestSuccess(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onError(String identifierKey, @NotNull Throwable data) {
|
||||
if (callback!=null){
|
||||
callback.onRequestFailure(data);
|
||||
}
|
||||
CommonCompositeManage.getInstance().unDisposable(identifierKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onComplete(String identifierKey) {
|
||||
CommonCompositeManage.getInstance().unDisposable(identifierKey);
|
||||
}
|
||||
}, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 全部在IO线程执行,不需要切换至UI线程
|
||||
*
|
||||
* @param observable 接口
|
||||
* @param callback 接收返回结果的监听接口
|
||||
* @param <T> 返回参数泛型
|
||||
*/
|
||||
public static <T> void requestIO(Observable<T> observable, final RequestCallback<T> callback) {
|
||||
requestIO(observable, new Observer<T>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
LogUtils.w(TAG, "onSubscribe " + d.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(T s) {
|
||||
if (callback != null)
|
||||
callback.onRequestSuccess(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (callback != null)
|
||||
callback.onRequestFailure(e);
|
||||
LogUtils.w(TAG, "onError " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
LogUtils.w(TAG, "onComplete ");
|
||||
}
|
||||
}, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 全部在IO线程执行,不需要切换至UI线程
|
||||
*
|
||||
* @param observable 请求体
|
||||
* @param observer
|
||||
* @param callback 接收返回结果的监听接口
|
||||
* @param <T> 返回参数泛型
|
||||
*/
|
||||
public static <T> void requestIO(Observable<T> observable, Observer<T> observer, final RequestCallback<T> callback) {
|
||||
observable
|
||||
.subscribeOn(Schedulers.io())
|
||||
.doOnSubscribe(new Consumer<Disposable>() {
|
||||
@Override
|
||||
public void accept(@io.reactivex.annotations.NonNull Disposable disposable) throws Exception {
|
||||
if (callback != null)
|
||||
callback.onStartRequest();
|
||||
}
|
||||
})
|
||||
//获得的数据返回主线程去更新界面
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(observer);
|
||||
}
|
||||
|
||||
/*private static MediaType getMediaType(String fileName) {
|
||||
MediaType mediaType = MediaType.parse("application/octet-stream");
|
||||
if (fileName.endsWith(".jpg")) {
|
||||
mediaType = MediaType.parse("image/jpg");
|
||||
} else if (fileName.endsWith(".png")) {
|
||||
mediaType = MediaType.parse("image/png");
|
||||
} else if (fileName.endsWith(".jpeg")) {
|
||||
mediaType = MediaType.parse("image/jpeg");
|
||||
} else if (fileName.endsWith(".mp4")) {
|
||||
mediaType = MediaType.parse("video/mp4");
|
||||
} else if (fileName.endsWith(".mp3")) {
|
||||
mediaType = MediaType.parse("audio/mpeg");
|
||||
} else if (fileName.endsWith(".json")) {
|
||||
mediaType = MediaType.parse("application/json");
|
||||
} else if (fileName.endsWith(".jar")) {
|
||||
mediaType = MediaType.parse("application/java-archive");
|
||||
} else if (fileName.endsWith(".html")) {
|
||||
mediaType = MediaType.parse("text/html");
|
||||
} else if (fileName.endsWith(".gif")) {
|
||||
mediaType = MediaType.parse("image/gif");
|
||||
}
|
||||
return mediaType;
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* 上传统一日志,前端 无感知,不关心结果
|
||||
* @param logLevel 1 = ALL | 2 = debug | 3 = info | 4 = Warn | 5 = Error | 6 = FATAL | 7 OFF
|
||||
* 正常日志传 3,错误日志传5,应用报错日志传 6
|
||||
* @param optType 1 = 业务日志 | 2 = 安全日志 3 = 操作日志 | 4 = 其他
|
||||
* @param content 日志内容
|
||||
*/
|
||||
public static void uploadOperationLog(String logLevel, String optType, String content) {
|
||||
ParamMap map = new ParamMap();
|
||||
// map.put("sysCode", "adde349491f64c0980ce59bd882bff53");
|
||||
//个人中心日志代码
|
||||
map.put("sysCode", "b581b2a86bc10ade016bd5a74e880001");
|
||||
map.put("logType", "3");
|
||||
map.put("logLevel", logLevel);
|
||||
map.put("optUserNum", RuanseeApplication.getUserData().getUserCode());
|
||||
map.put("optUserName", RuanseeApplication.getUserData().getUserName());
|
||||
map.put("optOrgCode", RuanseeApplication.getUserData().getDeptCode());
|
||||
map.put("optOrgName", RuanseeApplication.getUserData().getDeptName());
|
||||
map.put("optType", optType);
|
||||
map.put("content", content);
|
||||
map.put("ip", RuanseeApplication.getAppCache().getLocalIp());
|
||||
//String转RequestBody String、ByteArray、ByteString都可以用toRequestBody()
|
||||
MediaType mediaType = MediaType.Companion.parse("application/json;charset=utf-8");
|
||||
RequestBody stringBody = RequestBody.Companion.create(new Gson().toJson(map.apply()), mediaType);
|
||||
RetrofitService.getBaseInstance()
|
||||
.uploadOperationLog("http://20.90.1.142:7350/api/log/save",stringBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
//获得的数据返回主线程去更新界面
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new Observer<JsonObject>() {
|
||||
@Override
|
||||
public void onSubscribe(@NotNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull JsonObject jsonObject) {
|
||||
LogUtils.w(jsonObject.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NotNull Throwable e) {
|
||||
LogUtils.e(e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,265 @@
|
|||
package com.ycgis.macall.personalcenter.p.request;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.rs.macall.androidx.basemodel.request.OkHttpUtils;
|
||||
import com.rs.macall.androidx.basemodel.utils.BitMapUtils;
|
||||
import com.rs.macall.androidx.basemodel.utils.LogUtils;
|
||||
import com.rs.macall.androidx.basemodel.utils.TypConversion;
|
||||
import com.ycgis.macall.personalcenter.p.app.RuanseeApplication;
|
||||
import com.ycgis.macall.personalcenter.p.callback.BaseRequestCallback;
|
||||
import com.ycgis.macall.personalcenter.p.callback.ImageCallBack;
|
||||
import com.ycgis.macall.personalcenter.util.FileUtils;
|
||||
import com.ycgis.macall.personalcenter.v.activity.applyfo.ApplyForMainActivity;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import top.zibin.luban.OnCompressListener;
|
||||
|
||||
public class AsyncBitmapLoader {
|
||||
|
||||
/**
|
||||
* 内存图片软引用缓冲
|
||||
*/
|
||||
private HashMap<String, SoftReference<Bitmap>> imageCache = null;
|
||||
private File files;
|
||||
|
||||
public AsyncBitmapLoader() {
|
||||
imageCache = new HashMap<String, SoftReference<Bitmap>>();
|
||||
}
|
||||
|
||||
/* public Bitmap loadBitmap(final Context context, final ZdyText imageView, final String imageURL, final ImageCallBack imageCallBack) {
|
||||
//在内存缓存中,则返回Bitmap对象
|
||||
if (imageCache.containsKey(imageURL)) {
|
||||
SoftReference<Bitmap> reference = imageCache.get(imageURL);
|
||||
Bitmap bitmap = reference.get();
|
||||
if (bitmap != null) {
|
||||
return bitmap;
|
||||
}
|
||||
} else {
|
||||
*//**
|
||||
* 加上一个对本地缓存的查找
|
||||
*//*
|
||||
final File cacheDir;
|
||||
if (imageURL.startsWith("/storage/emulated")) {
|
||||
cacheDir = new File(imageURL);
|
||||
} else {
|
||||
String bitmapName = imageURL.substring(imageURL.lastIndexOf("/") + 1);
|
||||
cacheDir = new File(FileUtils.IMAGE_DIR + bitmapName);
|
||||
}
|
||||
if (cacheDir.exists()) {
|
||||
try {
|
||||
return BitmapFactory.decodeFile(cacheDir.getAbsolutePath());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("HandlerLeak") final Handler handler = new Handler() {
|
||||
*//* (non-Javadoc)
|
||||
* @see android.os.Handler#handleMessage(android.os.Message)
|
||||
*//*
|
||||
@Override
|
||||
public void handleMessage(final Message msg) {
|
||||
// TODO Auto-generated method stub
|
||||
switch (msg.what) {
|
||||
case -2001:
|
||||
imageCallBack.imageLoadError(imageView, (String) msg.obj);
|
||||
break;
|
||||
case 200:
|
||||
Bitmap bitmap = (Bitmap) msg.obj;
|
||||
String lswn = System.currentTimeMillis() + "";
|
||||
lswn += new Random().nextInt(10) + ".jpg";
|
||||
files = BitMapUtils.saveBitmap(FileUtils.IMAGE_DIR, lswn, bitmap);
|
||||
if (files == null || !files.exists()) {
|
||||
imageCallBack.imageLoadError(imageView, "图片加载失败!");
|
||||
return;
|
||||
}
|
||||
String fileName = imageURL.substring(imageURL.lastIndexOf("/") + 1);
|
||||
ys(context, fileName, this);
|
||||
break;
|
||||
case 1414:
|
||||
Bitmap bitmap1 = (Bitmap) msg.obj;
|
||||
imageCallBack.imageLoad(imageView, bitmap1);
|
||||
imageCache.put(imageURL, new SoftReference<Bitmap>(bitmap1));
|
||||
break;
|
||||
case -2121:
|
||||
imageCallBack.imageLoadError(imageView, (String) msg.obj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//如果不在内存缓存中,也不在本地(被jvm回收掉),则开启线程下载图片
|
||||
getGetPhtot(AppCache.IMAGE_URL + imageURL, handler);
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
private void ys(Context context, final String newFileName, final Handler handler) {
|
||||
BitMapUtils.lubanCompress(context, files, FileUtils.IMAGE_DIR, new OnCompressListener() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
if (!files.getName().equals(file.getName()))
|
||||
files.delete();
|
||||
boolean is = FileUtils.renameFile(FileUtils.IMAGE_DIR, file.getName(), newFileName);
|
||||
if (is) {
|
||||
Bitmap bitmap1 = BitmapFactory.decodeFile(FileUtils.IMAGE_DIR + newFileName);
|
||||
Message message = handler.obtainMessage(1414, bitmap1);
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Message message = handler.obtainMessage(-2121, "图片加载失败!");
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* GET 方式请求数据 图片
|
||||
*/
|
||||
public static void getGetPhtot(String urlTal, final Handler handler) {
|
||||
URL url = null;
|
||||
try {
|
||||
url = new URL(urlTal);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
Message message = handler.obtainMessage();
|
||||
message.what = -2001;
|
||||
message.arg2 = 205;
|
||||
message.obj = "URL错误";
|
||||
handler.sendMessage(message);
|
||||
return;
|
||||
}
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.build();
|
||||
OkHttpUtils.getClient(10, 30, 40)
|
||||
.newCall(request)
|
||||
.enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
System.out.println("加载图片错误:" + e.getMessage());
|
||||
Message message = handler.obtainMessage();
|
||||
message.what = -2001;
|
||||
message.arg2 = 205;
|
||||
message.obj = "加载图片失败:请检查网络连接状况";
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
int responseCode = response.code();
|
||||
if (responseCode != 200) {
|
||||
System.out.println("加载图片错误:请求码错误");
|
||||
Message message = handler.obtainMessage();
|
||||
message.what = -2001;
|
||||
message.arg2 = 205;
|
||||
message.obj = "加载图片失败,请联系管理员";
|
||||
handler.sendMessage(message);
|
||||
return;
|
||||
}
|
||||
byte[] photoByte = response.body().bytes();
|
||||
Message message = new Message();
|
||||
message.what = 200;
|
||||
message.arg2 = 205;
|
||||
message.obj = BitmapFactory.decodeByteArray(photoByte, 0, photoByte.length);
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Bitmap loadSeal(String id,String deptCode,ImageView imageView,final ImageCallBack callback) {
|
||||
if (imageCache == null){
|
||||
imageCache = new HashMap<>();
|
||||
}
|
||||
SoftReference<Bitmap> bitmapSoftReference = imageCache.get(deptCode);
|
||||
if (bitmapSoftReference != null&&bitmapSoftReference.get() != null){
|
||||
return bitmapSoftReference.get();
|
||||
}
|
||||
File file = new File(FileUtils.IMAGE_DIR,deptCode+".png");
|
||||
if (file.exists()){
|
||||
return BitmapFactory.decodeFile(file.getAbsolutePath());
|
||||
}
|
||||
Map<String, String> headMap = new HashMap<>(1);
|
||||
headMap.put("app-yysq-token", RuanseeApplication.getAppCache().getApply_token());
|
||||
ApiModel.request(RetrofitService.getBaseInstance().applyGet(ApplyForMainActivity.BASE_URL + "audit/seal/" + id, headMap, new HashMap<>()), new BaseRequestCallback<JsonObject>() {
|
||||
@Override
|
||||
public void onRequestFailure(String msg) {
|
||||
LogUtils.e(msg);
|
||||
callback.imageLoadError(imageView,msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestSuccess(JsonObject result) {
|
||||
LogUtils.w(result.toString());
|
||||
try {
|
||||
JSONObject object = new JSONObject(result.toString());
|
||||
int code = TypConversion.getJsonInt(object, "code", 0);
|
||||
if (code == 200){
|
||||
JSONObject data = TypConversion.getJSONObject(object, "data");
|
||||
String seal_img = TypConversion.getJsonStr(data, "seal_img");
|
||||
Bitmap bitmap = BitMapUtils.base64ToBitmap(seal_img);
|
||||
if (bitmap!=null){
|
||||
Bitmap bitmap1 = BitMapUtils.removeWhiteBackground(bitmap);
|
||||
if (imageCache == null){
|
||||
imageCache = new HashMap<>();
|
||||
}
|
||||
imageCache.put(deptCode, new SoftReference<>(bitmap1));
|
||||
BitMapUtils.saveBitmap(FileUtils.IMAGE_DIR,deptCode+".png",bitmap1);
|
||||
callback.imageLoad(imageView,bitmap1);
|
||||
}else {
|
||||
callback.imageLoadError(imageView,"加载失败");
|
||||
}
|
||||
}else {
|
||||
callback.imageLoadError(imageView,"加载失败");
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
callback.imageLoadError(imageView,"加载失败");
|
||||
}
|
||||
// new SoftReference<>()
|
||||
// SoftReference<Bitmap> bitmapSoftReference = imageCache.get(deptCode);
|
||||
//
|
||||
//
|
||||
// if (bitmapSoftReference != null&&bitmapSoftReference.get() != null){
|
||||
// return bitmapSoftReference.get();
|
||||
// }
|
||||
// File file = new File(FileUtils.IMAGE_DIR,deptCode+".jpg");
|
||||
// if (file.exists()){
|
||||
// return BitmapFactory.decodeFile(file.getAbsolutePath());
|
||||
// }
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.ycgis.macall.personalcenter.p.request;
|
||||
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class CommonComposite {
|
||||
private CompositeDisposable mCompositeDisposable;
|
||||
|
||||
public void addDisposable(Disposable disposable) {
|
||||
if (mCompositeDisposable == null || mCompositeDisposable.isDisposed()) {
|
||||
mCompositeDisposable = new CompositeDisposable();
|
||||
}
|
||||
mCompositeDisposable.add(disposable);
|
||||
}
|
||||
|
||||
public void unDisposable() {
|
||||
if (mCompositeDisposable != null) {
|
||||
mCompositeDisposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
package com.ycgis.macall.personalcenter.p.request;
|
||||
|
||||
|
||||
import com.ycgis.macall.personalcenter.p.callback.RequestCallback;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* 负责 请求时activity退出 取消请求
|
||||
*/
|
||||
public class CommonCompositeManage {
|
||||
private static CommonCompositeManage commonCompositeManage;
|
||||
//用于存放 请求的
|
||||
private Map<String, CompositeDisposable> manage;
|
||||
|
||||
private CommonCompositeManage(){
|
||||
manage = new HashMap<>();
|
||||
}
|
||||
|
||||
public synchronized static CommonCompositeManage getInstance(){
|
||||
if (commonCompositeManage == null){
|
||||
synchronized (CommonCompositeManage.class){
|
||||
if (commonCompositeManage == null)
|
||||
commonCompositeManage = new CommonCompositeManage();
|
||||
}
|
||||
}
|
||||
return commonCompositeManage;
|
||||
}
|
||||
|
||||
//添加一个请求
|
||||
|
||||
/**
|
||||
* 添加一个请求
|
||||
* 该方法会在请求发起的时候自动调用 {@link ApiModel#requestRetry(String, Observable, RequestCallback)}
|
||||
* @param key 请求标识
|
||||
* @param disposable 请求
|
||||
*/
|
||||
public void addDisposable(String key, Disposable disposable){
|
||||
CompositeDisposable compositeDisposable = manage.get(key);
|
||||
if (compositeDisposable == null||compositeDisposable.isDisposed()){
|
||||
compositeDisposable = new CompositeDisposable();
|
||||
}
|
||||
compositeDisposable.add(disposable);
|
||||
manage.put(key,compositeDisposable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消一个请求 {@link #addDisposable(String, Disposable)} 取消在这里添加的请求
|
||||
* 该方法在请求完成后回自动调用 @see{@link ApiModel#request(String, Observable, RequestCallback)}
|
||||
* 为了应用安全,应当在 Activity、Fragment 的onDestroy() 方法里主动调用,这样当请求还未完成时 Activity、Fragment 销毁时取消请求
|
||||
* @param key 请求标识
|
||||
*/
|
||||
public void unDisposable(String key){
|
||||
CompositeDisposable compositeDisposable = manage.get(key);
|
||||
if (compositeDisposable != null&&!compositeDisposable.isDisposed()){
|
||||
compositeDisposable.dispose();
|
||||
}
|
||||
manage.remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消所有请求
|
||||
* 该发放需要主动调用,建议在 MAIN Activity 的 onDestroy() 方法里调用
|
||||
*/
|
||||
public void destory(){
|
||||
if (manage==null) return;
|
||||
if (manage.isEmpty()) return;
|
||||
Set<String> strings = manage.keySet();
|
||||
Iterator<String> iterator = strings.iterator();
|
||||
while (iterator.hasNext()){
|
||||
String next = iterator.next();
|
||||
CompositeDisposable compositeDisposable = manage.get(next);
|
||||
if (compositeDisposable != null&&!compositeDisposable.isDisposed()){
|
||||
compositeDisposable.dispose();
|
||||
}
|
||||
}
|
||||
manage.clear();
|
||||
manage = null ;
|
||||
commonCompositeManage = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,282 @@
|
|||
package com.ycgis.macall.personalcenter.p.request;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.utils.LogUtils;
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2022/11/21 17:39
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class DownloadUtil {
|
||||
private static final String TAG = DownloadUtil.class.getName();
|
||||
private static DownloadUtil downloadUtil;
|
||||
private final OkHttpClient okHttpClient;
|
||||
|
||||
public static DownloadUtil get() {
|
||||
if (downloadUtil == null) {
|
||||
downloadUtil = new DownloadUtil();
|
||||
}
|
||||
return downloadUtil;
|
||||
}
|
||||
|
||||
private DownloadUtil() {
|
||||
okHttpClient = new OkHttpClient.Builder()
|
||||
.connectTimeout(20, TimeUnit.SECONDS)
|
||||
.writeTimeout(20, TimeUnit.SECONDS)
|
||||
.readTimeout(60, TimeUnit.SECONDS).build();
|
||||
// new OkHttpClient();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制单个文件
|
||||
*
|
||||
* @param oldPath$Name String 原文件路径+文件名 如:data/user/0/com.test/files/abc.txt
|
||||
* @param newPath$Name String 复制后路径+文件名 如:data/user/0/com.test/cache/abc.txt
|
||||
* @return <code>true</code> if and only if the file was copied;
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
public static boolean copyFile(String oldPath$Name, String newPath$Name) {
|
||||
try {
|
||||
File oldFile = new File(oldPath$Name);
|
||||
if (!oldFile.exists()) {
|
||||
LogUtils.e("--Method--", "copyFile: oldFile not exist.");
|
||||
return false;
|
||||
} else if (!oldFile.isFile()) {
|
||||
LogUtils.e("--Method--", "copyFile: oldFile not file.");
|
||||
return false;
|
||||
} else if (!oldFile.canRead()) {
|
||||
LogUtils.e("--Method--", "copyFile: oldFile cannot read.");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* 如果不需要打log,可以使用下面的语句
|
||||
if (!oldFile.exists() || !oldFile.isFile() || !oldFile.canRead()) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
FileInputStream fileInputStream = new FileInputStream(oldPath$Name);
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(newPath$Name);
|
||||
byte[] buffer = new byte[1024];
|
||||
int byteRead;
|
||||
while (-1 != (byteRead = fileInputStream.read(buffer))) {
|
||||
fileOutputStream.write(buffer, 0, byteRead);
|
||||
}
|
||||
fileInputStream.close();
|
||||
fileOutputStream.flush();
|
||||
fileOutputStream.close();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知相册更新
|
||||
*
|
||||
* @param context
|
||||
* @param newFile
|
||||
*/
|
||||
public void updateDCIM(Context context, File newFile) {
|
||||
File cameraPath = new File(dcimPath, "Camera");
|
||||
File imgFile = new File(cameraPath, newFile.getAbsolutePath());
|
||||
if (imgFile.exists()) {
|
||||
Uri uri = Uri.fromFile(imgFile);
|
||||
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
||||
intent.setData(uri);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* url 下载连接
|
||||
* saveDir 储存下载文件的SDCard目录
|
||||
* listener 下载监听
|
||||
*/
|
||||
public void download(final String url, final String saveDir,String fileName,
|
||||
final OnDownloadListener listener) {
|
||||
Request request = new Request.Builder().url(url).build();
|
||||
okHttpClient.newCall(request).enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
// 下载失败
|
||||
listener.onDownloadFailed(e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
InputStream is = null;
|
||||
byte[] buf = new byte[2048];
|
||||
int len = 0;
|
||||
FileOutputStream fos = null;
|
||||
// 储存下载文件的目录
|
||||
String savePath = isExistDir(saveDir);
|
||||
try {
|
||||
is = response.body().byteStream();
|
||||
long total = response.body().contentLength();
|
||||
String nameFromUrl =fileName;
|
||||
if (StringUtil.isNullOrEmpty(nameFromUrl)){
|
||||
nameFromUrl = getNameFromUrl(url);
|
||||
}
|
||||
File file = new File(savePath, nameFromUrl);
|
||||
fos = new FileOutputStream(file);
|
||||
long sum = 0;
|
||||
while ((len = is.read(buf)) != -1) {
|
||||
fos.write(buf, 0, len);
|
||||
sum += len;
|
||||
int progress = (int) (sum * 1.0f / total * 100);
|
||||
// 下载中
|
||||
listener.onDownloading(progress);
|
||||
}
|
||||
fos.flush();
|
||||
// 下载完成
|
||||
listener.onDownloadSuccess(file);
|
||||
} catch (Exception e) {
|
||||
listener.onDownloadFailed(e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
if (is != null)
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if (fos != null)
|
||||
fos.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void handDownFile(String url, String saveDir, ResponseBody response, String fileName, OnDownloadListener listener) throws IOException {
|
||||
InputStream is = null;
|
||||
byte[] buf = new byte[2048];
|
||||
int len = 0;
|
||||
FileOutputStream fos = null;
|
||||
// 储存下载文件的目录
|
||||
String savePath = isExistDir(saveDir);
|
||||
try {
|
||||
is = response.byteStream();
|
||||
long total = response.contentLength();
|
||||
String nameFromUrl =fileName;
|
||||
if (StringUtil.isNullOrEmpty(nameFromUrl)){
|
||||
nameFromUrl = getNameFromUrl(url);
|
||||
}
|
||||
File file = new File(savePath, nameFromUrl);
|
||||
fos = new FileOutputStream(file);
|
||||
long sum = 0;
|
||||
while ((len = is.read(buf)) != -1) {
|
||||
fos.write(buf, 0, len);
|
||||
sum += len;
|
||||
int progress = (int) (sum * 1.0f / total * 100);
|
||||
// 下载中
|
||||
listener.onDownloading(progress);
|
||||
}
|
||||
fos.flush();
|
||||
// 下载完成
|
||||
listener.onDownloadSuccess(file);
|
||||
} catch (Exception e) {
|
||||
listener.onDownloadFailed(e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
if (is != null)
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if (fos != null)
|
||||
fos.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* saveDir
|
||||
* 判断下载目录是否存在
|
||||
*/
|
||||
private static String isExistDir(String saveDir) throws IOException {
|
||||
// 下载位置
|
||||
File downloadFile = new File(saveDir);
|
||||
if (!downloadFile.mkdirs()) {
|
||||
downloadFile.createNewFile();
|
||||
}
|
||||
String savePath = downloadFile.getAbsolutePath();
|
||||
return savePath;
|
||||
}
|
||||
|
||||
//系统相册路径
|
||||
static String dcimPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath();
|
||||
|
||||
/**
|
||||
* 创建文件夹
|
||||
*/
|
||||
public static void createFiles(File oldFile) {
|
||||
try {
|
||||
File file = new File(isExistDir(dcimPath + "/xxx"));
|
||||
String newPath = file.getPath() + "/" + oldFile.getName();
|
||||
LogUtils.d("TAG", "createFiles111: " + oldFile.getPath() + "--" + newPath);
|
||||
if (copyFile(oldFile.getPath(), newPath)) {
|
||||
LogUtils.d("TAG", "createFiles222: " + oldFile.getPath() + "--" + newPath);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* url
|
||||
* 从下载连接中解析出文件名
|
||||
*/
|
||||
@NonNull
|
||||
public static String getNameFromUrl(String url) {
|
||||
return url.substring(url.lastIndexOf("/") + 1);
|
||||
}
|
||||
|
||||
public interface OnDownloadListener {
|
||||
/**
|
||||
* 下载成功
|
||||
*/
|
||||
void onDownloadSuccess(File file);
|
||||
|
||||
/**
|
||||
* @param progress 下载进度
|
||||
*/
|
||||
void onDownloading(int progress);
|
||||
|
||||
/**
|
||||
* 下载失败
|
||||
*/
|
||||
void onDownloadFailed(String msg);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package com.ycgis.macall.personalcenter.p.request;/*
|
||||
* 项目名:xayss
|
||||
* 作者:马超
|
||||
* 类目:HttpErrorHander.java
|
||||
* 包名:com.ruansee.sx.xayss.p.request.HttpErrorHander
|
||||
* 当前修改时间:2023年07月04日 16:52:58
|
||||
* 上次修改时间:2023年07月04日 16:52:58
|
||||
* Copyright©:2023 安徽软思信息技术有限公司
|
||||
* 功能描述:
|
||||
*/
|
||||
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.rs.macall.androidx.basemodel.utils.LogUtils;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.net.ConnectException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.text.ParseException;
|
||||
|
||||
import retrofit2.HttpException;
|
||||
|
||||
public class HttpErrorHandler {
|
||||
private static final int UNAUTHORIZED = 401;
|
||||
private static final int FORBIDDEN = 403;
|
||||
private static final int NOT_FOUND = 404;
|
||||
private static final int REQUEST_TIMEOUT = 408;
|
||||
private static final int INTERNAL_SERVER_ERROR = 500;
|
||||
private static final int BAD_GATEWAY = 502;
|
||||
private static final int SERVICE_UNAVAILABLE = 503;
|
||||
private static final int GATEWAY_TIMEOUT = 504;
|
||||
|
||||
/**
|
||||
* 统一处理Throwable
|
||||
* @param e e
|
||||
* @return msg
|
||||
*/
|
||||
public static String requestHandle(Throwable e) {
|
||||
String msg;
|
||||
e.printStackTrace();
|
||||
if (e instanceof HttpException) {
|
||||
HttpException httpException = (HttpException) e;
|
||||
switch (httpException.code()) {
|
||||
case UNAUTHORIZED:
|
||||
case FORBIDDEN:
|
||||
case NOT_FOUND:
|
||||
case REQUEST_TIMEOUT:
|
||||
case GATEWAY_TIMEOUT:
|
||||
case INTERNAL_SERVER_ERROR:
|
||||
case BAD_GATEWAY:
|
||||
case SERVICE_UNAVAILABLE:
|
||||
default:
|
||||
msg = httpException.code()+"服务器错误";
|
||||
break;
|
||||
}
|
||||
} else if (e instanceof JsonParseException || e instanceof JSONException
|
||||
|| e instanceof ParseException) {
|
||||
msg = "数据解析异常";
|
||||
} else if (e instanceof ConnectException || e instanceof SocketTimeoutException
|
||||
|| e instanceof UnknownHostException) {
|
||||
msg = "连接失败,请检查网络";
|
||||
} else if (e instanceof NumberFormatException){
|
||||
msg = "数字格式化异常";
|
||||
} else {
|
||||
msg = e.getMessage();
|
||||
}
|
||||
LogUtils.e("Request failure",msg);
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,215 @@
|
|||
package com.ycgis.macall.personalcenter.p.request;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.request.OkHttpUtils;
|
||||
import com.rs.macall.androidx.basemodel.request.RequestCode;
|
||||
import com.rs.macall.androidx.basemodel.utils.BitMapUtils;
|
||||
import com.ycgis.macall.personalcenter.p.callback.ImageCallBack;
|
||||
import com.ycgis.macall.personalcenter.p.request.AsyncBitmapLoader;
|
||||
import com.ycgis.macall.personalcenter.util.AppTools;
|
||||
import com.ycgis.macall.personalcenter.util.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.FormBody;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import top.zibin.luban.OnCompressListener;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/11/16 9:45
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class LoadAppCenterImage {
|
||||
|
||||
/**
|
||||
* 内存图片软引用缓冲
|
||||
*/
|
||||
private HashMap<String, SoftReference<Bitmap>> imageCache = null;
|
||||
// private File files;
|
||||
|
||||
public LoadAppCenterImage() {
|
||||
imageCache = new HashMap<String, SoftReference<Bitmap>>();
|
||||
}
|
||||
|
||||
public Bitmap loadBitmapText(final Context context, final ImageView imageView, final String imageName, final ImageCallBack imageCallBack) {
|
||||
//在内存缓存中,则返回Bitmap对象
|
||||
if (imageCache.containsKey(imageName)) {
|
||||
SoftReference<Bitmap> reference = imageCache.get(imageName);
|
||||
Bitmap bitmap = reference.get();
|
||||
if (bitmap != null) {
|
||||
return bitmap;
|
||||
}
|
||||
} else {
|
||||
File cacheDir = new File(FileUtils.IMAGE_DIR + imageName);
|
||||
if (cacheDir.exists()) {
|
||||
try {
|
||||
return BitmapFactory.decodeFile(cacheDir.getAbsolutePath());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("HandlerLeak") final Handler handler = new Handler() {
|
||||
/* (non-Javadoc)
|
||||
* @see android.os.Handler#handleMessage(android.os.Message)
|
||||
*/
|
||||
@Override
|
||||
public void handleMessage(final Message msg) {
|
||||
// TODO Auto-generated method stub
|
||||
switch (msg.what) {
|
||||
case -2001:
|
||||
imageCallBack.imageLoadError(imageView, (String) msg.obj);
|
||||
break;
|
||||
case RequestCode.REQUEST_OK:
|
||||
Bitmap bitmap = (Bitmap) msg.obj;
|
||||
String wei = imageName.substring(imageName.lastIndexOf("."));
|
||||
String lswn = System.currentTimeMillis() + "" + new Random().nextInt(10) + wei;
|
||||
File files = BitMapUtils.saveBitmap(FileUtils.IMAGE_DIR, lswn, bitmap);
|
||||
if (files == null || !files.exists()) {
|
||||
imageCallBack.imageLoadError(imageView, "图片加载失败!");
|
||||
return;
|
||||
}
|
||||
// String fileName = imageURL.substring(imageURL.lastIndexOf("/") + 1);
|
||||
ys(context, files, imageName, this);
|
||||
break;
|
||||
case 1414:
|
||||
Bitmap bitmap1 = (Bitmap) msg.obj;
|
||||
imageCallBack.imageLoad(imageView, bitmap1);
|
||||
imageCache.put(imageName, new SoftReference<Bitmap>(bitmap1));
|
||||
break;
|
||||
case -2121:
|
||||
imageCallBack.imageLoadError(imageView, (String) msg.obj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Map<String, String> param = new HashMap<>();
|
||||
param.put("devCode", "442eab382e6a49649e3402115bd8837f");
|
||||
param.put("appId", AppTools.getPackageName(context));
|
||||
param.put("fileId", imageName);
|
||||
//如果不在内存缓存中,也不在本地(被jvm回收掉),则开启线程下载图片
|
||||
postGetPhoto("http://20.90.1.128:7310/api/v1/appInfo/downloadImg", param, handler);
|
||||
// BaseRequest.postRequestPhotoText("http://20.90.1.128:7310/api/v1/appInfo/downloadImg", param, handler);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void ys(Context context, File files, final String newFileName, final Handler handler) {
|
||||
BitMapUtils.lubanCompress(context, files, FileUtils.IMAGE_DIR, new OnCompressListener() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
if (!files.getName().equals(file.getName()))
|
||||
files.delete();
|
||||
boolean is = FileUtils.renameFile(FileUtils.IMAGE_DIR, file.getName(), newFileName);
|
||||
if (is) {
|
||||
Bitmap bitmap1 = BitmapFactory.decodeFile(FileUtils.IMAGE_DIR + newFileName);
|
||||
Message message = handler.obtainMessage(1414, bitmap1);
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Message message = handler.obtainMessage(-2121, "图片加载失败!");
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static FormBody getRequestParam(Map<String, String> map) {
|
||||
FormBody.Builder formBody = new FormBody.Builder();
|
||||
if (map == null || map.isEmpty()) return formBody.build();
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
if (entry.getValue() == null) {
|
||||
formBody.add(entry.getKey(), "");
|
||||
} else {
|
||||
formBody.add(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
return formBody.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* GET 方式请求数据 图片
|
||||
*/
|
||||
public static void postGetPhoto(String urlTal, Map<String, String> param, final Handler handler) {
|
||||
URL url = null;
|
||||
try {
|
||||
url = new URL(urlTal);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
Message message = handler.obtainMessage();
|
||||
message.what = -2001;
|
||||
message.arg2 = 205;
|
||||
message.obj = "URL错误";
|
||||
handler.sendMessage(message);
|
||||
return;
|
||||
}
|
||||
FormBody requestParam = getRequestParam(param);
|
||||
Request.Builder builder = new Request.Builder()
|
||||
.url(url);
|
||||
if (requestParam != null) {
|
||||
builder.post(requestParam);
|
||||
}
|
||||
Request request = builder.build();
|
||||
OkHttpUtils.getUploadPhotoClient(10, 30, 40)
|
||||
.newCall(request)
|
||||
.enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
System.out.println("加载图片错误:" + e.getMessage());
|
||||
Message message = handler.obtainMessage();
|
||||
message.what = -2001;
|
||||
message.arg2 = 205;
|
||||
message.obj = "加载图片失败:请检查网络连接状况";
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
int responseCode = response.code();
|
||||
if (responseCode != 200) {
|
||||
System.out.println("加载图片错误:请求码错误");
|
||||
Message message = handler.obtainMessage();
|
||||
message.what = -2001;
|
||||
message.arg2 = 205;
|
||||
message.obj = "加载图片失败,请联系管理员";
|
||||
handler.sendMessage(message);
|
||||
return;
|
||||
}
|
||||
byte[] photoByte = response.body().bytes();
|
||||
Message message = new Message();
|
||||
message.what = 200;
|
||||
message.arg2 = 205;
|
||||
message.obj = BitmapFactory.decodeByteArray(photoByte, 0, photoByte.length);
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
package com.ycgis.macall.personalcenter.p.request;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.rs.macall.androidx.basemodel.utils.BitMapUtils;
|
||||
import com.rs.macall.androidx.basemodel.utils.LogUtils;
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
import com.ycgis.macall.personalcenter.p.app.RuanseeApplication;
|
||||
import com.ycgis.macall.personalcenter.p.callback.BaseRequestCallback;
|
||||
import com.ycgis.macall.personalcenter.p.callback.ImageCallBack;
|
||||
import com.ycgis.macall.personalcenter.util.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/11/28 14:21
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class LoadPhotoImage {
|
||||
/**
|
||||
* 内存图片软引用缓冲
|
||||
*/
|
||||
private HashMap<String, SoftReference<Bitmap>> imageCache = null;
|
||||
|
||||
public LoadPhotoImage() {
|
||||
imageCache = new HashMap<String, SoftReference<Bitmap>>();
|
||||
}
|
||||
|
||||
public Bitmap loadPhotoImage(String id, ImageView view, ImageCallBack callBack) {
|
||||
//在内存缓存中,则返回Bitmap对象
|
||||
if (imageCache.containsKey(id)) {
|
||||
SoftReference<Bitmap> reference = imageCache.get(id);
|
||||
Bitmap bitmap = reference.get();
|
||||
if (bitmap != null) {
|
||||
return bitmap;
|
||||
}
|
||||
} else {
|
||||
File cacheDir = new File(FileUtils.IMAGE_DIR + id);
|
||||
if (cacheDir.exists()) {
|
||||
try {
|
||||
return BitmapFactory.decodeFile(cacheDir.getAbsolutePath());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, String> param = new HashMap<>();
|
||||
param.put("id", id);
|
||||
param.put("token", RuanseeApplication.getAppCache().getToken());
|
||||
param.put("clientType", "MOBILE");
|
||||
param.put("imsi1", StringUtil.get(RuanseeApplication.getAppCache().getImsi(),""));
|
||||
param.put("deviceFlags",StringUtil.get( RuanseeApplication.getAppCache().getImei(),""));
|
||||
param.put("sysCode", RuanseeApplication.getAppCache().getSysmCode());
|
||||
ApiModel.request(RetrofitService.getBaseInstance().loadPhoto("http://20.90.2.2/UniAuth/api/sso/v1/download", param),
|
||||
new BaseRequestCallback<ResponseBody>() {
|
||||
@Override
|
||||
public void onRequestFailure(String msg) {
|
||||
LogUtils.e(msg);
|
||||
if (callBack != null) {
|
||||
callBack.imageLoadError(view, msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestSuccess(ResponseBody result) {
|
||||
InputStream is = null;
|
||||
byte[] buf = new byte[2048];
|
||||
int len = 0;
|
||||
FileOutputStream fos = null;
|
||||
// 储存下载文件的目录
|
||||
String savePath = FileUtils.IMAGE_DIR;
|
||||
try {
|
||||
is = result.byteStream();
|
||||
// long total = result.contentLength();
|
||||
String nameFromUrl = (String) getPayloads().get(0);
|
||||
// if (StringUtil.isNullOrEmpty(nameFromUrl)){
|
||||
// nameFromUrl = getNameFromUrl(url);
|
||||
// }
|
||||
File file = new File(savePath, nameFromUrl);
|
||||
fos = new FileOutputStream(file);
|
||||
// long sum = 0;
|
||||
while ((len = is.read(buf)) != -1) {
|
||||
fos.write(buf, 0, len);
|
||||
// sum += len;
|
||||
// int progress = (int) (sum * 1.0f / total * 100);
|
||||
// 下载中
|
||||
// listener.onDownloading(progress);
|
||||
}
|
||||
fos.flush();
|
||||
if (callBack != null) {
|
||||
callBack.imageLoad(view,BitmapFactory.decodeFile(file.getAbsolutePath()));
|
||||
}
|
||||
// 下载完成
|
||||
// listener.onDownloadSuccess(file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (callBack != null) {
|
||||
callBack.imageLoadError(view, e.getMessage());
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (is != null)
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if (fos != null)
|
||||
fos.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}.addPayload(id));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.ycgis.macall.personalcenter.p.request;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/11/23 9:52
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class MediaTypeUtils {
|
||||
|
||||
public static MediaType getMediaType(String fileName) {
|
||||
MediaType mediaType = MediaType.parse("application/octet-stream");
|
||||
if (fileName.endsWith(".jpg")) {
|
||||
mediaType = MediaType.parse("image/jpg");
|
||||
} else if (fileName.endsWith(".png")) {
|
||||
mediaType = MediaType.parse("image/png");
|
||||
} else if (fileName.endsWith(".jpeg")) {
|
||||
mediaType = MediaType.parse("image/jpeg");
|
||||
} else if (fileName.endsWith(".mp4")) {
|
||||
mediaType = MediaType.parse("video/mp4");
|
||||
} else if (fileName.endsWith(".mp3")) {
|
||||
mediaType = MediaType.parse("audio/mpeg");
|
||||
} else if (fileName.endsWith(".json")) {
|
||||
mediaType = MediaType.parse("application/json");
|
||||
} else if (fileName.endsWith(".jar")) {
|
||||
mediaType = MediaType.parse("application/java-archive");
|
||||
} else if (fileName.endsWith(".html")) {
|
||||
mediaType = MediaType.parse("text/html");
|
||||
} else if (fileName.endsWith(".gif")) {
|
||||
mediaType = MediaType.parse("image/gif");
|
||||
}
|
||||
return mediaType;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.ycgis.macall.personalcenter.p.request;
|
||||
|
||||
import io.reactivex.functions.Function;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/2/20 10:48
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public abstract class MyFunction<T, R> implements Function<T,R> {
|
||||
// 设置变量
|
||||
// 可重试次数
|
||||
protected int maxConnectCount = 2;
|
||||
// 当前已重试次数
|
||||
protected int currentRetryCount = 0;
|
||||
// 重试等待时间
|
||||
protected int waitRetryTime = 0;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,267 @@
|
|||
package com.ycgis.macall.personalcenter.p.request;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.ycgis.macall.personalcenter.m.adapterbean.AppInfoBean;
|
||||
import com.ycgis.macall.personalcenter.m.adapterbean.FeedbackBean;
|
||||
import com.ycgis.macall.personalcenter.m.adapterbean.MessageBean;
|
||||
import com.ycgis.macall.personalcenter.m.requestbean.BaseRequestModel;
|
||||
import com.ycgis.macall.personalcenter.m.requestbean.FrequentlyBean;
|
||||
import com.ycgis.macall.personalcenter.m.requestbean.GetDeptNameResult;
|
||||
import com.ycgis.macall.personalcenter.m.requestbean.HomeBannerBean;
|
||||
import com.ycgis.macall.personalcenter.m.requestbean.PagingModel;
|
||||
import com.ycgis.macall.personalcenter.m.requestbean.WorkbenchModel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FieldMap;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.HeaderMap;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Query;
|
||||
import retrofit2.http.QueryMap;
|
||||
import retrofit2.http.Url;
|
||||
|
||||
/**
|
||||
* @Describe Api 接口管理
|
||||
* 备注
|
||||
*/
|
||||
public interface RetrofitApi {
|
||||
// public final String baseJd = "";
|
||||
|
||||
/**
|
||||
* 获取常见问题
|
||||
*/
|
||||
@GET("app/v1/question")
|
||||
Observable<BaseRequestModel<List<FrequentlyBean>>> getQuestion();
|
||||
|
||||
//获取热门城市、轨迹
|
||||
//http://192.168.0.109:8081/app/v1/reimburse/getPopularCity?userId=123
|
||||
@GET("app/v1/reimburse/getPopularCity")
|
||||
Observable<JsonObject> getPopularCity(@Query("userId") String userId);
|
||||
|
||||
//城市报销标准
|
||||
//http://192.168.0.109:8081/app/v1/reimburse/getMoney?userId=123&city=%E4%B8%8A%E6%B5%B7&level=2
|
||||
@GET("app/v1/reimburse/getMoney")
|
||||
Observable<JsonObject> getMoneyCity(@Query("userId") String userId,@Query("city") String city,@Query("level") String level);
|
||||
|
||||
//城市报销标准
|
||||
//http://192.168.0.109:8081/app/v1/reimburse/getCity?city=bd
|
||||
@GET("app/v1/reimburse/getCity")
|
||||
Observable<JsonObject> getSearchCity(@Query("city") String cityName);
|
||||
|
||||
//城市报销标准
|
||||
//http://192.168.0.109:8081/app/v1/reimburse/getCity?city=bd
|
||||
@GET("app/v1/zamh/deptList")
|
||||
Observable<JsonObject> getDeptList(@Query("deptName") String deptName,@Query("page") Integer page, @Query("pageSize") Integer pageSize);
|
||||
|
||||
// app/v1/zamh/deptList?deptName=安徽&page=1&pageSize=3
|
||||
|
||||
/**
|
||||
* 获取登录方式
|
||||
* http://20.90.2.2/UniAuth/api/sso/v1/verifyBind
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST()
|
||||
Observable<JsonObject> getLoginType(@Url String url,@FieldMap Map<String,String> param);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST()
|
||||
Observable<ResponseBody> loadPhoto(@Url String url,@FieldMap Map<String,String> param);
|
||||
|
||||
/**
|
||||
* 添加第三方应用操作日志
|
||||
*/
|
||||
@POST()
|
||||
Observable<JsonObject> saveAppOperationLog(@Url String url,@Body RequestBody body);
|
||||
|
||||
/**
|
||||
* 添加第三方应用操作日志
|
||||
*/
|
||||
@POST("app/v1/zamh/addOperationRecords")
|
||||
Observable<JsonObject> saveAppOperationLog(@Body RequestBody body);
|
||||
|
||||
/**
|
||||
* 获取所属地市
|
||||
*/
|
||||
@GET()
|
||||
Observable<BaseRequestModel<GetDeptNameResult>> getDeptName(@Url String url,@Query("deptId") String deptId);
|
||||
|
||||
/**
|
||||
* 非分页获取应用列表
|
||||
* @param deptCode
|
||||
* @param appName
|
||||
* @return
|
||||
*/
|
||||
@GET("app/v1/zamh/applicationList")
|
||||
Observable<BaseRequestModel< List<AppInfoBean>>> applicationList(@Query("name") String appName, @Query("cityNumber") String deptCode, @Query("attribution") Integer attribution);
|
||||
|
||||
/**
|
||||
* 增加应用点击次数
|
||||
* @param applicationId 应用ID
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("app/v1/zamh/addClickCount")
|
||||
Observable<JsonObject> addClickCount(@Field("applicationId") long applicationId );
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@GET("app/v1/zamh/recommendApplication")
|
||||
Observable<JsonObject> recommendApplication( );
|
||||
|
||||
@GET("app/v1/zamh/getAllApplicationPage")
|
||||
Observable<BaseRequestModel<PagingModel<AppInfoBean>>> selectAppList(@Query("name") String appName,@Query("page") Integer page, @Query("pageSize") Integer pageSize);
|
||||
|
||||
/**
|
||||
* 分页获取应用列表
|
||||
* @param cityNumber
|
||||
* @param page
|
||||
* @param pageSize
|
||||
* @param appName
|
||||
* @return
|
||||
*/
|
||||
@GET("app/v1/zamh/applicationPage")
|
||||
Observable<BaseRequestModel<PagingModel<AppInfoBean>>> applicationPage( @Query("cityNumber") String cityNumber, @Query("page") Integer page, @Query("pageSize") Integer pageSize, @Query("name") String appName, @Query("attribution") Integer attribution);
|
||||
/**
|
||||
* 分页获取应用列表
|
||||
* @param page
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@GET("app/v1/zamh/getWorkbenchApplication")
|
||||
Observable<BaseRequestModel<WorkbenchModel>> getWorkbenchApplication(@Query("page") Integer page, @Query("pageSize") Integer pageSize);
|
||||
|
||||
|
||||
/**
|
||||
* 获取有操作手册的列表
|
||||
* @param appName qpp名称用于检索应用
|
||||
* @param cityNumber 机构编码
|
||||
* @param page 分页页码
|
||||
* @param pageSize 每页长度
|
||||
*/
|
||||
@GET("app/v1/zamh/applicationHaveOperationGuide")
|
||||
Observable<BaseRequestModel<PagingModel<AppInfoBean>>> applicationCzsc(@Query("name") String appName,@Query("cityNumber") String cityNumber,@Query("page") Integer page,@Query("pageSize") Integer pageSize);
|
||||
|
||||
/**
|
||||
* 根据ID获取操作手册列表
|
||||
*/
|
||||
@GET("app/v1/zamh/operationGuideList")
|
||||
Observable<JsonObject> operationGuideList(@Query("applicationId") String appId);
|
||||
/**
|
||||
* 获取轮播图列表
|
||||
*/
|
||||
@GET("app/v1/zamh/pictureList")
|
||||
Observable<BaseRequestModel<List<HomeBannerBean>>> getBannerList();
|
||||
|
||||
/**
|
||||
* 添加反馈
|
||||
*/
|
||||
@POST("app/v1/zamh/addFeedBack")
|
||||
Observable<JsonObject> addFeedBack(@Body RequestBody body);
|
||||
|
||||
/**
|
||||
* 添加反馈
|
||||
*/
|
||||
@GET("app/v1/zamh/feedbackList")
|
||||
Observable<BaseRequestModel<PagingModel<FeedbackBean>>> feedbackList(@Query("page") Integer page, @Query("pageSize") Integer pageSize);
|
||||
|
||||
|
||||
/**
|
||||
* 获取消息列表
|
||||
*/
|
||||
@GET("app/v1/zamh/getMessage")
|
||||
Observable<BaseRequestModel<PagingModel<MessageBean>>> getMessage(@Query("state") Integer state, @Query("page") Integer page, @Query("pageSize") Integer pageSize);
|
||||
|
||||
/**
|
||||
* 设置消息状态为已读
|
||||
*/
|
||||
@GET("app/v1/zamh/readMessage")
|
||||
Observable<JsonObject> readMessage(@Query("id") String id);
|
||||
|
||||
/**
|
||||
* 设置消息状态为已读
|
||||
*/
|
||||
@GET("tztb/list")
|
||||
Observable<JsonObject> getNews(@Query("page") Integer page,@Query("pageSize") Integer pageSize);
|
||||
|
||||
/**
|
||||
* 查询人员
|
||||
*/
|
||||
@GET("phone/person/checkPersonBySFZ")
|
||||
Observable<JsonObject> querySfzh(@QueryMap Map<String,String> param);
|
||||
|
||||
/**
|
||||
* 查询车辆
|
||||
*/
|
||||
@GET("phone/car/checkCar")
|
||||
Observable<JsonObject> queryCar(@QueryMap Map<String,String> param);
|
||||
|
||||
/**
|
||||
* 根据警种搜索
|
||||
* 警察
|
||||
* @see
|
||||
*/
|
||||
@GET("app/v1/zamh/recommendApplicationByPoliceRole")
|
||||
Observable<JsonObject> recommendApplicationByPoliceRole(@Query("role") String role,@Query("applicationName")String applicationName);
|
||||
|
||||
@POST("phone/car/saveCheckCarHistory")
|
||||
Observable<JsonObject> saveCheckCarHistory(@Body RequestBody body);
|
||||
|
||||
/**
|
||||
* 查询 =通讯录
|
||||
*/
|
||||
@GET("zatxl/list")
|
||||
Observable<JsonObject> getTxlData(@Query("sjgsdwId") String sjgsdwId,@Query("condition") String condition);
|
||||
|
||||
// @GET()
|
||||
// Observable<JsonObject> getTxlData(@Url String url,@Query("sjgsdwId") String sjgsdwId,@Query("condition") String condition);
|
||||
|
||||
/**
|
||||
* 获取督办单列表
|
||||
*/
|
||||
@GET()
|
||||
Observable<JsonObject> getDbdList(@Url String url,@Query("gmsfhm") String gmsfhm,@Query("pageNo") String pageNo,@Query("pageSize") String pageSize);
|
||||
|
||||
/**
|
||||
* 查询督办单详情
|
||||
*/
|
||||
@GET()
|
||||
Observable<JsonObject> getDbdDetails(@Url String url,@Query("gmsfhm") String gmsfhm,@Query("id") String id);
|
||||
|
||||
@GET()
|
||||
Observable<ResponseBody> downFile(@Url String url);
|
||||
|
||||
/* 上传操作日志*/
|
||||
@POST
|
||||
Observable<JsonObject> uploadOperationLog(@Url String url, @Body RequestBody requestBody);
|
||||
|
||||
// ====================== 应用申请相关 =========================================================
|
||||
/**
|
||||
* 应用申请
|
||||
*/
|
||||
@GET()
|
||||
Observable<JsonObject> applyLogin(@Url String url,@Query("policeNo") String policeNo);
|
||||
/**
|
||||
* 应用申请
|
||||
*/
|
||||
@GET()
|
||||
Observable<JsonObject> applyGet(@Url String url,@HeaderMap Map<String,String> headMap, @QueryMap Map<String,Object> param);
|
||||
|
||||
/* 上传操作日志*/
|
||||
@POST
|
||||
Observable<JsonObject> applyPost(@Url String url,@HeaderMap Map<String,String> headMap, @Body RequestBody requestBody);
|
||||
|
||||
/* 上传操作日志*/
|
||||
// @FormUrlEncoded
|
||||
// @POST
|
||||
// Observable<JsonObject> applyPost(@Url String url, @FieldMap Map<String,Object> paramMap);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
package com.ycgis.macall.personalcenter.p.request;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.request.OkHttpUtils;
|
||||
import com.ycgis.macall.personalcenter.m.requestbean.BaseRequestModel;
|
||||
import com.ycgis.macall.personalcenter.p.app.RuanseeApplication;
|
||||
import com.ycgis.macall.personalcenter.p.request.interceptors.HttpLoggingInterceptor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Converter;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
/**
|
||||
* @Author macall
|
||||
* @Create 2019/12/4 0004
|
||||
* @Describe
|
||||
*/
|
||||
public class RetrofitService {
|
||||
|
||||
private static RetrofitApi retrofitService;
|
||||
|
||||
public static void resetRetrofitApi() {
|
||||
retrofitService = new Retrofit.Builder()
|
||||
.baseUrl(RuanseeApplication.getAppCache().getBaseUrlPath())
|
||||
.addConverterFactory(new NullOnEmptyConverterFactory())//处理接口返回没有响应体body
|
||||
// 添加Gson转换器
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
// .addConverterFactory(GsonConverterFactory.create(new GsonBuilder()
|
||||
// .setLenient()
|
||||
// .create()
|
||||
// ))
|
||||
// 添加Retrofit到RxJava的转换器
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
.client(OkHttpUtils.getClient(10, 10, 10,new HttpLoggingInterceptor()))
|
||||
.build()
|
||||
.create(
|
||||
RetrofitApi.class);
|
||||
}
|
||||
|
||||
// private void init(){
|
||||
// retrofitService = new Retrofit.Builder()
|
||||
// .baseUrl(RuanseeApplication.getAppCache().getBaseUrlPath())
|
||||
// .addConverterFactory(new NullOnEmptyConverterFactory())//处理接口返回没有响应体body
|
||||
// // 添加Gson转换器
|
||||
// .addConverterFactory(GsonConverterFactory.create())
|
||||
//// .addConverterFactory(GsonConverterFactory.create(new GsonBuilder()
|
||||
//// .setLenient()
|
||||
//// .create()
|
||||
//// ))
|
||||
// // 添加Retrofit到RxJava的转换器
|
||||
// .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
// .client(OkHttpUtils.getClient(10, 10, 10))
|
||||
// .build()
|
||||
// .create(RetrofitApi.class);
|
||||
// }
|
||||
|
||||
|
||||
//获得RetrofitService对象
|
||||
public static RetrofitApi getBaseInstance() {
|
||||
try {
|
||||
if (retrofitService == null) {
|
||||
resetRetrofitApi();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
resetRetrofitApi();
|
||||
}
|
||||
return retrofitService;
|
||||
}
|
||||
|
||||
public static class NullOnEmptyConverterFactory extends Converter.Factory {
|
||||
|
||||
@Override
|
||||
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) {
|
||||
final Converter<ResponseBody, ?> delegate = retrofit.nextResponseBodyConverter(this, type, annotations);
|
||||
return new Converter<ResponseBody, Object>() {
|
||||
@Override
|
||||
public Object convert(ResponseBody body) throws IOException {
|
||||
if (body.contentLength() == 0) {
|
||||
if (type == BaseRequestModel.class) {
|
||||
BaseRequestModel baseRequestModel = new BaseRequestModel() {
|
||||
};
|
||||
baseRequestModel.setCode(-1);
|
||||
baseRequestModel.setMsg("未知错误!");
|
||||
return baseRequestModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return delegate.convert(body);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
package com.ycgis.macall.personalcenter.p.request;
|
||||
|
||||
|
||||
|
||||
import com.ycgis.macall.personalcenter.p.callback.UploadProgressListener;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
import okio.Buffer;
|
||||
import okio.BufferedSink;
|
||||
import okio.Okio;
|
||||
import okio.Source;
|
||||
|
||||
/**
|
||||
* Created by macall on 2018-06-06.
|
||||
* copyright:ycgis
|
||||
*/
|
||||
public class UploadProgressResponsBody {
|
||||
|
||||
public static RequestBody createCustomRequestBody(final MediaType contentType, final File file, final UploadProgressListener listener) {
|
||||
return new RequestBody() {
|
||||
@Override public MediaType contentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
@Override public long contentLength() {
|
||||
return file.length();
|
||||
}
|
||||
|
||||
@Override public void writeTo(@NotNull BufferedSink sink) throws IOException {
|
||||
Source source;
|
||||
try {
|
||||
source = Okio.source(file);
|
||||
Buffer buf = new Buffer();
|
||||
long remaining = contentLength();
|
||||
for (long readCount; (readCount = source.read(buf, 2048)) != -1; ) {
|
||||
sink.write(buf, readCount);
|
||||
listener.onUploadProgress(contentLength(), remaining -= readCount, remaining == 0);
|
||||
}
|
||||
listener.onUploadDone(remaining);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,306 @@
|
|||
package com.ycgis.macall.personalcenter.p.request.interceptors;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.base.code.binary.Base64;
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
import com.ycgis.macall.personalcenter.p.app.RuanseeApplication;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okhttp3.Connection;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import okhttp3.internal.http.HttpHeaders;
|
||||
import okhttp3.internal.platform.Platform;
|
||||
import okio.Buffer;
|
||||
import okio.BufferedSource;
|
||||
|
||||
import static okhttp3.internal.platform.Platform.INFO;
|
||||
|
||||
public class HttpLoggingInterceptor implements Interceptor {
|
||||
|
||||
private static final Charset UTF8 = Charset.forName("UTF-8");
|
||||
|
||||
private Map<String, String> headers;
|
||||
|
||||
public enum Level {
|
||||
/**
|
||||
* No logs.
|
||||
*/
|
||||
NONE,
|
||||
/**
|
||||
* Logs request and response lines.
|
||||
*
|
||||
* <p>Example:
|
||||
* <pre>{@code
|
||||
* --> POST /greeting http/ic_btn_compare_mode.ic_btn_compare_mode (ic_tv_left_house-byte body)
|
||||
*
|
||||
* <-- 200 OK (22ms, 6-byte body)
|
||||
* }</pre>
|
||||
*/
|
||||
BASIC,
|
||||
/**
|
||||
* Logs request and response lines and their respective headers.
|
||||
*
|
||||
* <p>Example:
|
||||
* <pre>{@code
|
||||
* --> POST /greeting http/ic_btn_compare_mode.ic_btn_compare_mode
|
||||
* Host: example.com
|
||||
* Content-Type: plain/text
|
||||
* Content-Length: ic_tv_left_house
|
||||
* --> END POST
|
||||
*
|
||||
* <-- 200 OK (22ms)
|
||||
* Content-Type: plain/text
|
||||
* Content-Length: 6
|
||||
* <-- END HTTP
|
||||
* }</pre>
|
||||
*/
|
||||
HEADERS,
|
||||
/**
|
||||
* Logs request and response lines and their respective headers and bodies (if present).
|
||||
*
|
||||
* <p>Example:
|
||||
* <pre>{@code
|
||||
* --> POST /greeting http/ic_btn_compare_mode.ic_btn_compare_mode
|
||||
* Host: example.com
|
||||
* Content-Type: plain/text
|
||||
* Content-Length: ic_tv_left_house
|
||||
*
|
||||
* Hi?
|
||||
* --> END POST
|
||||
*
|
||||
* <-- 200 OK (22ms)
|
||||
* Content-Type: plain/text
|
||||
* Content-Length: 6
|
||||
*
|
||||
* Hello!
|
||||
* <-- END HTTP
|
||||
* }</pre>
|
||||
*/
|
||||
BODY
|
||||
}
|
||||
|
||||
public interface Logger {
|
||||
void log(String message);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
Logger DEFAULT = new Logger() {
|
||||
@Override
|
||||
public void log(String message) {
|
||||
Platform.get().log(message, INFO, null);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public HttpLoggingInterceptor() {
|
||||
this(Logger.DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置请求Header
|
||||
*
|
||||
* @param headers header 集合
|
||||
*/
|
||||
public HttpLoggingInterceptor(Map<String, String> headers) {
|
||||
this(Logger.DEFAULT);
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
public HttpLoggingInterceptor(Logger logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
private final Logger logger;
|
||||
private volatile Level level = Level.BODY;
|
||||
|
||||
private void log(String msg){
|
||||
if (RuanseeApplication.isPrintLog){
|
||||
logger.log(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Response intercept(@NonNull Chain chain) throws IOException {
|
||||
// 在这里设置公共的Header
|
||||
Request requestS = chain.request();
|
||||
Request.Builder requestBuilder = requestS.newBuilder();
|
||||
// if (StringUtil.hasContent(RuanseeApplication.getAppCache().getSystem_token())) {
|
||||
// String heard = "Bearer " + RuanseeApplication.getAppCache().getSystem_token();
|
||||
// }
|
||||
if (StringUtil.isNullOrEmpty(RuanseeApplication.getAppCache().getUserInfo())){
|
||||
String s = Base64.encodeBase64String(RuanseeApplication.getUserData().toJson().getBytes());
|
||||
RuanseeApplication.getAppCache().setUserInfo(s);
|
||||
}
|
||||
requestBuilder.addHeader("userInfo", RuanseeApplication.getAppCache().getUserInfo());
|
||||
String se = requestS.url().toString();
|
||||
// if (StringUtil.hasContent(se)) {
|
||||
// if (!se.endsWith(".jpg") && !se.endsWith(".png")&&!se.contains("wzt")){
|
||||
// se = se.replace("http://" + RuanseeApplication.getAppCache().getIp() + ":8081/", RuanseeApplication.getAppCache().getBaseUrlPath());
|
||||
// }
|
||||
// if (!se.endsWith(".jpg") && !se.endsWith(".png")&&!se.contains("wzt_api_out")){
|
||||
// se = se.replace("http://" + RuanseeApplication.getAppCache().getIp() + "/", RuanseeApplication.getAppCache().getBaseUrlPath());
|
||||
// }
|
||||
// requestBuilder.url(se);
|
||||
// }
|
||||
//在这里设置公共的Header
|
||||
Level level = this.level;
|
||||
|
||||
Request request = requestBuilder.build();
|
||||
|
||||
// Request request = chain.request();
|
||||
if (level == Level.NONE) {
|
||||
return chain.proceed(request);
|
||||
}
|
||||
|
||||
boolean logBody = level == Level.BODY;
|
||||
boolean logHeaders = logBody || level == Level.HEADERS;
|
||||
|
||||
RequestBody requestBody = request.body();
|
||||
boolean hasRequestBody = requestBody != null;
|
||||
|
||||
Connection connection = chain.connection();
|
||||
String requestStartMessage = "--> "
|
||||
+ request.method()
|
||||
+ ' ' + request.url()
|
||||
+ (connection != null ? " " + connection.protocol() : "");
|
||||
if (!logHeaders && hasRequestBody) {
|
||||
requestStartMessage += " (" + requestBody.contentLength() + "-byte body)";
|
||||
}
|
||||
log(requestStartMessage);
|
||||
|
||||
if (logHeaders) {
|
||||
if (hasRequestBody) {
|
||||
// Request body headers are only present when installed as a network interceptor. Force
|
||||
// them to be included (when available) so there values are known.
|
||||
if (requestBody.contentType() != null) {
|
||||
log("Content-Type: " + requestBody.contentType());
|
||||
}
|
||||
if (requestBody.contentLength() != -1) {
|
||||
log("Content-Length: " + requestBody.contentLength());
|
||||
}
|
||||
}
|
||||
|
||||
Headers headers = request.headers();
|
||||
for (int i = 0, count = headers.size(); i < count; i++) {
|
||||
log("Headers.name: " + headers.name(i) + ", Header.value: " + headers.value(i));
|
||||
}
|
||||
|
||||
if (!logBody || !hasRequestBody) {
|
||||
log("--> END " + request.method());
|
||||
} else if (bodyEncoded(request.headers())) {
|
||||
log("--> END " + request.method() + " (encoded body omitted)");
|
||||
} else {
|
||||
Buffer buffer = new Buffer();
|
||||
requestBody.writeTo(buffer);
|
||||
|
||||
Charset charset = UTF8;
|
||||
MediaType contentType = requestBody.contentType();
|
||||
if (contentType != null) {
|
||||
charset = contentType.charset(UTF8);
|
||||
}
|
||||
|
||||
log("");
|
||||
if (isPlaintext(buffer)) {
|
||||
log(buffer.readString(charset));
|
||||
log("--> END " + request.method()
|
||||
+ " (" + requestBody.contentLength() + "-byte body)");
|
||||
} else {
|
||||
log("--> END " + request.method() + " (binary "
|
||||
+ requestBody.contentLength() + "-byte body omitted)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
long startNs = System.nanoTime();
|
||||
Response response;
|
||||
try {
|
||||
response = chain.proceed(request);
|
||||
} catch (Exception e) {
|
||||
log("<-- HTTP FAILED: " + e);
|
||||
throw e;
|
||||
}
|
||||
long tookMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNs);
|
||||
|
||||
ResponseBody responseBody = response.body();
|
||||
long contentLength = responseBody.contentLength();
|
||||
String bodySize = contentLength != -1 ? contentLength + "-byte" : "unknown-length";
|
||||
log("<-- response.code->"
|
||||
+ response.code()
|
||||
+ (response.message().isEmpty() ? "" : ' ' + response.message())
|
||||
+ ' ' + response.request().url()
|
||||
+ " (" + tookMs + "ms" + (!logHeaders ? ", " + bodySize + " body" : "") + ')');
|
||||
|
||||
if (logHeaders) {
|
||||
Headers headers = response.headers();
|
||||
for (int i = 0, count = headers.size(); i < count; i++) {
|
||||
log("Headers: " + headers.name(i) + " = " + Uri.decode(headers.value(i)));
|
||||
}
|
||||
if (!logBody || !HttpHeaders.hasBody(response)) {
|
||||
log("<-- END HTTP");
|
||||
} else if (bodyEncoded(response.headers())) {
|
||||
log("<-- END HTTP (encoded body omitted)");
|
||||
} else {
|
||||
BufferedSource source = responseBody.source();
|
||||
source.request(Long.MAX_VALUE); // Buffer the entire body.
|
||||
Buffer buffer = source.buffer();
|
||||
Charset charset = UTF8;
|
||||
MediaType contentType = responseBody.contentType();
|
||||
if (contentType != null) {
|
||||
charset = contentType.charset(UTF8);
|
||||
}
|
||||
if (!isPlaintext(buffer)) {
|
||||
log("");
|
||||
log("<-- END HTTP (binary " + buffer.size() + "-byte body omitted)");
|
||||
return response;
|
||||
}
|
||||
if (contentLength != 0) {
|
||||
log("");
|
||||
log(buffer.clone().readString(charset));
|
||||
}
|
||||
log("<-- END HTTP (" + buffer.size() + "-byte body)");
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
private static boolean isPlaintext(Buffer buffer) {
|
||||
try {
|
||||
Buffer prefix = new Buffer();
|
||||
long byteCount = buffer.size() < 64 ? buffer.size() : 64;
|
||||
buffer.copyTo(prefix, 0, byteCount);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (prefix.exhausted()) {
|
||||
break;
|
||||
}
|
||||
int codePoint = prefix.readUtf8CodePoint();
|
||||
if (Character.isISOControl(codePoint) && !Character.isWhitespace(codePoint)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (EOFException e) {
|
||||
return false; // Truncated UTF-8 sequence.
|
||||
}
|
||||
}
|
||||
|
||||
private boolean bodyEncoded(Headers headers) {
|
||||
String contentEncoding = headers.get("Content-Encoding");
|
||||
return contentEncoding != null && !contentEncoding.equalsIgnoreCase("identity");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package com.ycgis.macall.personalcenter.p.rxjava;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/11/20 14:21
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public abstract class ResultObserver<T> implements Observer<T> {
|
||||
private String identifierKey;
|
||||
|
||||
public ResultObserver(String identifierKey) {
|
||||
this.identifierKey = identifierKey;
|
||||
}
|
||||
|
||||
protected abstract void onNext(String identifierKey,@NotNull T data);
|
||||
|
||||
protected void onSubscribe(String identifierKey, @NotNull Disposable d) {
|
||||
|
||||
}
|
||||
protected void onError(String identifierKey, @NotNull Throwable data){
|
||||
|
||||
}
|
||||
protected void onComplete(String identifierKey){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribe(@NotNull Disposable d) {
|
||||
onSubscribe(identifierKey,d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull T o) {
|
||||
onNext(identifierKey,o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NotNull Throwable e) {
|
||||
onError(identifierKey,e);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
onComplete(identifierKey);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.ycgis.macall.personalcenter.p.rxjava;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/11/17 17:17
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public abstract class UpdateUiOnSubscribe<E,T> implements ObservableOnSubscribe<T> {
|
||||
|
||||
public E object;
|
||||
|
||||
public UpdateUiOnSubscribe(E object) {
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
public UpdateUiOnSubscribe() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public abstract void subscribe(E date, @NotNull ObservableEmitter<T> emitter);
|
||||
|
||||
@Override
|
||||
public void subscribe(@NotNull ObservableEmitter<T> emitter) throws Exception {
|
||||
subscribe(object,emitter);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
package com.ycgis.macall.personalcenter.p.service;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.job.JobInfo;
|
||||
import android.app.job.JobParameters;
|
||||
import android.app.job.JobScheduler;
|
||||
import android.app.job.JobService;
|
||||
import android.content.ComponentName;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.utils.LogUtils;
|
||||
import com.ycgis.macall.personalcenter.m.adapterbean.MessageBean;
|
||||
import com.ycgis.macall.personalcenter.m.event.MessageEvent;
|
||||
import com.ycgis.macall.personalcenter.m.requestbean.BaseRequestModel;
|
||||
import com.ycgis.macall.personalcenter.m.requestbean.PagingModel;
|
||||
import com.ycgis.macall.personalcenter.p.app.RuanseeApplication;
|
||||
import com.ycgis.macall.personalcenter.p.callback.BaseRequestCallback;
|
||||
import com.ycgis.macall.personalcenter.p.request.ApiModel;
|
||||
import com.ycgis.macall.personalcenter.p.request.RetrofitService;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/1/3 11:29
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public class GetMessageService extends JobService {
|
||||
private static String TAG = "GetMessageService";
|
||||
private JobParameters jobParameters;
|
||||
|
||||
@Override
|
||||
public boolean onStartJob(JobParameters params) {
|
||||
jobParameters = params;
|
||||
getMsg();
|
||||
doService();
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
private void doService() {
|
||||
// if (!MPush.I.hasStarted()) {
|
||||
JobScheduler jobScheduler = (JobScheduler) getSystemService(JOB_SCHEDULER_SERVICE);
|
||||
JobInfo.Builder builder = new JobInfo.Builder(1, new ComponentName(this, GetMessageService.class));
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
builder.setMinimumLatency(RuanseeApplication.REFRESH_MESSAGE_TIME); //执行的最小延迟时间
|
||||
builder.setOverrideDeadline(RuanseeApplication.REFRESH_MESSAGE_TIME); //执行的最长延时时间
|
||||
builder.setBackoffCriteria(RuanseeApplication.REFRESH_MESSAGE_TIME, JobInfo.BACKOFF_POLICY_LINEAR);//线性重试方案
|
||||
} else {
|
||||
builder.setPeriodic(RuanseeApplication.REFRESH_MESSAGE_TIME);
|
||||
}
|
||||
builder.setPersisted(true); // 设置设备重启时,执行该任务
|
||||
builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
|
||||
builder.setRequiresCharging(false);//设置是否在只有插入充电器的时候执行
|
||||
builder.setRequiresDeviceIdle(false);//设置手机系统处于空闲状态下执行
|
||||
JobInfo info = builder.build();
|
||||
jobScheduler.schedule(info); //开始定时执行该系统任务
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onStopJob(JobParameters params) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void getMsg() {
|
||||
ApiModel.requestIO(RetrofitService.getBaseInstance().getMessage(0, 1, 3),
|
||||
new BaseRequestCallback<BaseRequestModel<PagingModel<MessageBean>>>() {
|
||||
@Override
|
||||
public void onRequestFailure(String msg) {
|
||||
LogUtils.e(TAG, msg);
|
||||
jobFinished(jobParameters, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestSuccess(BaseRequestModel<PagingModel<MessageBean>> result) {
|
||||
// LogUtils.w(TAG, result.toString());
|
||||
if (result.getCode() == 20041) {
|
||||
PagingModel<MessageBean> data = result.getData();
|
||||
int counts = data.getCounts();
|
||||
if (counts <= 0) {
|
||||
jobFinished(jobParameters, false);
|
||||
return;
|
||||
}
|
||||
List<MessageBean> items = data.getItems();
|
||||
MessageEvent event = new MessageEvent();
|
||||
event.setCount(counts);
|
||||
String title = "<font color=\"#808080\">全部消息(</font><font color=\"#FF9124\">" + counts + "</font><font color=\"#808080\">)</font>";
|
||||
event.setMsg(title);
|
||||
// updateWidget(String.format("未读消息%s条", counts));
|
||||
int lengthNum = Math.min(items.size(), 3);
|
||||
List<MessageBean> messageBeans = items.subList(0, lengthNum);
|
||||
for (int i = 0; i < messageBeans.size(); i++) {
|
||||
MessageBean bean = messageBeans.get(i);
|
||||
bean.setBaseType(1);
|
||||
}
|
||||
if (!messageBeans.isEmpty()) {
|
||||
event.setMessageBeanList(messageBeans);
|
||||
EventBus.getDefault().post(event);
|
||||
}
|
||||
}
|
||||
jobFinished(jobParameters, false);
|
||||
|
||||
// List<MessageBean> messageBeanList = new ArrayList<>();
|
||||
// try {
|
||||
// JSONObject object = new JSONObject(result.toString());
|
||||
// String code = TypConversion.getJsonStr(object, "code");
|
||||
// if (code.equals("20041")) {
|
||||
// JSONObject data = object.getJSONObject("data");
|
||||
// int counts = TypConversion.getJsonInt(data, "counts", 0);
|
||||
// if (counts <= 0) {
|
||||
//// updateWidget("暂无新消息");
|
||||
// jobFinished(jobParameters, false);
|
||||
// return;
|
||||
// }
|
||||
// MessageEvent event = new MessageEvent();
|
||||
// event.setCount(counts);
|
||||
// updateWidget(String.format("未读消息%s条", counts));
|
||||
// String title = "<font color=\"#808080\">全部消息(</font><font color=\"#FF9124\">" + counts + "</font><font color=\"#808080\">)</font>";
|
||||
// event.setMsg(title);
|
||||
// JSONArray items = data.getJSONArray("items");
|
||||
// int lengthNum = Math.min(items.length(), 2);
|
||||
// for (int i = 0; i < lengthNum; i++) {
|
||||
// JSONObject jsonObject = TypConversion.getJSONObject(items, i);
|
||||
// if (jsonObject == null) continue;
|
||||
// MessageBean bean = new MessageBean();
|
||||
// bean.setBaseType(1);
|
||||
// bean.setAppName(TypConversion.getJsonStr(jsonObject, "appName"));
|
||||
// bean.setId(TypConversion.getJsonStr(jsonObject, "id"));
|
||||
// bean.setMsgId(TypConversion.getJsonStr(jsonObject, "msgId"));
|
||||
// bean.setTitle(TypConversion.getJsonStr(jsonObject, "msgTitle"));
|
||||
// bean.setContent(TypConversion.getJsonStr(jsonObject, "msgContent"));
|
||||
// bean.setClientId(TypConversion.getJsonStr(jsonObject, "appId"));
|
||||
// bean.setClientSecret(TypConversion.getJsonStr(jsonObject, "appSecret"));
|
||||
// bean.setAppLinkUrl(TypConversion.getJsonStr(jsonObject, "appUrl"));
|
||||
// bean.setMsgType(TypConversion.getJsonStr(jsonObject, "msgType"));
|
||||
// bean.setTime(TypConversion.getJsonStr(jsonObject, "sendingTime"));
|
||||
// int state = TypConversion.getJsonInt(jsonObject, "state", 0);
|
||||
// bean.setRead(state != 0);
|
||||
// messageBeanList.add(bean);
|
||||
// }
|
||||
// if (!messageBeanList.isEmpty()) {
|
||||
// event.setMessageBeanList(messageBeanList);
|
||||
// EventBus.getDefault().post(event);
|
||||
// }
|
||||
// jobFinished(jobParameters, false);
|
||||
// }
|
||||
// } catch(JSONException e){
|
||||
// e.printStackTrace();
|
||||
// jobFinished(jobParameters, false);
|
||||
// }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateWidget(String msg) {
|
||||
// RemoteViews rv = new RemoteViews(this.getPackageName(), R.layout.layout_widget);
|
||||
// rv.setTextViewText(R.id.tv_msg_count, msg);
|
||||
// ComponentName cn = new ComponentName(this, ListWidgetProvider.class);
|
||||
// AppWidgetManager am = AppWidgetManager.getInstance(this);
|
||||
// am.updateAppWidget(cn, rv);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.ycgis.macall.personalcenter.p.service;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
|
||||
public class MyService extends Service {
|
||||
public MyService() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
// TODO: Return the communication channel to the service.
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.ycgis.macall.personalcenter.util;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2022/12/3 10:25
|
||||
* copyright: @ruansee.com
|
||||
* Describe: 安徽各地市
|
||||
*/
|
||||
public class AhdsAddressUtils {
|
||||
|
||||
private final static String[][] addresss = new String[][]{
|
||||
{"省厅","3400"},
|
||||
{"合肥","3401"},
|
||||
{"芜湖","3402"},
|
||||
{"蚌埠","3403"},
|
||||
{"淮南","3404"},
|
||||
{"马鞍山","3405"},
|
||||
{"淮北","3406"},
|
||||
{"铜陵","3407"},
|
||||
{"安庆","3408"},
|
||||
{"黄山","3410"},
|
||||
{"滁州","3411"},
|
||||
{"阜阳","3412"},
|
||||
{"宿州","3413"},
|
||||
{"六安","3415"},
|
||||
{"亳州","3416"},
|
||||
{"池州","3417"},
|
||||
{"宣城","3418"}
|
||||
};
|
||||
|
||||
public static String getAddressNameByCode(String code){
|
||||
if (StringUtil.isNullOrEmpty(code)) return "";
|
||||
for (int i = 0; i < addresss.length; i++) {
|
||||
if (code.startsWith(addresss[i][1])) {
|
||||
return addresss[i][0];
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,300 @@
|
|||
/**
|
||||
* probject:lvxin
|
||||
* @version 5.0
|
||||
*
|
||||
* @author 3979434@qq.com
|
||||
*/
|
||||
package com.ycgis.macall.personalcenter.util;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Environment;
|
||||
import android.os.StatFs;
|
||||
import android.text.format.Formatter;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.MeasureSpec;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
import com.rs.macall.androidx.basemodel.utils.ToastUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class AppTools {
|
||||
|
||||
public void measureView(View child) {
|
||||
ViewGroup.LayoutParams p = child.getLayoutParams();
|
||||
if (p == null) {
|
||||
p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
int childWidthSpec = ViewGroup.getChildMeasureSpec(0, 0 + 0, p.width);
|
||||
int lpHeight = p.height;
|
||||
int childHeightSpec;
|
||||
if (lpHeight > 0) {
|
||||
childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight,
|
||||
MeasureSpec.EXACTLY);
|
||||
} else {
|
||||
childHeightSpec = MeasureSpec.makeMeasureSpec(0,
|
||||
MeasureSpec.UNSPECIFIED);
|
||||
}
|
||||
child.measure(childWidthSpec, childHeightSpec);
|
||||
}
|
||||
|
||||
public boolean isSystemApplication(Context context) {
|
||||
final PackageManager pm = (PackageManager) context.getPackageManager();
|
||||
try {
|
||||
final PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
|
||||
if ((pi.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}catch(Exception err)
|
||||
{
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private final static int kSystemRootStateUnknow = -1;
|
||||
private final static int kSystemRootStateDisable = 0;
|
||||
private final static int kSystemRootStateEnable = 1;
|
||||
private static int systemRootState = kSystemRootStateUnknow;
|
||||
|
||||
public static boolean isRootSystem() {
|
||||
if (systemRootState == kSystemRootStateEnable) {
|
||||
return true;
|
||||
} else if (systemRootState == kSystemRootStateDisable) {
|
||||
return false;
|
||||
}
|
||||
File f = null;
|
||||
final String kSuSearchPaths[] = { "/system/bin/", "/system/xbin/",
|
||||
"/system/sbin/", "/sbin/", "/vendor/bin/" };
|
||||
try {
|
||||
for (int i = 0; i < kSuSearchPaths.length; i++) {
|
||||
f = new File(kSuSearchPaths[i] + "su");
|
||||
if (f != null && f.exists()) {
|
||||
systemRootState = kSystemRootStateEnable;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
systemRootState = kSystemRootStateDisable;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean netWorkAvailable(Context context) {
|
||||
try {
|
||||
ConnectivityManager nw = (ConnectivityManager) context
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo networkInfo = nw.getActiveNetworkInfo();
|
||||
return networkInfo != null;
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**根据包名判断某个应用程序是否安装方法*/
|
||||
public static boolean isInstall(Context context , String packageName) {
|
||||
if (packageName == null || "".equals(packageName))
|
||||
return false;
|
||||
try {
|
||||
ApplicationInfo info = context.getPackageManager().getApplicationInfo(
|
||||
packageName, PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
return true;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean startApp(Context context,String appPageName){
|
||||
if (StringUtil.isNullOrEmpty(appPageName)){
|
||||
ToastUtil.centered(context,"包名错误,请联系管理员!");
|
||||
return false;
|
||||
}
|
||||
//首先判断调用的apk是否安装
|
||||
boolean isAlive = isInstall(context,appPageName);
|
||||
if(isAlive){
|
||||
jumpApp(context,appPageName);
|
||||
return true;
|
||||
}else{
|
||||
|
||||
ToastUtil.centeredLong(context,"应用未安装,请至应用商店下载!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动APP
|
||||
* @param packageName 包名
|
||||
*/
|
||||
public static void jumpApp(Context context,String packageName) {
|
||||
String className = "";
|
||||
Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
|
||||
// resolveIntent.addCategory(Constant.CATEGORY_YCGIS_LAUNCHER);
|
||||
resolveIntent.setPackage(packageName);
|
||||
// 通过getPackageManager()的queryIntentActivities方法遍历
|
||||
List<ResolveInfo> resolveinfoList = context.getPackageManager()
|
||||
.queryIntentActivities(resolveIntent, 0);
|
||||
ResolveInfo resolveinfo = resolveinfoList.iterator().next();
|
||||
if (resolveinfo != null) {
|
||||
className = resolveinfo.activityInfo.name;
|
||||
} else {
|
||||
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
ComponentName component = new ComponentName(packageName, className);
|
||||
intent.setComponent(component);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得SD卡总大小
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getSDTotalSize(Context context) {
|
||||
File path = Environment.getExternalStorageDirectory();
|
||||
StatFs stat = new StatFs(path.getPath());
|
||||
long blockSize = stat.getBlockSize();
|
||||
long totalBlocks = stat.getBlockCount();
|
||||
return Formatter.formatFileSize(context, blockSize * totalBlocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得sd卡剩余容量,即可用大小
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getSDAvailableSize(Context context) {
|
||||
File path = Environment.getExternalStorageDirectory();
|
||||
StatFs stat = new StatFs(path.getPath());
|
||||
long blockSize = stat.getBlockSize();
|
||||
long availableBlocks = stat.getAvailableBlocks();
|
||||
return Formatter.formatFileSize(context, blockSize * availableBlocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得机身内存总大小
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getRomTotalSize(Context context) {
|
||||
File path = Environment.getDataDirectory();
|
||||
StatFs stat = new StatFs(path.getPath());
|
||||
long blockSize = stat.getBlockSize();
|
||||
long totalBlocks = stat.getBlockCount();
|
||||
return Formatter.formatFileSize(context, blockSize * totalBlocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得机身可用内存
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getRomAvailableSize(Context context) {
|
||||
File path = Environment.getDataDirectory();
|
||||
StatFs stat = new StatFs(path.getPath());
|
||||
long blockSize = stat.getBlockSize();
|
||||
long availableBlocks = stat.getAvailableBlocks();
|
||||
return Formatter.formatFileSize(context, blockSize * availableBlocks);
|
||||
}
|
||||
|
||||
public static boolean contains(int[] loc,MotionEvent event)
|
||||
{
|
||||
return event.getY() >= loc[1] && event.getY() <= loc[3]
|
||||
&& event.getX() >= loc[0] && event.getX() <= loc[2];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* compute Sample Size
|
||||
*
|
||||
* @param options
|
||||
* @param minSideLength
|
||||
* @param maxNumOfPixels
|
||||
* @return
|
||||
*/
|
||||
public static int computeSampleSize(BitmapFactory.Options options,
|
||||
int minSideLength, int maxNumOfPixels) {
|
||||
int initialSize = computeInitialSampleSize(options, minSideLength,
|
||||
maxNumOfPixels);
|
||||
|
||||
int roundedSize;
|
||||
if (initialSize <= 8) {
|
||||
roundedSize = 1;
|
||||
while (roundedSize < initialSize) {
|
||||
roundedSize <<= 1;
|
||||
}
|
||||
} else {
|
||||
roundedSize = (initialSize + 7) / 8 * 8;
|
||||
}
|
||||
|
||||
return roundedSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* compute Initial Sample Size
|
||||
*
|
||||
* @param options
|
||||
* @param minSideLength
|
||||
* @param maxNumOfPixels
|
||||
* @return
|
||||
*/
|
||||
private static int computeInitialSampleSize(BitmapFactory.Options options,
|
||||
int minSideLength, int maxNumOfPixels) {
|
||||
double w = options.outWidth;
|
||||
double h = options.outHeight;
|
||||
|
||||
// 上下限范围
|
||||
int lowerBound = (maxNumOfPixels == -1) ? 1 : (int) Math.ceil(Math
|
||||
.sqrt(w * h / maxNumOfPixels));
|
||||
int upperBound = (minSideLength == -1) ? 128 : (int) Math.min(
|
||||
Math.floor(w / minSideLength), Math.floor(h / minSideLength));
|
||||
|
||||
if (upperBound < lowerBound) {
|
||||
// return the larger one when there is no overlapping zone.
|
||||
return lowerBound;
|
||||
}
|
||||
|
||||
if ((maxNumOfPixels == -1) && (minSideLength == -1)) {
|
||||
return 1;
|
||||
} else if (minSideLength == -1) {
|
||||
return lowerBound;
|
||||
} else {
|
||||
return upperBound;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [获取应用程序版本名称信息]
|
||||
* @param context
|
||||
* @return 当前应用的版本名称
|
||||
*/
|
||||
public static synchronized String getPackageName(Context context) {
|
||||
try {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
PackageInfo packageInfo = packageManager.getPackageInfo(
|
||||
context.getPackageName(), 0);
|
||||
return packageInfo.packageName;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,514 @@
|
|||
package com.ycgis.macall.personalcenter.util;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Matrix;
|
||||
import android.media.ExifInterface;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.util.Base64;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.utils.LogUtils;
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
import com.rs.macall.androidx.basemodel.utils.ToastUtil;
|
||||
import com.ycgis.macall.personalcenter.R;
|
||||
import com.ycgis.macall.personalcenter.p.callback.SelectReturnCallback;
|
||||
import com.ycgis.macall.personalcenter.p.request.ApiModel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2022/10/26 15:09
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class FileUtils {
|
||||
|
||||
private static String filePath;
|
||||
|
||||
//文件路径
|
||||
public static String FILE_DIR = "file";
|
||||
//数据库文件路径
|
||||
public static String DB_DIR = "dateBase";
|
||||
//图片文件存储路径
|
||||
public static String IMAGE_DIR = "Image";
|
||||
//视频文件存储路径
|
||||
public static String VOID_DIR = "Void";
|
||||
//下载文件存储路径
|
||||
public static String DOWNLOADS_DIR = "downloads";
|
||||
//下载文件存储路径
|
||||
public static String LOG_DIR = "Log";
|
||||
|
||||
/**
|
||||
* 初始化文件目录,Android10以下可以访问外部存储的任意位置,Android10(包括)以上只能访问指定目录。
|
||||
* 为适配Android 10 及以上,应用目录应存储在该目录下
|
||||
*
|
||||
* @param context 上下文环境
|
||||
* @return 文件录
|
||||
*/
|
||||
public static String initFilePath(Context context) {
|
||||
if (StringUtil.isNullOrEmpty(filePath)) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
filePath = context.getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath().replace("Documents", "");
|
||||
DOWNLOADS_DIR = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath() + File.separator;
|
||||
IMAGE_DIR = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES).getAbsolutePath() + File.separator;
|
||||
VOID_DIR = context.getExternalFilesDir(Environment.DIRECTORY_DCIM).getAbsolutePath() + File.separator;
|
||||
FILE_DIR = context.getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath() + File.separator;
|
||||
DB_DIR = FILE_DIR + "/dateBase/";
|
||||
LOG_DIR = filePath + "log/";
|
||||
} else {
|
||||
// /storage/emulated/0/Android/data/com.spsj.data/files/Documents
|
||||
filePath = Environment.getExternalStorageDirectory().getPath() + "/Android/data/com.ycgis.macall.personalcenter/";
|
||||
DOWNLOADS_DIR = filePath + "Downloads/";
|
||||
IMAGE_DIR = filePath + "Pictures/";
|
||||
VOID_DIR = filePath + "DCIM/";
|
||||
FILE_DIR = filePath + "Documents/";
|
||||
DB_DIR = FILE_DIR + "/dateBase/";
|
||||
LOG_DIR = filePath + "log/";
|
||||
}
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public static String getPhotoName() {
|
||||
return System.currentTimeMillis() + ".jpg";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param attrsName
|
||||
* @param filePath
|
||||
* @return
|
||||
*/
|
||||
public static File copyAPK(Context context, String attrsName, String filePath) {
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = context.getAssets().open(attrsName);
|
||||
File destFile = new File(filePath, attrsName);
|
||||
if (destFile.exists()) {
|
||||
destFile.delete();
|
||||
}
|
||||
// if (!destFile.exists()) {
|
||||
return copy(is, destFile.getAbsolutePath());
|
||||
// }
|
||||
// return null;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static File copy(InputStream is, String path) {
|
||||
try {
|
||||
File file = new File(path);
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int len;
|
||||
while ((len = is.read(buffer)) != -1) {
|
||||
fos.write(buffer, 0, len);
|
||||
}
|
||||
fos.flush();
|
||||
fos.close();
|
||||
is.close();
|
||||
|
||||
return file;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地图片转 base64 字符
|
||||
*
|
||||
* @param filePath 图标全路径
|
||||
* @return base64 字符
|
||||
*/
|
||||
public static String fileToBase64(String filePath) {
|
||||
if (StringUtil.isNullOrEmpty(filePath)) return "";
|
||||
File f = new File(filePath);
|
||||
if (!f.exists()) return "";
|
||||
InputStream in = null;
|
||||
byte[] data = null;
|
||||
try {
|
||||
in = new FileInputStream(f);
|
||||
data = new byte[(int) f.length()];
|
||||
in.read(data);
|
||||
in.close();
|
||||
// return Base64.encodeBase64String(data);
|
||||
// return Base64.encodeBase64URLSafeString(data);
|
||||
return Base64.encodeToString(data, Base64.DEFAULT);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteFiles(File file) {
|
||||
if (file == null || !file.exists()) return;
|
||||
if (file.isDirectory()) {
|
||||
File[] files = file.listFiles();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
File file1 = files[i];
|
||||
deleteFiles(file1);
|
||||
}
|
||||
} else {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static long calculateFileSize(File file) {
|
||||
long totals = 0;
|
||||
if (!file.exists()) return 0;
|
||||
if (file.isDirectory()) {
|
||||
File[] files = file.listFiles();
|
||||
if (files == null) return 0;
|
||||
for (File fl : files) {
|
||||
totals += calculateFileSize(fl);
|
||||
}
|
||||
} else {
|
||||
totals += file.length();
|
||||
}
|
||||
return totals;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件重命名
|
||||
*
|
||||
* @param dir 文件路径
|
||||
* @param sourcePath 原文件名
|
||||
* @param targetPath 修改后的文件名
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
public static boolean renameFile(String dir, String sourcePath, String targetPath) {
|
||||
File toBeRenamed = new File(dir, sourcePath);
|
||||
//检查要重命名的文件是否存在,是否是文件
|
||||
if (!toBeRenamed.exists() || toBeRenamed.isDirectory()) {
|
||||
LogUtils.e("FileUtils", "待重命名文件不存在: " + sourcePath);
|
||||
return false;
|
||||
}
|
||||
File newFile = new File(dir, targetPath);
|
||||
//修改文件名
|
||||
return toBeRenamed.renameTo(newFile);
|
||||
}
|
||||
|
||||
/*打开app*/
|
||||
@TargetApi(Build.VERSION_CODES.DONUT)
|
||||
private void doStartApplicationWithPackageName(Context context, String packagename) {
|
||||
|
||||
// 通过包名获取此APP详细信息,包括Activities、services、versioncode、name等等
|
||||
PackageInfo packageinfo = null;
|
||||
try {
|
||||
packageinfo = context.getPackageManager().getPackageInfo(packagename, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (packageinfo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 创建一个类别为CATEGORY_LAUNCHER的该包名的Intent
|
||||
Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
|
||||
resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
resolveIntent.setPackage(packageinfo.packageName);
|
||||
|
||||
// 通过getPackageManager()的queryIntentActivities方法遍历
|
||||
List<ResolveInfo> resolveinfoList = context.getPackageManager()
|
||||
.queryIntentActivities(resolveIntent, 0);
|
||||
|
||||
ResolveInfo resolveinfo = resolveinfoList.iterator().next();
|
||||
if (resolveinfo != null) {
|
||||
// packagename = 参数packname
|
||||
String packageName = resolveinfo.activityInfo.packageName;
|
||||
// 这个就是我们要找的该APP的LAUNCHER的Activity[组织形式:packagename.mainActivityname]
|
||||
String className = resolveinfo.activityInfo.name;
|
||||
// LAUNCHER Intent
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
|
||||
// 设置ComponentName参数1:packagename参数2:MainActivity路径
|
||||
ComponentName cn = new ComponentName(packageName, className);
|
||||
|
||||
intent.setComponent(cn);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件大小单位
|
||||
*/
|
||||
@IntDef(value = {FileSizeFormType.B, FileSizeFormType.K, FileSizeFormType.M, FileSizeFormType.T})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface FileSizeFormType {
|
||||
int B = 0; //bit
|
||||
int K = 1; //KB
|
||||
int M = 2; //MB
|
||||
int T = 3; //TB
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化文件大小
|
||||
*
|
||||
* @param fileSize 文件大小单位 bit
|
||||
* @param type 格式化单位{@link FileSizeFormType}
|
||||
* @return 格式化后的大小
|
||||
*/
|
||||
public static String formatFileSize(long fileSize, int type) {
|
||||
DecimalFormat decimalFormat = new DecimalFormat("#.00");
|
||||
if (FileSizeFormType.K == type) {
|
||||
return decimalFormat.format((double)fileSize / 1024 )+ "K";
|
||||
} else if (FileSizeFormType.M == type) {
|
||||
return decimalFormat.format((double)fileSize / 1024 / 1024 )+ "M";
|
||||
} else if (FileSizeFormType.T == type) {
|
||||
return decimalFormat.format((double)fileSize / 1024 / 1024 / 1024) + "T";
|
||||
}
|
||||
return fileSize + "B";
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开原生APP
|
||||
*
|
||||
* @param context
|
||||
* @param strPackage 包名
|
||||
* @param callback
|
||||
*/
|
||||
public static void startAPP(Context context, String strPackage, SelectReturnCallback<Boolean> callback) {
|
||||
try {
|
||||
// 通过包名获取此APP详细信息,包括Activities、services、versioncode、name等等
|
||||
PackageInfo packageinfo = null;
|
||||
try {
|
||||
packageinfo = context.getPackageManager().getPackageInfo(strPackage, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
if (callback != null) {
|
||||
callback.returnMsg(false);
|
||||
}
|
||||
}
|
||||
if (packageinfo == null) {
|
||||
if (callback != null) {
|
||||
callback.returnMsg(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// 创建一个类别为CATEGORY_LAUNCHER的该包名的Intent
|
||||
Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
|
||||
resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
resolveIntent.setPackage(packageinfo.packageName);
|
||||
|
||||
// 通过getPackageManager()的queryIntentActivities方法遍历
|
||||
List<ResolveInfo> resolveinfoList = context.getPackageManager()
|
||||
.queryIntentActivities(resolveIntent, 0);
|
||||
|
||||
ResolveInfo resolveinfo = resolveinfoList.iterator().next();
|
||||
if (resolveinfo != null) {
|
||||
// packagename = 参数packname
|
||||
String packageName = resolveinfo.activityInfo.packageName;
|
||||
// 这个就是我们要找的该APP的LAUNCHER的Activity[组织形式:packagename.mainActivityname]
|
||||
String className = resolveinfo.activityInfo.name;
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
//TODO 打开第三方应用 应当设置 启动模式为新的任务栈
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.setClassName(packageName, className);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
ApiModel.uploadOperationLog("3","3","用户跳转到第三方应用:"+strPackage);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (callback != null) {
|
||||
callback.returnMsg(false);
|
||||
}
|
||||
// ToastUtil.centered(context, "没有安装应用,请至应用中心下载安装!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据路径打开文件
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param path 文件路径
|
||||
*/
|
||||
public static void openFileByPath(Activity context, String path) {
|
||||
if (context == null || path == null) return;
|
||||
File file = new File(path);
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
Uri photoURI;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
//如果是7.0及以上的系统使用FileProvider的方式创建一个Uri
|
||||
LogUtils.e("相机权限", "系统版本大于7.0");
|
||||
// String provider = context.getString(MResource.getIdByName(context.getApplication(), "string", "app_file_provider_authority"));
|
||||
photoURI = FileProvider.getUriForFile(context, context.getString(R.string.fileProviderName), file);
|
||||
} else {
|
||||
//7.0以下使用这种方式创建一个Uri
|
||||
photoURI = Uri.fromFile(file);
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
//设置intent的Action属性
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
//文件的类型
|
||||
intent.addCategory(Intent.CATEGORY_DEFAULT);
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
String type = "";
|
||||
for (int i = 0; i < MATCH_ARRAY.length; i++) {
|
||||
//判断文件的格式
|
||||
if (path.endsWith(MATCH_ARRAY[i][0])) {
|
||||
type = MATCH_ARRAY[i][1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
//设置intent的data和Type属性
|
||||
intent.setDataAndType(photoURI, type);
|
||||
//跳转
|
||||
context.startActivity(intent);
|
||||
} catch (Exception e) { //当系统没有携带文件打开软件,提示
|
||||
ToastUtil.centered(context, "无法打开该格式文件!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//建立一个文件类型与文件后缀名的匹配表
|
||||
private static final String[][] MATCH_ARRAY = {
|
||||
//{后缀名, 文件类型}
|
||||
{".3gp", "video/3gpp"},
|
||||
{".apk", "application/vnd.android.package-archive"},
|
||||
{".asf", "video/x-ms-asf"},
|
||||
{".avi", "video/x-msvideo"},
|
||||
{".bin", "application/octet-stream"},
|
||||
{".bmp", "image/bmp"},
|
||||
{".c", "text/plain"},
|
||||
{".class", "application/octet-stream"},
|
||||
{".conf", "text/plain"},
|
||||
{".cpp", "text/plain"},
|
||||
{".doc", "application/msword"},
|
||||
{".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"},
|
||||
{".xls", "application/vnd.ms-excel"},
|
||||
{".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},
|
||||
{".exe", "application/octet-stream"},
|
||||
{".gif", "image/gif"},
|
||||
{".gtar", "application/x-gtar"},
|
||||
{".gz", "application/x-gzip"},
|
||||
{".h", "text/plain"},
|
||||
{".htm", "text/html"},
|
||||
{".html", "text/html"},
|
||||
{".jar", "application/java-archive"},
|
||||
{".java", "text/plain"},
|
||||
{".jpeg", "image/jpeg"},
|
||||
{".jpg", "image/jpeg"},
|
||||
{".js", "application/x-javascript"},
|
||||
{".log", "text/plain"},
|
||||
{".m3u", "audio/x-mpegurl"},
|
||||
{".m4a", "audio/mp4a-latm"},
|
||||
{".m4b", "audio/mp4a-latm"},
|
||||
{".m4p", "audio/mp4a-latm"},
|
||||
{".m4u", "video/vnd.mpegurl"},
|
||||
{".m4v", "video/x-m4v"},
|
||||
{".mov", "video/quicktime"},
|
||||
{".mp2", "audio/x-mpeg"},
|
||||
{".mp3", "audio/x-mpeg"},
|
||||
{".mp4", "video/mp4"},
|
||||
{".mpc", "application/vnd.mpohun.certificate"},
|
||||
{".mpe", "video/mpeg"},
|
||||
{".mpeg", "video/mpeg"},
|
||||
{".mpg", "video/mpeg"},
|
||||
{".mpg4", "video/mp4"},
|
||||
{".mpga", "audio/mpeg"},
|
||||
{".msg", "application/vnd.ms-outlook"},
|
||||
{".ogg", "audio/ogg"},
|
||||
{".pdf", "application/pdf"},
|
||||
{".png", "image/png"},
|
||||
{".pps", "application/vnd.ms-powerpoint"},
|
||||
{".ppt", "application/vnd.ms-powerpoint"},
|
||||
{".prop", "text/plain"},
|
||||
{".rar", "application/x-rar-compressed"},
|
||||
{".rc", "text/plain"},
|
||||
{".rmvb", "audio/x-pn-realaudio"},
|
||||
{".rtf", "application/rtf"},
|
||||
{".sh", "text/plain"},
|
||||
{".tar", "application/x-tar"},
|
||||
{".tgz", "application/x-compressed"},
|
||||
{".txt", "text/plain"},
|
||||
{".wav", "audio/x-wav"},
|
||||
{".wma", "audio/x-ms-wma"},
|
||||
{".wmv", "audio/x-ms-wmv"},
|
||||
{".wps", "application/vnd.ms-works"},
|
||||
{".xml", "text/plain"},
|
||||
{".z", "application/x-compress"},
|
||||
{".zip", "application/zip"},
|
||||
{"", "*/*"}
|
||||
};
|
||||
|
||||
/**
|
||||
* 读取图片属性:旋转的角度
|
||||
*
|
||||
* @param path 图片绝对路径
|
||||
* @return degree 旋转角度
|
||||
*/
|
||||
public static int readPictureDegree(String path) {
|
||||
int degree = 0;
|
||||
try {
|
||||
ExifInterface exifInterface = new ExifInterface(path);
|
||||
int orientation = exifInterface.getAttributeInt(
|
||||
ExifInterface.TAG_ORIENTATION,
|
||||
ExifInterface.ORIENTATION_NORMAL);
|
||||
switch (orientation) {
|
||||
case ExifInterface.ORIENTATION_ROTATE_90:
|
||||
degree = 90;
|
||||
break;
|
||||
case ExifInterface.ORIENTATION_ROTATE_180:
|
||||
degree = 180;
|
||||
break;
|
||||
case ExifInterface.ORIENTATION_ROTATE_270:
|
||||
degree = 270;
|
||||
break;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return degree;
|
||||
}
|
||||
|
||||
/**
|
||||
* 旋转图片
|
||||
*
|
||||
* @param angle 旋转角度
|
||||
* @param bitmap 原图
|
||||
* @return bitmap 旋转后的图片
|
||||
*/
|
||||
public static Bitmap rotateImage(int angle, Bitmap bitmap) {
|
||||
// 图片旋转矩阵
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.postRotate(angle);
|
||||
// 得到旋转后的图片
|
||||
return Bitmap.createBitmap(bitmap, 0, 0,
|
||||
bitmap.getWidth(), bitmap.getHeight(), matrix, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
package com.ycgis.macall.personalcenter.util;
|
||||
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.utils.LogUtils;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2024/1/17 16:55
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class IPAddressUtils {
|
||||
private static final String IPV4_BASIC_PATTERN_STRING = "(([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){1}(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){2}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])";
|
||||
private static final Pattern IPV4_PATTERN = Pattern.compile("^(([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){1}(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){2}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$");
|
||||
private static final Pattern IPV4_MAPPED_IPV6_PATTERN = Pattern.compile("^::[fF]{4}:(([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){1}(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){2}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$");
|
||||
private static final Pattern IPV6_STD_PATTERN = Pattern.compile("^[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){7}$");
|
||||
private static final Pattern IPV6_HEX_COMPRESSED_PATTERN = Pattern.compile("^(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)::(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)$");
|
||||
private static final char COLON_CHAR = ':';
|
||||
private static final int MAX_COLON_COUNT = 7;
|
||||
|
||||
private IPAddressUtils() {
|
||||
|
||||
}
|
||||
|
||||
public static boolean isIPv4Address(String input) {
|
||||
return IPV4_PATTERN.matcher(input).matches();
|
||||
}
|
||||
|
||||
public static boolean isIPv4MappedIPv64Address(String input) {
|
||||
return IPV4_MAPPED_IPV6_PATTERN.matcher(input).matches();
|
||||
}
|
||||
|
||||
public static boolean isIPv6StdAddress(String input) {
|
||||
return IPV6_STD_PATTERN.matcher(input).matches();
|
||||
}
|
||||
|
||||
public static boolean isIPv6HexCompressedAddress(String input) {
|
||||
int colonCount = 0;
|
||||
|
||||
for(int i = 0; i < input.length(); ++i) {
|
||||
if (input.charAt(i) == ':') {
|
||||
++colonCount;
|
||||
}
|
||||
}
|
||||
|
||||
return colonCount <= 7 && IPV6_HEX_COMPRESSED_PATTERN.matcher(input).matches();
|
||||
}
|
||||
|
||||
public static boolean isIPv6Address(String input) {
|
||||
return isIPv6StdAddress(input) || isIPv6HexCompressedAddress(input);
|
||||
}
|
||||
|
||||
public static String getLocalIpAddress() {
|
||||
List<String> list = new ArrayList<>();
|
||||
try {
|
||||
String ipv4;
|
||||
ArrayList<NetworkInterface> nilist = Collections.list(NetworkInterface.getNetworkInterfaces());
|
||||
for (NetworkInterface ni : nilist) {
|
||||
ArrayList<InetAddress> ialist = Collections.list(ni.getInetAddresses());
|
||||
for (InetAddress address : ialist) {
|
||||
if (!address.isLoopbackAddress()) {
|
||||
ipv4 = address.getHostAddress();
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
|
||||
if (isIPv4Address(ipv4)) {
|
||||
list.add(ipv4);
|
||||
// return ipv4;
|
||||
}
|
||||
} else {
|
||||
if (address instanceof Inet4Address) {
|
||||
list.add(ipv4);
|
||||
// return ipv4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!list.isEmpty()){
|
||||
if (list.size() ==1)
|
||||
return list.get(0);
|
||||
for (String ip :list) {
|
||||
if (ip.startsWith("127.0."))continue;
|
||||
if (ip.startsWith("192.168."))continue;
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
return ipAddress();
|
||||
} catch (SocketException ex) {
|
||||
Log.e("localip", ex.toString());
|
||||
return ipAddress();
|
||||
}
|
||||
}
|
||||
|
||||
public static String ipAddress() {
|
||||
try {
|
||||
for (final Enumeration<NetworkInterface> enumerationNetworkInterface = NetworkInterface.getNetworkInterfaces(); enumerationNetworkInterface.hasMoreElements(); ) {
|
||||
final NetworkInterface networkInterface = enumerationNetworkInterface.nextElement();
|
||||
for (Enumeration<InetAddress> enumerationInetAddress = networkInterface.getInetAddresses(); enumerationInetAddress.hasMoreElements(); ) {
|
||||
final InetAddress inetAddress = enumerationInetAddress.nextElement();
|
||||
final String ipAddress = inetAddress.getHostAddress();
|
||||
if (!inetAddress.isLoopbackAddress()){
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
|
||||
if (isIPv4Address(ipAddress)) {
|
||||
return ipAddress;
|
||||
}
|
||||
} else {
|
||||
if (inetAddress instanceof Inet4Address) {
|
||||
return ipAddress;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return "127.0.0.1";
|
||||
} catch (final Exception e) {
|
||||
LogUtils.e("获取Ip失败:" + e.getMessage());
|
||||
return "127.0.0.1";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,676 @@
|
|||
package com.ycgis.macall.personalcenter.util;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by Administrator on 2018/1/2.
|
||||
*/
|
||||
|
||||
public class IdcardUtils {
|
||||
/**
|
||||
* 中国公民身份证号码最小长度。
|
||||
*/
|
||||
public static final int CHINA_ID_MIN_LENGTH = 15;
|
||||
/**
|
||||
* 中国公民身份证号码最大长度。
|
||||
*/
|
||||
public static final int CHINA_ID_MAX_LENGTH = 18;
|
||||
/**
|
||||
* 省、直辖市代码表
|
||||
*/
|
||||
public static final String cityCode[] = {
|
||||
"11", "12", "13", "14", "15", "21", "22", "23", "31", "32", "33", "34", "35", "36", "37", "41",
|
||||
"42", "43", "44", "45", "46", "50", "51", "52", "53", "54", "61", "62", "63", "64", "65", "71",
|
||||
"81", "82", "91"
|
||||
};
|
||||
/**
|
||||
* 每位加权因子
|
||||
*/
|
||||
public static final int power[] = {
|
||||
7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2
|
||||
};
|
||||
/**
|
||||
* 第18位校检码
|
||||
*/
|
||||
public static final String verifyCode[] = {
|
||||
"1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"
|
||||
};
|
||||
/**
|
||||
* 最低年限
|
||||
*/
|
||||
public static final int MIN = 1930;
|
||||
public static Map<String, String> cityCodes = new HashMap<String, String>();
|
||||
/**
|
||||
* 台湾身份首字母对应数字
|
||||
*/
|
||||
public static Map<String, Integer> twFirstCode = new HashMap<String, Integer>();
|
||||
/**
|
||||
* 香港身份首字母对应数字
|
||||
*/
|
||||
public static Map<String, Integer> hkFirstCode = new HashMap<String, Integer>();
|
||||
|
||||
static {
|
||||
cityCodes.put("11", "北京");
|
||||
cityCodes.put("12", "天津");
|
||||
cityCodes.put("13", "河北");
|
||||
cityCodes.put("14", "山西");
|
||||
cityCodes.put("15", "内蒙古");
|
||||
cityCodes.put("21", "辽宁");
|
||||
cityCodes.put("22", "吉林");
|
||||
cityCodes.put("23", "黑龙江");
|
||||
cityCodes.put("31", "上海");
|
||||
cityCodes.put("32", "江苏");
|
||||
cityCodes.put("33", "浙江");
|
||||
cityCodes.put("34", "安徽");
|
||||
cityCodes.put("35", "福建");
|
||||
cityCodes.put("36", "江西");
|
||||
cityCodes.put("37", "山东");
|
||||
cityCodes.put("41", "河南");
|
||||
cityCodes.put("42", "湖北");
|
||||
cityCodes.put("43", "湖南");
|
||||
cityCodes.put("44", "广东");
|
||||
cityCodes.put("45", "广西");
|
||||
cityCodes.put("46", "海南");
|
||||
cityCodes.put("50", "重庆");
|
||||
cityCodes.put("51", "四川");
|
||||
cityCodes.put("52", "贵州");
|
||||
cityCodes.put("53", "云南");
|
||||
cityCodes.put("54", "西藏");
|
||||
cityCodes.put("61", "陕西");
|
||||
cityCodes.put("62", "甘肃");
|
||||
cityCodes.put("63", "青海");
|
||||
cityCodes.put("64", "宁夏");
|
||||
cityCodes.put("65", "新疆");
|
||||
cityCodes.put("71", "台湾");
|
||||
cityCodes.put("81", "香港");
|
||||
cityCodes.put("82", "澳门");
|
||||
cityCodes.put("91", "国外");
|
||||
twFirstCode.put("A", 10);
|
||||
twFirstCode.put("B", 11);
|
||||
twFirstCode.put("C", 12);
|
||||
twFirstCode.put("D", 13);
|
||||
twFirstCode.put("E", 14);
|
||||
twFirstCode.put("F", 15);
|
||||
twFirstCode.put("G", 16);
|
||||
twFirstCode.put("H", 17);
|
||||
twFirstCode.put("J", 18);
|
||||
twFirstCode.put("K", 19);
|
||||
twFirstCode.put("L", 20);
|
||||
twFirstCode.put("M", 21);
|
||||
twFirstCode.put("N", 22);
|
||||
twFirstCode.put("P", 23);
|
||||
twFirstCode.put("Q", 24);
|
||||
twFirstCode.put("R", 25);
|
||||
twFirstCode.put("S", 26);
|
||||
twFirstCode.put("T", 27);
|
||||
twFirstCode.put("U", 28);
|
||||
twFirstCode.put("V", 29);
|
||||
twFirstCode.put("X", 30);
|
||||
twFirstCode.put("Y", 31);
|
||||
twFirstCode.put("W", 32);
|
||||
twFirstCode.put("Z", 33);
|
||||
twFirstCode.put("I", 34);
|
||||
twFirstCode.put("O", 35);
|
||||
hkFirstCode.put("A", 1);
|
||||
hkFirstCode.put("B", 2);
|
||||
hkFirstCode.put("C", 3);
|
||||
hkFirstCode.put("R", 18);
|
||||
hkFirstCode.put("U", 21);
|
||||
hkFirstCode.put("Z", 26);
|
||||
hkFirstCode.put("X", 24);
|
||||
hkFirstCode.put("W", 23);
|
||||
hkFirstCode.put("O", 15);
|
||||
hkFirstCode.put("N", 14);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将15位身份证号码转换为18位
|
||||
*
|
||||
* @param idCard 15位身份编码
|
||||
* @return 18位身份编码
|
||||
*/
|
||||
public static String conver15CardTo18(String idCard) {
|
||||
String idCard18 = "";
|
||||
if (idCard.length() != CHINA_ID_MIN_LENGTH) {
|
||||
return idCard;
|
||||
}
|
||||
if (isNum(idCard)) {
|
||||
// 获取出生年月日
|
||||
String birthday = idCard.substring(6, 12);
|
||||
Date birthDate = null;
|
||||
try {
|
||||
birthDate = new SimpleDateFormat("yyMMdd").parse(birthday);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Calendar cal = Calendar.getInstance();
|
||||
if (birthDate != null)
|
||||
cal.setTime(birthDate);
|
||||
// 获取出生年(完全表现形式,如:2010)
|
||||
String sYear = String.valueOf(cal.get(Calendar.YEAR));
|
||||
idCard18 = idCard.substring(0, 6) + sYear + idCard.substring(8);
|
||||
// 转换字符数组
|
||||
char[] cArr = idCard18.toCharArray();
|
||||
if (cArr != null) {
|
||||
int[] iCard = converCharToInt(cArr);
|
||||
int iSum17 = getPowerSum(iCard);
|
||||
// 获取校验位
|
||||
String sVal = getCheckCode18(iSum17);
|
||||
if (sVal.length() > 0) {
|
||||
idCard18 += sVal;
|
||||
} else {
|
||||
return idCard;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return idCard;
|
||||
}
|
||||
return idCard18;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证身份证是否合法
|
||||
*/
|
||||
public static boolean validateCard15(String idCard) {
|
||||
String card = idCard.trim();
|
||||
if (validateIdCard18(card)) {
|
||||
return true;
|
||||
}
|
||||
//15位的不可查
|
||||
if (validateIdCard15(card)) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 验证身份证是否合法
|
||||
*/
|
||||
public static boolean validateCard(String idCard) {
|
||||
String card = idCard.trim();
|
||||
if (validateIdCard18(card)) {
|
||||
return true;
|
||||
}
|
||||
// //15位的不可查
|
||||
// if (validateIdCard15(card)) {
|
||||
// return false;
|
||||
// }
|
||||
if (card.length() == 8) {
|
||||
return false;
|
||||
}
|
||||
String[] cardval = validateIdCard10(card);
|
||||
if (cardval != null) {
|
||||
if (cardval[2].equals("true")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证18位身份编码是否合法
|
||||
*
|
||||
* @param idCard 身份编码
|
||||
* @return 是否合法
|
||||
*/
|
||||
public static boolean validateIdCard18(String idCard) {
|
||||
boolean bTrue = false;
|
||||
if (idCard.length() == CHINA_ID_MAX_LENGTH) {
|
||||
// 前17位
|
||||
String code17 = idCard.substring(0, 17);
|
||||
// 第18位
|
||||
String code18 = idCard.substring(17, CHINA_ID_MAX_LENGTH);
|
||||
if (isNum(code17)) {
|
||||
char[] cArr = code17.toCharArray();
|
||||
if (cArr != null) {
|
||||
int[] iCard = converCharToInt(cArr);
|
||||
int iSum17 = getPowerSum(iCard);
|
||||
// 获取校验位
|
||||
String val = getCheckCode18(iSum17);
|
||||
if (val.length() > 0) {
|
||||
if (val.equalsIgnoreCase(code18)) {
|
||||
bTrue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return bTrue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证15位身份编码是否合法
|
||||
*
|
||||
* @param idCard 身份编码
|
||||
* @return 是否合法
|
||||
*/
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
public static boolean validateIdCard15(String idCard) {
|
||||
if (idCard.length() != CHINA_ID_MIN_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
if (isNum(idCard)) {
|
||||
String proCode = idCard.substring(0, 2);
|
||||
if (cityCodes.get(proCode) == null) {
|
||||
return false;
|
||||
}
|
||||
String birthCode = idCard.substring(6, 12);
|
||||
Date birthDate = null;
|
||||
try {
|
||||
birthDate = new SimpleDateFormat("yy").parse(birthCode.substring(0, 2));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Calendar cal = Calendar.getInstance();
|
||||
if (birthDate != null)
|
||||
cal.setTime(birthDate);
|
||||
try {
|
||||
if (!valiDate(cal.get(Calendar.YEAR), Integer.parseInt(birthCode.substring(2, 4)),
|
||||
Integer.parseInt(birthCode.substring(4, 6)))) {
|
||||
return false;
|
||||
}
|
||||
}catch (NumberFormatException e){
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证10位身份编码是否合法
|
||||
*
|
||||
* @param idCard 身份编码
|
||||
* @return 身份证信息数组
|
||||
* <p>
|
||||
* [0] - 台湾、澳门、香港 [1] - 性别(男M,女F,未知N) [2] - 是否合法(合法true,不合法false)
|
||||
* 若不是身份证件号码则返回null
|
||||
* </p>
|
||||
*/
|
||||
public static String[] validateIdCard10(String idCard) {
|
||||
String[] info = new String[3];
|
||||
String card = idCard.replaceAll("[\\(|\\)]", "");
|
||||
if (card.length() != 8 && card.length() != 9 && idCard.length() != 10) {
|
||||
return null;
|
||||
}
|
||||
if (idCard.matches("^[a-zA-Z][0-9]{9}$")) { // 台湾
|
||||
info[0] = "台湾";
|
||||
System.out.println("11111");
|
||||
String char2 = idCard.substring(1, 2);
|
||||
if (char2.equals("1")) {
|
||||
info[1] = "M";
|
||||
System.out.println("MMMMMMM");
|
||||
} else if (char2.equals("2")) {
|
||||
info[1] = "F";
|
||||
System.out.println("FFFFFFF");
|
||||
} else {
|
||||
info[1] = "N";
|
||||
info[2] = "false";
|
||||
System.out.println("NNNN");
|
||||
return info;
|
||||
}
|
||||
info[2] = validateTWCard(idCard) ? "true" : "false";
|
||||
} else if (idCard.matches("^[1|5|7][0-9]{6}\\(?[0-9A-Z]\\)?$")) { // 澳门
|
||||
info[0] = "澳门";
|
||||
info[1] = "N";
|
||||
// TODO
|
||||
} else if (idCard.matches("^[A-Z]{1,2}[0-9]{6}\\(?[0-9A]\\)?$")) { // 香港
|
||||
info[0] = "香港";
|
||||
info[1] = "N";
|
||||
info[2] = validateHKCard(idCard) ? "true" : "false";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证台湾身份证号码
|
||||
*
|
||||
* @param idCard 身份证号码
|
||||
* @return 验证码是否符合
|
||||
*/
|
||||
public static boolean validateTWCard(String idCard) {
|
||||
String start = idCard.substring(0, 1);
|
||||
String mid = idCard.substring(1, 9);
|
||||
String end = idCard.substring(9, 10);
|
||||
Integer iStart = twFirstCode.get(start);
|
||||
Integer sum = iStart / 10 + (iStart % 10) * 9;
|
||||
char[] chars = mid.toCharArray();
|
||||
Integer iflag = 8;
|
||||
for (char c : chars) {
|
||||
sum = sum + Integer.valueOf(c + "") * iflag;
|
||||
iflag--;
|
||||
}
|
||||
return (sum % 10 == 0 ? 0 : (10 - sum % 10)) == Integer.valueOf(end) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证香港身份证号码(存在Bug,部份特殊身份证无法检查)
|
||||
* <p>
|
||||
* 身份证前2位为英文字符,如果只出现一个英文字符则表示第一位是空格,对应数字58 前2位英文字符A-Z分别对应数字10-35
|
||||
* 最后一位校验码为0-9的数字加上字符"A","A"代表10
|
||||
* </p>
|
||||
* <p>
|
||||
* 将身份证号码全部转换为数字,分别对应乘9-1相加的总和,整除11则证件号码有效
|
||||
* </p>
|
||||
*
|
||||
* @param idCard 身份证号码
|
||||
* @return 验证码是否符合
|
||||
*/
|
||||
public static boolean validateHKCard(String idCard) {
|
||||
String card = idCard.replaceAll("[\\(|\\)]", "");
|
||||
Integer sum = 0;
|
||||
if (card.length() == 9) {
|
||||
sum = (Integer.valueOf(card.substring(0, 1).toUpperCase().toCharArray()[0]) - 55) * 9
|
||||
+ (Integer.valueOf(card.substring(1, 2).toUpperCase().toCharArray()[0]) - 55) * 8;
|
||||
card = card.substring(1, 9);
|
||||
} else {
|
||||
sum = 522 + (Integer.valueOf(card.substring(0, 1).toUpperCase().toCharArray()[0]) - 55) * 8;
|
||||
}
|
||||
String mid = card.substring(1, 7);
|
||||
String end = card.substring(7, 8);
|
||||
char[] chars = mid.toCharArray();
|
||||
Integer iflag = 7;
|
||||
for (char c : chars) {
|
||||
sum = sum + Integer.valueOf(c + "") * iflag;
|
||||
iflag--;
|
||||
}
|
||||
if (end.toUpperCase().equals("A")) {
|
||||
sum = sum + 10;
|
||||
} else {
|
||||
sum = sum + Integer.valueOf(end);
|
||||
}
|
||||
return (sum % 11 == 0) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符数组转换成数字数组
|
||||
*
|
||||
* @param ca 字符数组
|
||||
* @return 数字数组
|
||||
*/
|
||||
public static int[] converCharToInt(char[] ca) {
|
||||
int len = ca.length;
|
||||
int[] iArr = new int[len];
|
||||
try {
|
||||
for (int i = 0; i < len; i++) {
|
||||
iArr[i] = Integer.parseInt(String.valueOf(ca[i]));
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return iArr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将身份证的每位和对应位的加权因子相乘之后,再得到和值
|
||||
*
|
||||
* @param iArr
|
||||
* @return 身份证编码。
|
||||
*/
|
||||
public static int getPowerSum(int[] iArr) {
|
||||
int iSum = 0;
|
||||
if (power.length == iArr.length) {
|
||||
for (int i = 0; i < iArr.length; i++) {
|
||||
for (int j = 0; j < power.length; j++) {
|
||||
if (i == j) {
|
||||
iSum = iSum + iArr[i] * power[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return iSum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将power和值与11取模获得余数进行校验码判断
|
||||
*
|
||||
* @param iSum
|
||||
* @return 校验位
|
||||
*/
|
||||
public static String getCheckCode18(int iSum) {
|
||||
String sCode = "";
|
||||
switch (iSum % 11) {
|
||||
case 10:
|
||||
sCode = "2";
|
||||
break;
|
||||
case 9:
|
||||
sCode = "3";
|
||||
break;
|
||||
case 8:
|
||||
sCode = "4";
|
||||
break;
|
||||
case 7:
|
||||
sCode = "5";
|
||||
break;
|
||||
case 6:
|
||||
sCode = "6";
|
||||
break;
|
||||
case 5:
|
||||
sCode = "7";
|
||||
break;
|
||||
case 4:
|
||||
sCode = "8";
|
||||
break;
|
||||
case 3:
|
||||
sCode = "9";
|
||||
break;
|
||||
case 2:
|
||||
sCode = "X";
|
||||
break;
|
||||
case 1:
|
||||
sCode = "0";
|
||||
break;
|
||||
case 0:
|
||||
sCode = "1";
|
||||
break;
|
||||
}
|
||||
return sCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据身份编号获取年龄
|
||||
*
|
||||
* @param idCard 身份编号
|
||||
* @return 年龄
|
||||
*/
|
||||
public static int getAgeByIdCard(String idCard) {
|
||||
int iAge = 0;
|
||||
if (idCard.length() == CHINA_ID_MIN_LENGTH) {
|
||||
idCard = conver15CardTo18(idCard);
|
||||
}
|
||||
String year = idCard.substring(6, 10);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int iCurrYear = cal.get(Calendar.YEAR);
|
||||
iAge = iCurrYear - Integer.valueOf(year);
|
||||
return iAge;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据身份编号获取生日
|
||||
*
|
||||
* @param idCard 身份编号
|
||||
* @return 生日(yyyyMMdd)
|
||||
*/
|
||||
public static String getBirthByIdCard(String idCard) {
|
||||
Integer len = idCard.length();
|
||||
if (len < CHINA_ID_MIN_LENGTH) {
|
||||
return null;
|
||||
} else if (len == CHINA_ID_MIN_LENGTH) {
|
||||
idCard = conver15CardTo18(idCard);
|
||||
}
|
||||
return idCard.substring(6, 14);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据身份编号获取生日年
|
||||
*
|
||||
* @param idCard 身份编号
|
||||
* @return 生日(yyyy)
|
||||
*/
|
||||
public static Short getYearByIdCard(String idCard) {
|
||||
Integer len = idCard.length();
|
||||
if (len < CHINA_ID_MIN_LENGTH) {
|
||||
return null;
|
||||
} else if (len == CHINA_ID_MIN_LENGTH) {
|
||||
idCard = conver15CardTo18(idCard);
|
||||
}
|
||||
return Short.valueOf(idCard.substring(6, 10));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据身份编号获取生日月
|
||||
*
|
||||
* @param idCard 身份编号
|
||||
* @return 生日(MM)
|
||||
*/
|
||||
public static Short getMonthByIdCard(String idCard) {
|
||||
Integer len = idCard.length();
|
||||
if (len < CHINA_ID_MIN_LENGTH) {
|
||||
return null;
|
||||
} else if (len == CHINA_ID_MIN_LENGTH) {
|
||||
idCard = conver15CardTo18(idCard);
|
||||
}
|
||||
return Short.valueOf(idCard.substring(10, 12));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据身份编号获取生日天
|
||||
*
|
||||
* @param idCard 身份编号
|
||||
* @return 生日(dd)
|
||||
*/
|
||||
public static Short getDateByIdCard(String idCard) {
|
||||
Integer len = idCard.length();
|
||||
if (len < CHINA_ID_MIN_LENGTH) {
|
||||
return null;
|
||||
} else if (len == CHINA_ID_MIN_LENGTH) {
|
||||
idCard = conver15CardTo18(idCard);
|
||||
}
|
||||
return Short.valueOf(idCard.substring(12, 14));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据身份编号获取性别
|
||||
*
|
||||
* @param idCard 身份编号
|
||||
* @return 性别(M - icon_man , F - icon_woman , N - 未知)
|
||||
*/
|
||||
public static String getGenderByIdCard(String idCard) {
|
||||
String sGender = "N";
|
||||
if (StringUtil.isNullOrEmpty(idCard)||idCard.length()<15){
|
||||
return sGender;
|
||||
}
|
||||
if (idCard.length() == CHINA_ID_MIN_LENGTH) {
|
||||
idCard = conver15CardTo18(idCard);
|
||||
}
|
||||
String sCardNum = idCard.substring(16, 17);
|
||||
if (Integer.parseInt(sCardNum) % 2 != 0) {
|
||||
sGender = "M";
|
||||
} else {
|
||||
sGender = "F";
|
||||
}
|
||||
return sGender;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据身份编号获取户籍省份
|
||||
*
|
||||
* @param idCard 身份编码
|
||||
* @return 省级编码。
|
||||
*/
|
||||
public static String getProvinceByIdCard(String idCard) {
|
||||
int len = idCard.length();
|
||||
String sProvince = null;
|
||||
String sProvinNum = "";
|
||||
if (len == CHINA_ID_MIN_LENGTH || len == CHINA_ID_MAX_LENGTH) {
|
||||
sProvinNum = idCard.substring(0, 2);
|
||||
}
|
||||
sProvince = cityCodes.get(sProvinNum);
|
||||
return sProvince;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是身份证开头
|
||||
*
|
||||
* @param idCard 要判断的身份证号
|
||||
* @return null 或者省份
|
||||
*/
|
||||
public static String isStartIdCard(String idCard) {
|
||||
if (idCard == null) return null;
|
||||
if (idCard.length() < 2) return null;
|
||||
String sProvinNum = idCard.substring(0, 2);
|
||||
return cityCodes.get(sProvinNum);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数字验证
|
||||
*
|
||||
* @param val 需要验证的字符串
|
||||
*/
|
||||
public static boolean isNum(String val) {
|
||||
return val != null && !"".equals(val) && val.matches("^[0-9]*$");
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证小于当前日期 是否有效
|
||||
*
|
||||
* @param iYear 待验证日期(年)
|
||||
* @param iMonth 待验证日期(月 1-12)
|
||||
* @param iDate 待验证日期(日)
|
||||
* @return 是否有效
|
||||
*/
|
||||
public static boolean valiDate(int iYear, int iMonth, int iDate) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int year = cal.get(Calendar.YEAR);
|
||||
int datePerMonth;
|
||||
if (iYear < MIN || iYear >= year) {
|
||||
return false;
|
||||
}
|
||||
if (iMonth < 1 || iMonth > 12) {
|
||||
return false;
|
||||
}
|
||||
switch (iMonth) {
|
||||
case 4:
|
||||
case 6:
|
||||
case 9:
|
||||
case 11:
|
||||
datePerMonth = 30;
|
||||
break;
|
||||
case 2:
|
||||
boolean dm = ((iYear % 4 == 0 && iYear % 100 != 0) || (iYear % 400 == 0))
|
||||
&& (iYear > MIN && iYear < year);
|
||||
datePerMonth = dm ? 29 : 28;
|
||||
break;
|
||||
default:
|
||||
datePerMonth = 31;
|
||||
}
|
||||
return (iDate >= 1) && (iDate <= datePerMonth);
|
||||
}
|
||||
|
||||
public static boolean isCarnumberNO(String carnumber) {
|
||||
if (StringUtil.isNullOrEmpty(carnumber)) return false;
|
||||
String carnumRegex = "([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF])|([DF]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1})";
|
||||
return carnumber.matches(carnumRegex);
|
||||
}
|
||||
|
||||
public static boolean isWan(String cph) {
|
||||
if (StringUtil.isNullOrEmpty(cph)) return false;
|
||||
String ss = "^[A-Z]";
|
||||
return cph.matches(ss);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,197 @@
|
|||
package com.ycgis.macall.personalcenter.util;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorSpace;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.utils.BitMapUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2024/1/11 9:09
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class ImageOptimizationUtil {
|
||||
// 阈值0-255
|
||||
public static int YZ = 200;
|
||||
|
||||
/**
|
||||
* 图像二值化处理
|
||||
*
|
||||
* @param filePath 要处理的图片路径
|
||||
* @param fileOutputPath 处理后的图片输出路径
|
||||
*/
|
||||
public static void binarization(String filePath, String fileOutputPath) throws IOException {
|
||||
// File file = new File(filePath);
|
||||
Bitmap bitmap = BitmapFactory.decodeFile(filePath);
|
||||
// BufferedImage bi = ImageIO.read(file);
|
||||
// 获取当前图片的高,宽,ARGB
|
||||
int h = bitmap.getHeight();
|
||||
int w = bitmap.getWidth();
|
||||
int arr[][] = new int[w][h];
|
||||
|
||||
// 获取图片每一像素点的灰度值
|
||||
for (int i = 0; i < w; i++) {
|
||||
for (int j = 0; j < h; j++) {
|
||||
// getRGB()返回默认的RGB颜色模型(十进制)
|
||||
arr[i][j] = getImageGray(bitmap.getPixel(i, j));// 该点的灰度值
|
||||
}
|
||||
}
|
||||
Bitmap bitmaps = Bitmap.createBitmap(w, h,
|
||||
Bitmap.Config.ARGB_8888);
|
||||
// 构造一个类型为预定义图像类型,BufferedImage
|
||||
// BufferedImage bufferedImage = new BufferedImage(w, h, BufferedImage.TYPE_BYTE_BINARY);
|
||||
|
||||
// 和预先设置的阈值大小进行比较,大的就显示为255即白色,小的就显示为0即黑色
|
||||
for (int i = 0; i < w; i++) {
|
||||
for (int j = 0; j < h; j++) {
|
||||
if (getGray(arr, i, j, w, h) > YZ) {
|
||||
int rgb = Color.rgb(255, 255, 255);
|
||||
// int rgb = new Color(255, 255, 255).getRGB();
|
||||
bitmaps.setPixel(i, j, rgb);
|
||||
} else {
|
||||
int black = Color.rgb(0, 0, 0);
|
||||
// int black = new Color(0, 0, 0).getRGB();
|
||||
bitmaps.setPixel(i, j, black);
|
||||
}
|
||||
}
|
||||
}
|
||||
BitMapUtils.saveBitmapFile(bitmap,new File(fileOutputPath));
|
||||
}
|
||||
|
||||
/**
|
||||
* 图像的灰度处理
|
||||
* 利用浮点算法:Gray = R*0.3 + G*0.59 + B*0.11;
|
||||
*
|
||||
* @param rgb 该点的RGB值
|
||||
* @return 返回处理后的灰度值
|
||||
*/
|
||||
private static int getImageGray(int rgb) {
|
||||
String argb = Integer.toHexString(rgb);// 将十进制的颜色值转为十六进制
|
||||
// argb分别代表透明,红,绿,蓝 分别占16进制2位
|
||||
int r = Integer.parseInt(argb.substring(2, 4), 16);// 后面参数为使用进制
|
||||
int g = Integer.parseInt(argb.substring(4, 6), 16);
|
||||
int b = Integer.parseInt(argb.substring(6, 8), 16);
|
||||
int gray = (int) (r*0.28 + g*0.95 + b*0.11);
|
||||
return gray;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自己加周围8个灰度值再除以9,算出其相对灰度值
|
||||
*
|
||||
* @param gray
|
||||
* @param x 要计算灰度的点的横坐标
|
||||
* @param y 要计算灰度的点的纵坐标
|
||||
* @param w 图像的宽度
|
||||
* @param h 图像的高度
|
||||
* @return
|
||||
*/
|
||||
public static int getGray(int gray[][], int x, int y, int w, int h) {
|
||||
int rs = gray[x][y] + (x == 0 ? 255 : gray[x - 1][y]) + (x == 0 || y == 0 ? 255 : gray[x - 1][y - 1])
|
||||
+ (x == 0 || y == h - 1 ? 255 : gray[x - 1][y + 1]) + (y == 0 ? 255 : gray[x][y - 1])
|
||||
+ (y == h - 1 ? 255 : gray[x][y + 1]) + (x == w - 1 ? 255 : gray[x + 1][y])
|
||||
+ (x == w - 1 || y == 0 ? 255 : gray[x + 1][y - 1])
|
||||
+ (x == w - 1 || y == h - 1 ? 255 : gray[x + 1][y + 1]);
|
||||
return rs / 9;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 二值化后的图像的开运算:先腐蚀再膨胀(用于去除图像的小黑点)
|
||||
// *
|
||||
// * @param filePath 要处理的图片路径
|
||||
// * @param fileOutputPath 处理后的图片输出路径
|
||||
// * @throws IOException
|
||||
// */
|
||||
// public static void opening(String filePath, String fileOutputPath) throws IOException {
|
||||
// File file = new File(filePath);
|
||||
// BufferedImage bi = ImageIO.read(file);
|
||||
// // 获取当前图片的高,宽,ARGB
|
||||
// int h = bi.getHeight();
|
||||
// int w = bi.getWidth();
|
||||
// int arr[][] = new int[w][h];
|
||||
// // 获取图片每一像素点的灰度值
|
||||
// for (int i = 0; i < w; i++) {
|
||||
// for (int j = 0; j < h; j++) {
|
||||
// // getRGB()返回默认的RGB颜色模型(十进制)
|
||||
// arr[i][j] = getImageGray(bi.getRGB(i, j));// 该点的灰度值
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// int black = new Color(0, 0, 0).getRGB();
|
||||
// int white = new Color(255, 255, 255).getRGB();
|
||||
// BufferedImage bufferedImage = new BufferedImage(w, h, BufferedImage.TYPE_BYTE_BINARY);
|
||||
// // 临时存储腐蚀后的各个点的亮度
|
||||
// int temp[][] = new int[w][h];
|
||||
// // 1.先进行腐蚀操作
|
||||
// for (int i = 0; i < w; i++) {
|
||||
// for (int j = 0; j < h; j++) {
|
||||
// /*
|
||||
// * 为0表示改点和周围8个点都是黑,则该点腐蚀操作后为黑
|
||||
// * 由于公司图片态模糊,完全达到9个点全为黑的点太少,最后效果很差,故改为了小于30
|
||||
// * (写30的原因是,当只有一个点为白,即总共255,调用getGray方法后得到255/9 = 28)
|
||||
// */
|
||||
// if (getGray(arr, i, j, w, h) < 30) {
|
||||
// temp[i][j] = 0;
|
||||
// } else{
|
||||
// temp[i][j] = 255;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 2.再进行膨胀操作
|
||||
// for (int i = 0; i < w; i++) {
|
||||
// for (int j = 0; j < h; j++) {
|
||||
// bufferedImage.setRGB(i, j, white);
|
||||
// }
|
||||
// }
|
||||
// for (int i = 0; i < w; i++) {
|
||||
// for (int j = 0; j < h; j++) {
|
||||
// // 为0表示改点和周围8个点都是黑,则该点腐蚀操作后为黑
|
||||
// if (temp[i][j] == 0) {
|
||||
// bufferedImage.setRGB(i, j, black);
|
||||
// if(i > 0) {
|
||||
// bufferedImage.setRGB(i-1, j, black);
|
||||
// }
|
||||
// if (j > 0) {
|
||||
// bufferedImage.setRGB(i, j-1, black);
|
||||
// }
|
||||
// if (i > 0 && j > 0) {
|
||||
// bufferedImage.setRGB(i-1, j-1, black);
|
||||
// }
|
||||
// if (j < h-1) {
|
||||
// bufferedImage.setRGB(i, j+1, black);
|
||||
// }
|
||||
// if (i < w-1) {
|
||||
// bufferedImage.setRGB(i+1, j, black);
|
||||
// }
|
||||
// if (i < w-1 && j > 0) {
|
||||
// bufferedImage.setRGB(i+1, j-1, black);
|
||||
// }
|
||||
// if (i < w-1 && j < h-1) {
|
||||
// bufferedImage.setRGB(i+1, j+1, black);
|
||||
// }
|
||||
// if (i > 0 && j < h-1) {
|
||||
// bufferedImage.setRGB(i-1, j+1, black);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// ImageIO.write(bufferedImage, "jpeg", new File(fileOutputPath));
|
||||
// }
|
||||
|
||||
public static void main(String[] args) {
|
||||
String fullPath="code.jpeg";
|
||||
String newPath="code2.jpeg";
|
||||
try {
|
||||
ImageOptimizationUtil.binarization(fullPath,newPath);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
package com.ycgis.macall.personalcenter.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/2/2 15:33
|
||||
* copyright: @ruansee.com
|
||||
* Describe: 安装应用
|
||||
*/
|
||||
public class InsertAppUtils {
|
||||
|
||||
/**
|
||||
* 检测是否安装应用
|
||||
* @param context 上下文环境
|
||||
* @return true 未安装 false 安装
|
||||
*/
|
||||
public boolean isInspectStaticFaceSDK(Context context) {
|
||||
PackageInfo packageInfo = null;
|
||||
try {
|
||||
packageInfo = context.getPackageManager().getPackageInfo("com.ruansee.unifiedservicecomponent", 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
packageInfo = null;
|
||||
e.printStackTrace();
|
||||
}
|
||||
return packageInfo == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测本地安装的版本是否需要更是
|
||||
* @param context 上下文环境
|
||||
* @return true 不需要更新 false 需要安装
|
||||
*/
|
||||
public boolean isUpdateStaticFaceSDK(Context context) {
|
||||
PackageInfo packageInfo = null;
|
||||
try {
|
||||
//读取本地组件版本号,版本号
|
||||
packageInfo = context.getPackageManager().getPackageInfo("com.ruansee.unifiedservicecomponent", 0);
|
||||
if (packageInfo == null) return false;
|
||||
//这是新版本的 版本号
|
||||
int nweCode = 2;
|
||||
// 满足条件说明 本地安装的是最新版 返回true
|
||||
return packageInfo.versionCode>=nweCode;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
packageInfo = null;
|
||||
e.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//申请应用安装权限后安装应用
|
||||
public void installApp(String titleMessage, Activity context, File file, DialogInterface.OnClickListener cancelClickListener) throws Exception {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
boolean isGranted = context.getPackageManager().canRequestPackageInstalls();
|
||||
if (!isGranted) {
|
||||
applyInstallPermission(context,titleMessage, cancelClickListener);
|
||||
} else {
|
||||
instead(context, file);
|
||||
}
|
||||
} else {
|
||||
instead(context, file);
|
||||
}
|
||||
}
|
||||
|
||||
//申请应用安装权限
|
||||
public void applyInstallPermission(Activity context, String titleMessage,DialogInterface.OnClickListener cancelClickListener) {
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle("重要提示")
|
||||
.setMessage(titleMessage)
|
||||
.setCancelable(false)
|
||||
.setNegativeButton("取消", cancelClickListener)
|
||||
.setPositiveButton("继续", (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES);
|
||||
context.startActivityForResult(intent, 1023);
|
||||
}).create().show();
|
||||
}
|
||||
|
||||
|
||||
private void instead(Activity context, File file) throws Exception {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
Uri apkUri = UriUtils.getUri(context, file);
|
||||
intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
context.startActivityForResult(intent, 10145);
|
||||
} else {
|
||||
context.startActivityForResult(intent, 10145);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
package com.ycgis.macall.personalcenter.util;
|
||||
|
||||
import com.base.code.binary.Base64;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.SecretKeyFactory;
|
||||
import javax.crypto.spec.DESKeySpec;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2022/11/1 9:42
|
||||
* copyright: @ruansee.com
|
||||
* Describe:
|
||||
*/
|
||||
public class JiaMi {
|
||||
|
||||
/**
|
||||
* 根据 key 加密 data , 并将加密后的数据进行Base64转码
|
||||
* @param data 待加密的数据
|
||||
* @param id id
|
||||
* @param secret 秘钥
|
||||
* @return Base64字符
|
||||
*/
|
||||
public static String desCrypto(byte[] data, String id,String secret) {
|
||||
return desCrypto(data,String.format("%s:%s",id,secret));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 key 加密 data , 并将加密后的数据进行Base64转码
|
||||
* @param data 待加密的数据
|
||||
* @param key 加密的KEY
|
||||
* @return Base64字符
|
||||
*/
|
||||
public static String desCrypto(byte[] data, String key) {
|
||||
try{
|
||||
SecureRandom random = new SecureRandom();
|
||||
DESKeySpec desKey = new DESKeySpec(key.getBytes());
|
||||
//创建一个密匙工厂,然后用它把DESKeySpec转换成
|
||||
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
|
||||
SecretKey securekey = keyFactory.generateSecret(desKey);
|
||||
//Cipher对象实际完成加密操作
|
||||
Cipher cipher = Cipher.getInstance("DES");
|
||||
//用密匙初始化Cipher对象
|
||||
cipher.init(Cipher.ENCRYPT_MODE, securekey, random);
|
||||
//现在,获取数据并加密
|
||||
//正式执行加密操作
|
||||
byte[] bytes = cipher.doFinal(data);
|
||||
//进行Base64转码
|
||||
return Base64.encodeBase64String(bytes);
|
||||
}catch(Throwable e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* DES 解密
|
||||
* @param data 加密后的字符
|
||||
* @param key key
|
||||
* @return 解密后的数据
|
||||
* @throws Exception 异常信息
|
||||
*/
|
||||
public static byte[] decrypt(byte[] data, String key) throws Exception {
|
||||
// DES算法要求有一个可信任的随机数源
|
||||
SecureRandom random = new SecureRandom();
|
||||
// 创建一个DESKeySpec对象
|
||||
DESKeySpec desKey = new DESKeySpec(key.getBytes());
|
||||
// 创建一个密匙工厂
|
||||
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
|
||||
// 将DESKeySpec对象转换成SecretKey对象
|
||||
SecretKey securekey = keyFactory.generateSecret(desKey);
|
||||
// Cipher对象实际完成解密操作
|
||||
Cipher cipher = Cipher.getInstance("DES");
|
||||
// 用密匙初始化Cipher对象
|
||||
cipher.init(Cipher.DECRYPT_MODE, securekey, random);
|
||||
// 真正开始解密操作
|
||||
return cipher.doFinal(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* DES 解密
|
||||
* @param encryptData 加密后的字符
|
||||
* @param key key
|
||||
* @return 解密后的数据
|
||||
* @throws Exception 异常信息
|
||||
*/
|
||||
public static String decrypt(String encryptData, String key) throws Exception {
|
||||
byte[] data = Base64.decodeBase64(encryptData);
|
||||
byte[] decrypt = decrypt(data, key);
|
||||
return new String(decrypt,"UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* DES 解密
|
||||
* @param encryptData 加密后的字符
|
||||
* @param id ID
|
||||
* @param secret 秘钥
|
||||
* @return 解密后的数据
|
||||
* @throws Exception 异常信息
|
||||
*/
|
||||
public static String decrypt(String encryptData, String id,String secret) throws Exception {
|
||||
byte[] data = Base64.decodeBase64(encryptData);
|
||||
byte[] decrypt = decrypt(data, String.format("%s:%s",id,secret));
|
||||
return new String(decrypt,"UTF-8");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,381 @@
|
|||
package com.ycgis.macall.personalcenter.util;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Criteria;
|
||||
import android.location.GnssStatus;
|
||||
import android.location.GpsSatellite;
|
||||
import android.location.GpsStatus;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.location.LocationProvider;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.utils.LogUtils;
|
||||
import com.ycgis.macall.personalcenter.p.app.RuanseeApplication;
|
||||
import com.ycgis.macall.personalcenter.p.callback.GPSLocationListener;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* created by: Macall
|
||||
* create time: 2023/3/28 9:30
|
||||
* copyright: @ruansee.com
|
||||
* Describe: 封装了GPS定位工具类 该类实现了 LifecycleObserver 用于监听 Activity 和 Fragment 的生命周期
|
||||
* 避免因退出页面而忘记关闭定位导致应用耗时增加的问题
|
||||
* TODO @see #onDestroy(LifecycleOwner) 使用时请在调用者(Activity 或 Fragment ) 调用如下代码
|
||||
* TODO { getLifecycle().addObserver(locationGPSManage) }
|
||||
*/
|
||||
public class LocationGPSManage implements LifecycleObserver {
|
||||
private static LocationGPSManage locationGPSManage;
|
||||
private LocationManager locationManager;
|
||||
private boolean isLocation = false;
|
||||
private MyLocationListener locationListener;
|
||||
private MyGPSListener gpsListener;
|
||||
private GnssStatus.Callback gnssStatusCallback;
|
||||
|
||||
/**
|
||||
* 记录上次搜索到的卫星数
|
||||
*/
|
||||
private int startCount = -1;
|
||||
|
||||
private List<GPSLocationListener> locationListenerList;
|
||||
|
||||
/**
|
||||
* 该方法不需要手动调用
|
||||
* 宿主执行了onDestroy时 会分发该事件
|
||||
* 使用时请在宿主(Activity 或 Fragment ) 中调用如下代码,调用后当 宿主执行什么周期方法 onDestroy 该方法自动被调用
|
||||
* { getLifecycle().addObserver(locationGPSManage) }
|
||||
*/
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
||||
void onDestroy(@NotNull LifecycleOwner owner) {
|
||||
stopLocation();
|
||||
}
|
||||
|
||||
private LocationGPSManage() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加一个位置监听
|
||||
*
|
||||
* @param gpsLocationListener 监听接口实例对象
|
||||
*/
|
||||
@NotNull
|
||||
public void addGPSLocationListener(@NotNull GPSLocationListener gpsLocationListener) {
|
||||
if (locationListenerList == null) {
|
||||
locationListenerList = new ArrayList<>();
|
||||
}
|
||||
if (locationListenerList.contains(gpsLocationListener)) return;
|
||||
locationListenerList.add(gpsLocationListener);
|
||||
}
|
||||
|
||||
public static synchronized LocationGPSManage getInstance() {
|
||||
if (locationGPSManage == null) {
|
||||
synchronized (LocationGPSManage.class) {
|
||||
if (locationGPSManage == null) {
|
||||
locationGPSManage = new LocationGPSManage();
|
||||
}
|
||||
}
|
||||
}
|
||||
return locationGPSManage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启定位
|
||||
*
|
||||
* @param context 上下文环境
|
||||
* @param gpsLocationListener 位置监听,也可以调用{@link #addGPSLocationListener(GPSLocationListener)}方法传递
|
||||
* @throws RuntimeException 要先获取定位权限,否则将抛出异常
|
||||
*/
|
||||
@SuppressLint("MissingPermission")
|
||||
public void startGPSLocation(Context context, GPSLocationListener gpsLocationListener) throws RuntimeException {
|
||||
boolean gpsPermission = isGPSPermission(context);
|
||||
if (!gpsPermission)
|
||||
throw new RuntimeException("Not ACCESS_FINE_LOCATION AND ACCESS_COARSE_LOCATION Permission");
|
||||
//避免重复开启定位,该实例只允许开启一次定位
|
||||
if (isLocation) return;
|
||||
if (gpsLocationListener != null) {
|
||||
addGPSLocationListener(gpsLocationListener);
|
||||
}
|
||||
LogUtils.w("启动GPS定位");
|
||||
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
|
||||
String bestProvider = locationManager.getBestProvider(getCriteria(), true);
|
||||
String currentProvider = "gps";
|
||||
if ("gps".equals(bestProvider)) {
|
||||
currentProvider = bestProvider;
|
||||
} else {
|
||||
//根据设置的Criteria对象,获取最符合此标准的provider对象
|
||||
LocationProvider provider = locationManager.getProvider(LocationManager.GPS_PROVIDER);
|
||||
if (provider != null) {
|
||||
currentProvider = provider.getName();
|
||||
}
|
||||
}
|
||||
LogUtils.w("获取的定位类型:" + currentProvider);
|
||||
//根据当前provider对象获取最后一次位置信息
|
||||
Location currentLocation = locationManager.getLastKnownLocation(currentProvider);
|
||||
if (locationListener == null) {
|
||||
locationListener = new MyLocationListener();
|
||||
}
|
||||
//如果位置信息不为NULL,则通知调用者最后一次位置
|
||||
if (currentLocation != null) {
|
||||
locationListener.onLocationChanged(currentLocation);
|
||||
}
|
||||
//根据系统版本确定使用哪个卫星搜索监听
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
if (gnssStatusCallback == null) {
|
||||
gnssStatusCallback = getGnssStatusCallback();
|
||||
}
|
||||
locationManager.registerGnssStatusCallback(gnssStatusCallback);
|
||||
} else {
|
||||
if (gpsListener == null) {
|
||||
gpsListener = new MyGPSListener();
|
||||
}
|
||||
locationManager.addGpsStatusListener(gpsListener);
|
||||
}
|
||||
locationManager.requestLocationUpdates(currentProvider, 5 * 1000, 3, locationListener);
|
||||
isLocation = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启定位
|
||||
*
|
||||
* @param context 上下文环境
|
||||
* @throws RuntimeException 要先获取定位权限,否则将抛出异常
|
||||
*/
|
||||
@SuppressLint("MissingPermission")
|
||||
public void startGPSLocation(Context context) throws RuntimeException {
|
||||
startGPSLocation(context, null);
|
||||
}
|
||||
|
||||
private Criteria getCriteria() {
|
||||
Criteria criteria = new Criteria();
|
||||
// 设置定位精确度 Criteria.ACCURACY_COARSE比较粗略,Criteria.ACCURACY_FINE则比较精细
|
||||
criteria.setAccuracy(Criteria.ACCURACY_COARSE);
|
||||
// 设置是否要求速度
|
||||
criteria.setSpeedRequired(false);
|
||||
// 设置是否允许运营商收费
|
||||
criteria.setCostAllowed(false);
|
||||
// 设置是否需要方位信息
|
||||
criteria.setBearingRequired(true);
|
||||
// 设置是否需要海拔信息
|
||||
criteria.setAltitudeRequired(true);
|
||||
// 设置对电源的需求
|
||||
criteria.setPowerRequirement(Criteria.POWER_LOW);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止定位,无论 {@link #startGPSLocation(Context)} 被执行多少此,该方法被执行时将停止位置监听,其他以监听位置的活动也无法继续获取位置监听
|
||||
* 需要重新执行 startGPSLocation 才能继续监听位置
|
||||
* TODO 该方法被调用后 所有的 调用 {@link #addGPSLocationListener(GPSLocationListener)}该方法添加的监听都会被清空,再次开启定位是需要重新传递监听回调
|
||||
*/
|
||||
public void stopLocation() {
|
||||
isLocation = false;
|
||||
LogUtils.w("停止GPS定位");
|
||||
if (locationListenerList != null) {
|
||||
for (GPSLocationListener l : locationListenerList) {
|
||||
if (l != null) {
|
||||
l.stopLocation();
|
||||
}
|
||||
}
|
||||
removeGPSLocationListenerAll();
|
||||
}
|
||||
if (locationManager != null) {
|
||||
if (gpsListener != null) {
|
||||
locationManager.removeGpsStatusListener(gpsListener);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
if (gnssStatusCallback != null) {
|
||||
locationManager.unregisterGnssStatusCallback(gnssStatusCallback);
|
||||
}
|
||||
}
|
||||
if (locationListener != null) {
|
||||
locationManager.removeUpdates(locationListener);
|
||||
}
|
||||
}
|
||||
locationListener = null;
|
||||
gpsListener = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注销某个位置监听
|
||||
*
|
||||
* @param gpsLocationListener 监听实例对象
|
||||
*/
|
||||
public void removeGPSLocationListener(GPSLocationListener gpsLocationListener) {
|
||||
if (gpsLocationListener == null) return;
|
||||
if (locationListenerList == null) return;
|
||||
locationListenerList.remove(gpsLocationListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注销所有位置监听
|
||||
*/
|
||||
public void removeGPSLocationListenerAll() {
|
||||
if (locationListenerList == null) return;
|
||||
locationListenerList.clear();
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
private class MyGPSListener implements GpsStatus.Listener {
|
||||
//GPS状态发生变化时触发
|
||||
@Override
|
||||
public void onGpsStatusChanged(int event) {
|
||||
//获取当前状态
|
||||
GpsStatus gpsstatus = locationManager.getGpsStatus(null);
|
||||
switch (event) {
|
||||
//第一次定位时的事件
|
||||
case GpsStatus.GPS_EVENT_FIRST_FIX:
|
||||
break;
|
||||
//开始定位的事件
|
||||
case GpsStatus.GPS_EVENT_STARTED:
|
||||
break;
|
||||
//发送GPS卫星状态事件
|
||||
case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
|
||||
if (gpsstatus == null) return;
|
||||
if (locationListenerList == null) return;
|
||||
Iterable<GpsSatellite> allSatellites = gpsstatus.getSatellites();
|
||||
if (allSatellites == null) return;
|
||||
Iterator<GpsSatellite> it = allSatellites.iterator();
|
||||
if (it == null) return;
|
||||
int count = 0;
|
||||
while (it.hasNext()) {
|
||||
GpsSatellite next = it.next();
|
||||
if (next.getSnr() != 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
// LogUtils.v("搜索到:" + count + "颗卫星!");
|
||||
if (count == startCount) return;
|
||||
for (GPSLocationListener l : locationListenerList) {
|
||||
if (l != null) {
|
||||
l.onScanSatellite(startCount, 0, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
//停止定位事件
|
||||
case GpsStatus.GPS_EVENT_STOPPED:
|
||||
LogUtils.w("Location", "GPS_EVENT_STOPPED");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
private GnssStatus.Callback getGnssStatusCallback() {
|
||||
return new GnssStatus.Callback() {
|
||||
@Override
|
||||
public void onStarted() {
|
||||
super.onStarted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSatelliteStatusChanged(GnssStatus status) {
|
||||
if (locationListenerList == null) return;
|
||||
int satelliteCount = status.getSatelliteCount();
|
||||
if (startCount != satelliteCount) {
|
||||
startCount = satelliteCount;
|
||||
//计算北东卫星数量
|
||||
int bdCount = 0;
|
||||
//计算用于定位的卫星数量
|
||||
int locationCount = 0;
|
||||
for (int i = 0; i < satelliteCount; i++) {
|
||||
int constellationType = status.getConstellationType(i);
|
||||
if (constellationType == GnssStatus.CONSTELLATION_BEIDOU) {
|
||||
bdCount++;
|
||||
}
|
||||
if (status.usedInFix(i)) {
|
||||
locationCount++;
|
||||
}
|
||||
}
|
||||
for (GPSLocationListener l : locationListenerList) {
|
||||
if (l != null) {
|
||||
l.onScanSatellite(startCount, bdCount, locationCount);
|
||||
}
|
||||
}
|
||||
if (RuanseeApplication.isPrintLog) {
|
||||
LogUtils.d("搜索卫星", String.format("搜索到:%s颗卫星,北斗卫星:%s颗,用于定位的卫星:%s颗", startCount, bdCount, locationCount));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public boolean isGPSPermission(Context context) {
|
||||
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
|
||||
ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
// TODO: Consider calling
|
||||
// ActivityCompat#requestPermissions
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private class MyLocationListener implements LocationListener {
|
||||
|
||||
/**
|
||||
* 位置发生改变
|
||||
*
|
||||
* @param location
|
||||
*/
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
if (locationListenerList == null) return;
|
||||
for (GPSLocationListener l : locationListenerList) {
|
||||
if (l != null) {
|
||||
l.onLocationChanged(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定位状态发生改变
|
||||
*
|
||||
* @param provider
|
||||
* @param status
|
||||
* @param extras
|
||||
*/
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用 定位模式
|
||||
*
|
||||
* @param provider
|
||||
*/
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 定位模式 被禁用
|
||||
*
|
||||
* @param provider
|
||||
*/
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,263 @@
|
|||
package com.ycgis.macall.personalcenter.util;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AppOpsManager;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
import com.ycgis.macall.personalcenter.R;
|
||||
import com.ycgis.macall.personalcenter.v.activity.MainActivity;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import static android.app.Notification.EXTRA_CHANNEL_ID;
|
||||
import static android.provider.Settings.EXTRA_APP_PACKAGE;
|
||||
|
||||
public class NotificationUtils {
|
||||
private final static String CHANNEL_ID = "channel_id"; //通道渠道id
|
||||
private final static String CHANEL_NAME = "chanel_name"; //通道渠道名称
|
||||
private final static int NOTIFICATION_SAMPLE = 1;
|
||||
|
||||
private static final String CHECK_OP_NO_THROW = "checkOpNoThrow";
|
||||
private static final String OP_POST_NOTIFICATION = "OP_POST_NOTIFICATION";
|
||||
|
||||
//调用该方法获取是否开启通知栏权限
|
||||
public static boolean isNotifyEnabled(Context context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
return isEnableV26(context);
|
||||
} else {
|
||||
return isEnabledV19(context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 8.0以下判断
|
||||
*
|
||||
* @param context api19 4.4及以上判断
|
||||
* @return
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
||||
private static boolean isEnabledV19(Context context) {
|
||||
|
||||
AppOpsManager mAppOps =
|
||||
(AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
||||
|
||||
ApplicationInfo appInfo = context.getApplicationInfo();
|
||||
String pkg = context.getApplicationContext().getPackageName();
|
||||
int uid = appInfo.uid;
|
||||
Class appOpsClass = null;
|
||||
|
||||
try {
|
||||
appOpsClass = Class.forName(AppOpsManager.class.getName());
|
||||
|
||||
Method checkOpNoThrowMethod =
|
||||
appOpsClass.getMethod(CHECK_OP_NO_THROW,
|
||||
Integer.TYPE, Integer.TYPE, String.class);
|
||||
|
||||
Field opPostNotificationValue = appOpsClass.getDeclaredField(OP_POST_NOTIFICATION);
|
||||
int value = (Integer) opPostNotificationValue.get(Integer.class);
|
||||
|
||||
return ((Integer) checkOpNoThrowMethod.invoke(mAppOps, value, uid, pkg) ==
|
||||
AppOpsManager.MODE_ALLOWED);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 8.0及以上通知权限判断
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
private static boolean isEnableV26(Context context) {
|
||||
ApplicationInfo appInfo = context.getApplicationInfo();
|
||||
String pkg = context.getApplicationContext().getPackageName();
|
||||
int uid = appInfo.uid;
|
||||
try {
|
||||
NotificationManager notificationManager = (NotificationManager)
|
||||
context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
Method sServiceField = notificationManager.getClass().getDeclaredMethod("getService");
|
||||
sServiceField.setAccessible(true);
|
||||
Object sService = sServiceField.invoke(notificationManager);
|
||||
|
||||
Method method = sService.getClass().getDeclaredMethod("areNotificationsEnabledForPackage"
|
||||
, String.class, Integer.TYPE);
|
||||
method.setAccessible(true);
|
||||
return (boolean) method.invoke(sService, pkg, uid);
|
||||
} catch (Exception e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setNotificationActivity(Context context) {
|
||||
Intent localIntent = new Intent();
|
||||
//直接跳转到应用通知设置的代码:
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {//8.0及以上
|
||||
localIntent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
|
||||
//这种方案适用于 API 26, 即8.0(含8.0)以上可以用
|
||||
localIntent.putExtra(EXTRA_APP_PACKAGE, context.getPackageName());
|
||||
localIntent.putExtra(EXTRA_CHANNEL_ID, context.getApplicationInfo().uid);
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//5.0以上到8.0以下
|
||||
//这种方案适用于 API21——25,即 5.0——7.1 之间的版本可以使用
|
||||
localIntent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
|
||||
localIntent.putExtra("app_package", context.getPackageName());
|
||||
localIntent.putExtra("app_uid", context.getApplicationInfo().uid);
|
||||
} else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {//4.4
|
||||
localIntent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
localIntent.addCategory(Intent.CATEGORY_DEFAULT);
|
||||
localIntent.setData(Uri.parse("package:" + context.getPackageName()));
|
||||
} else {
|
||||
//4.4以下没有从app跳转到应用通知设置页面的Action,可考虑跳转到应用详情页面,
|
||||
localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
localIntent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
|
||||
localIntent.setData(Uri.fromParts("package", context.getPackageName(), null));
|
||||
} else if (Build.VERSION.SDK_INT <= 8) {
|
||||
localIntent.setAction(Intent.ACTION_VIEW);
|
||||
localIntent.setClassName("com.android.settings", "com.android.setting.InstalledAppDetails");
|
||||
localIntent.putExtra("com.android.settings.ApplicationPkgName", context.getPackageName());
|
||||
}
|
||||
}
|
||||
context.startActivity(localIntent);
|
||||
}
|
||||
|
||||
public static void showNotification(Context context, String title, String message) {
|
||||
NotificationChannel channel = null;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
//创建 通知通道 channelid和channelname是必须的(自己命名就好)
|
||||
channel = new NotificationChannel(CHANNEL_ID, CHANEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
|
||||
channel.enableLights(true);//是否在桌面icon右上角展示小红点
|
||||
channel.setLightColor(Color.GREEN);//小红点颜色
|
||||
channel.setShowBadge(false); //是否在久按桌面图标时显示此渠道的通知
|
||||
}
|
||||
Notification notification;
|
||||
// 打开程序后图标消失
|
||||
Intent intent = new Intent(context, MainActivity.class);
|
||||
@SuppressLint("WrongConstant")
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
|
||||
|
||||
//获取Notification实例 获取Notification实例有很多方法处理 在此我只展示通用的方法(虽然这种方式是属于api16以上,但是已经可以了,毕竟16以下的Android机很少了,如果非要全面兼容可以用)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
//向上兼容 用Notification.Builder构造notification对象
|
||||
notification = new Notification.Builder(context, CHANNEL_ID)
|
||||
.setContentTitle(title)
|
||||
.setContentText(message)
|
||||
.setWhen(System.currentTimeMillis())
|
||||
.setSmallIcon(R.mipmap.icon_applogin)
|
||||
.setColor(Color.parseColor("#FEDA26"))
|
||||
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.icon_applogin))
|
||||
// .setTicker("巴士门")
|
||||
.setContentIntent(pendingIntent)
|
||||
.build();
|
||||
} else {
|
||||
//向下兼容 用NotificationCompat.Builder构造notification对象
|
||||
notification = new NotificationCompat.Builder(context)
|
||||
.setContentTitle(title)
|
||||
.setContentText(message)
|
||||
.setWhen(System.currentTimeMillis())
|
||||
.setSmallIcon(R.mipmap.icon_applogin)
|
||||
.setColor(Color.parseColor("#FEDA26"))
|
||||
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.icon_applogin))
|
||||
// .setTicker("巴士门")
|
||||
.setContentIntent(pendingIntent)
|
||||
.build();
|
||||
}
|
||||
notification.flags |= Notification.FLAG_AUTO_CANCEL;
|
||||
|
||||
//发送通知
|
||||
int notifiId = 1;
|
||||
//创建一个通知管理器
|
||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
if (notificationManager == null) return;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
// EventBus.getDefault().post(new BackLogEvent(4));
|
||||
notificationManager.notify(notifiId, notification);
|
||||
}
|
||||
|
||||
public static void sendSimpleNotification(Context context, String title, String message) {
|
||||
NotificationChannel channel = null;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
//创建 通知通道 channelid和channelname是必须的(自己命名就好)
|
||||
channel = new NotificationChannel(CHANNEL_ID, CHANEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
|
||||
channel.enableLights(true);//是否在桌面icon右上角展示小红点
|
||||
channel.setLightColor(Color.GREEN);//小红点颜色
|
||||
channel.setShowBadge(false); //是否在久按桌面图标时显示此渠道的通知
|
||||
}
|
||||
|
||||
//创建点击通知时发送的广播
|
||||
Intent intent = new Intent(context, MainActivity.class);
|
||||
PendingIntent pi = PendingIntent.getActivity(context, 0, intent, 0);
|
||||
//创建删除通知时发送的广播
|
||||
// Intent deleteIntent = new Intent(context,MainActivity.class);
|
||||
Notification notification;
|
||||
// PendingIntent deletePendingIntent = PendingIntent.getService(context,0,deleteIntent,0);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
//创建通知
|
||||
notification = new Notification.Builder(context, CHANNEL_ID)
|
||||
//设置通知左侧的小图标
|
||||
.setSmallIcon(R.mipmap.icon_applogin)
|
||||
//设置通知标题
|
||||
.setContentTitle(title)
|
||||
//设置通知内容
|
||||
.setContentText(message)
|
||||
//设置点击通知后自动删除通知
|
||||
.setAutoCancel(true)
|
||||
//设置显示通知时间
|
||||
.setShowWhen(true)
|
||||
//设置通知右侧的大图标
|
||||
// .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_applogo))
|
||||
//设置点击通知时的响应事件
|
||||
.setContentIntent(pi)
|
||||
//设置删除通知时的响应事件
|
||||
// .setDeleteIntent(deletePendingIntent)
|
||||
.build();
|
||||
} else {
|
||||
//向下兼容 用NotificationCompat.Builder构造notification对象
|
||||
notification = new NotificationCompat.Builder(context)
|
||||
.setContentTitle(title)
|
||||
.setContentText(message)
|
||||
.setWhen(System.currentTimeMillis())
|
||||
.setSmallIcon(R.mipmap.icon_applogin)
|
||||
.setColor(Color.parseColor("#FEDA26"))
|
||||
// .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_applogo))
|
||||
// .setTicker("巴士门")
|
||||
.setContentIntent(pi)
|
||||
.build();
|
||||
}
|
||||
|
||||
notification.flags |= Notification.FLAG_AUTO_CANCEL;
|
||||
//创建一个通知管理器
|
||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
if (notificationManager == null) return;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
// EventBus.getDefault().post(new BackLogEvent(4));
|
||||
notificationManager.notify(NOTIFICATION_SAMPLE, notification);
|
||||
//发送通知
|
||||
// nm.notify(NOTIFICATION_SAMPLE,notification);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.ycgis.macall.personalcenter.util;
|
||||
|
||||
import com.rs.macall.androidx.basemodel.utils.StringUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ParamMap {
|
||||
private Map<String,String> param ;
|
||||
|
||||
public ParamMap(){
|
||||
param = new HashMap<>();
|
||||
}
|
||||
|
||||
public ParamMap put(String key,String value){
|
||||
if (key == null ||value == null) return this;
|
||||
param.put(key.trim(),value.trim());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public String get(String key){
|
||||
return get(key,"");
|
||||
}
|
||||
public String get(String key,String defValue){
|
||||
if (key == null) return defValue;
|
||||
return param.get(key.trim());
|
||||
}
|
||||
|
||||
public Map<String,String> apply(){
|
||||
return param;
|
||||
}
|
||||
|
||||
public String remove(String key){
|
||||
if (StringUtil.isNullOrEmpty(key))return "";
|
||||
return param.remove(key.trim());
|
||||
}
|
||||
|
||||
public boolean isEmpty(){
|
||||
return param.isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue