Compare commits
15 Commits
dd3beea20e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9854b7b90d | ||
|
|
75014598ed | ||
|
|
795fcec1a2 | ||
|
|
e14087355f | ||
|
|
b1e0eef1ab | ||
|
|
3ddc5c23f6 | ||
|
|
a9ec548557 | ||
|
|
d6d1ad93f2 | ||
|
|
66160b45e0 | ||
|
|
53feace665 | ||
|
|
6e519da2d4 | ||
|
|
8bb497b548 | ||
|
|
ed0a3e803d | ||
|
|
4021989676 | ||
|
|
5663af6a17 |
@@ -28,9 +28,9 @@ android {
|
||||
applicationId "com.abbidot.tracker"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 35
|
||||
versionCode 2103
|
||||
// versionName "2.1.3"
|
||||
versionName "2.1.3-Beta1"
|
||||
versionCode 2107
|
||||
// versionName "2.1.7"
|
||||
versionName "2.1.7-Beta1"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ class MySubscriptionAdapter(
|
||||
}
|
||||
holder.setText(
|
||||
R.id.tv_my_subscription_active_time,
|
||||
Utils.stringToDate(item.updateTime, resultFormat = Utils.DATE_FORMAT_PATTERN_EN6)
|
||||
Utils.formatTime(item.payTime, Utils.DATE_FORMAT_PATTERN_EN6)
|
||||
)
|
||||
|
||||
holder.getTextView(R.id.tv_my_subscription_annual_care).apply {
|
||||
@@ -74,13 +74,17 @@ class MySubscriptionAdapter(
|
||||
else mContext.getString(R.string.txt_no)
|
||||
}
|
||||
|
||||
// val timestamp = getAfterHowTimestamp(
|
||||
// Utils.stringToTimestamp(item.currentTime), item.surplusDays
|
||||
// )
|
||||
holder.setText(
|
||||
R.id.tv_my_subscription_expires_on,
|
||||
Utils.formatTime(item.endTime, Utils.DATE_FORMAT_PATTERN_EN7)
|
||||
)
|
||||
holder.getTextView(R.id.tv_my_subscription_expires_on).apply {
|
||||
text = if (item.orderStatus == 6 && item.refundTime > 0L) {
|
||||
Utils.formatTime(item.refundTime, Utils.DATE_FORMAT_PATTERN_EN6)
|
||||
} else {
|
||||
Utils.formatTime(
|
||||
Utils.timestampAddHowTimestamp(
|
||||
item.payTime, item.mealPeriod, item.mealUnit
|
||||
), Utils.DATE_FORMAT_PATTERN_EN7
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (item.subscriptionStatus == ConstantInt.Close) {
|
||||
holder.setText(
|
||||
@@ -93,40 +97,45 @@ class MySubscriptionAdapter(
|
||||
mContext.getString(R.string.tracker_manage_set_led_on)
|
||||
)
|
||||
}
|
||||
|
||||
val cTimeMillis = System.currentTimeMillis()
|
||||
val expiredTime = item.endTime * 1000 - cTimeMillis
|
||||
//是否过期套餐
|
||||
val isExpired =
|
||||
item.orderStatus == 6 || (item.subscriptionStatus == ConstantInt.Close && expiredTime <= 0)
|
||||
val userId = MMKVUtil.getString(MMKVKey.UserId)
|
||||
val expiresTitle = holder.getTextView(R.id.tv_my_subscription_expires_title)
|
||||
holder.getButton(R.id.btn_my_subscription_recharge).apply {
|
||||
visibility =
|
||||
if (item.orderStatus == 6 || (item.surplusDays == 0L && item.subscriptionStatus == ConstantInt.Close)) {
|
||||
setText(R.string.txt_card_recharge)
|
||||
expiresTitle.setText(R.string.txt_expires_on2)
|
||||
View.VISIBLE
|
||||
} else if (item.subscriptionStatus == ConstantInt.Close) {
|
||||
setText(R.string.txt_enable_auto_renew)
|
||||
expiresTitle.setText(R.string.txt_expires_on1)
|
||||
View.VISIBLE
|
||||
} else {
|
||||
expiresTitle.setText(R.string.txt_expires_on1)
|
||||
View.GONE
|
||||
}
|
||||
visibility = if (isExpired) {
|
||||
setText(R.string.txt_card_recharge)
|
||||
expiresTitle.setText(R.string.txt_expires_on2)
|
||||
View.VISIBLE
|
||||
} else if (item.subscriptionStatus == ConstantInt.Close) {
|
||||
setText(R.string.txt_enable_auto_renew)
|
||||
expiresTitle.setText(R.string.txt_expires_on1)
|
||||
View.VISIBLE
|
||||
} else {
|
||||
expiresTitle.setText(R.string.txt_expires_on1)
|
||||
View.GONE
|
||||
}
|
||||
|
||||
//UserId不一样就是共享设备的订单
|
||||
visibility = if (item.userId == userId) visibility else View.GONE
|
||||
}
|
||||
|
||||
holder.getView(R.id.il_my_subscription_count_down).apply {
|
||||
visibility =
|
||||
if (item.orderStatus == 6 || (item.surplusDays == 0L && item.subscriptionStatus == ConstantInt.Close)) {
|
||||
View.GONE
|
||||
} else {
|
||||
View.VISIBLE
|
||||
}
|
||||
visibility = if (isExpired) {
|
||||
View.GONE
|
||||
} else {
|
||||
View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
val times = Utils.getDayToYearMonthDay(item.surplusDays)
|
||||
val times = Utils.differYear(cTimeMillis, item.endTime)
|
||||
holder.setText(R.id.tv_add_success_device_expires_days, times[0])
|
||||
holder.setText(R.id.tv_add_success_device_expires_hours, times[1])
|
||||
holder.setText(R.id.tv_add_success_device_expires_min, times[2])
|
||||
|
||||
holder.getView(R.id.fl_my_subscription_btn_layout).apply {
|
||||
val userId = MMKVUtil.getString(MMKVKey.UserId)
|
||||
//UserId不一样就是共享设备的订单
|
||||
visibility = if (item.userId == userId) {
|
||||
setOnClickListener {
|
||||
@@ -137,7 +146,7 @@ class MySubscriptionAdapter(
|
||||
}
|
||||
//充值
|
||||
holder.setClickListener(R.id.btn_my_subscription_recharge) {
|
||||
if (item.surplusDays == 0L && item.subscriptionStatus == ConstantInt.Close) {
|
||||
if (item.subscriptionStatus == ConstantInt.Close && expiredTime <= 0) {
|
||||
Intent(mContext, SubscriptionPlanActivity::class.java).let {
|
||||
it.putExtra(ConstantString.LkSetMeal, item)
|
||||
it.putExtra(ConstantString.RechargeType, ConstantInt.Type2)
|
||||
@@ -169,8 +178,10 @@ class MySubscriptionAdapter(
|
||||
}
|
||||
//升级套餐
|
||||
view.findViewById<TypefaceTextView>(R.id.tv_pop_my_subscription_auto_renew).apply {
|
||||
val cTimeMillis = System.currentTimeMillis()
|
||||
val expiredTime = item.endTime * 1000 - cTimeMillis
|
||||
visibility =
|
||||
if (item.planCategory == "Premium" || (item.surplusDays == 0L && item.subscriptionStatus == ConstantInt.Close)) {
|
||||
if (item.planCategory == "Premium" || (item.subscriptionStatus == ConstantInt.Close && expiredTime <= 0)) {
|
||||
View.GONE
|
||||
} else {
|
||||
View.VISIBLE
|
||||
|
||||
@@ -51,22 +51,27 @@ class NotificationV2Adapter(
|
||||
setTextColor(ContextCompat.getColor(mContext, textColor))
|
||||
}
|
||||
holder.getTextView(R.id.tv_home_route_notification_date).apply {
|
||||
text = getRelativeTimeString(Utils.stringToTimestamp(item.sendTime))
|
||||
text = getRelativeTimeString(item.sendTime)
|
||||
setTextColor(ContextCompat.getColor(mContext, textColor))
|
||||
}
|
||||
}
|
||||
|
||||
private fun getRelativeTimeString(time: Long): String {
|
||||
private fun getRelativeTimeString(sendTime: String): String {
|
||||
var formatDateStr = ""
|
||||
val time = Utils.stringToTimestamp(sendTime, isUtc = true)
|
||||
val now = System.currentTimeMillis()
|
||||
formatDateStr = if (DateUtils.isToday(time)) {
|
||||
mContext.getString(R.string.txt_today) + " " + Utils.formatTime(
|
||||
time, Utils.DATE_FORMAT_PATTERN_EN8
|
||||
)
|
||||
} else if (now - time < (48 * 60 * 60 * 1000)) {
|
||||
mContext.getString(R.string.txt_yesterday)
|
||||
mContext.getString(R.string.txt_yesterday) + " " + Utils.formatTime(
|
||||
time, Utils.DATE_FORMAT_PATTERN_EN8
|
||||
)
|
||||
} else {
|
||||
Utils.formatTime(time, Utils.DATE_FORMAT_PATTERN_EN9)
|
||||
Utils.formatTime(
|
||||
Utils.stringToTimestamp(sendTime), Utils.DATE_FORMAT_PATTERN_EN9
|
||||
)
|
||||
}
|
||||
return formatDateStr
|
||||
}
|
||||
|
||||
@@ -51,24 +51,27 @@ class SubscriptionHistoryAdapter(
|
||||
R.id.tv_subscription_annual_care_order_id,
|
||||
context.getString(R.string.txt_order_id) + item.orderNum
|
||||
)
|
||||
val cTimeMillis = System.currentTimeMillis()
|
||||
val expiredTime = item.endTime * 1000 - cTimeMillis
|
||||
val state =
|
||||
if (item.enabled == ConstantInt.Type0 || (item.surplusDays == 0L && item.subscriptionStatus == ConstantInt.Close)) {
|
||||
if (item.enabled == ConstantInt.Type0 || (item.subscriptionStatus == ConstantInt.Close && expiredTime <= 0)) {
|
||||
context.getString(R.string.txt_expired)
|
||||
} else {
|
||||
context.getString(R.string.txt_active)
|
||||
}
|
||||
holder.setText(R.id.tv_subscription_annual_care_state, state)
|
||||
holder.setText(
|
||||
R.id.tv_subscription_annual_care_active_time,
|
||||
Utils.stringToDate(item.createTime, resultFormat = Utils.DATE_FORMAT_PATTERN_EN7)
|
||||
R.id.tv_subscription_annual_care_active_time, Utils.formatTime(
|
||||
item.payTime, Utils.DATE_FORMAT_PATTERN_EN7
|
||||
)
|
||||
)
|
||||
//保险时长,不足一年按12个月算
|
||||
val insuranceTime =
|
||||
if (item.mealUnit == ConstantString.PackageUnitYear) item.mealPeriod else 1
|
||||
holder.setText(
|
||||
R.id.tv_subscription_annual_care_expiry_time, Utils.formatTime(
|
||||
Utils.getAfterHowTimestamp(
|
||||
Utils.stringToTimestamp(item.createTime), insuranceTime * 365L
|
||||
Utils.timestampAddHowTimestamp(
|
||||
item.payTime, insuranceTime, ConstantString.PackageUnitYear
|
||||
), Utils.DATE_FORMAT_PATTERN_EN7
|
||||
)
|
||||
)
|
||||
@@ -89,7 +92,7 @@ class SubscriptionHistoryAdapter(
|
||||
)
|
||||
holder.setText(
|
||||
R.id.tv_subscription_history_order_time,
|
||||
Utils.stringToDate(item.createTime, resultFormat = Utils.DATE_FORMAT_PATTERN_EN10)
|
||||
Utils.formatTime(item.payTime, Utils.DATE_FORMAT_PATTERN_EN10)
|
||||
)
|
||||
holder.setText(R.id.tv_subscription_history_package_name, item.mealName)
|
||||
holder.setText(
|
||||
@@ -107,10 +110,14 @@ class SubscriptionHistoryAdapter(
|
||||
visibility = View.VISIBLE
|
||||
when (item.orderStatus) {
|
||||
1 -> {
|
||||
val updateTimestamp = Utils.stringToTimestamp(item.updateTime)
|
||||
val updateTimestamp = Utils.stringToTimestamp(item.updateTime, isUtc = true)
|
||||
val nowTimestamp = System.currentTimeMillis()
|
||||
// val nowTimestamp = Utils.stringToTimestamp(item.currentTime)
|
||||
if (item.mealUnit == ConstantString.PackageUnitMonth) {
|
||||
if (item.enabled == ConstantInt.Type0 || (item.surplusDays == 0L && item.subscriptionStatus == ConstantInt.Close)) {
|
||||
visibility = View.GONE
|
||||
} else if (item.mealUnit == ConstantString.PackageUnitDay) {
|
||||
visibility = View.VISIBLE
|
||||
setText(R.string.txt_refund)
|
||||
} else if (item.mealUnit == ConstantString.PackageUnitMonth) {
|
||||
val day7Timestamp = 7 * 24 * 60 * 60 * 1000L
|
||||
//套餐超出7天不能退款
|
||||
if (nowTimestamp - updateTimestamp <= day7Timestamp) {
|
||||
@@ -155,8 +162,10 @@ class SubscriptionHistoryAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
val cTimeMillis = System.currentTimeMillis()
|
||||
val expiredTime = item.endTime * 1000 - cTimeMillis
|
||||
val state =
|
||||
if (item.enabled == ConstantInt.Type0 || (item.surplusDays == 0L && item.subscriptionStatus == ConstantInt.Close)) {
|
||||
if (item.enabled == ConstantInt.Type0 || (item.subscriptionStatus == ConstantInt.Close && expiredTime <= 0)) {
|
||||
context.getString(R.string.txt_expired)
|
||||
} else {
|
||||
context.getString(R.string.txt_active)
|
||||
|
||||
@@ -671,6 +671,41 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
|
||||
showToast(R.string.txt_no_dfu)
|
||||
return true
|
||||
}
|
||||
//系统异常
|
||||
"1001" -> {
|
||||
showToast(R.string.txt_system_error)
|
||||
return true
|
||||
}
|
||||
|
||||
"1002" -> {
|
||||
showToast(R.string.txt_missing_param)
|
||||
return true
|
||||
}
|
||||
|
||||
"1003" -> {
|
||||
showToast(R.string.txt_tracker_busy)
|
||||
return true
|
||||
}
|
||||
|
||||
"1004" -> {
|
||||
showToast(R.string.txt_tracker_offline)
|
||||
return true
|
||||
}
|
||||
|
||||
"1005" -> {
|
||||
showToast(R.string.txt_tracker_live)
|
||||
return true
|
||||
}
|
||||
|
||||
"1006" -> {
|
||||
showToast(R.string.txt_time_out_try_again)
|
||||
return true
|
||||
}
|
||||
|
||||
"1007" -> {
|
||||
showToast(R.string.txt_abnormity)
|
||||
return true
|
||||
}
|
||||
|
||||
else -> return false
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ data class SubscriptionsOrderBean(
|
||||
var mealDiscountPrice: Double,
|
||||
var orderNum: String,
|
||||
var orderStatus: Int,//0支付取消 1支付成功 2支付失败 3待支付 4申请审核中 5退款中 6退款成功 7退款失败 8审核失败
|
||||
var payTime: String,
|
||||
var payTime: Long,
|
||||
var payType: Int,
|
||||
var planCategory: String,
|
||||
var planId: String,
|
||||
@@ -53,6 +53,7 @@ data class SubscriptionsOrderBean(
|
||||
var username: String,
|
||||
var iccid: String,
|
||||
var endTime: Long,
|
||||
var refundTime: Long,
|
||||
var planTimeMonthsCount: Int,
|
||||
@MultipleEntity var menuType: Int,
|
||||
var isUpdateOrder: Int = 0//是否是升级订单 1:是 0:否
|
||||
@@ -76,7 +77,7 @@ data class SubscriptionsOrderBean(
|
||||
0.0,
|
||||
"",
|
||||
0,
|
||||
"",
|
||||
0L,
|
||||
0,
|
||||
"",
|
||||
"",
|
||||
@@ -98,6 +99,7 @@ data class SubscriptionsOrderBean(
|
||||
"",
|
||||
"",
|
||||
0L,
|
||||
0L,
|
||||
0,
|
||||
menuType,
|
||||
0
|
||||
@@ -122,7 +124,7 @@ data class SubscriptionsOrderBean(
|
||||
0.0,
|
||||
"",
|
||||
0,
|
||||
"",
|
||||
0L,
|
||||
0,
|
||||
"",
|
||||
"",
|
||||
@@ -144,6 +146,7 @@ data class SubscriptionsOrderBean(
|
||||
"",
|
||||
"",
|
||||
0L,
|
||||
0L,
|
||||
0,
|
||||
MultipleEntity.TEXT,
|
||||
0
|
||||
|
||||
@@ -173,6 +173,8 @@ class ShowCalenderAndTimeDialog(
|
||||
val timesTamp = Utils.stringToTimestamp(selectMonthYear)
|
||||
val nowTimestamp = System.currentTimeMillis()
|
||||
if (timesTamp > nowTimestamp) {
|
||||
//时间戳还原
|
||||
setSelectDate(nowTimestamp)
|
||||
mShowCalenderTextView.text = Utils.formatTime(nowTimestamp, mDateFormat)
|
||||
} else {
|
||||
mShowCalenderTextView.text = Utils.stringToDate(
|
||||
|
||||
@@ -103,6 +103,9 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
|
||||
//是否已经触发倒计时自动连接设备
|
||||
private var isCountdownAutoConnBle = false
|
||||
|
||||
//是否检查套餐过期
|
||||
private var isCheckPackageExpire = true
|
||||
|
||||
private val mFragments = mutableListOf<Fragment>(
|
||||
ActivityV2Fragment.newInstance(this),
|
||||
RouteV2Fragment.newInstance(this),
|
||||
@@ -171,6 +174,8 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
|
||||
mCountdownType = ConstantInt.Type0
|
||||
mCountDownTimerViewModel.startCountDown(4)
|
||||
} else {
|
||||
//清除首次绑定设备信息
|
||||
MMKVUtil.putString(MMKVKey.FirstDeviceMac, "")
|
||||
val connectivityManager = getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
val networkCallback: ConnectivityManager.NetworkCallback =
|
||||
object : ConnectivityManager.NetworkCallback() {
|
||||
@@ -539,13 +544,13 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
|
||||
* 套餐不可用状态
|
||||
*/
|
||||
private fun packageUnavailableState() {
|
||||
autoConnectDevice()
|
||||
getPet(false)?.apply {
|
||||
//判断套餐有没有到期
|
||||
if (shared == ConstantInt.NoShare && availableOrder == ConstantInt.Type0) {
|
||||
if (isCheckPackageExpire && shared == ConstantInt.NoShare && availableOrder == ConstantInt.Type0) {
|
||||
Util.checkPackageExpired(this@HomeV2Activity, deviceId)
|
||||
}
|
||||
}
|
||||
autoConnectDevice()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -573,7 +578,8 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
|
||||
/**
|
||||
* 选择宠物弹窗
|
||||
*/
|
||||
fun selectPetDialog() {
|
||||
fun selectPetDialog(checkPackageExpire: Boolean = true) {
|
||||
isCheckPackageExpire = checkPackageExpire
|
||||
if (mPetList.size == 0) {
|
||||
showToast(R.string.no_bind_pet)
|
||||
return
|
||||
@@ -616,14 +622,14 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
|
||||
mChangePetDialog?.dismiss()
|
||||
mSelectPetPosition = position
|
||||
mChangePetListDialogAdapter.setSelectPetPos(mSelectPetPosition)
|
||||
//判断套餐有没有到期
|
||||
packageUnavailableState()
|
||||
when (mViewBinding.homeV2ViewPager2.currentItem) {
|
||||
0 -> (mFragments[0] as ActivityV2Fragment).showPetNameAndHead(position)
|
||||
1 -> (mFragments[1] as RouteV2Fragment).showPetNameAndHead(position)
|
||||
2 -> (mFragments[2] as MapV3Fragment).showPetNameAndHead(position)
|
||||
3 -> (mFragments[3] as PetV2Fragment).showPetNameAndHead(position)
|
||||
}
|
||||
//判断套餐有没有到期
|
||||
packageUnavailableState()
|
||||
}
|
||||
|
||||
override fun onNavigationItemSelected(item: MenuItem): Boolean {
|
||||
@@ -684,6 +690,11 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
|
||||
* 自动连接设备
|
||||
*/
|
||||
private fun autoConnectDevice() {
|
||||
val share = MMKVUtil.getInt(MMKVKey.Shared)
|
||||
if (share != ConstantInt.NoShare) {
|
||||
LogUtil.e("分享的设备,不连接设备")
|
||||
return
|
||||
}
|
||||
getPet(false)?.apply {
|
||||
if (TextUtils.isEmpty(macID)) return@apply
|
||||
if (SRBleUtil.instance.isBleEnable(mContext)) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.commit
|
||||
import coil.load
|
||||
import coil.transform.BlurTransformation
|
||||
import com.abbidot.baselibrary.util.LogUtil
|
||||
import com.abbidot.tracker.R
|
||||
import com.abbidot.tracker.base.BaseActivity
|
||||
import com.abbidot.tracker.databinding.ActivityAddEmailValidBinding
|
||||
@@ -61,10 +62,13 @@ open class AddEmailValidActivity :
|
||||
R.anim.slide_out_right
|
||||
)
|
||||
|
||||
if (mFragmentList[index].isAdded) {
|
||||
show(mFragmentList[index])
|
||||
} else {
|
||||
add(R.id.fc_forgot_password_v2_frame, mFragmentList[index])
|
||||
mFragmentList[index].let {
|
||||
LogUtil.e("switchFragment--->$index,${it.isAdded},${it.isHidden}")
|
||||
if (it.isAdded || it.isHidden) {
|
||||
show(it)
|
||||
} else {
|
||||
add(R.id.fc_forgot_password_v2_frame, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,11 @@ package com.abbidot.tracker.ui.activity.device
|
||||
|
||||
import android.content.Intent
|
||||
import android.text.TextUtils
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import androidx.activity.viewModels
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.abbidot.baselibrary.constant.ConState
|
||||
import com.abbidot.baselibrary.constant.EventName
|
||||
import com.abbidot.baselibrary.constant.MMKVKey
|
||||
import com.abbidot.baselibrary.eventbus.XEventBus
|
||||
@@ -12,7 +15,9 @@ import com.abbidot.baselibrary.util.MMKVUtil
|
||||
import com.abbidot.baselibrary.util.Utils
|
||||
import com.abbidot.tracker.R
|
||||
import com.abbidot.tracker.base.BaseActivity
|
||||
import com.abbidot.tracker.bean.BleTrackDeviceBean
|
||||
import com.abbidot.tracker.bean.PetBean
|
||||
import com.abbidot.tracker.bean.ReceiveDeviceData
|
||||
import com.abbidot.tracker.bean.SubscriptionsOrderBean
|
||||
import com.abbidot.tracker.constant.ConstantInt
|
||||
import com.abbidot.tracker.constant.ConstantString
|
||||
@@ -22,9 +27,14 @@ import com.abbidot.tracker.deprecated.ui.activity.vm.AddTrackerDeviceViewModel
|
||||
import com.abbidot.tracker.ui.activity.device.wifi.AddWifiPowerZone1Activity
|
||||
import com.abbidot.tracker.ui.activity.subscribe.SubscriptionPlanActivity
|
||||
import com.abbidot.tracker.util.Util
|
||||
import com.abbidot.tracker.util.ViewUtil
|
||||
import com.abbidot.tracker.util.bluetooth.SRBleCmdUtil
|
||||
import com.abbidot.tracker.util.bluetooth.SRBleUtil
|
||||
import com.abbidot.tracker.vm.ConnectionDeviceViewModel
|
||||
import com.abbidot.tracker.vm.PetInfoViewModel
|
||||
import com.abbidot.tracker.vm.PetRelationViewModel
|
||||
import com.abbidot.tracker.vm.UserProfileViewModel
|
||||
import com.clj.fastble.BleManager
|
||||
|
||||
class AddPairedSuccessActivity :
|
||||
BaseActivity<ActivityAddPairedSuccessBinding>(ActivityAddPairedSuccessBinding::inflate) {
|
||||
@@ -33,6 +43,7 @@ class AddPairedSuccessActivity :
|
||||
private val mPetViewModel: PetInfoViewModel by viewModels()
|
||||
private val mUserProfileViewModel: UserProfileViewModel by viewModels()
|
||||
private val mPetRelationViewModel: PetRelationViewModel by viewModels()
|
||||
private val mConnectionDeviceViewModel: ConnectionDeviceViewModel by viewModels()
|
||||
|
||||
private lateinit var mSubscriptionsOrderBean: SubscriptionsOrderBean
|
||||
|
||||
@@ -42,6 +53,9 @@ class AddPairedSuccessActivity :
|
||||
private var mMac = ""
|
||||
private var mPetBean: PetBean? = null
|
||||
|
||||
//判断设备可用套餐状态
|
||||
private var mAvailableOrder = 0
|
||||
|
||||
override fun getTopBar() = mViewBinding.ilAddPairedSuccessTopBar.titleTopBar
|
||||
|
||||
override fun initData() {
|
||||
@@ -61,13 +75,14 @@ class AddPairedSuccessActivity :
|
||||
tvPairSuccessDeviceOutId.text = mDeviceOutId
|
||||
setOnClickListenerViews(btnPairSuccessActivate)
|
||||
}
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type0)
|
||||
mAddTrackerViewModel.getDeviceOrderStatus(this@AddPairedSuccessActivity, mDeviceOutId)
|
||||
}
|
||||
|
||||
override fun liveDataObserve() {
|
||||
mAddTrackerViewModel.apply {
|
||||
//获取设备套餐可用状态
|
||||
mDeviceOrderStatusLiveData.observe(this@AddPairedSuccessActivity) {
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type1)
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
it.getOrNull()?.apply {
|
||||
@@ -80,35 +95,41 @@ class AddPairedSuccessActivity :
|
||||
o.deviceId = mDeviceId
|
||||
o.userId = MMKVUtil.getString(MMKVKey.UserId)
|
||||
}
|
||||
mNetworkRequestsFailRetryCount = 0
|
||||
|
||||
mAvailableOrder = availableOrder
|
||||
//判断设备是否有可用套餐
|
||||
if (availableOrder == ConstantInt.Type1) {
|
||||
setButtonEnabled(
|
||||
mViewBinding.btnPairSuccessActivate, ConstantInt.Type0
|
||||
)
|
||||
//刷新设备绑定
|
||||
mAddTrackerViewModel.updatePayDeviceState(
|
||||
this@AddPairedSuccessActivity, mDeviceId
|
||||
)
|
||||
bleNotify()
|
||||
connectBle(mMac)
|
||||
} else {
|
||||
mAddTrackerViewModel.getIccId(
|
||||
this@AddPairedSuccessActivity, mDeviceOutId
|
||||
setButtonEnabled(
|
||||
mViewBinding.btnPairSuccessActivate, ConstantInt.Type1
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
LogUtil.e("获取设备套餐可用状态---->请求错误onRequestError,再次请求")
|
||||
if (exceptionCode == mNetworkRequestsFailLimit) {
|
||||
finish()
|
||||
} else {
|
||||
mAddTrackerViewModel.getDeviceOrderStatus(
|
||||
this@AddPairedSuccessActivity, mDeviceOutId
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//获取设备sim卡IccId
|
||||
mGetIccIdLiveData.observe(this@AddPairedSuccessActivity) {
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type1)
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
it.getOrNull()?.apply {
|
||||
mSubscriptionsOrderBean.deviceOutId = mDeviceOutId
|
||||
mSubscriptionsOrderBean.iccid = iccid
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type0)
|
||||
|
||||
val intent = Intent(mContext, SubscriptionPlanActivity::class.java)
|
||||
intent.putExtra(ConstantString.LkSetMeal, mSubscriptionsOrderBean)
|
||||
@@ -116,6 +137,11 @@ class AddPairedSuccessActivity :
|
||||
startActivityFinish(intent)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
super.onRequestError(exceptionCode)
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -126,20 +152,18 @@ class AddPairedSuccessActivity :
|
||||
MMKVUtil.putInt(MMKVKey.isBindDevice, ConstantInt.isBind)
|
||||
XEventBus.post(EventName.RefreshDevice)
|
||||
|
||||
mUserProfileViewModel.updateMeasureUnit(ConstantInt.Type1)
|
||||
// if (isFirstBind) {
|
||||
// mUserProfileViewModel.updateMeasureUnit(ConstantInt.Type1)
|
||||
//// val intent = Intent(mContext, FirstSetPetTypeActivity::class.java)
|
||||
//// intent.putExtra(ConstantString.isFirstBind, isFirstBind)
|
||||
//// startActivityFinish(intent)
|
||||
// } else finish()
|
||||
SRBleUtil.instance.getConnectMacDevice(mMac)?.let { ble ->
|
||||
SRBleUtil.instance.writeData(
|
||||
ble.bleDevice, SRBleCmdUtil.instance.setWorkingStatus()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
LogUtil.e("支付成功后,更新绑定状态------->请求宠物数据错误onRequestError,再次请求")
|
||||
LogUtil.e("有套餐,更新绑定状态--->请求数据错误onRequestError,再次请求")
|
||||
if (exceptionCode == mNetworkRequestsFailLimit) {
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type1)
|
||||
} else {
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type0)
|
||||
mAddTrackerViewModel.updatePayDeviceState(
|
||||
this@AddPairedSuccessActivity, mSubscriptionsOrderBean.deviceId
|
||||
)
|
||||
@@ -197,7 +221,7 @@ class AddPairedSuccessActivity :
|
||||
}
|
||||
//绑定默认宠物
|
||||
mPetRelationViewModel.mBindPetLiveData.observe(this@AddPairedSuccessActivity) {
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type1)
|
||||
// setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type1)
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
XEventBus.post(EventName.RefreshPet)
|
||||
@@ -216,15 +240,96 @@ class AddPairedSuccessActivity :
|
||||
}, 1500)
|
||||
}
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
super.onRequestError(exceptionCode)
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type1)
|
||||
}
|
||||
// override fun onRequestError(exceptionCode: String?) {
|
||||
// super.onRequestError(exceptionCode)
|
||||
// setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type1)
|
||||
// }
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun bleNotify() {
|
||||
//接收蓝牙连接状态
|
||||
XEventBus.observe(this, EventName.ConnectDeviceState) { ble: BleTrackDeviceBean ->
|
||||
if (TextUtils.isEmpty(mMac)) return@observe
|
||||
mViewBinding.ilPairSuccessBluetoothTips.trbBleConnectState.let { view ->
|
||||
val bgColor = if (ble.conState == ConState.CONNECTED) {
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type1)
|
||||
view.text = getString(R.string.tracker_manage_set_ble_connect)
|
||||
ContextCompat.getColor(mContext, R.color.cyan_color1)
|
||||
} else {
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type0)
|
||||
view.text = getString(R.string.tracker_manage_set_ble_unconnect)
|
||||
ContextCompat.getColor(mContext, R.color.red_color4)
|
||||
}
|
||||
view.setBackgroundColor(bgColor)
|
||||
ViewUtil.instance.bleConStateToast(this, ble.conState, Gravity.CENTER)
|
||||
}
|
||||
}
|
||||
|
||||
//搜索蓝牙的设备状态
|
||||
XEventBus.observe(this, EventName.ActionConDeviceState) { conState: Int ->
|
||||
if (TextUtils.isEmpty(mMac)) return@observe
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type0)
|
||||
if (conState == ConState.DEVICE_NOT_FOUND) {
|
||||
// ViewUtil.instance.showDialog(
|
||||
// mContext,
|
||||
// R.string.txt_no_search_device,
|
||||
// object : BaseDialog.OnDialogOkListener {
|
||||
// override fun onOkClick(dialog: BaseDialog<*>) {
|
||||
// dialog.dismiss()
|
||||
// }
|
||||
// },
|
||||
// okTextResId = R.string.txt_sure,
|
||||
// cancelTextResId = R.string.txt_cancel
|
||||
// )
|
||||
}
|
||||
mViewBinding.ilPairSuccessBluetoothTips.trbBleConnectState.let { view ->
|
||||
ViewUtil.instance.bleConActionState(this, view, conState)
|
||||
}
|
||||
}
|
||||
|
||||
//接收蓝牙返回数据
|
||||
XEventBus.observe(this, EventName.DeviceReceiveData) { receiveData: ReceiveDeviceData ->
|
||||
if (TextUtils.isEmpty(mMac)) return@observe
|
||||
if (mMac == receiveData.mac) {
|
||||
val data = receiveData.data
|
||||
parseData(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析数据
|
||||
*/
|
||||
private fun parseData(data: ByteArray?) {
|
||||
if (null != data && data.isNotEmpty()) {
|
||||
val data0 = SRBleCmdUtil.instance.byteToInt(data[0])
|
||||
val data1 = SRBleCmdUtil.instance.byteToInt(data[1])
|
||||
val data2 = SRBleCmdUtil.instance.byteToInt(data[2])
|
||||
if (data0 == 0x1A && data1 == 1 && data2 == 0) {
|
||||
mUserProfileViewModel.updateMeasureUnit(ConstantInt.Type1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun connectBle(mac: String) {
|
||||
mViewBinding.ilPairSuccessBluetoothTips.root.visibility = View.VISIBLE
|
||||
//是否连接了蓝牙
|
||||
if (BleManager.getInstance().isConnected(mac)) {
|
||||
mViewBinding.ilPairSuccessBluetoothTips.trbBleConnectState.let {
|
||||
it.setBackgroundColor(
|
||||
ContextCompat.getColor(mContext, R.color.cyan_color1)
|
||||
)
|
||||
it.text = getString(R.string.tracker_manage_set_ble_connect)
|
||||
}
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type1)
|
||||
} else {
|
||||
mConnectionDeviceViewModel.connectDeviceToMac(this@AddPairedSuccessActivity, mac)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun addBindActivateDevice() {
|
||||
if (TextUtils.isEmpty(mDeviceOutId)) {
|
||||
@@ -232,9 +337,12 @@ class AddPairedSuccessActivity :
|
||||
return
|
||||
}
|
||||
setButtonEnabled(mViewBinding.btnPairSuccessActivate, ConstantInt.Type0)
|
||||
mAddTrackerViewModel.getDeviceOrderStatus(
|
||||
this@AddPairedSuccessActivity, mDeviceOutId
|
||||
)
|
||||
if (mAvailableOrder == ConstantInt.Type1) {
|
||||
//刷新设备绑定
|
||||
mAddTrackerViewModel.updatePayDeviceState(this@AddPairedSuccessActivity, mDeviceId)
|
||||
} else {
|
||||
mAddTrackerViewModel.getIccId(this@AddPairedSuccessActivity, mDeviceOutId)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
|
||||
@@ -87,11 +87,10 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
ledMode = position + 1
|
||||
mViewBinding.ledLightMode.detailText = mLedModeList[position]
|
||||
mViewBinding.ledLightOpenAndClose.switch.let {
|
||||
if (it.isChecked) {
|
||||
setBleLedMode(ledMode)
|
||||
} else {
|
||||
if (!it.isChecked) {
|
||||
it.isChecked = true
|
||||
}
|
||||
setBleLedMode(ledMode)
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -195,6 +194,11 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
override fun onResult(any: Any) {
|
||||
showToast(R.string.txt_change_successful, isFinish = true)
|
||||
}
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
isFinishSave = false
|
||||
mViewBinding.btnLedLightSetSave.isEnabled = true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -440,6 +444,7 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
.isConnected(mBleTrackDeviceBean!!.bleDevice)
|
||||
) ConstantInt.Type1
|
||||
else ConstantInt.Type2
|
||||
btnLedLightSetSave.isEnabled = false
|
||||
finishAndSave(modeType)
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ class TrackingDurationSetActivity :
|
||||
|
||||
private fun setListData() {
|
||||
val durationList = mutableListOf<DataBean>()
|
||||
val timeList = mutableListOf(1, 3, 5, 10, 15)
|
||||
val timeList = mutableListOf(3, 5, 10, 15)
|
||||
for (time in timeList) {
|
||||
DataBean().apply {
|
||||
imageId = time
|
||||
|
||||
@@ -92,12 +92,15 @@ class InviteFamilyActivity :
|
||||
|
||||
override fun liveDataObserve() {
|
||||
mFamilyViewModel.mInviteLiveData.observe(this) {
|
||||
mViewBinding.btnInviteFamilyInvite.isEnabled = true
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
XEventBus.post(EventName.RefreshFamily)
|
||||
showToast(R.string.tracker_manage_set_add_family_succ, true)
|
||||
}
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
mViewBinding.btnInviteFamilyInvite.isEnabled = true
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,22 +63,16 @@ class PaymentSuccessActivity :
|
||||
ivPaymentSuccessAnim.load(R.drawable.pwd_reset_successful_done)
|
||||
mPayResult?.let {
|
||||
LogUtil.e("充值类型rechargeType=${it.rechargeType}")
|
||||
// if (it.rechargeType == ConstantInt.Type0) {
|
||||
// btnPaymentSuccessContinue.setText(R.string.txt_continue)
|
||||
// }
|
||||
if (it.rechargeType == ConstantInt.Type0 || it.rechargeType == ConstantInt.Type1) {
|
||||
btnPaymentSuccessContinue.isEnabled = false
|
||||
//刷新设备绑定
|
||||
mAddTrackerViewModel.updatePayDeviceState(
|
||||
this@PaymentSuccessActivity, it.deviceId
|
||||
)
|
||||
}
|
||||
|
||||
tvPaymentSuccessDeviceId.text = it.deviceOutId
|
||||
tvPaymentSuccessExpiresOnDate.text = Utils.stringToDate(
|
||||
it.expirationTime, resultFormat = Utils.DATE_FORMAT_PATTERN_EN7
|
||||
tvPaymentSuccessExpiresOnDate.text = Utils.formatTime(
|
||||
Utils.stringToTimestamp(
|
||||
it.expirationTime, isUtc = true
|
||||
), Utils.DATE_FORMAT_PATTERN_EN6
|
||||
)
|
||||
val times = Utils.differYear(
|
||||
System.currentTimeMillis(), Utils.stringToTimestamp(it.expirationTime)
|
||||
)
|
||||
val times = Utils.getDayToYearMonthDay(it.surplusDays)
|
||||
ilPaymentSuccessCountDownLayout.tvAddSuccessDeviceExpiresDays.text = times[0]
|
||||
ilPaymentSuccessCountDownLayout.tvAddSuccessDeviceExpiresHours.text = times[1]
|
||||
ilPaymentSuccessCountDownLayout.tvAddSuccessDeviceExpiresMin.text = times[2]
|
||||
@@ -89,7 +83,7 @@ class PaymentSuccessActivity :
|
||||
|
||||
mMac = MMKVUtil.getString(MMKVKey.FirstDeviceMac)
|
||||
if (TextUtils.isEmpty(mMac)) {
|
||||
btnPaymentSuccessContinue.setText(R.string.txt_continue)
|
||||
btnPaymentSuccessContinue.setText(R.string.txt_done)
|
||||
tvPaymentSuccessActivateTip.visibility = View.INVISIBLE
|
||||
ilPaymentSuccessBluetoothTips.root.visibility = View.GONE
|
||||
} else {
|
||||
@@ -155,9 +149,16 @@ class PaymentSuccessActivity :
|
||||
mAddTrackerViewModel.mUpdatePayDeviceStateLiveData.observe(this) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
mViewBinding.btnPaymentSuccessContinue.isEnabled = true
|
||||
MMKVUtil.putInt(MMKVKey.isBindDevice, ConstantInt.isBind)
|
||||
XEventBus.post(EventName.RefreshDevice)
|
||||
if (TextUtils.isEmpty(mMac)) {
|
||||
XEventBus.post(EventName.PayBack)
|
||||
finish()
|
||||
} else SRBleUtil.instance.getConnectMacDevice(mMac)?.let { ble ->
|
||||
SRBleUtil.instance.writeData(
|
||||
ble.bleDevice, SRBleCmdUtil.instance.setWorkingStatus()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
@@ -283,6 +284,22 @@ class PaymentSuccessActivity :
|
||||
}
|
||||
}
|
||||
|
||||
private fun payContinue() {
|
||||
mPayResult?.apply {
|
||||
if (rechargeType == ConstantInt.Type0 || rechargeType == ConstantInt.Type1) {
|
||||
mViewBinding.btnPaymentSuccessContinue.isEnabled = false
|
||||
//刷新设备绑定
|
||||
mAddTrackerViewModel.updatePayDeviceState(this@PaymentSuccessActivity, deviceId)
|
||||
} else if (TextUtils.isEmpty(mMac)) {
|
||||
XEventBus.post(EventName.PayBack)
|
||||
finish()
|
||||
} else SRBleUtil.instance.getConnectMacDevice(mMac)?.let {
|
||||
setButtonEnabled(mViewBinding.btnPaymentSuccessContinue, ConstantInt.Type0)
|
||||
SRBleUtil.instance.writeData(it.bleDevice, SRBleCmdUtil.instance.setWorkingStatus())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
mViewBinding.apply {
|
||||
when (v!!) {
|
||||
@@ -290,19 +307,7 @@ class PaymentSuccessActivity :
|
||||
ilPaymentSuccessBluetoothTips.trbBleConnectState.text.toString()
|
||||
)
|
||||
|
||||
btnPaymentSuccessContinue -> {
|
||||
if (TextUtils.isEmpty(mMac)) {
|
||||
XEventBus.post(EventName.PayBack)
|
||||
finish()
|
||||
} else SRBleUtil.instance.getConnectMacDevice(mMac)?.let {
|
||||
setButtonEnabled(
|
||||
mViewBinding.btnPaymentSuccessContinue, ConstantInt.Type0
|
||||
)
|
||||
SRBleUtil.instance.writeData(
|
||||
it.bleDevice, SRBleCmdUtil.instance.setWorkingStatus()
|
||||
)
|
||||
}
|
||||
}
|
||||
btnPaymentSuccessContinue -> payContinue()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.abbidot.tracker.ui.activity.subscribe
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.Paint
|
||||
import android.text.TextUtils
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import androidx.activity.viewModels
|
||||
@@ -294,25 +293,24 @@ class SureSubscriptionPlanActivity :
|
||||
}
|
||||
|
||||
//判断套餐是否过期 或者套餐没退款
|
||||
if (!TextUtils.isEmpty(it.orderNum) && it.orderStatus != 6 && it.surplusDays == 0L && it.subscriptionStatus == ConstantInt.Close) {
|
||||
// mOrderBean?.reactivation = 1
|
||||
mSubscriptionViewModel.getReactivationFee(it.orderNum)
|
||||
} else {
|
||||
if (isUpgrade) mSubscriptionViewModel.getReactivationFee(it.orderNum)
|
||||
else {
|
||||
mOrderBean?.reactivation = 0
|
||||
mOrderBean?.reactivatePrice = 0.0
|
||||
updateMoney()
|
||||
}
|
||||
}
|
||||
|
||||
// if (TextUtils.isEmpty(it.orderNum)) {
|
||||
// mOrderBean?.reactivation = 0
|
||||
// mOrderBean?.reactivatePrice = 0.0
|
||||
// updateMoney()
|
||||
// } else {
|
||||
// if (!TextUtils.isEmpty(it.orderNum) && it.orderStatus != 6 && it.surplusDays == 0L && it.subscriptionStatus == ConstantInt.Close) {
|
||||
//// mOrderBean?.reactivation = 1
|
||||
// mSubscriptionViewModel.getReactivationFee(it.orderNum)
|
||||
// } else {
|
||||
// if (isUpgrade) mSubscriptionViewModel.getReactivationFee(it.orderNum)
|
||||
// else {
|
||||
// mOrderBean?.reactivation = 0
|
||||
// mOrderBean?.reactivatePrice = 0.0
|
||||
// updateMoney()
|
||||
// }
|
||||
// }
|
||||
|
||||
mOrderBean?.reactivation = 0
|
||||
mOrderBean?.reactivatePrice = 0.0
|
||||
updateMoney()
|
||||
//隐藏保险
|
||||
mViewBinding.ilSubscribePlanInsurance.cbSureSubscribeInsureSwitch.isChecked = false
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,16 +329,6 @@ class SureSubscriptionPlanActivity :
|
||||
mReactivationFeeLiveData.observe(this@SureSubscriptionPlanActivity) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
// it.getOrNull()?.apply {
|
||||
// mOrderBean?.reactivatePrice = this
|
||||
// mSummaryAdapter.getData().add(
|
||||
// 2, MenuTxtBean(
|
||||
// getString(R.string.txt_reactivation), Utils.formatDecimal(this, 1)
|
||||
// ).apply {
|
||||
// colorRedId = R.color.data_black_color
|
||||
// })
|
||||
// mTotalMoney += this
|
||||
// }
|
||||
it.getOrNull()?.apply {
|
||||
mPackageBean?.let { p ->
|
||||
mTotalMoney -= mSumInsuranceMoney
|
||||
|
||||
@@ -66,7 +66,8 @@ class RouteV2Fragment : BaseFragment<FragmentRouteV2Binding>(FragmentRouteV2Bind
|
||||
|
||||
//是否选过自定义日期,没有则再次回到这个页面,刷新取24小时的记录
|
||||
private var isSelectCustomDate = false
|
||||
private var isFirst = true
|
||||
|
||||
// private var isFirst = true
|
||||
private var mProgress = -1
|
||||
|
||||
//充值续费或升级返回类型
|
||||
@@ -155,6 +156,7 @@ class RouteV2Fragment : BaseFragment<FragmentRouteV2Binding>(FragmentRouteV2Bind
|
||||
}
|
||||
|
||||
private fun initState() {
|
||||
mViewBinding.miHomeRouteAddressView.visibility = View.GONE
|
||||
mHistoryDataMapCommon.clearAllMarker()
|
||||
setSeekBarMax(0)
|
||||
}
|
||||
@@ -264,28 +266,23 @@ class RouteV2Fragment : BaseFragment<FragmentRouteV2Binding>(FragmentRouteV2Bind
|
||||
//详细位置
|
||||
address = it
|
||||
|
||||
// val timeString = String.format(
|
||||
// getString(R.string.map_current_update_time),
|
||||
// DateUtils.getRelativeTimeSpanString(timeStamp * 1000)
|
||||
// )
|
||||
val timeString = Utils.formatTime(timeStamp * 1000, Utils.DATE_FORMAT_PATTERN_EN10)
|
||||
//更新位置时间
|
||||
dayTime = timeString
|
||||
|
||||
var delay = 500L
|
||||
//第一次延时,等待地图动画执行完成
|
||||
if (isFirst) {
|
||||
isFirst = false
|
||||
delay = 1500
|
||||
}
|
||||
// var delay = 500L
|
||||
// //第一次延时,等待地图动画执行完成
|
||||
// if (isFirst) {
|
||||
// isFirst = false
|
||||
// delay = 1500
|
||||
// }
|
||||
mViewBinding.root.postDelayed(
|
||||
{
|
||||
// mHistoryDataMapCommon.showInfoWindow(this)
|
||||
mViewBinding.miHomeRouteAddressView.let { mi ->
|
||||
mi.visibility = View.VISIBLE
|
||||
mi.setShowText(timeString, it)
|
||||
}
|
||||
}, delay
|
||||
}, 100
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -389,7 +386,6 @@ class RouteV2Fragment : BaseFragment<FragmentRouteV2Binding>(FragmentRouteV2Bind
|
||||
|
||||
getHomeV2Activity()?.getPet()?.apply {
|
||||
initState()
|
||||
mViewBinding.miHomeRouteAddressView.visibility = View.GONE
|
||||
mDataDetailViewModel.getHistoryByDay(
|
||||
getHomeV2Activity()!!, deviceId, mFromTimestamp / 1000, mToTimestamp / 1000
|
||||
)
|
||||
@@ -432,7 +428,9 @@ class RouteV2Fragment : BaseFragment<FragmentRouteV2Binding>(FragmentRouteV2Bind
|
||||
// mContext, NotificationV2Activity::class.java
|
||||
// )
|
||||
// )
|
||||
ilHomeRoutePetHead.homeDataPetNameSmall, ilHomeRoutePetHead.homeDataPetHeadSmall.root -> getHomeV2Activity()?.selectPetDialog()
|
||||
ilHomeRoutePetHead.homeDataPetNameSmall, ilHomeRoutePetHead.homeDataPetHeadSmall.root -> getHomeV2Activity()?.selectPetDialog(
|
||||
false
|
||||
)
|
||||
|
||||
llHomeRouteCalendarFrom -> {
|
||||
getHomeV2Activity()?.getPet()?.let {
|
||||
@@ -452,6 +450,7 @@ class RouteV2Fragment : BaseFragment<FragmentRouteV2Binding>(FragmentRouteV2Bind
|
||||
tvHomeRouteCalendarFrom,
|
||||
object : BaseDialog.OnDialogOkListener {
|
||||
override fun onOkClick(dialog: BaseDialog<*>) {
|
||||
mCurrentTimestamp = System.currentTimeMillis()
|
||||
isSelectCustomDate = true
|
||||
getHistoryDay(tvHomeRouteCalendarFrom)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.content.Intent
|
||||
import android.text.TextUtils
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import androidx.fragment.app.viewModels
|
||||
import com.abbidot.baselibrary.constant.ConState
|
||||
import com.abbidot.baselibrary.constant.EventName
|
||||
@@ -121,8 +122,21 @@ class HomeTrackFragment :
|
||||
)
|
||||
}
|
||||
|
||||
4 -> connectionBtn(getData()[pos].menuValue)
|
||||
4 -> {
|
||||
val share = MMKVUtil.getInt(MMKVKey.Shared)
|
||||
if (share != ConstantInt.NoShare) {
|
||||
LogUtil.e("分享的设备,不可点击")
|
||||
return
|
||||
}
|
||||
connectionBtn(getData()[pos].menuValue)
|
||||
}
|
||||
|
||||
5 -> {
|
||||
val share = MMKVUtil.getInt(MMKVKey.Shared)
|
||||
if (share != ConstantInt.NoShare) {
|
||||
LogUtil.e("分享的设备,不可点击")
|
||||
return
|
||||
}
|
||||
if (mHomePetTrackStateAdapter.getData()[pos].type == ConstantInt.SpecialType) {
|
||||
return
|
||||
}
|
||||
@@ -329,8 +343,10 @@ class HomeTrackFragment :
|
||||
}
|
||||
} else if (progress == mDeviceDFUViewModel.mDFUFailCode) {
|
||||
// mTrackerDFUStateDialog?.dismiss()
|
||||
dfuEnd()
|
||||
mDFUNewDialogDialog?.setDFUFail {
|
||||
mFirmwareBean?.apply {
|
||||
dfuStart()
|
||||
mDownLoadFileViewModel.downLoadFile(
|
||||
mContext!!, fileName, firmwareUrl
|
||||
)
|
||||
@@ -416,9 +432,11 @@ class HomeTrackFragment :
|
||||
private fun shareDeviceState() {
|
||||
val share = MMKVUtil.getInt(MMKVKey.Shared)
|
||||
if (share == ConstantInt.NoShare) {
|
||||
mViewBinding.rvHomePetTrackMenu.visibility = View.VISIBLE
|
||||
mZoneAdapter.showNoDataAddButton(true)
|
||||
mFencesAdapter.showNoDataAddButton(true)
|
||||
} else {
|
||||
mViewBinding.rvHomePetTrackMenu.visibility = View.GONE
|
||||
mZoneAdapter.showNoDataAddButton(false)
|
||||
mFencesAdapter.showNoDataAddButton(false)
|
||||
}
|
||||
@@ -514,7 +532,7 @@ class HomeTrackFragment :
|
||||
val eTime = Utils.stringToDate(
|
||||
endTime, Utils.DATE_FORMAT_PATTERN_CN, Utils.DATE_FORMAT_PATTERN_EN7
|
||||
)
|
||||
val endTime = "${getString(R.string.txt_expires_on1)}$eTime"
|
||||
val endTime = "${getString(R.string.txt_end_time)}:$eTime"
|
||||
val id = "ID:$deviceOutId"
|
||||
mViewBinding.let {
|
||||
it.tvHomePetTrackPetStartTime.text = startTime
|
||||
@@ -591,8 +609,9 @@ class HomeTrackFragment :
|
||||
(gnssInterval / 60).toString() + getString(R.string.data_active_unit_min)
|
||||
it[2].menuValue =
|
||||
(liveTime / 60).toString() + getString(R.string.data_active_unit_min)
|
||||
it[4].type = if (powerSwitch == ConstantInt.Type3) ConstantInt.SpecialType
|
||||
else ConstantInt.Type0
|
||||
it[4].type =
|
||||
if (powerSwitch == ConstantInt.Type3 || powerSwitch == ConstantInt.Type0) ConstantInt.SpecialType
|
||||
else ConstantInt.Type0
|
||||
it[4].menuValue = when (powerSwitch) {
|
||||
ConstantInt.Type0 -> getString(R.string.tracker_manage_set_led_off)
|
||||
ConstantInt.Type1 -> getString(R.string.tracker_manage_set_led_on)
|
||||
@@ -723,6 +742,7 @@ class HomeTrackFragment :
|
||||
}
|
||||
if (trackBleDevice.conState == ConState.CONNECTED) {
|
||||
if (isDFUCallback) {
|
||||
dfuEnd()
|
||||
showToast(R.string.txt_upgrade_success)
|
||||
}
|
||||
mHomePetTrackStateAdapter.notifyItemChanged(4)
|
||||
@@ -861,6 +881,7 @@ class HomeTrackFragment :
|
||||
fun firmwareCheckUpdate() {
|
||||
getBleTrackDeviceBean()?.let {
|
||||
if (BleManager.getInstance().isConnected(it.bleDevice)) {
|
||||
dfuStart()
|
||||
setFirmwareData(mFirmwareBean)
|
||||
} else {
|
||||
showToast(R.string.tracker_manage_set_ble_unconnect)
|
||||
@@ -868,6 +889,26 @@ class HomeTrackFragment :
|
||||
}
|
||||
}
|
||||
|
||||
private fun dfuStart() {
|
||||
getHomeV2Activity()?.apply {
|
||||
//保持屏幕常亮
|
||||
window?.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
DfuServiceListenerHelper.registerProgressListener(
|
||||
mContext, mDeviceDFUViewModel.mDfuProgressListener
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun dfuEnd() {
|
||||
getHomeV2Activity()?.apply {
|
||||
//清除屏幕常亮
|
||||
window?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
DfuServiceListenerHelper.unregisterProgressListener(
|
||||
mContext, mDeviceDFUViewModel.mDfuProgressListener
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动连接/断开设备
|
||||
*/
|
||||
@@ -971,25 +1012,6 @@ class HomeTrackFragment :
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
getHomeV2Activity()?.apply {
|
||||
DfuServiceListenerHelper.registerProgressListener(
|
||||
mContext, mDeviceDFUViewModel.mDfuProgressListener
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
getHomeV2Activity()?.apply {
|
||||
DfuServiceListenerHelper.unregisterProgressListener(
|
||||
mContext, mDeviceDFUViewModel.mDfuProgressListener
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
mViewBinding.apply {
|
||||
when (v!!) {
|
||||
|
||||
@@ -248,6 +248,10 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
|
||||
XEventBus.observe(this, EventName.RefreshFences) {
|
||||
updateMapDeviceStatus()
|
||||
}
|
||||
//删除设备
|
||||
XEventBus.observe(this, EventName.DeleteDevice) {
|
||||
mMapViewModel.stopGetData()
|
||||
}
|
||||
//直播自动结束提示
|
||||
XEventBus.observe(this, EventName.LiveAutoEnd) {
|
||||
CommonDialog1(
|
||||
@@ -286,6 +290,13 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
|
||||
if (trackBle.mac == macID) {
|
||||
if (trackBle.conState == ConState.CONNECTED) {
|
||||
mMapDeviceBean?.let {
|
||||
//连接上蓝牙,关机不显示
|
||||
if (it.powerSwitch == ConstantInt.Type0) {
|
||||
it.canShowBattery = false
|
||||
it.isCloseBattery = true
|
||||
mViewBinding.llHomeMapDeviceBatteryLayout.visibility =
|
||||
View.INVISIBLE
|
||||
}
|
||||
mMapViewModel.setDeviceStateAndWarningData(
|
||||
mContext!!,
|
||||
getHomeV2Activity()?.getPet(),
|
||||
@@ -298,6 +309,12 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
|
||||
)
|
||||
}
|
||||
} else {
|
||||
mMapDeviceBean?.let {
|
||||
if (it.powerSwitch == ConstantInt.Type0) {
|
||||
it.canShowBattery = true
|
||||
it.isCloseBattery = false
|
||||
}
|
||||
}
|
||||
//隐藏蓝牙nearby
|
||||
mViewBinding.ilHomeMapDeviceMsg.root.visibility = View.GONE
|
||||
//蓝牙断开就重新获取服务器数据,蓝牙数据上报断开
|
||||
@@ -555,10 +572,19 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
|
||||
|
||||
private fun setMapDeviceBean(mapDeviceBean: MapDeviceBean) {
|
||||
mapDeviceBean.apply {
|
||||
//分钟后无上报、没有lte信号或在wifi中隐藏直播按钮
|
||||
isCanLive =
|
||||
!(Util.isTimeoutReport(updateTime) || powerSwitch == ConstantInt.Type0 || powerSwitch == ConstantInt.Type2 || powerSwitch == ConstantInt.Type3 || inWifiZone == ConstantInt.Type1)
|
||||
setLiveBtnState(isCanLive)
|
||||
val share = MMKVUtil.getInt(MMKVKey.Shared)
|
||||
mViewBinding.homeMapLiveBtn.visibility = if (share != ConstantInt.NoShare) {
|
||||
View.GONE
|
||||
} else {
|
||||
if (liveFlag == ConstantInt.Type1) View.GONE
|
||||
else {
|
||||
//分钟后无上报、没有lte信号或在wifi中隐藏直播按钮
|
||||
isCanLive =
|
||||
!(Util.isTimeoutReport(updateTime) || powerSwitch == ConstantInt.Type0 || powerSwitch == ConstantInt.Type2 || powerSwitch == ConstantInt.Type3 || inWifiZone == ConstantInt.Type1)
|
||||
setLiveBtnState(isCanLive)
|
||||
View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
mViewBinding.ilHomeMapDeviceBatteryLayout.let {
|
||||
mMapViewModel.setMapDeviceBattery(
|
||||
@@ -664,7 +690,7 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
|
||||
} else {
|
||||
mShowCenterLocationType = ConstantInt.PetLocationType
|
||||
isMoveCamera = true
|
||||
updateMapDeviceStatus(useBleLocation = true)
|
||||
updateMapDeviceStatus(useBleLocation = false)
|
||||
}
|
||||
ViewUtil.instance.setMapSwitchLocationButtonImage(
|
||||
homeMapRefreshBtn, mShowCenterLocationType
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.content.pm.PackageManager
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.Typeface
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.view.isVisible
|
||||
import com.abbidot.baselibrary.constant.MMKVKey
|
||||
import com.abbidot.baselibrary.util.AppUtils
|
||||
import com.abbidot.baselibrary.util.LogUtil
|
||||
@@ -92,7 +93,7 @@ class HistoryDataGoogleMapFragment : BaseGoogleMapFragment() {
|
||||
googleMap.apply {
|
||||
setOnCameraMoveListener {
|
||||
mCurLatLng?.let {
|
||||
setMarkerInfoViewOffset(mMarkerInfoView, it)
|
||||
if (mMarkerInfoView.isVisible) setMarkerInfoViewOffset(mMarkerInfoView, it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import java.util.UUID
|
||||
class SRBleUtil private constructor() {
|
||||
|
||||
//track设备蓝牙的开头名字
|
||||
val trackDeviceBleStartName = "Pet_Tracker"
|
||||
val trackDeviceBleStartName = "Pet_"
|
||||
|
||||
//是否正在连接蓝牙设备
|
||||
var isBleConnecting = false
|
||||
|
||||
@@ -32,7 +32,7 @@ class MapViewModel : ViewModel() {
|
||||
private var mCountDownTimer: CountDownTimer? = null
|
||||
|
||||
//几分钟倒计时(min)
|
||||
private var mRefreshDataMin = 0.5f
|
||||
private var mRefreshDataMin = 0.35f
|
||||
private var mDeviceId = ""
|
||||
|
||||
var mDeviceMsgType = ConstantInt.SpecialType
|
||||
@@ -440,9 +440,15 @@ class MapViewModel : ViewModel() {
|
||||
canShowBattery = true
|
||||
rootView.visibility = View.VISIBLE
|
||||
if (powerSwitch == ConstantInt.Type0) {
|
||||
it.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0)
|
||||
it.text = context.getString(R.string.txt_powered_off)
|
||||
ViewUtil.instance.viewShow(closeBtn)
|
||||
//连接蓝牙就不显示关机
|
||||
if (SRBleUtil.instance.isMacConnect(deviceMacId)) {
|
||||
rootView.visibility = View.INVISIBLE
|
||||
canShowBattery = false
|
||||
} else {
|
||||
it.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0)
|
||||
it.text = context.getString(R.string.txt_powered_off)
|
||||
ViewUtil.instance.viewShow(closeBtn)
|
||||
}
|
||||
} else if (powerSwitch == ConstantInt.Type3) {
|
||||
it.setCompoundDrawablesWithIntrinsicBounds(
|
||||
R.drawable.icon_charge_image, 0, 0, 0
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 31 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 33 KiB |
@@ -36,16 +36,25 @@
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<View
|
||||
android:id="@+id/v_add_new_tracker3_solid_view"
|
||||
android:layout_width="@dimen/dp_20"
|
||||
android:layout_height="@dimen/dp_1"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="@dimen/dp_20" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:layout_width="@dimen/dp_200"
|
||||
android:layout_height="@dimen/dp_200"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_width="@dimen/dp_160"
|
||||
android:layout_height="@dimen/dp_160"
|
||||
android:layout_alignTop="@id/v_add_new_tracker3_solid_view"
|
||||
android:layout_alignEnd="@id/v_add_new_tracker3_solid_view"
|
||||
android:src="@drawable/icon_pair_tracker_image1" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:layout_width="@dimen/dp_200"
|
||||
android:layout_height="@dimen/dp_200"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_width="@dimen/dp_160"
|
||||
android:layout_height="@dimen/dp_160"
|
||||
android:layout_alignStart="@id/v_add_new_tracker3_solid_view"
|
||||
android:layout_alignTop="@id/v_add_new_tracker3_solid_view"
|
||||
android:src="@drawable/icon_pair_tracker_image2" />
|
||||
|
||||
|
||||
@@ -54,7 +63,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginTop="@dimen/dp_210"
|
||||
android:layout_marginTop="@dimen/dp_200"
|
||||
android:layout_marginEnd="@dimen/dp_18"
|
||||
android:src="@drawable/icon_refresh" />
|
||||
|
||||
|
||||
@@ -62,12 +62,22 @@
|
||||
app:lineHeight="@dimen/textSize20"
|
||||
app:typeface="@string/roboto_regular_font" />
|
||||
|
||||
|
||||
<include
|
||||
android:id="@+id/il_pair_success_bluetooth_tips"
|
||||
layout="@layout/layout_ble_connect_state"
|
||||
android:layout_width="wrap_content"
|
||||
android:visibility="invisible"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/btn_payment_success_continue"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="@dimen/dp_38" />
|
||||
|
||||
<com.abbidot.tracker.widget.TypefaceButton
|
||||
android:id="@+id/btn_pair_success_activate"
|
||||
style="@style/my_match_RoundRect_Button_style"
|
||||
android:layout_height="@dimen/dp_50"
|
||||
android:layout_marginHorizontal="@dimen/dp_16"
|
||||
android:layout_marginTop="@dimen/dp_60"
|
||||
android:layout_marginBottom="@dimen/dp_49"
|
||||
android:text="@string/txt_continue"
|
||||
android:textStyle="bold"
|
||||
|
||||
@@ -33,11 +33,12 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="@dimen/dp_20"
|
||||
android:layout_marginTop="@dimen/dp_10" />
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:visibility="gone" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_list"
|
||||
android:layout_width="match_parent"
|
||||
android:visibility="gone"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
@@ -32,7 +32,8 @@
|
||||
layout="@layout/layout_sure_subscribe_plan_addons_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_16" />
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:visibility="gone" />
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
@@ -79,7 +80,7 @@
|
||||
style="@style/my_match_RoundRect_Button_style"
|
||||
android:layout_marginHorizontal="@dimen/dp_16"
|
||||
android:text="@string/txt_continue"
|
||||
app:qmui_radius="@dimen/dp_64"
|
||||
android:visibility="gone"
|
||||
app:qmui_radius="@dimen/dp_64"
|
||||
app:typeface="@string/roboto_bold_font" />
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
@@ -9,7 +9,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/dp_8">
|
||||
android:paddingBottom="@dimen/dp_10">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -142,6 +142,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_8"
|
||||
android:background="@drawable/shape16_white_color_bg"
|
||||
android:nestedScrollingEnabled="false"/>
|
||||
android:nestedScrollingEnabled="false" />
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
@@ -120,6 +120,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:visibility="gone"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
style="@style/my_TextView_style_v2"
|
||||
android:layout_below="@id/tv_subscription_history_order_time"
|
||||
android:text="@string/txt_annual_care_text1"
|
||||
android:visibility="gone"
|
||||
android:layout_marginTop="@dimen/dp_4"
|
||||
android:textSize="@dimen/textSize14"
|
||||
android:textStyle="bold" />
|
||||
@@ -49,13 +50,14 @@
|
||||
android:layout_marginStart="@dimen/dp_4"
|
||||
android:layout_toEndOf="@id/tv_subscription_history_annual_care_title"
|
||||
android:text="@string/app_name"
|
||||
android:visibility="gone"
|
||||
android:textSize="@dimen/textSize14"
|
||||
app:typeface="@string/roboto_regular_font" />
|
||||
|
||||
<com.abbidot.tracker.widget.TypefaceTextView
|
||||
android:id="@+id/tv_subscription_history_package_name"
|
||||
style="@style/my_TextView_style_v2"
|
||||
android:layout_below="@id/tv_subscription_history_annual_care_title"
|
||||
android:layout_below="@id/tv_subscription_history_order_time"
|
||||
android:layout_marginTop="@dimen/dp_6"
|
||||
android:text="@string/txt_order_id"
|
||||
android:textSize="@dimen/textSize14"
|
||||
|
||||
@@ -971,5 +971,11 @@
|
||||
|
||||
<string name="txt_as_low_as">低至</string>
|
||||
<string name="txt_show_crash">APP出现异常,即将退出!</string>
|
||||
<string name="txt_system_error">系统异常</string>
|
||||
<string name="txt_missing_param">缺少参数</string>
|
||||
<string name="txt_tracker_busy">Tracker设备繁忙,还有之前的下发任务未完成</string>
|
||||
<string name="txt_tracker_offline">Tracker设备未在线</string>
|
||||
<string name="txt_tracker_live">Tracker启动了Live直播</string>
|
||||
<string name="txt_abnormity">其他异常</string>
|
||||
|
||||
</resources>
|
||||
@@ -657,8 +657,8 @@
|
||||
<string name="txt_add_new_tracker">Add new tracker</string>
|
||||
<string name="txt_charge_power_on">Charge and Power On</string>
|
||||
<string name="txt_step_one">Step 1 :</string>
|
||||
<string name="txt_step_one_tips">Charge the tracker first; the \nred light is on.</string>
|
||||
<string name="txt_step_two_tips">Unplug cable, 3 green blinks – \ndevice is on.</string>
|
||||
<string name="txt_step_one_tips">Charge the tracker, 3 white lights flash, then red stays on.</string>
|
||||
<string name="txt_step_two_tips">Unplug cable; slow green blinking indicates device is on.</string>
|
||||
<string name="txt_step_two">Step 2 :</string>
|
||||
<string name="txt_searching_tracker">Searching for Tracker</string>
|
||||
<string name="txt_searching_tracker_tip">Bring the phone close to the tracker.</string>
|
||||
@@ -1056,11 +1056,17 @@
|
||||
<string name="txt_unbind_device">Unbind Device</string>
|
||||
<string name="txt_edit_profile">Edit Profile</string>
|
||||
<string name="txt_no_internet">No internet connection</string>
|
||||
<string name="txt_system_error">System Error: Please try again later.</string>
|
||||
<string name="txt_missing_param">Missing Parameters.</string>
|
||||
<string name="txt_tracker_busy">Tracker Busy. Please wait and retry.</string>
|
||||
<string name="txt_tracker_offline">Tracker Offline. Unable to proceed.</string>
|
||||
<string name="txt_tracker_live">Live stream in progress. Settings unavailable.</string>
|
||||
<string name="txt_abnormity">Operation failed. Please try again.</string>
|
||||
|
||||
<string name="txt_per_day">/day</string>
|
||||
<string name="txt_renewal_day">Renewal: $%s/%s day on %s</string>
|
||||
<string name="txt_day_unit">/day x%s</string>
|
||||
<string name="txt_location_tip"> "ABBIDOT APP collects location data,The route and distance between the current location and the device can be calculated."</string>
|
||||
<string name="txt_location_tip">"ABBIDOT APP collects location data,The route and distance between the current location and the device can be calculated."</string>
|
||||
<string name="txt_auto_subscription_day">(Renew at $%s per %s day thereafter)</string>
|
||||
|
||||
</resources>
|
||||
@@ -10,8 +10,8 @@ import java.time.Period
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
import java.util.regex.Pattern
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.atan2
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.roundToInt
|
||||
@@ -51,16 +51,15 @@ class Utils {
|
||||
/**
|
||||
* 时间戳转指定格式时间
|
||||
*
|
||||
* @param time 13位时间戳
|
||||
* @param cTimestamp 13位时间戳
|
||||
* @return 时间
|
||||
*/
|
||||
fun formatTime(time: Long, format: String): String {
|
||||
fun formatTime(cTimestamp: Long, format: String): String {
|
||||
val timeMillis = if (cTimestamp < 1000000000000) cTimestamp * 1000 else cTimestamp
|
||||
// 创建一个使用系统默认时区的格式化器
|
||||
val sdf = SimpleDateFormat(format, Locale.getDefault())
|
||||
return if (time < 1000000000000) {
|
||||
sdf.format(Date(time * 1000))
|
||||
} else {
|
||||
sdf.format(Date(time))
|
||||
}
|
||||
// 直接将时间戳(代表UTC时刻)格式化为本地时间字符串
|
||||
return sdf.format(Date(timeMillis))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,12 +94,16 @@ class Utils {
|
||||
/**
|
||||
* 把字符串转成时间戳,返回13位时间戳
|
||||
* @param parseFormat 字符串是什么格式的日期就传什么格式
|
||||
* @param isUtc 是否是0时区utc
|
||||
*/
|
||||
fun stringToTimestamp(
|
||||
dateString: String, parseFormat: String = DATE_FORMAT_PATTERN_CN2
|
||||
dateString: String,
|
||||
parseFormat: String = DATE_FORMAT_PATTERN_CN2,
|
||||
isUtc: Boolean = false
|
||||
): Long {
|
||||
return try {
|
||||
val formatter = SimpleDateFormat(parseFormat, Locale.getDefault())
|
||||
if (isUtc) formatter.timeZone = TimeZone.getTimeZone("UTC")
|
||||
val date = formatter.parse(dateString)
|
||||
date?.time ?: 0
|
||||
} catch (e: Exception) {
|
||||
@@ -110,6 +113,18 @@ class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
fun timestampAddHowTimestamp(cTimestamp: Long, period: Int, timeUnit: String): Long {
|
||||
val timeMillis = if (cTimestamp < 1000000000000) cTimestamp * 1000 else cTimestamp
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.timeInMillis = timeMillis
|
||||
when (timeUnit) {
|
||||
"DAY" -> calendar.add(Calendar.DAY_OF_MONTH, period)
|
||||
"MONTH" -> calendar.add(Calendar.MONTH, period)
|
||||
"YEAR" -> calendar.add(Calendar.YEAR, period)
|
||||
}
|
||||
return calendar.timeInMillis
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取这个时间戳的,前几天13位时间戳
|
||||
*/
|
||||
@@ -125,31 +140,45 @@ class Utils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算2个日期相册多少年,多少月
|
||||
* 计算2个日期相册多少年,多少月,多少天
|
||||
*/
|
||||
fun differYear(startDate: String, endDate: String): Array<Int?> {
|
||||
val result = arrayOfNulls<Int>(2)
|
||||
fun differYear(startTimestamp: Long, endTimestamp: Long): Array<String?> {
|
||||
val result = arrayOfNulls<String>(3)
|
||||
val startDate = formatTime(startTimestamp, DATE_FORMAT_PATTERN_CN)
|
||||
val endDate = formatTime(endTimestamp, DATE_FORMAT_PATTERN_CN)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val period = Period.between(LocalDate.parse(startDate), LocalDate.parse(endDate))
|
||||
result[0] = period.years
|
||||
result[1] = period.months
|
||||
result[0] = "${period.years}"
|
||||
result[1] = "${period.months}"
|
||||
result[2] = "${if (period.days < 0) 0 else period.days}"
|
||||
} else {
|
||||
val dfs = SimpleDateFormat(DATE_FORMAT_PATTERN_CN, Locale.getDefault())
|
||||
val sDate = dfs.parse(startDate)
|
||||
val eDate = dfs.parse(endDate)
|
||||
// 得到两者的毫秒数
|
||||
// val between = (eDate.time - sDate.time)
|
||||
val year = eDate.year - sDate.year
|
||||
val month = eDate.month - sDate.month
|
||||
//2021-8-1,2122-1-1
|
||||
if (month < 0) {
|
||||
result[0] = year - 1
|
||||
//取绝对值
|
||||
result[1] = 12 - abs(month)
|
||||
} else {
|
||||
result[0] = year
|
||||
result[1] = month
|
||||
val sDate = dfs.parse(startDate)!!
|
||||
val eDate = dfs.parse(endDate)!!
|
||||
|
||||
val calendarStart = Calendar.getInstance()
|
||||
calendarStart.time = sDate
|
||||
val calendarEnd = Calendar.getInstance()
|
||||
calendarEnd.time = eDate
|
||||
|
||||
var years = calendarEnd[Calendar.YEAR] - calendarStart[Calendar.YEAR]
|
||||
var months = calendarEnd[Calendar.MONTH] - calendarStart[Calendar.MONTH]
|
||||
var days = calendarEnd[Calendar.DAY_OF_MONTH] - calendarStart[Calendar.DAY_OF_MONTH]
|
||||
|
||||
// 调整月份和天数以处理跨年情况
|
||||
if (days < 0) {
|
||||
months--
|
||||
calendarStart.add(Calendar.MONTH, 1) // 将开始日期增加一个月以进行比较
|
||||
days =
|
||||
calendarEnd[Calendar.DAY_OF_MONTH] + (30 - calendarStart[Calendar.DAY_OF_MONTH]) // 假设每个月有30天,简化计算
|
||||
}
|
||||
if (months < 0) {
|
||||
years--
|
||||
months += 12 // 将月份调整为正数以处理跨年情况
|
||||
}
|
||||
result[0] = "$years"
|
||||
result[1] = "$months"
|
||||
result[2] = "${if (days < 0) 0 else days}"
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -195,20 +224,6 @@ class Utils {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 把秒转换为 year month day
|
||||
*/
|
||||
fun getDayToYearMonthDay(second: Long): Array<String> {
|
||||
if (second <= 0) return arrayOf("0", "0", "0")
|
||||
val year = second / 365
|
||||
val month = (second % 365) / 30
|
||||
val day = (second % 365) % 30
|
||||
return arrayOf(
|
||||
fill2Digits(year.toInt()), fill2Digits(month.toInt()), fill2Digits(day.toInt())
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param d 需要处理的数字
|
||||
* @param num 保留位数
|
||||
|
||||
Reference in New Issue
Block a user