diff --git a/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java b/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java index d5a24c3a7..4003b6a17 100644 --- a/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java +++ b/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java @@ -49,13 +49,21 @@ public class OpenAdManager { } private void init(boolean isShow) { + if (list != null && list.isEmpty()) { + return; + } LiveNetManager.get(CommonAppContext.getTopActivity()) .activityPopup(new HttpCallback>() { @Override public void onSuccess(List data) { + if (data == null || data.isEmpty()) { + Log.i(TAG, "onSuccess: 没有数据"); + list = new ArrayList<>(); + return; + } list = data; if (isShow) { - show(TYPE_HOME,false); + show(TYPE_HOME, false); } } @@ -67,31 +75,31 @@ public class OpenAdManager { } - public synchronized void show(int type,boolean isGuard) { - if (list==null) { + public synchronized void show(int type, boolean isGuard) { + if (list == null) { init(true); return; } - showType=type; + showType = type; for (OpenAdModel model : list) { if (model.getType() == type) { - if(type==OpenAdModel.TYPE_LIVE && !model.userIsPermission(isGuard)){ + if (type == OpenAdModel.TYPE_LIVE && !model.userIsPermission(isGuard)) { continue; } if (runnableMap.containsKey(model.getId())) { AdRunnable runnable = runnableMap.get(model.getId()); if (runnable != null) { - Log.d(TAG, "reset: "+model); + Log.d(TAG, "reset: " + model); handler.removeCallbacks(runnable); runnableMap.remove(model.getId()); } } if (!isShow(model)) { - Log.i(TAG, "show: "+model); + Log.i(TAG, "show: " + model); handler.postDelayed(new AdRunnable(model), model.getDelayShowTime()); - }else{ - Log.i(TAG, "notshow: "+model); + } else { + Log.i(TAG, "notshow: " + model); } } @@ -101,10 +109,10 @@ public class OpenAdManager { } public synchronized void dismiss() { - Log.d(TAG, "准备dismiss:"+runnableMap.size() ); + Log.d(TAG, "准备dismiss:" + runnableMap.size()); for (Integer model : runnableMap.keySet()) { AdRunnable runnable = runnableMap.get(model); - Log.d(TAG, "dismiss:"+runnable); + Log.d(TAG, "dismiss:" + runnable); if (runnable != null) { runnable.dismiss(); handler.removeCallbacks(runnable); @@ -127,13 +135,14 @@ public class OpenAdManager { this.model = model; runnableMap.put(model.getId(), this); } - public void dismiss(){ - Log.e(TAG, "dismiss: "+model ); + + public void dismiss() { + Log.e(TAG, "dismiss: " + model); } @Override public synchronized void run() { - Log.i(TAG, "run: "+model); + Log.i(TAG, "run: " + model); if (model == null) { ToastUtil.showDebug("model为空"); return; @@ -146,7 +155,7 @@ public class OpenAdManager { ToastUtil.showDebug(model.getId() + "|model展示过了"); return; } - if(model.getType()!=showType){ + if (model.getType() != showType) { return; } showMap.put(model.getId(), true);