fix 重复调用弹窗接口
This commit is contained in:
parent
bcd8f7af52
commit
4e4b5f90bb
@ -49,13 +49,21 @@ public class OpenAdManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void init(boolean isShow) {
|
private void init(boolean isShow) {
|
||||||
|
if (list != null && list.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
LiveNetManager.get(CommonAppContext.getTopActivity())
|
LiveNetManager.get(CommonAppContext.getTopActivity())
|
||||||
.activityPopup(new HttpCallback<List<OpenAdModel>>() {
|
.activityPopup(new HttpCallback<List<OpenAdModel>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<OpenAdModel> data) {
|
public void onSuccess(List<OpenAdModel> data) {
|
||||||
|
if (data == null || data.isEmpty()) {
|
||||||
|
Log.i(TAG, "onSuccess: 没有数据");
|
||||||
|
list = new ArrayList<>();
|
||||||
|
return;
|
||||||
|
}
|
||||||
list = data;
|
list = data;
|
||||||
if (isShow) {
|
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) {
|
public synchronized void show(int type, boolean isGuard) {
|
||||||
if (list==null) {
|
if (list == null) {
|
||||||
init(true);
|
init(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showType=type;
|
showType = type;
|
||||||
for (OpenAdModel model : list) {
|
for (OpenAdModel model : list) {
|
||||||
if (model.getType() == type) {
|
if (model.getType() == type) {
|
||||||
if(type==OpenAdModel.TYPE_LIVE && !model.userIsPermission(isGuard)){
|
if (type == OpenAdModel.TYPE_LIVE && !model.userIsPermission(isGuard)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (runnableMap.containsKey(model.getId())) {
|
if (runnableMap.containsKey(model.getId())) {
|
||||||
AdRunnable runnable = runnableMap.get(model.getId());
|
AdRunnable runnable = runnableMap.get(model.getId());
|
||||||
if (runnable != null) {
|
if (runnable != null) {
|
||||||
Log.d(TAG, "reset: "+model);
|
Log.d(TAG, "reset: " + model);
|
||||||
handler.removeCallbacks(runnable);
|
handler.removeCallbacks(runnable);
|
||||||
runnableMap.remove(model.getId());
|
runnableMap.remove(model.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isShow(model)) {
|
if (!isShow(model)) {
|
||||||
Log.i(TAG, "show: "+model);
|
Log.i(TAG, "show: " + model);
|
||||||
handler.postDelayed(new AdRunnable(model), model.getDelayShowTime());
|
handler.postDelayed(new AdRunnable(model), model.getDelayShowTime());
|
||||||
}else{
|
} else {
|
||||||
Log.i(TAG, "notshow: "+model);
|
Log.i(TAG, "notshow: " + model);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -101,10 +109,10 @@ public class OpenAdManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void dismiss() {
|
public synchronized void dismiss() {
|
||||||
Log.d(TAG, "准备dismiss:"+runnableMap.size() );
|
Log.d(TAG, "准备dismiss:" + runnableMap.size());
|
||||||
for (Integer model : runnableMap.keySet()) {
|
for (Integer model : runnableMap.keySet()) {
|
||||||
AdRunnable runnable = runnableMap.get(model);
|
AdRunnable runnable = runnableMap.get(model);
|
||||||
Log.d(TAG, "dismiss:"+runnable);
|
Log.d(TAG, "dismiss:" + runnable);
|
||||||
if (runnable != null) {
|
if (runnable != null) {
|
||||||
runnable.dismiss();
|
runnable.dismiss();
|
||||||
handler.removeCallbacks(runnable);
|
handler.removeCallbacks(runnable);
|
||||||
@ -127,13 +135,14 @@ public class OpenAdManager {
|
|||||||
this.model = model;
|
this.model = model;
|
||||||
runnableMap.put(model.getId(), this);
|
runnableMap.put(model.getId(), this);
|
||||||
}
|
}
|
||||||
public void dismiss(){
|
|
||||||
Log.e(TAG, "dismiss: "+model );
|
public void dismiss() {
|
||||||
|
Log.e(TAG, "dismiss: " + model);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void run() {
|
public synchronized void run() {
|
||||||
Log.i(TAG, "run: "+model);
|
Log.i(TAG, "run: " + model);
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
ToastUtil.showDebug("model为空");
|
ToastUtil.showDebug("model为空");
|
||||||
return;
|
return;
|
||||||
@ -146,7 +155,7 @@ public class OpenAdManager {
|
|||||||
ToastUtil.showDebug(model.getId() + "|model展示过了");
|
ToastUtil.showDebug(model.getId() + "|model展示过了");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(model.getType()!=showType){
|
if (model.getType() != showType) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showMap.put(model.getId(), true);
|
showMap.put(model.getId(), true);
|
||||||
|
Loading…
Reference in New Issue
Block a user