Commit 75dcdd43 authored by mengcuiguang's avatar mengcuiguang

添加wifi本地管理类,负责监听次数和分钟

parent d6365451
......@@ -51,7 +51,8 @@ class WifiAdManager {
tempAdType = Constant.GROMORE_FULL_AD
}
return tempAdType
// return tempAdType
return Constant.GROMORE_INSERTSCREEN_AD
}
/**
......
package com.mints.flowbox.manager.wifi
import android.text.format.DateUtils
import com.mints.flowbox.manager.AppPreferencesManager
import com.mints.flowbox.utils.TimeRender
/**
* wifi本地数据管理
*
* 孟崔广
*/
object WifiDataManager {
// 新的一天
private val NEW_DAY_FLAG = "NEW_DAY_FLAG"
// wifi连接 10次
private val WIFI_ON = "WIFI_ON"
// wifi断开 10次
private val WIFI_OFF = "WIFI_OFF"
// 充电 10次
private val BATTERY_ON = "BATTERY_ON"
// 拔电 10次
private val BATTERY_OFF = "BATTERY_OFF"
// 安装 引导
private val INSTALL_ON = "INSTALL_ON"
// 卸载 引导
private val UNINSTALL_OFF = "UNINSTALL_OFF"
// 定时 15分钟 在定时器触发
private val TIMER_15MIN = "TIMER_15MIN"
// 点击home键 30分钟
private val HOME_30MIN = "HOME_30MIN"
// 最近任务列表 30分钟
private val APPLIST_30MIN = "APPLIST_30MIN"
// 挂断电话 无广告
private val TELEPHONE_OFF = "TELEPHONE_OFF"
// 锁屏 100次
private val LOCK_ON = "LOCK_ON"
// 锁屏 单位:次数
var LOCK_TIMES = 100
// wifi、拔电 单位:次数
var WIFI_TIMES = 10
// 点击home键、最近任务列表 单位:分钟
var HOME_TIMES = 30
val sp by lazy { AppPreferencesManager.get() }
/**
* 是否显示wifi连接广告
*/
fun getWifiOn(): Boolean {
val wifiOn = sp.getInt(WIFI_ON, 0)
if (wifiOn < WIFI_TIMES) {
// 设置wifi次数+1
sp.put(WIFI_ON, wifiOn + 1)
return true
}
return false
}
/**
* 是否显示wifi断开广告
*/
fun getWifiOff(): Boolean {
val wifiOff = sp.getInt(WIFI_OFF, 0)
if (wifiOff < WIFI_TIMES) {
// 设置wifi次数+1
sp.put(WIFI_OFF, wifiOff + 1)
return true
}
return false
}
/**
* 是否显示充电连接广告
*/
fun getBatteryOn(): Boolean {
val batteryOn = sp.getInt(BATTERY_ON, 0)
if (batteryOn < WIFI_TIMES) {
// 设置充电次数+1
sp.put(BATTERY_ON, batteryOn + 1)
return true
}
return false
}
/**
* 是否显示断电连接广告
*/
fun getBatteryOff(): Boolean {
val batteryOff = sp.getInt(BATTERY_OFF, 0)
if (batteryOff < WIFI_TIMES) {
// 设置断电次数+1
sp.put(BATTERY_OFF, batteryOff + 1)
return true
}
return false
}
/**
* 是否锁屏
*/
fun getLockOn(): Boolean {
val lockOn = sp.getInt(LOCK_ON, 0)
if (lockOn < LOCK_TIMES) {
sp.put(LOCK_ON, lockOn + 1)
return true
}
return false
}
/**
* 是否点击home键 满足30分钟后
*/
fun getHomeKey(): Boolean {
// 保存的时间戳
val preTime = sp.getLong(HOME_30MIN, System.currentTimeMillis())
val currentTime = System.currentTimeMillis()
// 当前时间-保存的时间戳=间隔时间
val min = TimeRender.getMinForTimestamp(preTime, currentTime)
if (min < HOME_TIMES) {
return false
}
sp.put(HOME_30MIN, currentTime)
return true
}
/**
* 是否操作最近任务列表 满足30分钟后
*/
fun getApplistKey(): Boolean {
// 保存的时间戳
val preTime = sp.getLong(APPLIST_30MIN, System.currentTimeMillis())
val currentTime = System.currentTimeMillis()
// 当前时间-保存的时间戳=间隔时间
val min = TimeRender.getMinForTimestamp(preTime, currentTime)
if (min < HOME_TIMES) {
return false
}
sp.put(APPLIST_30MIN, currentTime)
return true
}
/**
* 是否当天
*/
fun getNewDay(time: Long): Boolean {
// 上一次服务器的时间,首次为系统时间
val preTime = sp.getLong(NEW_DAY_FLAG, System.currentTimeMillis())
// 判断时间是否是新的一天
if (DateUtils.isToday(preTime)) {
// 是新的一天
return true
}
// 第二天,新的一天
sp.put(NEW_DAY_FLAG, time)
resetData()
return false
}
/**
* 重置次数
*/
private fun resetData() {
sp.put(WIFI_ON, 0)
sp.put(WIFI_OFF, 0)
sp.put(BATTERY_ON, 0)
sp.put(BATTERY_OFF, 0)
sp.put(LOCK_ON, 0)
sp.put(HOME_30MIN, System.currentTimeMillis())
sp.put(APPLIST_30MIN, System.currentTimeMillis())
}
}
\ No newline at end of file
package com.mints.flowbox.mvp.model
import java.io.Serializable
data class WifiActiveBean(val ouTofApplicationAdCount: Int = 10,
val time: Long = 0,
val ouTofApplicationAdMins: Int = 10
) : Serializable
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.mints.flowbox.mvp.presenters;
import android.app.Activity;
import android.text.TextUtils;
import android.text.format.DateUtils;
import com.google.gson.JsonObject;
import com.mints.flowbox.MintsApplication;
......@@ -12,9 +13,11 @@ import com.mints.flowbox.manager.AppHttpManager;
import com.mints.flowbox.manager.ChannelManager;
import com.mints.flowbox.manager.SimulatorManager;
import com.mints.flowbox.manager.UserWeight;
import com.mints.flowbox.manager.wifi.WifiDataManager;
import com.mints.flowbox.mvp.model.BaseResponse;
import com.mints.flowbox.mvp.model.CommonParamBean;
import com.mints.flowbox.mvp.model.ServerAdBean;
import com.mints.flowbox.mvp.model.WifiActiveBean;
import com.mints.library.net.neterror.BaseSubscriber;
import com.mints.library.net.neterror.Throwable;
import com.mints.flowbox.mvp.model.UserTaskMsgBean;
......@@ -71,7 +74,7 @@ public class TrackPresenter extends BaseTrackPresenter {
public void setMinsActive(HashMap<String, Object> vo) {
AppHttpManager.getInstance(loanApplication)
.call(loanService.setMinsActive(vo),
new BaseSubscriber<BaseResponse<Object>>() {
new BaseSubscriber<BaseResponse<WifiActiveBean>>() {
@Override
public void onCompleted() {
}
......@@ -81,7 +84,18 @@ public class TrackPresenter extends BaseTrackPresenter {
}
@Override
public void onNext(BaseResponse<Object> baseResponse) {
public void onNext(BaseResponse<WifiActiveBean> baseResponse) {
try {
if (baseResponse.getStatus() == 200) {
WifiActiveBean data = baseResponse.getData();
if (data != null) {
// 本地标记未赋值时
WifiDataManager.INSTANCE.getNewDay(data.getTime());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
......
......@@ -29,6 +29,7 @@ import com.mints.flowbox.mvp.model.UserTaskMsgBean;
import com.mints.flowbox.mvp.model.Version;
import com.mints.flowbox.mvp.model.WalkBean;
import com.mints.flowbox.mvp.model.WaterBean;
import com.mints.flowbox.mvp.model.WifiActiveBean;
import com.mints.flowbox.mvp.model.XmlyUnlockBean;
import com.mints.flowbox.utils.AESUtils;
import com.orhanobut.logger.Logger;
......@@ -469,7 +470,7 @@ public interface LoanService {
* 提现排名
*/
@POST("na/setMinsActive")
Observable<BaseResponse<JsonObject>> setMinsActive(@Body Map<String, Object> vo);
Observable<BaseResponse<WifiActiveBean>> setMinsActive(@Body Map<String, Object> vo);
/**
* 默认http工厂
......
......@@ -276,4 +276,13 @@ public class TimeRender {
HMStime = wenshutr + ":" + sedStr;
return HMStime;
}
/**
* 根据时间戳 计算分钟间隔
*
* @return
*/
public static long getMinForTimestamp(long lastTime,long curTime){
return (curTime-lastTime) / (1000*60);
}
}
app/src/main/res/drawable/rockert.gif

15.9 KB | W: | H:

app/src/main/res/drawable/rockert.gif

14.7 KB | W: | H:

app/src/main/res/drawable/rockert.gif
app/src/main/res/drawable/rockert.gif
app/src/main/res/drawable/rockert.gif
app/src/main/res/drawable/rockert.gif
  • 2-up
  • Swipe
  • Onion skin
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