diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6f6ae0d..03a6b71 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -295,11 +295,26 @@ android:configChanges="keyboardHidden|orientation|locale" android:screenOrientation="portrait" android:windowSoftInputMode="adjustPan|stateHidden" /> + + + () { + override fun onBindViewHolder(holder: QuickViewHolder, position: Int, item: QuestionBean?) { + holder.run { + setText(R.id.tvTitle, item?.classroomName) + setText(R.id.tvDate, item?.updateTime) + ImageLoader.getInstance().loadImage(context,item?.classroomUrl,getView(R.id.ivBg)) + } + } + + override fun onCreateViewHolder( + context: Context, + parent: ViewGroup, + viewType: Int + ) = QuickViewHolder(R.layout.item_question, parent) +} \ No newline at end of file diff --git a/app/src/main/java/com/dahe/gldriver/base/App.kt b/app/src/main/java/com/dahe/gldriver/base/App.kt index 5f10987..ba16022 100644 --- a/app/src/main/java/com/dahe/gldriver/base/App.kt +++ b/app/src/main/java/com/dahe/gldriver/base/App.kt @@ -14,6 +14,7 @@ import com.github.gzuliyujiang.dialog.DialogStyle import com.tencent.bugly.crashreport.CrashReport import com.umeng.commonsdk.UMConfigure import com.umeng.message.PushAgent +import com.umeng.message.api.UPushRegisterCallback import com.umeng.umverify.UMVerifyHelper import com.umeng.umverify.listener.UMTokenResultListener import java.security.SecureRandom @@ -22,7 +23,6 @@ import javax.net.ssl.HttpsURLConnection import javax.net.ssl.SSLContext import javax.net.ssl.TrustManager import javax.net.ssl.X509TrustManager -import kotlin.concurrent.thread class App : Application() { override fun onCreate() { @@ -104,7 +104,26 @@ class App : Application() { // 推送注册 val api = PushAgent.getInstance(this) PushHelper.setting(api) + api.register(object : UPushRegisterCallback{ + override fun onSuccess(p0: String?) {//注册厂商通道 + Log.e( + "TAG", + "register failed! code:$p0" + ) + //注册厂商通道 +// registerDevicePush(context) + } + + override fun onFailure(p0: String?, p1: String?) { + Log.e( + "TAG", + "register failed! code:$p0,desc:$p1" + ) + + } + + }) UMConfigure.init( this, AppConfig.APP_KEY, diff --git a/app/src/main/java/com/dahe/gldriver/bean/ApiBean.kt b/app/src/main/java/com/dahe/gldriver/bean/ApiBean.kt index a1df354..a00124e 100644 --- a/app/src/main/java/com/dahe/gldriver/bean/ApiBean.kt +++ b/app/src/main/java/com/dahe/gldriver/bean/ApiBean.kt @@ -53,3 +53,36 @@ data class ProBean( val status: String, val contentData: String ) + +data class AppVersion( + val content: String, + val createTime: String, + val delete: String, + val downloadUrl: String, + val examine: String, + val force: String, + val qrocdeUrl: String, + val source: String, + val type: String, + val versionCode: Int, + val versionName: String, + val versionId: String +) + +data class QuestionBean( + val classroomDesc: String, + val classroomId: String, + val classroomName: String, + val classroomUrl: String, + val createTime: String, + val isRecommend: String, + val isTop: String, + val sortValue: String, + val status: String, + val updateTime: String +) + +data class QueDetail( + val classroomId: String, + val contentData: String +) diff --git a/app/src/main/java/com/dahe/gldriver/net/Api.kt b/app/src/main/java/com/dahe/gldriver/net/Api.kt index 3aad7f4..c844fff 100644 --- a/app/src/main/java/com/dahe/gldriver/net/Api.kt +++ b/app/src/main/java/com/dahe/gldriver/net/Api.kt @@ -2,6 +2,7 @@ package com.dahe.gldriver.net import com.dahe.gldriver.BuildConfig import com.dahe.gldriver.BuildConfig.BASE_URL +import com.dahe.gldriver.bean.AppVersion import com.dahe.gldriver.bean.AuthTeamBean import com.dahe.gldriver.bean.CaptainBean import com.dahe.gldriver.bean.CarBean @@ -14,6 +15,8 @@ import com.dahe.gldriver.bean.OrderChild import com.dahe.gldriver.bean.OrderDetailBean import com.dahe.gldriver.bean.OssBean import com.dahe.gldriver.bean.ProBean +import com.dahe.gldriver.bean.QueDetail +import com.dahe.gldriver.bean.QuestionBean import com.dahe.gldriver.bean.RateBean import com.dahe.gldriver.bean.UpBankInfoBean import com.dahe.gldriver.bean.UpCaptain @@ -464,7 +467,7 @@ interface Api { * @return Observable>> */ @GET(BASE_URL + "driver/app/info/commonProblemList") - fun commonProblemList():Observable>> + fun commonProblemList(): Observable>> /** @@ -473,8 +476,32 @@ interface Api { * @return Observable>> */ @GET(BASE_URL + "driver/app/info/commonProblemDetail") - fun commonProblemDetail(@Query("problemId") problemId :String):Observable> + fun commonProblemDetail(@Query("problemId") problemId: String): Observable> + /** + * 安全课堂详情 + * @param problemId String + * @return Observable> + */ + @GET(BASE_URL + "driver/app/info/safeClassroomDetail") + fun safeClassroomDetail(@Query("classroomId") problemId: String): Observable> + + + + + /** + * 获取APP最新版本信息 + * @return Observable> + */ + @GET(BASE_URL + "driver/app/info/getLastAppVersion") + fun getLastAppVersion(): Observable> + + /** + * 安全课堂列表 + * @return Observable> + */ + @GET(BASE_URL + "driver/app/info/safeClassroomList") + fun safeClassroomList(): Observable>> companion object { // String BASE_URL = "https://tmstest.dahehuoyun.com/"; diff --git a/app/src/main/java/com/dahe/gldriver/push/PushHelper.kt b/app/src/main/java/com/dahe/gldriver/push/PushHelper.kt index ec8da28..cdfc853 100644 --- a/app/src/main/java/com/dahe/gldriver/push/PushHelper.kt +++ b/app/src/main/java/com/dahe/gldriver/push/PushHelper.kt @@ -5,6 +5,7 @@ import android.content.Context import android.util.Log import com.dahe.gldriver.utils.SPUtils import com.dahe.glex.bean.UserBean +import com.dahe.mylibrary.callback.PushAliasListener import com.umeng.message.PushAgent import com.umeng.message.UmengMessageHandler import com.umeng.message.UmengNotificationClickHandler @@ -105,7 +106,7 @@ object PushHelper { * 绑定别名,绑定成功后可通过别名推送消息 */ fun setAlias(context: Context, userBean: UserBean) { - val alias = userBean.userid + val alias = userBean.contactPhone val type = "uid" PushAgent.getInstance(context).setAlias(alias, type) { success, message -> val msg: String @@ -120,11 +121,12 @@ object PushHelper { /** * 删除别名 */ - fun delete(context: Context) { - val alias = SPUtils.instance.getUserInfo(context)?.userid + fun delete(context: Context, listener: PushAliasListener? = null) { + val alias = SPUtils.instance.getUserInfo(context)?.contactPhone val type = "uid" PushAgent.getInstance(context).deleteAlias(alias, type) { success, message -> val msg: String + listener?.onResult(success) msg = if (success) { "delete alias success! type:$type alias:$alias" } else { @@ -133,4 +135,21 @@ object PushHelper { } } + /** + * 绑定别名,绑定成功后可通过别名推送消息 + */ + fun setAlias(context: Context, listener: PushAliasListener) { + val alias = (SPUtils.instance.getUserInfo(context) as UserBean).contactPhone + val type = "uid" + PushAgent.getInstance(context).setAlias(alias, type) { success, message -> + val msg: String + listener.onResult(success) + msg = if (success) { + "set alias success! type:$type alias:$alias" + } else { + "set alias failure! msg:$message" + } + } + } + } diff --git a/app/src/main/java/com/dahe/gldriver/ui/mine/MineFragment.kt b/app/src/main/java/com/dahe/gldriver/ui/mine/MineFragment.kt index 0bca04b..378ab4a 100644 --- a/app/src/main/java/com/dahe/gldriver/ui/mine/MineFragment.kt +++ b/app/src/main/java/com/dahe/gldriver/ui/mine/MineFragment.kt @@ -16,9 +16,12 @@ import com.dahe.gldriver.ui.mine.activity.CarsManActivity import com.dahe.gldriver.ui.mine.activity.ComProActivity import com.dahe.gldriver.ui.mine.activity.DriverTeamsActivity import com.dahe.gldriver.ui.mine.activity.PersonInfoActivity +import com.dahe.gldriver.ui.mine.activity.QuesActivity import com.dahe.gldriver.ui.mine.activity.RateManActivity import com.dahe.gldriver.ui.mine.activity.RulesActivity +import com.dahe.gldriver.ui.mine.activity.SettingActivity import com.dahe.gldriver.ui.mine.activity.WalletActivity +import com.dahe.gldriver.utils.AppVersionUtils import com.dahe.gldriver.utils.SPUtils import com.dahe.gldriver.utils.UserUtils import com.dahe.glex.bean.UserBean @@ -63,20 +66,7 @@ class MineFragment : BaseFragment(), View.OnClickListener, override fun onFragmentFirstVisible() { setRefresh(binding.refresh, this) - val userInfo = SPUtils.instance.getUserInfo(mContext) - if (userInfo != null) { - binding.run { - tvName.text = userInfo.idcardName - tvCarType.text = userInfo.approvedType - tvPhone.text = PhoneFormatCheckUtils.hintPhone(userInfo.contactPhone) - tvCarType.visibility = - if (userInfo.approvedType.isNullOrEmpty()) View.GONE else View.VISIBLE - ivPart.visibility = - if (userInfo.partyMemberCertification == "1") View.VISIBLE else View.GONE - ImageLoader.getInstance() - .loadCircleImage(mContext, userInfo.avatar, ivHead, R.drawable.head_defaut) - } - } + refreshView() binding.run { //初始化常用工具 @@ -106,20 +96,9 @@ class MineFragment : BaseFragment(), View.OnClickListener, override fun onClick(v: View) { when (v.id) { -// R.id.rlPass->ActivityUtils.startActivity(mContext,ChangePwdActivity::class.java) -// R.id.rlPhone-> AppActivityUtils.openWebViewActivity(mContext, "隐私政策", -// "http://tms.down.user.test.dahehuodongbao.com/user-privacy.html") -//// R.id.rlPhone->ActivityUtils.startActivity(mContext,ChangePhoneActivity::class.java) -// R.id.btnOut-> CrashReport.testJavaCrash(); } } - fun logOut() { -// UserUtils.instance.loginOut(requireActivity()) -// val intent = Intent(mContext, LoginActivity::class.java) -// intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK -// requireActivity().startActivity(intent) - } /** * 常用工具跳转逻辑 @@ -141,11 +120,12 @@ class MineFragment : BaseFragment(), View.OnClickListener, } 2 -> { - var bundle = Bundle() - bundle.putString("title", "我的百度") - bundle.putString("url", "www.baidu.com") - ActivityUtils.startActivity(mContext, WebActivity::class.java, bundle) - ToastUtils.showToast(mContext, tools[pos].title) + ActivityUtils.startActivity(mContext, QuesActivity::class.java) +// var bundle = Bundle() +// bundle.putString("title", "我的百度") +// bundle.putString("url", "www.baidu.com") +// ActivityUtils.startActivity(mContext, WebActivity::class.java, bundle) +// ToastUtils.showToast(mContext, tools[pos].title) } 3 -> { @@ -184,17 +164,18 @@ class MineFragment : BaseFragment(), View.OnClickListener, } 5 -> { - ToastUtils.showToast(mContext, plats[pos].title) + AppVersionUtils.getInstance().checkVersion(mContext) } 6 -> { - ToastUtils.showToast(mContext, plats[pos].title) + ActivityUtils.startActivity(mContext, WebActivity::class.java, Bundle().apply { + putString("title", "关于我们") + putString("url", "www.baidu.com") + }) } 7 -> { - SPUtils.instance.removeUserToken(mContext) - ActivityUtils.finishAllActivities() - showToast("清除token") + ActivityUtils.startActivity(mContext,SettingActivity::class.java) // exitProcess(0) } @@ -210,9 +191,27 @@ class MineFragment : BaseFragment(), View.OnClickListener, super.onSuccess(t) UserUtils.instance.updateUser(mContext, t.data) binding.refresh.finishRefresh() + refreshView() } })) } + private fun refreshView() { + val userInfo = SPUtils.instance.getUserInfo(mContext) + if (userInfo != null) { + binding.run { + tvName.text = userInfo.idcardName + tvCarType.text = userInfo.approvedType + tvPhone.text = PhoneFormatCheckUtils.hintPhone(userInfo.contactPhone) + tvCarType.visibility = + if (userInfo.approvedType.isNullOrEmpty()) View.GONE else View.VISIBLE + ivPart.visibility = + if (userInfo.partyMemberCertification == "1") View.VISIBLE else View.GONE + ImageLoader.getInstance() + .loadCircleImage(mContext, userInfo.avatar, ivHead, R.drawable.head_defaut) + } + } + + } } \ No newline at end of file diff --git a/app/src/main/java/com/dahe/gldriver/ui/mine/activity/CarDetailActivity.kt b/app/src/main/java/com/dahe/gldriver/ui/mine/activity/CarDetailActivity.kt index b61a6b7..de787e5 100644 --- a/app/src/main/java/com/dahe/gldriver/ui/mine/activity/CarDetailActivity.kt +++ b/app/src/main/java/com/dahe/gldriver/ui/mine/activity/CarDetailActivity.kt @@ -136,21 +136,25 @@ class CarDetailActivity : BaseActivity(), View.OnClick if (data.vehicleNum.isNullOrEmpty()) { tvInfo.text = "证件缺失将无法进行接单" - missInfo.plus("行驶证、") + missInfo = missInfo.plus("行驶证") } else { doneInfoCount++ tvInfo.text = """${data.vehicleNum} ${data.vehicleType}""" } if (data.trailerVehicleNum.isNullOrEmpty()) { tvDriverInfo.text = "证件缺失将无法进行接单" - missInfo.plus("挂车行驶证、") + missInfo = + if (missInfo.isNullOrEmpty()) missInfo.plus("挂车行驶证") else missInfo.plus("、挂车行驶证") } else { doneInfoCount++ tvDriverInfo.text = """${data.trailerVehicleNum} ${data.trailerVehicleType}""" } if (data.roadLicense.isNullOrEmpty()) { tvQualiInfo.text = "证件缺失将无法进行接单" - missInfo.plus("道路运输许可证、") + missInfo = + if (missInfo.isNullOrEmpty()) missInfo.plus("道路运输许可证") else missInfo.plus( + "、道路运输许可证" + ) } else { doneInfoCount++ tvQualiInfo.text = """${data.roadLicense}""" @@ -158,7 +162,8 @@ class CarDetailActivity : BaseActivity(), View.OnClick btnNext.text = if (doneInfoCount == 3) "已完成" else "继续认证" - tvContent.text = if (missInfo.isNullOrEmpty()) "认证成功,请接单把!!!" else missInfo + tvContent.text = + if (missInfo.isNullOrEmpty()) "认证成功,请接单把!!!" else missInfo.plus("缺失") llId.visibility = if (data.vehicleNum.isNullOrEmpty()) View.GONE else View.VISIBLE diff --git a/app/src/main/java/com/dahe/gldriver/ui/mine/activity/PersonInfoActivity.kt b/app/src/main/java/com/dahe/gldriver/ui/mine/activity/PersonInfoActivity.kt index e2e659e..4bf6c9e 100644 --- a/app/src/main/java/com/dahe/gldriver/ui/mine/activity/PersonInfoActivity.kt +++ b/app/src/main/java/com/dahe/gldriver/ui/mine/activity/PersonInfoActivity.kt @@ -125,21 +125,21 @@ class PersonInfoActivity : BaseActivity(), View.OnCli if (data.idcardNo.isNullOrEmpty()) { tvInfo.text = "证件缺失将无法进行接单" - missInfo.plus("身份证、") + missInfo = missInfo.plus("身份证") } else { doneInfoCount++ tvInfo.text = """${data.idcardName} ${data.idcardNo}""" } if (data.licenseNo.isNullOrEmpty()) { tvDriverInfo.text = "证件缺失将无法进行接单" - missInfo.plus("驾驶证、") + missInfo = if (missInfo.isNullOrEmpty()) missInfo.plus("驾驶证") else missInfo.plus("、驾驶证") } else { doneInfoCount++ tvDriverInfo.text = """${data.licenseName} ${data.licenseNo}""" } if (data.qualificationCertificateNo.isNullOrEmpty()) { tvQualiInfo.text = "证件缺失将无法进行接单" - missInfo.plus("从业资格证、") + missInfo = if (missInfo.isNullOrEmpty()) missInfo.plus("从业资格证") else missInfo.plus("、从业资格证") } else { doneInfoCount++ tvQualiInfo.text = """${data.qualificationCertificateNo}""" @@ -147,14 +147,14 @@ class PersonInfoActivity : BaseActivity(), View.OnCli if (data?.isRealName == "0") { tvFaceInfo.text = "未实名认证将无法进行接单" - missInfo.plus("实名认证缺失") + missInfo = if (missInfo.isNullOrEmpty()) missInfo.plus("实名认证") else missInfo.plus("、实名认证") } else { doneInfoCount++ tvFaceInfo.text = "实名认证成功" } btnNext.text = if (doneInfoCount == 4) "已完成" else "继续认证" - tvContent.text = if (missInfo.isNullOrEmpty()) "认证成功,请接单把!!!" else missInfo + tvContent.text = if (missInfo.isNullOrEmpty()) "认证成功,请接单把!!!" else missInfo.plus("缺失") llId.visibility = if (data.idcardNo.isNullOrEmpty()) View.GONE else View.VISIBLE diff --git a/app/src/main/java/com/dahe/gldriver/ui/mine/activity/QueDetailActivity.kt b/app/src/main/java/com/dahe/gldriver/ui/mine/activity/QueDetailActivity.kt new file mode 100644 index 0000000..c06b37a --- /dev/null +++ b/app/src/main/java/com/dahe/gldriver/ui/mine/activity/QueDetailActivity.kt @@ -0,0 +1,50 @@ +package com.dahe.gldriver.ui.mine.activity + +import android.os.Bundle +import android.text.Html +import com.dahe.gldriver.R +import com.dahe.gldriver.base.AppConfig.DATA +import com.dahe.gldriver.bean.ProBean +import com.dahe.gldriver.bean.QueDetail +import com.dahe.gldriver.bean.QuestionBean +import com.dahe.gldriver.databinding.ActivityComProDetailBinding +import com.dahe.gldriver.databinding.ActivityQueDetailBinding +import com.dahe.gldriver.net.BaseObserver +import com.dahe.gldriver.net.DataManager +import com.dahe.gldriver.net.RxHttpCallBack +import com.dahe.mylibrary.base.BaseActivity +import com.dahe.mylibrary.net.CommonResponseBean +import com.google.gson.Gson +import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers +import io.reactivex.rxjava3.schedulers.Schedulers + +/** + * @ClassName ComProActivity + * @Author john + * @Date 2024/3/25 16:42 + * @Description 安全课堂详情 + */ +class QueDetailActivity : BaseActivity() { + + override fun initView(savedInstanceState: Bundle?) { + setStatusBarColor(R.color.white) + setTitleBar("安全课堂", true) + } + + override fun initDate() { + var proBean = Gson().fromJson(intent.extras?.getString(DATA), QuestionBean::class.java) + + + DataManager.getInstance().safeClassroomDetail(proBean.classroomId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(BaseObserver(mContext, object : RxHttpCallBack() { + override fun onSuccess(t: CommonResponseBean) { + super.onSuccess(t) + binding.run { + tvContent.text = Html.fromHtml(t.data.contentData) + } + } + })) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/dahe/gldriver/ui/mine/activity/QuesActivity.kt b/app/src/main/java/com/dahe/gldriver/ui/mine/activity/QuesActivity.kt new file mode 100644 index 0000000..62304fe --- /dev/null +++ b/app/src/main/java/com/dahe/gldriver/ui/mine/activity/QuesActivity.kt @@ -0,0 +1,76 @@ +package com.dahe.gldriver.ui.mine.activity + +import android.graphics.Color +import android.os.Bundle +import android.widget.LinearLayout +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView +import com.dahe.gldriver.R +import com.dahe.gldriver.adapter.ComProAdatper +import com.dahe.gldriver.adapter.QuestionAdatper +import com.dahe.gldriver.base.AppConfig +import com.dahe.gldriver.bean.ProBean +import com.dahe.gldriver.bean.QuestionBean +import com.dahe.gldriver.databinding.ActivityQuesBinding +import com.dahe.gldriver.net.BaseObserver +import com.dahe.gldriver.net.DataManager +import com.dahe.gldriver.net.RxHttpCallBack +import com.dahe.mylibrary.base.BaseActivity +import com.dahe.mylibrary.net.CommonResponseBean +import com.dahe.mylibrary.recycleviewswipe.RecycleViewDivider +import com.dahe.mylibrary.utils.ActivityUtils +import com.dahe.mylibrary.utils.ConvertUtils +import com.google.gson.Gson +import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers +import io.reactivex.rxjava3.schedulers.Schedulers + +/** + * @ClassName QuesActivity + * @Author john + * @Date 2024/3/27 16:00 + * @Description 安全课堂 + */ +class QuesActivity : BaseActivity() { + + lateinit var adapter: QuestionAdatper + override fun initView(savedInstanceState: Bundle?) { + setStatusBarColor(R.color.white) + setTitleBar("安全课堂", true) + + binding.run { + adapter = recycler.run { + layoutManager = LinearLayoutManager(mContext, RecyclerView.VERTICAL, false) + addItemDecoration( + RecycleViewDivider( + LinearLayout.VERTICAL, + ConvertUtils.dp2px(10.0f), + Color.TRANSPARENT + ) + ) + adapter = QuestionAdatper() + adapter as QuestionAdatper + }.apply { + setOnItemClickListener { _, _, position -> + ActivityUtils.startActivity( + mContext, + QueDetailActivity::class.java, + Bundle().apply { + putString(AppConfig.DATA, Gson().toJson(items[position])) + }) + } + } + } + } + + override fun initDate() { + DataManager.getInstance().safeClassroomList() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(BaseObserver(mContext, object : RxHttpCallBack>() { + override fun onSuccess(t: CommonResponseBean>) { + super.onSuccess(t) + adapter.submitList(t.data) + } + })) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/dahe/gldriver/ui/mine/activity/SettingActivity.kt b/app/src/main/java/com/dahe/gldriver/ui/mine/activity/SettingActivity.kt new file mode 100644 index 0000000..752e69a --- /dev/null +++ b/app/src/main/java/com/dahe/gldriver/ui/mine/activity/SettingActivity.kt @@ -0,0 +1,69 @@ +package com.dahe.gldriver.ui.mine.activity + +import android.os.Bundle +import android.view.View +import com.dahe.gldriver.R +import com.dahe.gldriver.databinding.ActivitySettingBinding +import com.dahe.gldriver.push.PushHelper +import com.dahe.gldriver.utils.CommonPopUtils +import com.dahe.gldriver.utils.SPUtils +import com.dahe.glex.bean.UserBean +import com.dahe.mylibrary.base.BaseActivity +import com.dahe.mylibrary.callback.PushAliasListener +import com.dahe.mylibrary.utils.ActivityUtils + +/** + * @ClassName SettingActivity + * @Author john + * @Date 2024/3/27 10:21 + * @Description TODO + */ +class SettingActivity : BaseActivity(), View.OnClickListener { + override fun initView(savedInstanceState: Bundle?) { + setStatusBarColor(R.color.white) + setTitleBar("设置", true) + binding.run { + rlOne.setOnClickListener(this@SettingActivity) + rlTwo.setOnClickListener(this@SettingActivity) + } + } + + override fun initDate() { + } + + override fun onClick(view: View?) { + super.onClick(view) + when (view?.id) { + binding.rlOne.id -> { + if (binding.svTog.isOpened) { + PushHelper.delete(mContext, object : PushAliasListener { + override fun onResult(isSuccess: Boolean) { + binding.svTog.toggleSwitch(false) + } + }) + + } else { + PushHelper.setAlias(mContext, object : PushAliasListener { + override fun onResult(isSuccess: Boolean) { + if (isSuccess){ + binding.svTog.toggleSwitch(true) + }else{ + showToast("开启失败,请登录重试") + } + + } + }) + } + } + + binding.rlTwo.id -> { + CommonPopUtils.getInstance() + .showCommCenterPop(mContext, content = "您确定退出当前app么?") { + SPUtils.instance.removeUserToken(mContext) + ActivityUtils.finishAllActivities() + showToast("清除token") + } + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/dahe/gldriver/utils/AppVersionUtils.kt b/app/src/main/java/com/dahe/gldriver/utils/AppVersionUtils.kt new file mode 100644 index 0000000..78b0973 --- /dev/null +++ b/app/src/main/java/com/dahe/gldriver/utils/AppVersionUtils.kt @@ -0,0 +1,40 @@ +package com.dahe.gldriver.utils + +import android.content.Context +import com.dahe.gldriver.bean.AppVersion +import com.dahe.gldriver.net.BaseObserver +import com.dahe.gldriver.net.DataManager +import com.dahe.gldriver.net.RxHttpCallBack +import com.dahe.glex.bean.UserBean +import com.dahe.mylibrary.base.SingletonNoPHolder +import com.dahe.mylibrary.net.CommonResponseBean +import com.dahe.mylibrary.utils.AppUtils +import com.dahe.mylibrary.utils.ToastUtils +import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers +import io.reactivex.rxjava3.schedulers.Schedulers + +/** + * @ClassName AppVersionUtils + * @Author john + * @Date 2024/3/26 11:12 + * @Description TODO + */ +class AppVersionUtils private constructor() { + companion object : SingletonNoPHolder(::AppVersionUtils) + + fun checkVersion(context: Context) { + DataManager.getInstance().getLastAppVersion() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(BaseObserver(context, object : RxHttpCallBack() { + override fun onSuccess(t: CommonResponseBean) { + super.onSuccess(t) + if (t.data.versionCode> AppUtils.getAppVersionCode()) { + CommonPopUtils.getInstance().showUpApp(context,t.data) + } else { + ToastUtils.showToast(context, "已是最新版本") + } + } + })) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/dahe/gldriver/utils/CommonPopUtils.kt b/app/src/main/java/com/dahe/gldriver/utils/CommonPopUtils.kt index 0a539e6..5b8b87c 100644 --- a/app/src/main/java/com/dahe/gldriver/utils/CommonPopUtils.kt +++ b/app/src/main/java/com/dahe/gldriver/utils/CommonPopUtils.kt @@ -5,11 +5,13 @@ import android.graphics.Color import android.widget.ImageView import androidx.recyclerview.widget.RecyclerView import com.dahe.gldriver.R +import com.dahe.gldriver.bean.AppVersion import com.dahe.gldriver.bean.CarBean import com.dahe.gldriver.callback.OnResultListener import com.dahe.gldriver.mypop.AgreementAlert import com.dahe.gldriver.mypop.OnCarSelectListener import com.dahe.gldriver.mypop.PopBottomCar +import com.dahe.gldriver.weight.pop.UpAppPop import com.dahe.mylibrary.base.SingletonNoPHolder import com.dahe.mylibrary.utils.ConvertUtils import com.lxj.xpopup.XPopup @@ -142,4 +144,22 @@ class CommonPopUtils private constructor() { .show() } + /** + * app版本检查 + * @param context Context + * @param appVersion AppVersion + */ + fun showUpApp(context: Context, appVersion: AppVersion) { + XPopup.Builder(context) + .dismissOnBackPressed(false) + .dismissOnTouchOutside(false) + .asCustom( + UpAppPop( + context, + appVersion + ) + ) + .show() + } + } \ No newline at end of file diff --git a/app/src/main/java/com/dahe/gldriver/weight/pop/UpAppPop.kt b/app/src/main/java/com/dahe/gldriver/weight/pop/UpAppPop.kt new file mode 100644 index 0000000..c4db5a2 --- /dev/null +++ b/app/src/main/java/com/dahe/gldriver/weight/pop/UpAppPop.kt @@ -0,0 +1,118 @@ +package com.dahe.gldriver.weight.pop + +import android.content.Context +import android.util.Log +import android.view.View +import android.view.View.OnClickListener +import android.widget.Button +import android.widget.ImageButton +import android.widget.LinearLayout +import android.widget.ProgressBar +import android.widget.TextView +import com.dahe.gldriver.R +import com.dahe.gldriver.bean.AppVersion +import com.king.app.updater.AppUpdater +import com.king.app.updater.callback.AppUpdateCallback +import com.king.app.updater.constant.Constants +import com.lxj.xpopup.core.CenterPopupView +import java.io.File + +/** + * @author hlh + * @version 1.0.0 + * @date 2021/9/6 17:23 + * @description: + */ +class UpAppPop : CenterPopupView { + private var content: TextView? = null + private var vs: TextView? = null + private var tvContent: TextView? = null + private var tv_cancel: Button? = null + private var tv_confirm: Button? = null + private var tvOk: Button? = null + private var up_div: LinearLayout? = null + + private var con: Context? = null + private var progress_view: ProgressBar? = null + + private var force_box: LinearLayout? = null + private var force_btn: ImageButton? = null + private var appVersion : AppVersion? = null + + constructor( + context: Context, + appVersion: AppVersion + ) : super(context) { + con = context + this.appVersion = appVersion + } + + override fun getImplLayoutId(): Int { + return R.layout.alert_up_app + } + + constructor(context: Context) : super(context) + + override fun onCreate() { + super.onCreate() + content = findViewById(R.id.tv_content) + tv_cancel = findViewById(R.id.tv_cancel) + tv_confirm = findViewById(R.id.tv_confirm) + tvContent = findViewById(R.id.tvContent) + tvOk = findViewById