随机生成巴西电话号码
This commit is contained in:
parent
49a96758aa
commit
dae7ab4da9
|
|
@ -13,6 +13,7 @@ import com.remax.notification.builder.entryPointPendingIntent
|
|||
import com.remax.notification.builder.type2notificationId
|
||||
import com.remax.notification.check.NotificationCheckController
|
||||
import com.remax.notification.config.PushContent
|
||||
import java.util.Random
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
|
||||
|
|
@ -193,12 +194,13 @@ object NotificationDatas {
|
|||
entryPointPendingIntent(context, NOTI_ID_TYPE_RANDOM_9))
|
||||
)
|
||||
|
||||
val randomPhoneNum = generateRandomBrazilPhoneNumber() + ", " + generateRandomBrazilPhoneNumber()
|
||||
mRandomConfigList.add(NotificationConfig(
|
||||
NOTI_ID_TYPE_RANDOM_10,
|
||||
CHANNEL_TYPE_RANDOM,
|
||||
CHANNEL_TYPE_RANDOM_NAME,
|
||||
ResUtil.getString(R.string.notify_title_10),
|
||||
ResUtil.getString(R.string.notify_des_10),
|
||||
randomPhoneNum, //ResUtil.getString(R.string.notify_des_10),
|
||||
R.mipmap.task_cash,
|
||||
entryPointPendingIntent(context, NOTI_ID_TYPE_RANDOM_10))
|
||||
)
|
||||
|
|
@ -238,6 +240,41 @@ object NotificationDatas {
|
|||
return mRandomConfigList[mLastRandomIndexMap[randomType]!!]
|
||||
}
|
||||
|
||||
|
||||
private fun generateRandomBrazilPhoneNumber(
|
||||
withCountryCode: Boolean = true,
|
||||
formatted: Boolean = true
|
||||
): String {
|
||||
val random = Random()
|
||||
|
||||
// 1. 生成随机的2位地区码(巴西主要城市区号范围)
|
||||
val areaCodes = arrayOf("11", "21", "31", "41", "48", "51", "61", "71", "81", "84")
|
||||
val areaCode = areaCodes[random.nextInt(areaCodes.size)]
|
||||
|
||||
// 2. 生成本地号码:首位必须是9,后面8位随机
|
||||
val localNumber = StringBuilder().apply {
|
||||
append("9") // 巴西手机号首位固定为9
|
||||
for (i in 0 until 8) {
|
||||
append(random.nextInt(10)) // 生成0-9的随机数
|
||||
}
|
||||
}.toString()
|
||||
|
||||
// 3. 组合成完整号码
|
||||
return if (formatted) {
|
||||
if (withCountryCode) {
|
||||
"+55 ($areaCode) $localNumber"
|
||||
} else {
|
||||
"($areaCode) $localNumber"
|
||||
}
|
||||
} else {
|
||||
if (withCountryCode) {
|
||||
"55$areaCode$localNumber"
|
||||
} else {
|
||||
"$areaCode$localNumber"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface IResidentDataCallback {
|
||||
fun getGoldNumber(): Long
|
||||
fun getCashNumber(): Double
|
||||
|
|
|
|||
Loading…
Reference in New Issue