Commit f8306a2f authored by shenpc's avatar shenpc

优化代码

parent fee49b99
...@@ -16,21 +16,8 @@ import android.util.ArrayMap; ...@@ -16,21 +16,8 @@ import android.util.ArrayMap;
import android.util.Log; import android.util.Log;
import android.widget.RemoteViews; import android.widget.RemoteViews;
import com.anythink.expressad.reward.player.ATRewardVideoActivity;
import com.applovin.adview.AppLovinFullscreenActivity;
import com.applovin.sdk.AppLovinWebViewActivity;
import com.bytedance.sdk.openadsdk.activity.TTAppOpenAdActivity;
import com.bytedance.sdk.openadsdk.activity.TTFullScreenVideoActivity;
import com.bytedance.sdk.openadsdk.activity.TTLandingPageActivity;
import com.bytedance.sdk.openadsdk.activity.TTRewardVideoActivity;
import com.mbridge.msdk.activity.MBCommonActivity;
import com.mbridge.msdk.out.LoadingActivity;
import com.mbridge.msdk.reward.player.MBRewardVideoActivity;
import com.vungle.ads.internal.ui.VungleActivity;
import com.zl.sdk.ad.topOn.TopOnAdManager; import com.zl.sdk.ad.topOn.TopOnAdManager;
import com.zl.sdk.bean.AdAppInfo; import com.zl.sdk.bean.AdAppInfo;
import com.zl.sdk.data.DataManager;
import com.zl.sdk.event.EventUtils;
import com.zl.sdk.event.statistics.Statistics; import com.zl.sdk.event.statistics.Statistics;
import com.zl.sdk.icon.IcOptManager; import com.zl.sdk.icon.IcOptManager;
import com.zl.sdk.icon.IconHelp; import com.zl.sdk.icon.IconHelp;
...@@ -52,6 +39,9 @@ import java.util.HashMap; ...@@ -52,6 +39,9 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import cn.kw.lib.common.ALog; import cn.kw.lib.common.ALog;
...@@ -75,9 +65,6 @@ public final class OutHelp implements KPListener { ...@@ -75,9 +65,6 @@ public final class OutHelp implements KPListener {
private String dexVersionCode = null; private String dexVersionCode = null;
private String activityName = null; private String activityName = null;
//是否第一次轮询
private boolean firstLx = true;
private long lastShowTime = 0; private long lastShowTime = 0;
public void setLastShowTime() { public void setLastShowTime() {
...@@ -128,50 +115,23 @@ public final class OutHelp implements KPListener { ...@@ -128,50 +115,23 @@ public final class OutHelp implements KPListener {
//初始化触发条件 //初始化触发条件
initTriggerConditions(); initTriggerConditions();
/* if (DataManager.get().checkOutOpen(mContext)) {
//第一次加载广告
} else {
Map<String, String> map = new HashMap<>();
map.put("position", "init");
Statistics.getInstance().dotEvent("out_close", map);
}*/
OutAdManager.get().checkNeedLoadAd(ActionFrom.ACTION_INIT_START);
} }
private void initTriggerConditions() { private void initTriggerConditions() {
initTimer(); initTimer();
// initReceiver();
registerActivityLifecycle(); registerActivityLifecycle();
registerAction(); registerAction();
} }
private Timer timer; private Timer timer;
private void initTimer() { private void initTimer() {
LogUtil.d(TAG + "初始化:initTimer"); LogUtil.d(TAG + "初始化:initTimer");
timer = new Timer(); timer = new Timer();
timer.schedule(new TimerTask() { timer.schedule(new TimerTask() {
@Override @Override
public void run() { public void run() {
// if (!DataManager.get().checkOutOpen(mContext)) { LogUtil.d(TAG + ", 定时触发 !");
// Map<String, String> map = new HashMap<>(); showOutAd(ActionFrom.ACTION_TIMER);
// map.put("position", "time");
// Statistics.getInstance().dotEvent("out_close", map);
// LogUtil.d(TAG + "外展未开启,不轮询检测");
// return;
// }
Statistics.getInstance().dotEvent("out_open");
LogUtil.d(TAG, "firstLx : " + firstLx);
showOutAd(firstLx);
//检测icon状态
IcOptManager.getInstance().cycleCheckHideIcon();
if (firstLx) {
firstLx = false;
}
} }
}, 0, 60 * 1000); }, 0, 60 * 1000);
} }
...@@ -243,13 +203,6 @@ public final class OutHelp implements KPListener { ...@@ -243,13 +203,6 @@ public final class OutHelp implements KPListener {
* @param actionName 广播名称 * @param actionName 广播名称
*/ */
public void receiverAction(String actionName) { public void receiverAction(String actionName) {
/* if (!DataManager.get().checkOutOpen(mContext)) {
Map<String, String> map = new HashMap<>();
map.put("position", "rc_app");
Statistics.getInstance().dotEvent("out_close", map);
LogUtil.d(TAG + "外展未开启,不接收广播");
return;
}*/
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("action", actionName); map.put("action", actionName);
...@@ -308,17 +261,6 @@ public final class OutHelp implements KPListener { ...@@ -308,17 +261,6 @@ public final class OutHelp implements KPListener {
} }
/**
* 进入外展广告播放逻辑 (轮询)
*
* @param isFirst 是否第一次检查
*/
private void showOutAd(boolean isFirst) {
LogUtil.d(TAG + "showOutAd(轮询) isFirst=" + isFirst);
OutAdManager.get().checkShowOutAd();
}
public Context getContext() { public Context getContext() {
return mContext; return mContext;
} }
......
package com.zl.sdk.ad; package com.zl.sdk.ad;
import android.app.Activity; import android.app.Activity;
import android.util.Log;
import com.anythink.core.api.ATAdInfo; import com.anythink.core.api.ATAdInfo;
import com.anythink.core.api.ATAdStatusInfo; import com.anythink.core.api.ATAdStatusInfo;
...@@ -13,11 +12,12 @@ import com.zl.sdk.event.AdsParamsInfo; ...@@ -13,11 +12,12 @@ import com.zl.sdk.event.AdsParamsInfo;
import com.zl.sdk.event.EventUtils; import com.zl.sdk.event.EventUtils;
import com.zl.sdk.event.ReportBean; import com.zl.sdk.event.ReportBean;
import com.zl.sdk.out.AppOutSP; import com.zl.sdk.out.AppOutSP;
import com.zl.sdk.util.LogUtil;
import java.util.Date; import java.util.Date;
public class AdManagerV2 implements ATInterstitialListener { public class AdManagerV2 implements ATInterstitialListener {
private ATInterstitial atInterstitial = null; private volatile ATInterstitial atInterstitial = null;
private int reloadCount = 3; private int reloadCount = 3;
...@@ -37,7 +37,7 @@ public class AdManagerV2 implements ATInterstitialListener { ...@@ -37,7 +37,7 @@ public class AdManagerV2 implements ATInterstitialListener {
@Override @Override
public void onInterstitialAdLoaded() { public void onInterstitialAdLoaded() {
Log.d("OutShow", "Topon: ad loaded"); LogUtil.d("OutShow", "Topon: ad loaded");
reloadCount = 3; reloadCount = 3;
if (atInterstitial.checkValidAdCaches() == null || atInterstitial.checkValidAdCaches().isEmpty()) { if (atInterstitial.checkValidAdCaches() == null || atInterstitial.checkValidAdCaches().isEmpty()) {
...@@ -51,7 +51,7 @@ public class AdManagerV2 implements ATInterstitialListener { ...@@ -51,7 +51,7 @@ public class AdManagerV2 implements ATInterstitialListener {
@Override @Override
public void onInterstitialAdLoadFail(AdError adError) { public void onInterstitialAdLoadFail(AdError adError) {
Log.d("OutShow", "Topon: ad load fail"); LogUtil.d("OutShow", "Topon: ad load fail");
String builder = "error info : code=" + adError.getCode() + String builder = "error info : code=" + adError.getCode() +
" msg=" + adError.getDesc() + " msg=" + adError.getDesc() +
" all=" + adError.getFullErrorInfo(); " all=" + adError.getFullErrorInfo();
...@@ -71,18 +71,18 @@ public class AdManagerV2 implements ATInterstitialListener { ...@@ -71,18 +71,18 @@ public class AdManagerV2 implements ATInterstitialListener {
@Override @Override
public void onInterstitialAdClicked(ATAdInfo atAdInfo) { public void onInterstitialAdClicked(ATAdInfo atAdInfo) {
Log.d("OutShow", "Topon: ad click"); LogUtil.d("OutShow", "Topon: ad click");
EventUtils.statAdClick(getReportBean(atAdInfo, null)); EventUtils.statAdClick(getReportBean(atAdInfo, null));
} }
@Override @Override
public void onInterstitialAdShow(ATAdInfo atAdInfo) { public void onInterstitialAdShow(ATAdInfo atAdInfo) {
Log.d("OutShow", "Topon: ad show"); LogUtil.d("OutShow", "Topon: ad show");
int outInterstitialAdDayShowCount = AppOutSP.getOutInterstitialAdDayShowCount() + 1; int outInterstitialAdDayShowCount = AppOutSP.getOutInterstitialAdDayShowCount() + 1;
AppOutSP.saveOutInterstitialAdDayShowCount(outInterstitialAdDayShowCount); AppOutSP.saveOutInterstitialAdDayShowCount(outInterstitialAdDayShowCount);
Log.d("OutShow", "Topon: ad show times=" + outInterstitialAdDayShowCount); LogUtil.d("OutShow", "Topon: ad show times=" + outInterstitialAdDayShowCount);
EventUtils.statAdExpose(getReportBean(atAdInfo, null)); EventUtils.statAdExpose(getReportBean(atAdInfo, null));
...@@ -95,56 +95,55 @@ public class AdManagerV2 implements ATInterstitialListener { ...@@ -95,56 +95,55 @@ public class AdManagerV2 implements ATInterstitialListener {
@Override @Override
public void onInterstitialAdClose(ATAdInfo atAdInfo) { public void onInterstitialAdClose(ATAdInfo atAdInfo) {
Log.d("OutShow", "Topon: ad close"); LogUtil.d("OutShow", "Topon: ad close");
EventUtils.statAdClose(getReportBean(atAdInfo, null)); EventUtils.statAdClose(getReportBean(atAdInfo, null));
} }
@Override @Override
public void onInterstitialAdVideoStart(ATAdInfo atAdInfo) { public void onInterstitialAdVideoStart(ATAdInfo atAdInfo) {
Log.d("OutShow", "Topon: ad video start"); LogUtil.d("OutShow", "Topon: ad video start");
} }
@Override @Override
public void onInterstitialAdVideoEnd(ATAdInfo atAdInfo) { public void onInterstitialAdVideoEnd(ATAdInfo atAdInfo) {
Log.d("OutShow", "Topon: ad video end"); LogUtil.d("OutShow", "Topon: ad video end");
} }
@Override @Override
public void onInterstitialAdVideoError(AdError adError) { public void onInterstitialAdVideoError(AdError adError) {
Log.d("OutShow", "Topon: ad video error"); LogUtil.d("OutShow", "Topon: ad video error");
} }
public void loadAd(String id) { public boolean loadAd(String id) {
Log.d("OutShow", "Topon: loadAd : " + id); LogUtil.d("OutShow", "Topon: loadAd : " + id);
adId = id; adId = id;
if (atInterstitial != null) { if (atInterstitial != null) {
ATAdStatusInfo atAdStatusInfo = atInterstitial.checkAdStatus(); ATAdStatusInfo atAdStatusInfo = atInterstitial.checkAdStatus();
if (!atAdStatusInfo.isReady() && !atAdStatusInfo.isLoading()) { if (atAdStatusInfo.isReady()) {
LogUtil.d("OutShow", "ad isReady!");
return false;
}
if (!atAdStatusInfo.isLoading()) {
LogUtil.d("OutShow", "load ad !");
atInterstitial.load(); atInterstitial.load();
requestTime = System.currentTimeMillis(); requestTime = System.currentTimeMillis();
EventUtils.statAdReport(getReportRequestBean(adId)); EventUtils.statAdReport(getReportRequestBean(adId));
} else {
LogUtil.d("OutShow", "ad is loading !");
} }
} else { } else {
LogUtil.d("OutShow", "new ad and load !");
atInterstitial = new ATInterstitial(OutHelp.get().getContext(), adId); atInterstitial = new ATInterstitial(OutHelp.get().getContext(), adId);
atInterstitial.setAdListener(this); atInterstitial.setAdListener(this);
atInterstitial.load(); atInterstitial.load();
requestTime = System.currentTimeMillis(); requestTime = System.currentTimeMillis();
EventUtils.statAdReport(getReportRequestBean(adId)); EventUtils.statAdReport(getReportRequestBean(adId));
} }
} return true;
public boolean isAdReady() {
if (atInterstitial != null) {
ATAdStatusInfo atAdStatusInfo = atInterstitial.checkAdStatus();
return atAdStatusInfo.isReady();
} else {
return false;
}
} }
public void showAd(Activity activity) { public void showAd(Activity activity) {
Log.d("OutShow", "Topon: showAd"); LogUtil.d("OutShow", "Topon: showAd");
ATInterstitial.entryAdScenario("111", ""); ATInterstitial.entryAdScenario("111", "");
atInterstitial.show(activity); atInterstitial.show(activity);
} }
......
...@@ -30,7 +30,7 @@ public final class AppOutSP { ...@@ -30,7 +30,7 @@ public final class AppOutSP {
return OutLastScreenOff; return OutLastScreenOff;
} }
private static int OutInterstitialAdDayShowCount = -1; private volatile static int OutInterstitialAdDayShowCount = -1;
public static void saveOutInterstitialAdDayShowCount(int value) { public static void saveOutInterstitialAdDayShowCount(int value) {
getAppOutPref().put(KEY_OUT_INTERSTITIAL_AD_DAY_SHOW_COUNT, value); getAppOutPref().put(KEY_OUT_INTERSTITIAL_AD_DAY_SHOW_COUNT, value);
...@@ -85,12 +85,4 @@ public final class AppOutSP { ...@@ -85,12 +85,4 @@ public final class AppOutSP {
return outPref; return outPref;
} }
public static boolean isAppFirstStart() {
return getAppOutPref().getBoolean(KEY_IS_APP_FIRST_START, true);
}
public static void setIsAppFirstStart(boolean firstStart) {
getAppOutPref().put(KEY_IS_APP_FIRST_START, firstStart);
}
} }
...@@ -12,5 +12,4 @@ public abstract class BaseOutShowManager { ...@@ -12,5 +12,4 @@ public abstract class BaseOutShowManager {
abstract RemindersInfo getReminderInfo(); abstract RemindersInfo getReminderInfo();
abstract boolean checkCanShowForRemindInfo(RemindersInfo remindersInfo); abstract boolean checkCanShowForRemindInfo(RemindersInfo remindersInfo);
abstract boolean checkCanShowForActionState(OutAdData.NormalAdData adData, int actionState);
} }
...@@ -7,17 +7,13 @@ import android.net.NetworkInfo; ...@@ -7,17 +7,13 @@ import android.net.NetworkInfo;
import android.text.format.DateUtils; import android.text.format.DateUtils;
import com.zl.sdk.OutHelp; import com.zl.sdk.OutHelp;
import com.zl.sdk.ad.AdManagerV2;
import com.zl.sdk.bean.OutAdData; import com.zl.sdk.bean.OutAdData;
import com.zl.sdk.event.DialogFailReason; import com.zl.sdk.event.DialogFailReason;
import com.zl.sdk.event.EventUtils; import com.zl.sdk.event.EventUtils;
import com.zl.sdk.event.statistics.Statistics;
import com.zl.sdk.util.AppOutUtils; import com.zl.sdk.util.AppOutUtils;
import com.zl.sdk.util.LogUtil; import com.zl.sdk.util.LogUtil;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
public class CheckHelper { public class CheckHelper {
private static final String TAG = "OutShow CheckHelper --> "; private static final String TAG = "OutShow CheckHelper --> ";
...@@ -27,26 +23,9 @@ public class CheckHelper { ...@@ -27,26 +23,9 @@ public class CheckHelper {
* 解锁/回到桌面 触发展示的外展广告 * 解锁/回到桌面 触发展示的外展广告
*/ */
public static boolean checkAdCanShowByScene(int actionState, String scenes) { public static boolean checkAdCanShowByScene(int actionState, String scenes) {
// boolean isInit = OutHelp.get().isInit(); if ((actionState == ActionFrom.ACTION_TIMER.getAction()
// if (!isInit) { || actionState == ActionFrom.ACTION_BATTERY_CHANGED.getAction())
// LogUtil.d(TAG + "(场景检查)保活未初始化,不能展示"); && !AppOutUtils.isScreenOn()) {
// EventUtils.staDialogFail(DialogFailReason.NO_INIT, actionState, EventUtils.DIALOG_TYPE_AD);
// return false;
// }
// if (DxManager.get().existAppOutActivities()) {
// LogUtil.d(TAG + "(场景检查)存在外展弹窗,不能展示");
// EventUtils.staDialogFail(DialogFailReason.EXIST_OUT, actionState, EventUtils.DIALOG_TYPE_AD);
// return false;
// }
// if (!isNetworkAvailable(OutHelp.get().getContext())) {
// LogUtil.d(TAG + "(场景检查)网络未连接,不能展示");
// EventUtils.staDialogFail(DialogFailReason.NO_NET, actionState, scenes, EventUtils.DIALOG_TYPE_AD);
// return false;
// }
//
if (needCheckScreenOff(actionState) && !AppOutUtils.isScreenOn()) {
LogUtil.d(TAG + "(场景检查)手机未亮屏,不能展示"); LogUtil.d(TAG + "(场景检查)手机未亮屏,不能展示");
EventUtils.staDialogFail(DialogFailReason.SCREEN_OFF, actionState, scenes, EventUtils.DIALOG_TYPE_AD); EventUtils.staDialogFail(DialogFailReason.SCREEN_OFF, actionState, scenes, EventUtils.DIALOG_TYPE_AD);
return false; return false;
...@@ -64,12 +43,6 @@ public class CheckHelper { ...@@ -64,12 +43,6 @@ public class CheckHelper {
return false; return false;
} }
// if (AppOutUtils.isScreenLock()) {
// LogUtil.d(TAG + "(场景检查)锁屏中,不能展示");
// EventUtils.staDialogFail(DialogFailReason.LOCK, actionState, scenes, EventUtils.DIALOG_TYPE_AD);
// return false;
// }
LogUtil.d(TAG + "(场景检查)能展示"); LogUtil.d(TAG + "(场景检查)能展示");
return true; return true;
} }
...@@ -78,39 +51,8 @@ public class CheckHelper { ...@@ -78,39 +51,8 @@ public class CheckHelper {
* 检查广告数据是否可以播放 * 检查广告数据是否可以播放
*/ */
public static boolean checkCanShowAdByTimesFromAdData(OutAdData.NormalAdData data, int actionState, String scenes) { public static boolean checkCanShowAdByTimesFromAdData(OutAdData.NormalAdData data, int actionState, String scenes) {
if (data == null) {
LogUtil.d(TAG + "(次数检查)广告信息为空 不能播放");
EventUtils.staDialogFail(DialogFailReason.NO_DATA, actionState, scenes, EventUtils.DIALOG_TYPE_AD);
return false;
}
long curTime = System.currentTimeMillis(); long curTime = System.currentTimeMillis();
long showIntervalTime = Math.abs(curTime - OutHelp.get().getLastShowTime());
LogUtil.d(TAG + "(次数检查)上次展示时间=" + OutHelp.get().getLastShowTime());
long spaceTime;
if (OutHelp.get().iconIsHide()) {
spaceTime = data.intervalHide * DateUtils.SECOND_IN_MILLIS;
LogUtil.d(TAG + "(次数检查)间隔时间(icon隐藏)=" + spaceTime);
} else {
spaceTime = data.interval * DateUtils.SECOND_IN_MILLIS;
LogUtil.d(TAG + "(次数检查)间隔时间(icon未隐藏)=" + spaceTime);
}
// //TODO
// if (DeepNight.checkDeepNightRunning()) {
// spaceTime = 60 * 1000L;
// }
if (showIntervalTime < spaceTime) {
LogUtil.d(TAG + "(次数检查)未到间隔时间 不能播放");
EventUtils.staDialogFail(DialogFailReason.INTERVAL_TIME, actionState, scenes, EventUtils.DIALOG_TYPE_AD);
return false;
}
int homeInterstitialAdDayShowCount = AppOutSP.getOutInterstitialAdDayShowCount(); int homeInterstitialAdDayShowCount = AppOutSP.getOutInterstitialAdDayShowCount();
int homeDayShowCount = homeInterstitialAdDayShowCount; int homeDayShowCount = homeInterstitialAdDayShowCount;
...@@ -161,6 +103,33 @@ public class CheckHelper { ...@@ -161,6 +103,33 @@ public class CheckHelper {
return true; return true;
} }
public static boolean checkCanShowAdByInterValFromAdData(OutAdData.NormalAdData data, int actionState, String scenes) {
long curTime = System.currentTimeMillis();
long showIntervalTime = Math.abs(curTime - OutHelp.get().getLastShowTime());
LogUtil.d(TAG + "(次数检查)上次展示时间=" + OutHelp.get().getLastShowTime());
long spaceTime;
if (OutHelp.get().iconIsHide()) {
spaceTime = data.intervalHide * DateUtils.SECOND_IN_MILLIS;
LogUtil.d(TAG + "(次数检查)间隔时间(icon隐藏)=" + spaceTime);
} else {
spaceTime = data.interval * DateUtils.SECOND_IN_MILLIS;
LogUtil.d(TAG + "(次数检查)间隔时间(icon未隐藏)=" + spaceTime);
}
if (showIntervalTime < spaceTime) {
LogUtil.d(TAG + "(次数检查)未到间隔时间 不能播放");
EventUtils.staDialogFail(DialogFailReason.INTERVAL_TIME, actionState, scenes, EventUtils.DIALOG_TYPE_AD);
return false;
}
LogUtil.d(TAG + "(时间间隔检查)可播放");
return true;
}
public static boolean isSameDay(long time1, long time2) { public static boolean isSameDay(long time1, long time2) {
Calendar cal1 = Calendar.getInstance(); Calendar cal1 = Calendar.getInstance();
Calendar cal2 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance();
...@@ -171,31 +140,6 @@ public class CheckHelper { ...@@ -171,31 +140,6 @@ public class CheckHelper {
} }
/**
* 检查广告是否准备好
*/
public static boolean checkAdReady(OutAdData.NormalAdData data, String scenes) {
if (data == null) {
return false;
}
try {
// boolean ready = TopOnAdLoadManager.getInstance().isInterstitialReady(data.cpName, data.cpAdslot);
boolean ready = AdManagerV2.get().isAdReady();
LogUtil.d(TAG + "(缓存检查)是否有缓存:" + ready);
if (!ready) {
EventUtils.staDialogFail(DialogFailReason.NOT_READY, -1, scenes, EventUtils.DIALOG_TYPE_AD);
}
return ready;
} catch (Exception e) {
Map<String, Object> map = new HashMap<>();
map.put("reason", e.getMessage());
map.put("scenes", "check ready");
Statistics.getInstance().dotEvent(OutHelp.get().getContext(), "class error", "", map);
return false;
}
}
/** /**
* 是否在通话中 * 是否在通话中
*/ */
......
package com.zl.sdk.out.deepNightModle;
import android.util.Log;
import com.zl.sdk.ad.AdDataManager;
import com.zl.sdk.event.EventUtils;
import com.zl.sdk.out.AppOutSP;
import com.zl.sdk.out.CheckHelper;
import com.zl.sdk.util.LogUtil;
import java.util.Calendar;
public class DeepNight {
private static boolean isOpen = true;
private static int start_time = 2;
private static int end_time = 5;
private static boolean deepNightRunning = false;
/**
* 深夜模式是否开启
*
* @return
*/
public static boolean deepNightIsOpen() {
return isOpen;
}
/**
* 深夜模式能否开始
*
* @return
*/
public static boolean checkDeepNightRunning() {
// if (deepNightRunning) {
// deepNightRunning = checkTime() && checkAdTimes();
// } else {
// deepNightRunning = deepNightIsOpen() && checkTime() && checkAdTimes();
// }
return deepNightIsOpen() && checkTime();
}
/**
* 深夜模式 检查当前时间
*
* @return
*/
private static boolean checkTime() {
int curr_hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
LogUtil.d("OutShow curr_hour =" + curr_hour);
return start_time <= curr_hour && curr_hour < end_time;
}
/**
* 深夜模式 检查上次熄屏时间
*
* @return
*/
private static boolean checkLastScreenOffTime() {
return System.currentTimeMillis() - AppOutSP.getLastScreenOffTime() >= 10 * 60 * 1000L;
}
private static boolean checkAdTimes() {
return CheckHelper.checkCanShowAdByTimesFromAdData(AdDataManager.get().getShowAdData(), -1, EventUtils.SCENES_SHOW);
}
}
...@@ -10,15 +10,12 @@ import android.view.Window; ...@@ -10,15 +10,12 @@ import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import com.zl.sdk.Config;
import com.zl.sdk.OutHelp; import com.zl.sdk.OutHelp;
import com.zl.sdk.ad.AdManagerV2; import com.zl.sdk.ad.AdManagerV2;
import com.zl.sdk.bean.OutAdData;
import com.zl.sdk.bean.RemindersInfo;
import com.zl.sdk.event.EventUtils; import com.zl.sdk.event.EventUtils;
import com.zl.sdk.event.statistics.Statistics; import com.zl.sdk.event.statistics.Statistics;
import com.zl.sdk.icon.IconHelp; import com.zl.sdk.icon.IconHelp;
import com.zl.sdk.out.DxManager; import com.zl.sdk.util.AppOutUtils;
import com.zl.sdk.util.LogUtil; import com.zl.sdk.util.LogUtil;
import java.util.HashMap; import java.util.HashMap;
...@@ -27,11 +24,6 @@ import java.util.Map; ...@@ -27,11 +24,6 @@ import java.util.Map;
public class DxActivity extends BaseActivity { public class DxActivity extends BaseActivity {
private static final String TAG = "OutShow Dx ---> "; private static final String TAG = "OutShow Dx ---> ";
// private Intent intent = null;
// private RemindersInfo remindersInfo;
// private OutAdData.NormalAdData adData;
// private IView proxyView;
private long onceStayTime; private long onceStayTime;
private boolean hadStart = false; private boolean hadStart = false;
...@@ -45,36 +37,31 @@ public class DxActivity extends BaseActivity { ...@@ -45,36 +37,31 @@ public class DxActivity extends BaseActivity {
@Override @Override
public void onBeforeCreate(Bundle bundle) { public void onBeforeCreate(Bundle bundle) {
// OutHelp.get().setShowLock(true);
hadStart = false; hadStart = false;
} }
@Override @Override
public void onAfterCreate(Bundle bundle) { public void onAfterCreate(Bundle bundle) {
LogUtil.d(TAG + "onCreate"); LogUtil.d(TAG + "onCreate");
// DxManager.get().addActivity(this);
} }
@Override @Override
public void onNewIntent(Intent intent) { public void onNewIntent(Intent intent) {
super.onNewIntent(intent); super.onNewIntent(intent);
// LogUtil.d(TAG + "onNewIntent : " + hasExecuteInLifeCycle);
// if (!hasExecuteInLifeCycle) {
// execute();
// }
} }
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
LogUtil.d(TAG + "onStart");
if (hadStart) { if (hadStart) {
close(); close();
return; return;
} }
LogUtil.d(TAG + "onStart");
mainHandler.removeCallbacksAndMessages(null); mainHandler.removeCallbacksAndMessages(null);
mainHandler.postDelayed(new Runnable() { mainHandler.postDelayed(new Runnable() {
@Override @Override
...@@ -89,18 +76,12 @@ public class DxActivity extends BaseActivity { ...@@ -89,18 +76,12 @@ public class DxActivity extends BaseActivity {
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
LogUtil.d(TAG + "onResume hashCode=" + hashCode()); LogUtil.d(TAG + "onResume hashCode=" + hashCode());
// if (proxyView != null) {
// proxyView.onResume();
// }
} }
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
LogUtil.d(TAG + "onPause hashCode=" + hashCode()); LogUtil.d(TAG + "onPause hashCode=" + hashCode());
// if (proxyView != null) {
// proxyView.onPause();
// }
} }
@Override @Override
...@@ -112,10 +93,6 @@ public class DxActivity extends BaseActivity { ...@@ -112,10 +93,6 @@ public class DxActivity extends BaseActivity {
@Override @Override
public void onDestroy() { public void onDestroy() {
LogUtil.d(TAG + "onDestroy hashCode=" + hashCode()); LogUtil.d(TAG + "onDestroy hashCode=" + hashCode());
// if (proxyView != null) {
// proxyView.onDestroy();
// proxyView = null;
// }
mainHandler.removeCallbacksAndMessages(null); mainHandler.removeCallbacksAndMessages(null);
...@@ -124,8 +101,6 @@ public class DxActivity extends BaseActivity { ...@@ -124,8 +101,6 @@ public class DxActivity extends BaseActivity {
map.put("s_d_t", String.valueOf(time)); map.put("s_d_t", String.valueOf(time));
Statistics.getInstance().onEvent(OutHelp.get().getContext(), EventUtils.OUT_DIALOG_EXPOSE_ONCE_STAY_TIME, null, map); Statistics.getInstance().onEvent(OutHelp.get().getContext(), EventUtils.OUT_DIALOG_EXPOSE_ONCE_STAY_TIME, null, map);
super.onDestroy(); super.onDestroy();
// DxManager.get().removeActivity(this);
} }
@Override @Override
...@@ -134,10 +109,6 @@ public class DxActivity extends BaseActivity { ...@@ -134,10 +109,6 @@ public class DxActivity extends BaseActivity {
} }
public void close() { public void close() {
// if (proxyView != null) {
// proxyView.onDestroy();
// proxyView = null;
// }
activity.finish(); activity.finish();
} }
...@@ -152,47 +123,20 @@ public class DxActivity extends BaseActivity { ...@@ -152,47 +123,20 @@ public class DxActivity extends BaseActivity {
} }
private void statSLKStart(RemindersInfo remindersInfo, boolean isHide) { private void statSLKStart(boolean isHide) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
String type = "";
// if (remindersInfo != null) {
// type = String.valueOf(remindersInfo.reminderType);
// }
map.put("type", type);
map.put("hide", String.valueOf(isHide)); map.put("hide", String.valueOf(isHide));
map.put("screen_state", String.valueOf(AppOutUtils.isScreenOn()));
map.put("foreground", OutHelp.get().isAppForeground());
Statistics.getInstance().dotEvent(activity, "slk_start", "", map); Statistics.getInstance().dotEvent(activity, "slk_start", "", map);
} }
private void execute() { private void execute() {
// checkIntent();
startShowDialog(); startShowDialog();
} }
// private void checkIntent() {
// adData = null;
// remindersInfo = null;
//
// adData = (OutAdData.NormalAdData) DxManager.get().getOutAdData();
// LogUtil.d(TAG + "广告信息 =" + adData);
//
// remindersInfo = DxManager.get().getOutRemindersInfo();
// LogUtil.d(TAG + "弹窗信息 =" + remindersInfo);
// }
private void startShowDialog() { private void startShowDialog() {
statSLKStart(null, IconHelp.get().isIconHide()); statSLKStart(IconHelp.get().isIconHide());
// if (remindersInfo == null) {
// LogUtil.d(TAG + "finish remindersInfo为空");
// close();
// return;
// }
//
// if (remindersInfo.reminderType != Config.REMINDER_TYPE_WEATHER_PURE_AD && IconHelp.get().isIconHide()) {
// LogUtil.d(TAG + "finish 不是纯广告并且隐藏了icon");
// close();
// return;
// }
Window window = activity.getWindow(); Window window = activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_SECURE); window.addFlags(WindowManager.LayoutParams.FLAG_SECURE);
...@@ -202,21 +146,6 @@ public class DxActivity extends BaseActivity { ...@@ -202,21 +146,6 @@ public class DxActivity extends BaseActivity {
onceStayTime = System.currentTimeMillis(); onceStayTime = System.currentTimeMillis();
if (AdManagerV2.get().isAdReady()) { AdManagerV2.get().showAd(activity);
AdManagerV2.get().showAd(activity);
} else {
close();
}
// LogUtil.d(TAG + "加载新的Dialog");
// proxyView = DialogFactory.createDialog(remindersInfo, adData);
//
// if (proxyView == null) {
// LogUtil.d(TAG + "finish 5 View=null");
// close();
// return;
// }
//
// proxyView.onCreate(activity, intent, rootView);
} }
} }
...@@ -51,7 +51,9 @@ public final class AppOutUtils { ...@@ -51,7 +51,9 @@ public final class AppOutUtils {
public static boolean isScreenOn() { public static boolean isScreenOn() {
try { try {
PowerManager powerManager = (PowerManager) OutHelp.get().getContext().getSystemService(Context.POWER_SERVICE); PowerManager powerManager = (PowerManager) OutHelp.get().getContext().getSystemService(Context.POWER_SERVICE);
return powerManager.isScreenOn(); boolean isScreenOn = powerManager.isInteractive();
LogUtil.d(TAG + "isScreenOn=" + isScreenOn);
return isScreenOn;
} catch (Exception e) { } catch (Exception e) {
} }
return true; return true;
......
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