diff --git a/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java b/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java index f0619923c..7f872d4e3 100644 --- a/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java +++ b/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java @@ -113,6 +113,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL res.updateConfiguration(config, res.getDisplayMetrics()); return res; } + @Override protected void onCreate(@Nullable Bundle savedInstanceState) { getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS); @@ -144,7 +145,11 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL } }; mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000); - LogUtil.uploadErrorLog(AppContext.sInstance); + try { + LogUtil.uploadErrorLog(AppContext.sInstance); + } catch (Exception e) { + e.printStackTrace(); + } SpUtil.getInstance().setBooleanValue("NOTIFICATION", NotificationManagerCompat.from(this).areNotificationsEnabled()); } @@ -229,7 +234,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL } else { checkUidAndToken(); } - }else{ + } else { ToastUtil.show(getString(R.string.net_error)); } } diff --git a/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java b/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java index 8260ee377..3a8777ae9 100644 --- a/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java +++ b/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java @@ -4,6 +4,7 @@ import com.google.gson.annotations.SerializedName; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.StringUtil; +import com.yunbao.common.views.weight.ViewClicksAntiShake; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -22,6 +23,8 @@ public class OpenAdModel extends BaseModel { public static final int SHOW_ONE = 3;//3. 仅弹出一次; @SerializedName("id") private int id; + @SerializedName("popup_name") + private String name; @SerializedName("popup_location") private int type = TYPE_HOME; @SerializedName("activity_url") @@ -35,24 +38,25 @@ public class OpenAdModel extends BaseModel { @SerializedName("popup_model") private int model = MODEL_SQUARE; @SerializedName("start_show_time") - private String startTime;//活动开始时间 + private String startTime;//活动开始时间 1 @SerializedName("end_show_time") - private String endTime;//活动结束时间 + private String endTime;//活动结束时间 5 @SerializedName("popup_permission") private int permission; @SerializedName("popup_frequency") private int showModel = SHOW_DEF;//显示模式,1:杀死程序后弹出 2:指定时间内(本机时间) 3:1. 仅弹出一次 @SerializedName("popup_frequency_time") - private String section = "0";// SHOW_DEF = 2 - + private String section = "0";// SHOW_DEF = 2 1 + @SerializedName("popup_sort") + private int sort = 1;//弹框类型 1.图片 2.H5 public OpenAdModel() { } public static OpenAdModel createTestData() { OpenAdModel model = new OpenAdModel(); - model.id=3; - model.type=1; + model.id = 3; + model.type = 1; model.url = "/h5/GuildTournament/20230821/rank.html"; model.imageUrl = "https://ceshi.yaoulive.com/data/upload/20230913/1694589490.png"; model.showTime = 10; @@ -66,6 +70,22 @@ public class OpenAdModel extends BaseModel { return model; } + public int getSort() { + return sort; + } + + public void setSort(int sort) { + this.sort = sort; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + public int getShowModel() { return showModel; } @@ -96,7 +116,8 @@ public class OpenAdModel extends BaseModel { } return url + "?t=" + System.currentTimeMillis() / 1000; } - public String getOriginalUrl(){ + + public String getOriginalUrl() { return url; } @@ -198,6 +219,7 @@ public class OpenAdModel extends BaseModel { public String toString() { return "OpenAdModel{" + "id=" + id + + ", name='" + name + '\'' + ", type=" + type + ", url='" + url + '\'' + ", imageUrl='" + imageUrl + '\'' + @@ -206,7 +228,10 @@ public class OpenAdModel extends BaseModel { ", model=" + model + ", startTime='" + startTime + '\'' + ", endTime='" + endTime + '\'' + - ", permission='" + permission + '\'' + + ", permission=" + permission + + ", showModel=" + showModel + + ", section='" + section + '\'' + + ", sort=" + sort + '}'; } } diff --git a/common/src/main/java/com/yunbao/common/dialog/DebugDialog.java b/common/src/main/java/com/yunbao/common/dialog/DebugDialog.java index 48131bfbf..6ad00a421 100644 --- a/common/src/main/java/com/yunbao/common/dialog/DebugDialog.java +++ b/common/src/main/java/com/yunbao/common/dialog/DebugDialog.java @@ -20,13 +20,14 @@ import com.yunbao.common.utils.AppManager; import com.yunbao.common.utils.ToastUtil; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Timer; import java.util.TimerTask; public class DebugDialog { RecyclerView recyclerView; - HashMap params; + LinkedHashMap params; DebugDialogAdapter adapter; private static DebugDialog debugDialog; Context mContext; @@ -69,7 +70,7 @@ public class DebugDialog { this.runnable = runnable; if (params == null) { Log.i("debug弹窗", "DebugDialog: 初始化参数"); - params = new HashMap<>(); + params = new LinkedHashMap<>(); } init(); } @@ -102,6 +103,7 @@ public class DebugDialog { } public void show() { + if (recyclerView != null) return; if (showPattern == ShowPattern.CURRENT_ACTIVITY) { createView(); return; diff --git a/common/src/main/java/com/yunbao/common/dialog/OpenAdBottomDialogPopup.java b/common/src/main/java/com/yunbao/common/dialog/OpenAdBottomDialogPopup.java index 072ab97a8..9c475e1a7 100644 --- a/common/src/main/java/com/yunbao/common/dialog/OpenAdBottomDialogPopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/OpenAdBottomDialogPopup.java @@ -1,7 +1,10 @@ package com.yunbao.common.dialog; +import android.app.Activity; import android.content.Context; +import android.webkit.WebView; import android.widget.ImageView; +import android.widget.LinearLayout; import androidx.annotation.NonNull; @@ -9,12 +12,18 @@ import com.lxj.xpopup.XPopup; import com.yunbao.common.R; import com.yunbao.common.activity.WebViewActivity; import com.yunbao.common.bean.OpenAdModel; +import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.utils.JavascriptInterfaceUtils; + +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; public class OpenAdBottomDialogPopup extends AbsDialogPopupWindow { - private ImageView mImageView; private ImageView mClose; + private LinearLayout contentLayout; private OpenAdModel model; private OnItemClickListener mListener; @@ -27,6 +36,11 @@ public class OpenAdBottomDialogPopup extends AbsDialogPopupWindow { @Override public void buildDialog(XPopup.Builder builder) { builder.animationDuration(0); + builder.hasShadowBg(true); + if(model.getSort()==2){ + builder.dismissOnTouchOutside(false); + builder.dismissOnBackPressed(false); + } } @Override @@ -51,8 +65,47 @@ public class OpenAdBottomDialogPopup extends AbsDialogPopupWindow { @Override protected void onCreate() { super.onCreate(); - mImageView = findViewById(R.id.img); + contentLayout = findViewById(R.id.content_layout); mClose = findViewById(R.id.close); + if (model.getSort() == 1) { + setImage(); + } else { + setWeb(); + } + + mClose.setOnClickListener(v -> dismiss()); + if (model.getShowTime() > 0) { + mClose.postDelayed(this::dismiss, model.getShowTime()); + } + } + + private void setWeb() { + WebView mWebView = new WebView(mContext); + mWebView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); + mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext((Activity) mContext, mWebView).setPageClose(true).setLiveZhuangBana(false), "androidObject"); + mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 + mWebView.getSettings().setJavaScriptEnabled(true); + mWebView.getSettings().setDomStorageEnabled(true); + String appCachePath = mContext.getCacheDir().getAbsolutePath(); +// mWebView.getSettings().setAppCachePath(appCachePath); + mWebView.getSettings().setAllowFileAccess(true); + mWebView.getSettings().setUseWideViewPort(true); // 关键点 + mWebView.getSettings().setAllowFileAccess(true); // 允许访问文件 + mWebView.setHorizontalScrollBarEnabled(false); + mWebView.setVerticalScrollBarEnabled(false); + String url=model.getUrl(); + if(url.contains("?")){ + url+="&uid="+ IMLoginManager.get(mContext).getUserInfo().getId()+"&token="+IMLoginManager.get(mContext).getUserInfo().getToken(); + }else{ + url+="?uid="+ IMLoginManager.get(mContext).getUserInfo().getId()+"&token="+IMLoginManager.get(mContext).getUserInfo().getToken(); + } + mWebView.loadUrl(url); + contentLayout.addView(mWebView); + } + + private void setImage() { + ImageView mImageView = new ImageView(mContext); + mImageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); mImageView.setOnClickListener(v -> { WebViewActivity.forward(mContext, model.getUrl(), model.getType() != OpenAdModel.TYPE_HOME); if (mListener != null) { @@ -61,10 +114,12 @@ public class OpenAdBottomDialogPopup extends AbsDialogPopupWindow { } dismiss(); }); - mClose.setOnClickListener(v -> dismiss()); ImgLoader.display(mContext, model.getImageUrl(), mImageView); - if (model.getShowTime() > 0) { - mClose.postDelayed(this::dismiss, model.getShowTime()); - } + contentLayout.addView(mImageView); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) { + } } diff --git a/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java b/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java index d5a0de407..f75c323dc 100644 --- a/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java @@ -1,8 +1,13 @@ package com.yunbao.common.dialog; +import android.app.Activity; import android.content.Context; +import android.graphics.Color; import android.util.Log; +import android.view.ViewGroup; +import android.webkit.WebView; import android.widget.ImageView; +import android.widget.LinearLayout; import androidx.annotation.NonNull; import androidx.constraintlayout.widget.ConstraintLayout; @@ -11,14 +16,23 @@ import com.lxj.xpopup.XPopup; import com.yunbao.common.R; import com.yunbao.common.activity.WebViewActivity; import com.yunbao.common.bean.OpenAdModel; +import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ScreenDimenUtil; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.Map; + public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow { private ImageView mImageView; + private LinearLayout contentLayout; private ImageView mClose; private OpenAdModel model; private OnItemClickListener mListener; @@ -39,7 +53,8 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow { @Override public void buildDialog(XPopup.Builder builder) { - builder.hasShadowBg(false); + builder.hasShadowBg(true); + builder.shadowBgColor(Color.parseColor("#80000000")); builder.animationDuration(0); } @@ -61,12 +76,61 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow { @Override protected void onCreate() { super.onCreate(); - Log.e("-----弹窗-----", "onCreate: 创建弹窗" ); - mImageView = findViewById(R.id.img); + Log.e("-----弹窗-----", "onCreate: 创建弹窗"); + contentLayout = findViewById(R.id.content_layout); mClose = findViewById(R.id.close); - findViewById(R.id.layout).setOnClickListener(v -> dismiss()); + if (model.getSort() == 1) { + setImage(model); + findViewById(R.id.layout).setOnClickListener(v -> dismiss()); + } else { + setWeb(model); + } + mClose.setOnClickListener(v -> dismiss()); + if (model.getShowTime() > 0) { + mClose.postDelayed(this::dismiss, model.getShowTime()); + } + } + + private void setWeb(OpenAdModel model) { + int width = ScreenDimenUtil.getInstance().getScreenWdith() - DpUtil.dp2px(20); + int height = (int) (width * 1.4); + if (model.getModel() == OpenAdModel.MODEL_SQUARE) { + height = (int) (width * 1.2); + } + WebView mWebView = new WebView(mContext); + mWebView.setLayoutParams(new LinearLayout.LayoutParams(width, height)); + mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext((Activity) mContext, mWebView).setPageClose(true).setLiveZhuangBana(false), "androidObject"); + mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 + mWebView.getSettings().setJavaScriptEnabled(true); + mWebView.getSettings().setDomStorageEnabled(true); + String appCachePath = mContext.getCacheDir().getAbsolutePath(); +// mWebView.getSettings().setAppCachePath(appCachePath); + mWebView.getSettings().setAllowFileAccess(true); + mWebView.getSettings().setUseWideViewPort(true); // 关键点 + mWebView.getSettings().setAllowFileAccess(true); // 允许访问文件 + mWebView.setHorizontalScrollBarEnabled(false); + mWebView.setVerticalScrollBarEnabled(false); + String url = model.getUrl(); + if (url.contains("?")) { + url += "&uid=" + IMLoginManager.get(mContext).getUserInfo().getId() + "&token=" + IMLoginManager.get(mContext).getUserInfo().getToken(); + } else { + url += "?uid=" + IMLoginManager.get(mContext).getUserInfo().getId() + "&token=" + IMLoginManager.get(mContext).getUserInfo().getToken(); + } + Log.i("-----弹窗-----", "setWeb: "+url); + mWebView.loadUrl(url); + contentLayout.addView(mWebView); + } + + private void setImage(OpenAdModel model) { + int width = ScreenDimenUtil.getInstance().getScreenWdith() - DpUtil.dp2px(20); + int height = (int) (width * 1.4); + if (model.getModel() == OpenAdModel.MODEL_SQUARE) { + height = (int) (width * 1.2); + } + mImageView = new ImageView(mContext); + mImageView.setLayoutParams(new LinearLayout.LayoutParams(width, height)); mImageView.setOnClickListener(v -> { - if("home_page_banner_battle".equals(model.getOriginalUrl())){ + if ("home_page_banner_battle".equals(model.getOriginalUrl())) { RouteUtil.forwardBattlePass(); dismiss(); return; @@ -78,19 +142,12 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow { } dismiss(); }); - mClose.setOnClickListener(v -> dismiss()); ImgLoader.display(mContext, model.getImageUrl(), mImageView); - int width = ScreenDimenUtil.getInstance().getScreenWdith() - DpUtil.dp2px(40); - int height = (int) (width * 1.4); - if (model.getModel() == OpenAdModel.MODEL_SQUARE) { - height = width; - } - ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) mImageView.getLayoutParams(); - params.width = width; - params.height = height; - mImageView.setLayoutParams(params); - if (model.getShowTime() > 0) { - mClose.postDelayed(this::dismiss, model.getShowTime()); - } + contentLayout.addView(mImageView); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) { + } } 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 46242290d..4aaa0ea2e 100644 --- a/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java +++ b/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java @@ -7,19 +7,25 @@ import android.util.Log; import com.yunbao.common.CommonAppContext; import com.yunbao.common.bean.OpenAdModel; +import com.yunbao.common.dialog.DebugDialog; import com.yunbao.common.dialog.OpenAdBottomDialogPopup; import com.yunbao.common.dialog.OpenAdCenterDialogPopup; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.utils.AppManager; import com.yunbao.common.utils.SpUtil; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; +import java.lang.ref.WeakReference; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Objects; public class OpenAdManager { public static final int TYPE_HOME = 1; @@ -28,21 +34,40 @@ public class OpenAdManager { private Map showMap; private List list = null; private Handler handler = new Handler(Looper.getMainLooper()); - private Map runnableMap = new HashMap<>(); + private Map runnableMap = new LinkedHashMap<>(); + private Map waitRunnableMap = new LinkedHashMap<>();//等待运行的弹窗 private int showType; + private WeakReference runNowRunnable; + private static final boolean IS_QUEUE_SHOW = true;//是否按队列显示弹窗,true就会等待上一个弹窗关闭后弹出,false就按原逻辑顺序直接弹出 private OpenAdManager() { showMap = new HashMap<>(); + DebugDialog.getInstance(new DebugDialog.DebugDialogRunnable() { + @Override + public void run(DebugDialog dialog) { + dialog.show(); + onItemClickListener = new OnItemClickListener() { + @Override + public void onItemClick(String bean, int position) { + dialog.setParams(bean, "剩余:" + position); + } + }; + } + }); init(false); } - public void reset() { + public void close() { dismiss(); runnableMap.clear(); showMap.clear(); list.clear(); } + public void reset() { + next(); + } + private static final class MInstanceHolder { static final OpenAdManager mInstance = new OpenAdManager(); } @@ -70,30 +95,38 @@ public class OpenAdManager { list = new ArrayList<>(); return; } + Collections.sort(data, new AdListComparator()); list = data; if (isShow) { - show(TYPE_HOME, false); + if (showType == 0) { + show(TYPE_HOME, false); + } else { + show(showType, false); + } } } @Override public void onError(String error) { - System.err.println("弹框列表:" + error); + Log.e(TAG, "弹框列表:" + error); } }); } - private static long showTime=0; + private static long showTime = 0; + private OnItemClickListener onItemClickListener; + public synchronized void show(int type, boolean isGuard) { + showType = type; if (list == null) { init(true); return; } - if(System.currentTimeMillis()-showTime<100){ + Log.i(TAG, "show: 调用显示 " + type + " " + isGuard); + if (System.currentTimeMillis() - showTime < 100) { return; } - showTime=System.currentTimeMillis(); - showType = type; + showTime = System.currentTimeMillis(); for (OpenAdModel model : list) { if (model.getType() == type) { if (type == OpenAdModel.TYPE_LIVE && !model.userIsPermission(isGuard)) { @@ -122,13 +155,22 @@ public class OpenAdManager { if (!isShow(model)) { Log.i(TAG, "show: " + model); - handler.postDelayed(new AdRunnable(model), model.getDelayShowTime()); + if (IS_QUEUE_SHOW) { + waitRunnableMap.put(new AdRunnable(model), model.getDelayShowTime()); + } else { + handler.postDelayed(new AdRunnable(model), model.getDelayShowTime()); + } } else { Log.i(TAG, "notshow: " + model); } } } + Log.i(TAG, "show: 循环完毕,调用next"); + if (IS_QUEUE_SHOW) { + onItemClickListener.onItemClick("接口返回需要展示的弹窗数:", waitRunnableMap.size()); + next(); + } Log.i(TAG, "------------------------------"); } @@ -144,6 +186,9 @@ public class OpenAdManager { } } runnableMap.clear(); + if (runNowRunnable != null && runNowRunnable.get() != null) { + handler.removeCallbacks(runNowRunnable.get()); + } } private synchronized boolean isShow(OpenAdModel type) { @@ -153,11 +198,26 @@ public class OpenAdManager { return false; } + void next() { + Log.i(TAG, "next: " + waitRunnableMap.size()); + if (waitRunnableMap.isEmpty()) return; + AdRunnable next = waitRunnableMap.keySet().iterator().next(); + Integer i = waitRunnableMap.get(next); + if (i == null) { + i = 0; + } + onItemClickListener.onItemClick("当前加载id:" + next.model.getId() + " " + next.model.getName() + " 延迟展示时间:" + i, (waitRunnableMap.size() - 1)); + handler.postDelayed(next, i); + } + private class AdRunnable implements Runnable { OpenAdModel model; + AdRunnable runnable; public AdRunnable(OpenAdModel model) { this.model = model; + this.runnable = this; + runNowRunnable = new WeakReference<>(this); runnableMap.put(model.getId(), this); } @@ -183,23 +243,45 @@ public class OpenAdManager { if (model.getType() != showType) { return; } - if(isShow(model)){ - Log.i(TAG,"展示过:"+model); + if (isShow(model)) { + Log.i(TAG, "展示过:" + model); return; } showMap.put(model.getId(), true); if (model.getShowModel() == OpenAdModel.SHOW_DIY) { - String nextTime= String.valueOf(System.currentTimeMillis() + (Long.parseLong(model.getSection()) * 60 * 1000)); + String nextTime = String.valueOf(System.currentTimeMillis() + (Long.parseLong(model.getSection()) * 60 * 1000)); SpUtil.setStringValue("open_ad_popup_time_" + model.getId(), nextTime); showMap.remove(model.getId()); } if (model.getModel() == OpenAdModel.MODEL_BOTTOM) { - new OpenAdBottomDialogPopup(CommonAppContext.getTopActivity(), model).setListener((bean, position) -> { + new OpenAdBottomDialogPopup(AppManager.getInstance().getLastActivity(), model).setListener((bean, position) -> { + Log.i(TAG, "run: 弹框回调:" + position); + if (IS_QUEUE_SHOW) { + waitRunnableMap.remove(runnable); + if (position == 0) { + next(); + } + } }).showDialog(); } else { - new OpenAdCenterDialogPopup(CommonAppContext.getTopActivity(), model).setListener((bean, position) -> { + new OpenAdCenterDialogPopup(AppManager.getInstance().getLastActivity(), model).setListener((bean, position) -> { + Log.i(TAG, "run: 弹框回调:" + position); + if (IS_QUEUE_SHOW) { + waitRunnableMap.remove(runnable); + if (position == 0) { + next(); + } + } }).showDialog(); } } } + + private class AdListComparator implements Comparator { + + @Override + public int compare(OpenAdModel openAdModel, OpenAdModel t1) { + return openAdModel.getSort() - t1.getSort(); + } + } } diff --git a/common/src/main/res/layout/dialog_open_bottom_ad.xml b/common/src/main/res/layout/dialog_open_bottom_ad.xml index 192f2d295..07cbd6f4f 100644 --- a/common/src/main/res/layout/dialog_open_bottom_ad.xml +++ b/common/src/main/res/layout/dialog_open_bottom_ad.xml @@ -5,16 +5,19 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - + app:srcCompat="@mipmap/background_gift_wall"> + + + + diff --git a/common/src/main/res/layout/dialog_open_center_ad.xml b/common/src/main/res/layout/dialog_open_center_ad.xml index dd60e83a6..3e09feb6c 100644 --- a/common/src/main/res/layout/dialog_open_center_ad.xml +++ b/common/src/main/res/layout/dialog_open_center_ad.xml @@ -6,17 +6,20 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - + app:layout_constraintStart_toStartOf="parent" + android:layout_marginBottom="12dp"> + + + \ No newline at end of file diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index 05d7a1ab9..3f2a47ced 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -13,8 +13,6 @@ import android.app.PendingIntent; import android.content.ClipData; import android.content.Context; import android.content.Intent; -import android.net.ConnectivityManager; -import android.net.NetworkInfo; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -51,14 +49,12 @@ import com.tencent.imsdk.v2.V2TIMManager; import com.tencent.imsdk.v2.V2TIMSDKConfig; import com.tencent.imsdk.v2.V2TIMSDKListener; import com.tencent.imsdk.v2.V2TIMUserFullInfo; -import com.yunbao.common.dialog.DebugDialog; import com.yunbao.common.utils.MobclickAgent; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.activity.WebViewActivity; import com.yunbao.common.adapter.ViewPagerAdapter; -import com.yunbao.common.bean.AnchorRecommendItemModel; import com.yunbao.common.bean.AnchorRecommendModel; import com.yunbao.common.bean.AnchorStartLiveBean; import com.yunbao.common.bean.ChatRemarksBean; @@ -223,7 +219,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene protected void main() { ActivityCompat.postponeEnterTransition(this); ConversationIMListManager.get(this); - OpenAdManager.getInstance(); //在请求一下这个接口给我后台版本号 CommonHttpUtil.getConfig(mContext, new CommonCallback() { @Override @@ -362,6 +357,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene } break; } + OpenAdManager.getInstance().show(OpenAdManager.TYPE_HOME, false); if (mTabButtonGroup.getCurPosition() != position) { System.err.println("重连IM:" + IMLoginManager.isLogin(mContext)); if (!IMLoginManager.isLogin(mContext)) { @@ -555,6 +551,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene //获取指导员账号 ConversationIMListManager.get(this).getUserInstructor(this); checkVersion(); + OpenAdManager.getInstance().show(OpenAdManager.TYPE_HOME, false); } /** @@ -948,6 +945,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene NoviceInstructorManager.get(mContext).getNoviceInstructor(); NoviceInstructorManager.get(mContext).checktHomeZdyPop(); initAnchorRecommendBanner(); + OpenAdManager.getInstance().reset(); } /** @@ -1146,7 +1144,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene if (EasyFloat.isShow("LiveFloatView")) { EasyFloat.dismiss("LiveFloatView", true); } - OpenAdManager.getInstance().reset(); + OpenAdManager.getInstance().close(); super.onBackPressed(); } } diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java index db9a1933b..904886749 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java @@ -560,7 +560,6 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement @Override public void onResume() { super.onResume(); - OpenAdManager.getInstance().show(OpenAdManager.TYPE_HOME, false); } @Override