Commit dd604309 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 696f22c4
...@@ -11,7 +11,7 @@ import com.mints.flowbox.utils.TimeRender ...@@ -11,7 +11,7 @@ import com.mints.flowbox.utils.TimeRender
*/ */
object WifiDataManager { object WifiDataManager {
// 新的一天 // 新的一天(无需重置状态,自动修改)
private val NEW_DAY_FLAG = "NEW_DAY_FLAG" private val NEW_DAY_FLAG = "NEW_DAY_FLAG"
// wifi连接 10次 // wifi连接 10次
...@@ -26,14 +26,8 @@ object WifiDataManager { ...@@ -26,14 +26,8 @@ object WifiDataManager {
// 拔电 10次 // 拔电 10次
private val BATTERY_OFF = "BATTERY_OFF" private val BATTERY_OFF = "BATTERY_OFF"
// 安装 引导 // 安装,卸载 引导 10秒
private val INSTALL_ON = "INSTALL_ON" private val INSTALLANDUN_SEC = "INSTALLANDUN_SEC"
// 卸载 引导
private val UNINSTALL_OFF = "UNINSTALL_OFF"
// // 定时 15分钟 在定时器触发
// private val TIMER_15MIN = "TIMER_15MIN"
// 点击home键 30分钟 // 点击home键 30分钟
private val HOME_30MIN = "HOME_30MIN" private val HOME_30MIN = "HOME_30MIN"
...@@ -42,7 +36,7 @@ object WifiDataManager { ...@@ -42,7 +36,7 @@ object WifiDataManager {
private val APPLIST_30MIN = "APPLIST_30MIN" private val APPLIST_30MIN = "APPLIST_30MIN"
// 挂断电话 无广告 // 挂断电话 无广告
// private val TELEPHONE_OFF = "TELEPHONE_OFF" private val TELEPHONE_OFF = "TELEPHONE_OFF"
// 锁屏 100次 // 锁屏 100次
private val LOCK_ON = "LOCK_ON" private val LOCK_ON = "LOCK_ON"
...@@ -56,6 +50,9 @@ object WifiDataManager { ...@@ -56,6 +50,9 @@ object WifiDataManager {
// 点击home键、最近任务列表 单位:分钟 // 点击home键、最近任务列表 单位:分钟
var HOME_TIMES = 30 var HOME_TIMES = 30
// 安装、卸载 单位:秒
var INSTALL_TIMES = 10
val sp by lazy { AppPreferencesManager.get() } val sp by lazy { AppPreferencesManager.get() }
/** /**
...@@ -122,6 +119,18 @@ object WifiDataManager { ...@@ -122,6 +119,18 @@ object WifiDataManager {
return false return false
} }
/**
* 是否挂断电脑
*/
fun getTelephoneOff(): Boolean {
val telephoneOff = sp.getInt(TELEPHONE_OFF, 0)
if (telephoneOff < LOCK_TIMES) {
sp.put(TELEPHONE_OFF, telephoneOff + 1)
return true
}
return false
}
/** /**
* 是否点击home键 满足30分钟后 * 是否点击home键 满足30分钟后
...@@ -155,6 +164,22 @@ object WifiDataManager { ...@@ -155,6 +164,22 @@ object WifiDataManager {
return true return true
} }
/**
* 是否操作卸载安装 满足10秒后
*/
fun getInstallAndUnstall(): Boolean {
// 保存的时间戳
val preTime = sp.getLong(INSTALLANDUN_SEC, System.currentTimeMillis())
val currentTime = System.currentTimeMillis()
// 当前时间-保存的时间戳=间隔时间
val sec = TimeRender.getSecForTimestamp(preTime, currentTime)
if (sec < INSTALL_TIMES) {
return false
}
sp.put(INSTALLANDUN_SEC, currentTime)
return true
}
/** /**
* 是否当天 * 是否当天
*/ */
...@@ -183,7 +208,9 @@ object WifiDataManager { ...@@ -183,7 +208,9 @@ object WifiDataManager {
sp.put(BATTERY_ON, 0) sp.put(BATTERY_ON, 0)
sp.put(BATTERY_OFF, 0) sp.put(BATTERY_OFF, 0)
sp.put(LOCK_ON, 0) sp.put(LOCK_ON, 0)
sp.put(TELEPHONE_OFF, 0)
sp.put(HOME_30MIN, System.currentTimeMillis()) sp.put(HOME_30MIN, System.currentTimeMillis())
sp.put(INSTALLANDUN_SEC, System.currentTimeMillis())
sp.put(APPLIST_30MIN, System.currentTimeMillis()) sp.put(APPLIST_30MIN, System.currentTimeMillis())
} }
......
...@@ -455,7 +455,7 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener { ...@@ -455,7 +455,7 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
AppConfig.app_black_name = data.userRiskApps.userRiskAppName AppConfig.app_black_name = data.userRiskApps.userRiskAppName
AppConfig.app_black_pkg = data.userRiskApps.userRiskAppPkg AppConfig.app_black_pkg = data.userRiskApps.userRiskAppPkg
// CsjGroMoreManager.updataIdByChannel(data.gromoreAdcodes) CsjGroMoreManager.updataIdByChannel(data.gromoreAdcodes)
// 更新权重 // 更新权重
UserWeight.initAdWeight(data) UserWeight.initAdWeight(data)
......
...@@ -279,7 +279,6 @@ public class TimeRender { ...@@ -279,7 +279,6 @@ public class TimeRender {
} }
/** /**
* <<<<<<< Updated upstream
* 根据时间戳 计算分钟间隔 * 根据时间戳 计算分钟间隔
* *
* @return * @return
...@@ -288,6 +287,15 @@ public class TimeRender { ...@@ -288,6 +287,15 @@ public class TimeRender {
return (curTime - lastTime) / (1000 * 60); return (curTime - lastTime) / (1000 * 60);
} }
/**
* 根据时间戳 计算秒间隔
*
* @return
*/
public static long getSecForTimestamp(long lastTime, long curTime) {
return (curTime - lastTime) / 1000;
}
/** /**
* 获取今天星期几 * 获取今天星期几
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment