修复:低版本Android解析Cron表达式会报错,暂时不处理
This commit is contained in:
parent
c7166ae3ba
commit
ba356e63b3
|
@ -305,11 +305,6 @@ dependencies {
|
|||
//Location 是一个通过 Android 自带的 LocationManager 来实现的定位功能:https://github.com/jenly1314/Location
|
||||
implementation 'com.github.pppscn:location:1.0.0'
|
||||
|
||||
//crontab解析库:https://github.com/jmrozanec/cron-utils 官网:http://cron-parser.com
|
||||
//implementation 'com.cronutils:cron-utils:9.2.1'
|
||||
//JSR-310 backport for Android:https://github.com/JakeWharton/ThreeTenABP
|
||||
//implementation 'com.jakewharton.threetenabp:threetenabp:1.4.6'
|
||||
|
||||
//Partial implementation of Quartz Cron Java for Android: https://github.com/gatewayapps/crondroid
|
||||
implementation 'gatewayapps.crondroid:crondroid:1.0.0'
|
||||
//Java Parser For Cron Expressions: https://github.com/grahamar/cron-parser
|
||||
|
@ -317,8 +312,6 @@ dependencies {
|
|||
|
||||
//侧边栏菜单:https://github.com/yarolegovich/SlidingRootNav
|
||||
implementation 'com.yarolegovich:sliding-root-nav:1.1.1'
|
||||
//TabBar:https://github.com/xuexiangjys/JPTabBar
|
||||
// implementation 'com.github.xuexiangjys:JPTabBar:1.0.1'
|
||||
}
|
||||
//自动添加X-Library依赖
|
||||
apply from: 'x-library.gradle'
|
||||
|
|
|
@ -305,3 +305,7 @@
|
|||
|
||||
# MultiLanguages
|
||||
-keep class com.hjq.language.** {*;}
|
||||
|
||||
# crontab解析
|
||||
-keep class gatewayapps.crondroid.** { *; }
|
||||
-keep class net.redhogs.cronparser.** { *; }
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.idormy.sms.forwarder.fragment.condition
|
|||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.LayoutInflater
|
||||
|
@ -161,7 +162,8 @@ class CronFragment : BaseFragment<FragmentTasksConditionCronBinding?>(), View.On
|
|||
times++
|
||||
}
|
||||
binding!!.tvDescription.text = description
|
||||
binding!!.tvCronExpressionCheckTips.text = "$expression\n$description"
|
||||
//TODO:低版本Android解析Cron表达式会报错,暂时不处理
|
||||
binding!!.tvCronExpressionCheckTips.text = if (expression == description) expression else "$expression\n$description"
|
||||
binding!!.tvNextTimeList.text = String.format(getString(R.string.next_execution_times), times.toString(), nextTimeList.joinToString("\n"))
|
||||
binding!!.tvNextTimeList.visibility = View.VISIBLE
|
||||
binding!!.separatorCronExpressionCheck.visibility = View.VISIBLE
|
||||
|
@ -1589,6 +1591,8 @@ class CronFragment : BaseFragment<FragmentTasksConditionCronBinding?>(), View.On
|
|||
//判断cronExpression是否有效
|
||||
CronExpression.validateExpression(expression)
|
||||
|
||||
//TODO:低版本Android解析Cron表达式会报错,暂时不处理
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
//生成cron表达式描述
|
||||
val options = Options()
|
||||
options.isTwentyFourHourTime = true
|
||||
|
@ -1597,6 +1601,9 @@ class CronFragment : BaseFragment<FragmentTasksConditionCronBinding?>(), View.On
|
|||
//Chinese, Japanese, Korean and other East Asian languages have no spaces between words
|
||||
options.isNeedSpaceBetweenWords = locale == Locale("zh") || locale == Locale("ja") || locale == Locale("ko")
|
||||
description = CronExpressionDescriptor.getDescription(expression, options, locale)
|
||||
} else {
|
||||
description = expression
|
||||
}
|
||||
|
||||
return CronSetting(description, expression)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue