feat: 初始化项目结构和基本功能

- 创建项目根目录和主要子模块
- 添加基本的 Activity 和布局文件
- 实现简单的导航和电话拨打功能
- 添加相机和图像处理相关代码
- 创建网络请求和数据加密工具类
- 设置 AndroidManifest 文件和权限
This commit is contained in:
songzhiling
2025-04-11 11:52:07 +08:00
parent 74ce8fc526
commit 91305ab9d1
386 changed files with 36517 additions and 34 deletions

View File

@ -0,0 +1,127 @@
package com.za.net
import android.net.ParseException
import com.blankj.utilcode.util.ActivityUtils
import com.blankj.utilcode.util.NetworkUtils
import com.blankj.utilcode.util.ToastUtils
import com.google.gson.JsonParseException
import com.za.base.Const
import com.za.bean.BaseResponse
import com.za.common.GlobalData
import com.za.common.log.LogUtil
import com.za.service.location.ZdLocationManager
import io.reactivex.rxjava3.core.Observer
import io.reactivex.rxjava3.disposables.Disposable
import org.json.JSONException
import java.net.ConnectException
import java.net.SocketTimeoutException
import java.net.UnknownHostException
import java.util.concurrent.TimeoutException
import javax.net.ssl.SSLHandshakeException
/**
* Created by DoggieX on 2017/7/26.
*/
abstract class BaseObserver<T> : Observer<BaseResponse<T>> {
override fun onSubscribe(d: Disposable) {
// if (!NetworkUtils.isAvailable()) {
// doFailure(999, "网络无法使用")
// d.dispose()
// }
}
override fun onNext(tBaseResponse: BaseResponse<T>) {
if (tBaseResponse.isOk) {
doSuccess(tBaseResponse.result)
} else {
when (tBaseResponse.code) {
3, 401 -> handlerTokenExpired()
// 4 -> RsaRouter.navigate(context, "/page/Standby")
}
if (null != tBaseResponse.msg) {
doFailure(tBaseResponse.code, tBaseResponse.msg)
} else if (null != tBaseResponse.message) {
doFailure(tBaseResponse.code, tBaseResponse.message)
} else {
doFailure(tBaseResponse.code, "error")
}
}
}
override fun onError(e: Throwable) {
LogUtil.print("net error", e)
when (e) {
is JsonParseException -> {
doFailure(1, "数据解析错误")
}
is JSONException -> {
doFailure(1, "数据解析错误")
}
is ParseException -> {
doFailure(1, "数据解析错误")
}
is ConnectException -> {
doFailure(Const.NetWorkException, "与服务器断开连接")
}
is UnknownHostException -> {
doFailure(Const.NetWorkException, "与服务器断开连接")
}
is SSLHandshakeException -> {
doFailure(1, "证书验证失败")
LogUtil.print("SSLHandshakeException", e)
}
is TimeoutException -> {
doFailure(Const.NetWorkException, "网络连接超时1")
LogUtil.print("TimeoutException", e)
}
is SocketTimeoutException -> {
doFailure(Const.NetWorkException, "网络连接超时2")
LogUtil.print("SocketTimeoutException2", e)
}
else -> {
doFailure(1, "error:" + e.message)
LogUtil.print("other error", e)
}
}
}
override fun onComplete() {
}
abstract fun doSuccess(it: T?)
abstract fun doFailure(code: Int, msg: String?)
private fun handlerTokenExpired() {
ToastUtils.showShort("登陆信息已过期,请重新登录")
try {
GlobalData.clearUserCache()
ZdLocationManager.stopContinuousLocation()
ActivityUtils.finishAllActivities()
// val oldLoginInfo: LoginInfo = DbManager.getInstance(context).queryLoginInfo()
// val loginInfo: LoginInfo = LoginInfo()
// loginInfo.setSupplierId(oldLoginInfo.getSupplierId())
// loginInfo.setSupplierCode(oldLoginInfo.getSupplierCode())
// loginInfo.setJobNumber(oldLoginInfo.getJobNumber())
// loginInfo.setPassword(oldLoginInfo.getPassword())
// DbManager.getInstance(context).deleteLoginInfo()
// DbManager.getInstance(context).saveLoginInfo(loginInfo)
// SPKit.saveString(context, "userId", "-1")
// SPKit.saveString(context, "vehicleId", "-1")
//
// LBSManager.getInstance().cancel()
// DaemonService.stopService()
// //跳转
// RsaRouter.navigateNoFlag(context, "/page/login")
} catch (e: Exception) {
LogUtil.print("handlerTokenExpired", e)
}
}
}