fix[声望升级-同步弹窗功能]
This commit is contained in:
parent
8c89fc1de1
commit
6132338c6c
@ -162,6 +162,9 @@
|
|||||||
<meta-data
|
<meta-data
|
||||||
android:name="firebase_crashlytics_collection_enabled"
|
android:name="firebase_crashlytics_collection_enabled"
|
||||||
android:value="${isUploadLog}" />
|
android:value="${isUploadLog}" />
|
||||||
|
<meta-data
|
||||||
|
android:name="BUILD_TIME"
|
||||||
|
android:value="${buildTime}" />
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.openinstall.APP_KEY"
|
android:name="com.openinstall.APP_KEY"
|
||||||
android:value="smvslm" />
|
android:value="smvslm" />
|
||||||
|
@ -30,6 +30,7 @@ import com.tencent.imsdk.v2.V2TIMGroupMemberInfo;
|
|||||||
import com.tencent.imsdk.v2.V2TIMManager;
|
import com.tencent.imsdk.v2.V2TIMManager;
|
||||||
import com.tencent.imsdk.v2.V2TIMSimpleMsgListener;
|
import com.tencent.imsdk.v2.V2TIMSimpleMsgListener;
|
||||||
import com.tencent.imsdk.v2.V2TIMUserInfo;
|
import com.tencent.imsdk.v2.V2TIMUserInfo;
|
||||||
|
import com.yunbao.common.manager.OpenAdManager;
|
||||||
import com.yunbao.common.utils.MobclickAgent;
|
import com.yunbao.common.utils.MobclickAgent;
|
||||||
import com.yunbao.common.BuildConfig;
|
import com.yunbao.common.BuildConfig;
|
||||||
import com.yunbao.common.CommonAppConfig;
|
import com.yunbao.common.CommonAppConfig;
|
||||||
@ -37,7 +38,6 @@ import com.yunbao.common.CommonAppContext;
|
|||||||
import com.yunbao.common.Constants;
|
import com.yunbao.common.Constants;
|
||||||
import com.yunbao.common.bean.AnchorStartLiveBean;
|
import com.yunbao.common.bean.AnchorStartLiveBean;
|
||||||
import com.yunbao.common.bean.CrashSaveBean;
|
import com.yunbao.common.bean.CrashSaveBean;
|
||||||
import com.yunbao.common.dialog.DebugDialog;
|
|
||||||
import com.yunbao.common.event.SudGameSocketImEvent;
|
import com.yunbao.common.event.SudGameSocketImEvent;
|
||||||
import com.yunbao.common.manager.imrongcloud.InstructorSendReward;
|
import com.yunbao.common.manager.imrongcloud.InstructorSendReward;
|
||||||
import com.yunbao.common.manager.imrongcloud.InstructorSendRewardProvider;
|
import com.yunbao.common.manager.imrongcloud.InstructorSendRewardProvider;
|
||||||
@ -55,6 +55,7 @@ import com.yunbao.live.socket.SocketSwClient;
|
|||||||
import com.yunbao.live.utils.LiveImDeletUtil;
|
import com.yunbao.live.utils.LiveImDeletUtil;
|
||||||
import com.yunbao.live.views.PortraitLiveManager;
|
import com.yunbao.live.views.PortraitLiveManager;
|
||||||
import com.yunbao.live.views.RecommendLiveRoomProvider;
|
import com.yunbao.live.views.RecommendLiveRoomProvider;
|
||||||
|
import com.yunbao.main.activity.LoginActivity;
|
||||||
import com.yunbao.main.activity.MsgSettActivity;
|
import com.yunbao.main.activity.MsgSettActivity;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
@ -109,20 +110,25 @@ public class AppContext extends CommonAppContext {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityDestroyed(@NonNull Activity activity) {
|
public void onActivityDestroyed(@NonNull Activity activity) {
|
||||||
|
AppManager.getInstance().removeActivity(activity);
|
||||||
for (WeakReference<Activity> reference : activities) {
|
for (WeakReference<Activity> reference : activities) {
|
||||||
if (reference.get() == activity) {
|
if (reference.get() == activity) {
|
||||||
activities.remove(reference);
|
activities.remove(reference);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AppManager.getInstance().removeActivity(activity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
|
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
|
||||||
activities.add(new WeakReference<>(activity));
|
activities.add(new WeakReference<>(activity));
|
||||||
|
if(activity instanceof LoginActivity){
|
||||||
|
AppManager.getInstance().clear();
|
||||||
|
}
|
||||||
CrashSaveBean.getInstance().setActivitySize(activities);
|
CrashSaveBean.getInstance().setActivitySize(activities);
|
||||||
AppManager.getInstance().addActivity(activity);
|
AppManager.getInstance().addActivity(activity);
|
||||||
|
OpenAdManager.getInstance().dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -113,6 +113,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
|||||||
res.updateConfiguration(config, res.getDisplayMetrics());
|
res.updateConfiguration(config, res.getDisplayMetrics());
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
|
getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
|
||||||
@ -144,7 +145,11 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000);
|
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000);
|
||||||
|
try {
|
||||||
LogUtil.uploadErrorLog(AppContext.sInstance);
|
LogUtil.uploadErrorLog(AppContext.sInstance);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
SpUtil.getInstance().setBooleanValue("NOTIFICATION", NotificationManagerCompat.from(this).areNotificationsEnabled());
|
SpUtil.getInstance().setBooleanValue("NOTIFICATION", NotificationManagerCompat.from(this).areNotificationsEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ public class CommonAppConfig {
|
|||||||
public static final boolean IS_UPLOAD_ERROR_LOG = getMetaDataBoolean("IS_UPLOAD_ERROR_LOG");
|
public static final boolean IS_UPLOAD_ERROR_LOG = getMetaDataBoolean("IS_UPLOAD_ERROR_LOG");
|
||||||
//是否为插件包模式
|
//是否为插件包模式
|
||||||
public static final boolean IS_PLUGIN_MODEL = getMetaDataBoolean("IS_PLUGIN_MODEL");
|
public static final boolean IS_PLUGIN_MODEL = getMetaDataBoolean("IS_PLUGIN_MODEL");
|
||||||
|
public static final String BUILD_TIME = getMetaDataString("BUILD_TIME");
|
||||||
|
|
||||||
//外部sd卡
|
//外部sd卡
|
||||||
public static final String DCMI_PATH = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath();
|
public static final String DCMI_PATH = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath();
|
||||||
|
@ -2,7 +2,6 @@ package com.yunbao.common.bean;
|
|||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import com.yunbao.common.CommonAppConfig;
|
import com.yunbao.common.CommonAppConfig;
|
||||||
import com.yunbao.common.manager.IMLoginManager;
|
|
||||||
import com.yunbao.common.utils.StringUtil;
|
import com.yunbao.common.utils.StringUtil;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
@ -22,6 +21,8 @@ public class OpenAdModel extends BaseModel {
|
|||||||
public static final int SHOW_ONE = 3;//3. 仅弹出一次;
|
public static final int SHOW_ONE = 3;//3. 仅弹出一次;
|
||||||
@SerializedName("id")
|
@SerializedName("id")
|
||||||
private int id;
|
private int id;
|
||||||
|
@SerializedName("popup_name")
|
||||||
|
private String name;
|
||||||
@SerializedName("popup_location")
|
@SerializedName("popup_location")
|
||||||
private int type = TYPE_HOME;
|
private int type = TYPE_HOME;
|
||||||
@SerializedName("activity_url")
|
@SerializedName("activity_url")
|
||||||
@ -35,16 +36,19 @@ public class OpenAdModel extends BaseModel {
|
|||||||
@SerializedName("popup_model")
|
@SerializedName("popup_model")
|
||||||
private int model = MODEL_SQUARE;
|
private int model = MODEL_SQUARE;
|
||||||
@SerializedName("start_show_time")
|
@SerializedName("start_show_time")
|
||||||
private String startTime;//活动开始时间
|
private String startTime;//活动开始时间 1
|
||||||
@SerializedName("end_show_time")
|
@SerializedName("end_show_time")
|
||||||
private String endTime;//活动结束时间
|
private String endTime;//活动结束时间 5
|
||||||
@SerializedName("popup_permission")
|
@SerializedName("popup_permission")
|
||||||
private int permission;
|
private int permission;
|
||||||
@SerializedName("popup_frequency")
|
@SerializedName("popup_frequency")
|
||||||
private int showModel = SHOW_DEF;//显示模式,1:杀死程序后弹出 2:指定时间内(本机时间) 3:1. 仅弹出一次
|
private int showModel = SHOW_DEF;//显示模式,1:杀死程序后弹出 2:指定时间内(本机时间) 3:1. 仅弹出一次
|
||||||
@SerializedName("popup_frequency_time")
|
@SerializedName("popup_frequency_time")
|
||||||
private String section = "0";// SHOW_DEF = 2
|
private String section = "0";// SHOW_DEF = 2 1
|
||||||
|
@SerializedName("popup_sort")
|
||||||
|
private int popupSort = 1;//弹框类型 1.图片 2.H5
|
||||||
|
@SerializedName("sort")
|
||||||
|
private int sort = 0;
|
||||||
|
|
||||||
public OpenAdModel() {
|
public OpenAdModel() {
|
||||||
}
|
}
|
||||||
@ -66,6 +70,30 @@ public class OpenAdModel extends BaseModel {
|
|||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPopupSort() {
|
||||||
|
return popupSort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSort() {
|
||||||
|
return sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSort(int sort) {
|
||||||
|
this.sort = sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPopupSort(int popupSort) {
|
||||||
|
this.popupSort = popupSort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
public int getShowModel() {
|
public int getShowModel() {
|
||||||
return showModel;
|
return showModel;
|
||||||
}
|
}
|
||||||
@ -91,11 +119,12 @@ public class OpenAdModel extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
if (!url.startsWith("http://") || !url.startsWith("https://")) {
|
if (!url.startsWith("http://") && !url.startsWith("https://")) {
|
||||||
url = CommonAppConfig.HOST + url;
|
url = CommonAppConfig.HOST + (url.startsWith("/") ? url : "/" + url);
|
||||||
}
|
}
|
||||||
return url + "?t=" + System.currentTimeMillis() / 1000;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOriginalUrl() {
|
public String getOriginalUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
@ -198,6 +227,7 @@ public class OpenAdModel extends BaseModel {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "OpenAdModel{" +
|
return "OpenAdModel{" +
|
||||||
"id=" + id +
|
"id=" + id +
|
||||||
|
", name='" + name + '\'' +
|
||||||
", type=" + type +
|
", type=" + type +
|
||||||
", url='" + url + '\'' +
|
", url='" + url + '\'' +
|
||||||
", imageUrl='" + imageUrl + '\'' +
|
", imageUrl='" + imageUrl + '\'' +
|
||||||
@ -206,7 +236,10 @@ public class OpenAdModel extends BaseModel {
|
|||||||
", model=" + model +
|
", model=" + model +
|
||||||
", startTime='" + startTime + '\'' +
|
", startTime='" + startTime + '\'' +
|
||||||
", endTime='" + endTime + '\'' +
|
", endTime='" + endTime + '\'' +
|
||||||
", permission='" + permission + '\'' +
|
", permission=" + permission +
|
||||||
|
", showModel=" + showModel +
|
||||||
|
", section='" + section + '\'' +
|
||||||
|
", sort=" + popupSort +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,18 +15,20 @@ import com.lzf.easyfloat.EasyFloat;
|
|||||||
import com.lzf.easyfloat.enums.ShowPattern;
|
import com.lzf.easyfloat.enums.ShowPattern;
|
||||||
import com.lzf.easyfloat.interfaces.OnPermissionResult;
|
import com.lzf.easyfloat.interfaces.OnPermissionResult;
|
||||||
import com.lzf.easyfloat.permission.PermissionUtils;
|
import com.lzf.easyfloat.permission.PermissionUtils;
|
||||||
|
import com.yunbao.common.CommonAppConfig;
|
||||||
import com.yunbao.common.adapter.DebugDialogAdapter;
|
import com.yunbao.common.adapter.DebugDialogAdapter;
|
||||||
import com.yunbao.common.utils.AppManager;
|
import com.yunbao.common.utils.AppManager;
|
||||||
import com.yunbao.common.utils.ToastUtil;
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
|
||||||
public class DebugDialog {
|
public class DebugDialog {
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
HashMap<String, View> params;
|
LinkedHashMap<String, View> params;
|
||||||
DebugDialogAdapter adapter;
|
DebugDialogAdapter adapter;
|
||||||
private static DebugDialog debugDialog;
|
private static DebugDialog debugDialog;
|
||||||
Context mContext;
|
Context mContext;
|
||||||
@ -69,7 +71,7 @@ public class DebugDialog {
|
|||||||
this.runnable = runnable;
|
this.runnable = runnable;
|
||||||
if (params == null) {
|
if (params == null) {
|
||||||
Log.i("debug弹窗", "DebugDialog: 初始化参数");
|
Log.i("debug弹窗", "DebugDialog: 初始化参数");
|
||||||
params = new HashMap<>();
|
params = new LinkedHashMap<>();
|
||||||
}
|
}
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@ -102,6 +104,7 @@ public class DebugDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void show() {
|
public void show() {
|
||||||
|
if (recyclerView != null) return;
|
||||||
if (showPattern == ShowPattern.CURRENT_ACTIVITY) {
|
if (showPattern == ShowPattern.CURRENT_ACTIVITY) {
|
||||||
createView();
|
createView();
|
||||||
return;
|
return;
|
||||||
@ -136,7 +139,7 @@ public class DebugDialog {
|
|||||||
EasyFloat.updateFloat("debug");
|
EasyFloat.updateFloat("debug");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
params.put("debug弹窗", textView);
|
params.put("发包时间:" + CommonAppConfig.BUILD_TIME, textView);
|
||||||
adapter.setParamMap(params);
|
adapter.setParamMap(params);
|
||||||
|
|
||||||
EasyFloat.with(mContext)
|
EasyFloat.with(mContext)
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
package com.yunbao.common.dialog;
|
package com.yunbao.common.dialog;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
@ -9,12 +13,21 @@ import com.lxj.xpopup.XPopup;
|
|||||||
import com.yunbao.common.R;
|
import com.yunbao.common.R;
|
||||||
import com.yunbao.common.activity.WebViewActivity;
|
import com.yunbao.common.activity.WebViewActivity;
|
||||||
import com.yunbao.common.bean.OpenAdModel;
|
import com.yunbao.common.bean.OpenAdModel;
|
||||||
|
import com.yunbao.common.event.JavascriptInterfaceEvent;
|
||||||
import com.yunbao.common.glide.ImgLoader;
|
import com.yunbao.common.glide.ImgLoader;
|
||||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
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.L;
|
||||||
|
import com.yunbao.common.utils.ScreenDimenUtil;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
|
||||||
public class OpenAdBottomDialogPopup extends AbsDialogPopupWindow {
|
public class OpenAdBottomDialogPopup extends AbsDialogPopupWindow {
|
||||||
private ImageView mImageView;
|
|
||||||
private ImageView mClose;
|
private ImageView mClose;
|
||||||
|
private LinearLayout contentLayout;
|
||||||
private OpenAdModel model;
|
private OpenAdModel model;
|
||||||
private OnItemClickListener<OpenAdModel> mListener;
|
private OnItemClickListener<OpenAdModel> mListener;
|
||||||
|
|
||||||
@ -27,6 +40,11 @@ public class OpenAdBottomDialogPopup extends AbsDialogPopupWindow {
|
|||||||
@Override
|
@Override
|
||||||
public void buildDialog(XPopup.Builder builder) {
|
public void buildDialog(XPopup.Builder builder) {
|
||||||
builder.animationDuration(0);
|
builder.animationDuration(0);
|
||||||
|
builder.hasShadowBg(true);
|
||||||
|
if(model.getPopupSort()==2){
|
||||||
|
builder.dismissOnTouchOutside(false);
|
||||||
|
builder.dismissOnBackPressed(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -51,8 +69,63 @@ public class OpenAdBottomDialogPopup extends AbsDialogPopupWindow {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate() {
|
protected void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
mImageView = findViewById(R.id.img);
|
contentLayout = findViewById(R.id.content_layout);
|
||||||
mClose = findViewById(R.id.close);
|
mClose = findViewById(R.id.close);
|
||||||
|
if (model.getPopupSort() == 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);
|
||||||
|
mWebView.setWebViewClient(new WebViewClient() {
|
||||||
|
@Override
|
||||||
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
|
L.e("H5-------->" + url);
|
||||||
|
view.loadUrl(url);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageFinished(WebView view, String url) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
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() {
|
||||||
|
int width = ScreenDimenUtil.getInstance().getScreenWdith();
|
||||||
|
int height = (int) (width * 1.4);
|
||||||
|
|
||||||
|
ImageView mImageView = new ImageView(mContext);
|
||||||
|
mImageView.setLayoutParams(new LinearLayout.LayoutParams(width, height));
|
||||||
mImageView.setOnClickListener(v -> {
|
mImageView.setOnClickListener(v -> {
|
||||||
WebViewActivity.forward(mContext, model.getUrl(), model.getType() != OpenAdModel.TYPE_HOME);
|
WebViewActivity.forward(mContext, model.getUrl(), model.getType() != OpenAdModel.TYPE_HOME);
|
||||||
if (mListener != null) {
|
if (mListener != null) {
|
||||||
@ -61,10 +134,12 @@ public class OpenAdBottomDialogPopup extends AbsDialogPopupWindow {
|
|||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
mClose.setOnClickListener(v -> dismiss());
|
|
||||||
ImgLoader.display(mContext, model.getImageUrl(), mImageView);
|
ImgLoader.display(mContext, model.getImageUrl(), mImageView);
|
||||||
if (model.getShowTime() > 0) {
|
contentLayout.addView(mImageView);
|
||||||
mClose.postDelayed(this::dismiss, model.getShowTime());
|
}
|
||||||
}
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,44 @@
|
|||||||
package com.yunbao.common.dialog;
|
package com.yunbao.common.dialog;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewTreeObserver;
|
||||||
|
import android.view.WindowInsets;
|
||||||
|
import android.webkit.WebResourceRequest;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
||||||
|
|
||||||
import com.lxj.xpopup.XPopup;
|
import com.lxj.xpopup.XPopup;
|
||||||
|
import com.lzf.easyfloat.enums.ShowPattern;
|
||||||
import com.yunbao.common.R;
|
import com.yunbao.common.R;
|
||||||
import com.yunbao.common.activity.WebViewActivity;
|
import com.yunbao.common.activity.WebViewActivity;
|
||||||
import com.yunbao.common.bean.OpenAdModel;
|
import com.yunbao.common.bean.OpenAdModel;
|
||||||
|
import com.yunbao.common.event.JavascriptInterfaceEvent;
|
||||||
import com.yunbao.common.glide.ImgLoader;
|
import com.yunbao.common.glide.ImgLoader;
|
||||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||||
|
import com.yunbao.common.manager.IMLoginManager;
|
||||||
import com.yunbao.common.utils.DpUtil;
|
import com.yunbao.common.utils.DpUtil;
|
||||||
|
import com.yunbao.common.utils.JavascriptInterfaceUtils;
|
||||||
|
import com.yunbao.common.utils.L;
|
||||||
import com.yunbao.common.utils.RouteUtil;
|
import com.yunbao.common.utils.RouteUtil;
|
||||||
import com.yunbao.common.utils.ScreenDimenUtil;
|
import com.yunbao.common.utils.ScreenDimenUtil;
|
||||||
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
|
||||||
public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
|
public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
|
||||||
private ImageView mImageView;
|
private ImageView mImageView;
|
||||||
|
private LinearLayout contentLayout;
|
||||||
private ImageView mClose;
|
private ImageView mClose;
|
||||||
private OpenAdModel model;
|
private OpenAdModel model;
|
||||||
private OnItemClickListener<OpenAdModel> mListener;
|
private OnItemClickListener<OpenAdModel> mListener;
|
||||||
@ -39,7 +59,8 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildDialog(XPopup.Builder builder) {
|
public void buildDialog(XPopup.Builder builder) {
|
||||||
builder.hasShadowBg(false);
|
builder.hasShadowBg(true);
|
||||||
|
builder.shadowBgColor(Color.parseColor("#80000000"));
|
||||||
builder.animationDuration(0);
|
builder.animationDuration(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,9 +83,100 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
|
|||||||
protected void onCreate() {
|
protected void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
Log.e("-----弹窗-----", "onCreate: 创建弹窗");
|
Log.e("-----弹窗-----", "onCreate: 创建弹窗");
|
||||||
mImageView = findViewById(R.id.img);
|
contentLayout = findViewById(R.id.content_layout);
|
||||||
mClose = findViewById(R.id.close);
|
mClose = findViewById(R.id.close);
|
||||||
|
|
||||||
|
|
||||||
|
contentLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
|
boolean isShow = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
if (isShow)
|
||||||
|
return;
|
||||||
|
isShow = true;
|
||||||
|
int width = contentLayout.getWidth() - DpUtil.dp2px(20);
|
||||||
|
int height = (int) (width * 1.5);
|
||||||
|
if (model.getModel() == OpenAdModel.MODEL_SQUARE) {
|
||||||
|
height = (int) (width * 1.2);
|
||||||
|
}
|
||||||
|
Log.i("-----弹窗-----", "高度:" + height + " 宽度:" + width + " 屏幕宽度: " + ScreenDimenUtil.getInstance().getScreenWdith());
|
||||||
|
/*DebugDialog.getInstance(new DebugDialog.DebugDialogRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run(DebugDialog dialog) {
|
||||||
|
dialog.setShowPattern(ShowPattern.ALL_TIME);
|
||||||
|
dialog.show();
|
||||||
|
int width = contentLayout.getWidth() - DpUtil.dp2px(10);
|
||||||
|
int height = (int) (width * 1.5);
|
||||||
|
if (model.getModel() == OpenAdModel.MODEL_SQUARE) {
|
||||||
|
height = (int) (width * 1.2);
|
||||||
|
}
|
||||||
|
Log.i("-----弹窗-----", "弹框debug高宽 高度:" + height + " 宽度:" + width);
|
||||||
|
dialog.setParams(model.getName() + "弹框高宽", "高度:" + height + " 宽度:" + width);
|
||||||
|
}
|
||||||
|
});*/
|
||||||
|
if (model.getPopupSort() == 1) {
|
||||||
|
setImage(model, width, height);
|
||||||
findViewById(R.id.layout).setOnClickListener(v -> dismiss());
|
findViewById(R.id.layout).setOnClickListener(v -> dismiss());
|
||||||
|
} else {
|
||||||
|
setWeb(model, width, height);
|
||||||
|
}
|
||||||
|
mClose.setOnClickListener(v -> dismiss());
|
||||||
|
if (model.getShowTime() > 0) {
|
||||||
|
mClose.postDelayed(OpenAdCenterDialogPopup.this::dismiss, model.getShowTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setWeb(OpenAdModel model, int width, int height) {
|
||||||
|
WebView mWebView = new WebView(mContext);
|
||||||
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, height);
|
||||||
|
params.gravity = Gravity.CENTER;
|
||||||
|
mWebView.setLayoutParams(params);
|
||||||
|
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);
|
||||||
|
mWebView.setWebViewClient(new WebViewClient() {
|
||||||
|
@Override
|
||||||
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
|
L.e("H5-------->" + url);
|
||||||
|
view.loadUrl(url);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageFinished(WebView view, String url) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
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, int height) {
|
||||||
|
mImageView = new ImageView(mContext);
|
||||||
|
mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||||
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, height);
|
||||||
|
params.gravity = Gravity.CENTER;
|
||||||
|
mImageView.setLayoutParams(params);
|
||||||
|
|
||||||
mImageView.setOnClickListener(v -> {
|
mImageView.setOnClickListener(v -> {
|
||||||
if ("home_page_banner_battle".equals(model.getOriginalUrl())) {
|
if ("home_page_banner_battle".equals(model.getOriginalUrl())) {
|
||||||
RouteUtil.forwardBattlePass();
|
RouteUtil.forwardBattlePass();
|
||||||
@ -78,19 +190,12 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
|
|||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
mClose.setOnClickListener(v -> dismiss());
|
|
||||||
ImgLoader.display(mContext, model.getImageUrl(), mImageView);
|
ImgLoader.display(mContext, model.getImageUrl(), mImageView);
|
||||||
int width = ScreenDimenUtil.getInstance().getScreenWdith() - DpUtil.dp2px(40);
|
contentLayout.addView(mImageView);
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,34 @@
|
|||||||
package com.yunbao.common.manager;
|
package com.yunbao.common.manager;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.lzf.easyfloat.enums.ShowPattern;
|
||||||
import com.yunbao.common.CommonAppContext;
|
import com.yunbao.common.CommonAppContext;
|
||||||
import com.yunbao.common.bean.OpenAdModel;
|
import com.yunbao.common.bean.OpenAdModel;
|
||||||
|
import com.yunbao.common.dialog.DebugDialog;
|
||||||
import com.yunbao.common.dialog.OpenAdBottomDialogPopup;
|
import com.yunbao.common.dialog.OpenAdBottomDialogPopup;
|
||||||
import com.yunbao.common.dialog.OpenAdCenterDialogPopup;
|
import com.yunbao.common.dialog.OpenAdCenterDialogPopup;
|
||||||
import com.yunbao.common.http.base.HttpCallback;
|
import com.yunbao.common.http.base.HttpCallback;
|
||||||
import com.yunbao.common.http.live.LiveNetManager;
|
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.SpUtil;
|
||||||
import com.yunbao.common.utils.StringUtil;
|
import com.yunbao.common.utils.StringUtil;
|
||||||
import com.yunbao.common.utils.ToastUtil;
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class OpenAdManager {
|
public class OpenAdManager {
|
||||||
public static final int TYPE_HOME = 1;
|
public static final int TYPE_HOME = 1;
|
||||||
@ -28,19 +37,34 @@ public class OpenAdManager {
|
|||||||
private Map<Integer, Boolean> showMap;
|
private Map<Integer, Boolean> showMap;
|
||||||
private List<OpenAdModel> list = null;
|
private List<OpenAdModel> list = null;
|
||||||
private Handler handler = new Handler(Looper.getMainLooper());
|
private Handler handler = new Handler(Looper.getMainLooper());
|
||||||
private Map<Integer, AdRunnable> runnableMap = new HashMap<>();
|
private Map<Integer, AdRunnable> runnableMap = new LinkedHashMap<>();
|
||||||
|
private Map<AdRunnable, Integer> waitRunnableMap = new LinkedHashMap<>();//等待运行的弹窗
|
||||||
private int showType;
|
private int showType;
|
||||||
|
private WeakReference<AdRunnable> runNowRunnable;
|
||||||
|
private static final boolean IS_QUEUE_SHOW = true;//是否按队列显示弹窗,true就会等待上一个弹窗关闭后弹出,false就按原逻辑顺序直接弹出
|
||||||
|
|
||||||
private OpenAdManager() {
|
private OpenAdManager() {
|
||||||
showMap = new HashMap<>();
|
showMap = new HashMap<>();
|
||||||
init(false);
|
init(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void close() {
|
||||||
dismiss();
|
dismiss();
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
runnableMap.clear();
|
runnableMap.clear();
|
||||||
showMap.clear();
|
showMap.clear();
|
||||||
list.clear();
|
list.clear();
|
||||||
|
waitRunnableMap.clear();
|
||||||
|
list = null;
|
||||||
|
runNowRunnable = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
Log.i(TAG, "reset: ");
|
||||||
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class MInstanceHolder {
|
private static final class MInstanceHolder {
|
||||||
@ -55,13 +79,14 @@ public class OpenAdManager {
|
|||||||
if (list != null && list.isEmpty()) {
|
if (list != null && list.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Context context = CommonAppContext.getTopActivity();
|
Context context = AppManager.getInstance().getMainActivity();
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
context = CommonAppContext.sInstance;
|
context = CommonAppContext.sInstance;
|
||||||
}
|
}
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LiveNetManager.get(context).activityPopup(new HttpCallback<List<OpenAdModel>>() {
|
LiveNetManager.get(context).activityPopup(new HttpCallback<List<OpenAdModel>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<OpenAdModel> data) {
|
public void onSuccess(List<OpenAdModel> data) {
|
||||||
@ -70,35 +95,64 @@ public class OpenAdManager {
|
|||||||
list = new ArrayList<>();
|
list = new ArrayList<>();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Collections.sort(data, new AdListComparator());
|
||||||
list = data;
|
list = data;
|
||||||
if (isShow) {
|
if (isShow) {
|
||||||
|
if (showType == 0) {
|
||||||
show(TYPE_HOME, false);
|
show(TYPE_HOME, false);
|
||||||
|
} else {
|
||||||
|
show(showType, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(String error) {
|
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<String> onItemClickListener=new OnItemClickListener<String>() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(String bean, int position) {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public synchronized void show(int type, boolean isGuard) {
|
public synchronized void show(int type, boolean isGuard) {
|
||||||
|
showType = type;
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
init(true);
|
init(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Log.i(TAG, "show: 调用显示 " + type + " " + isGuard);
|
||||||
if (System.currentTimeMillis() - showTime < 100) {
|
if (System.currentTimeMillis() - showTime < 100) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/*DebugDialog.getInstance(new DebugDialog.DebugDialogRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run(DebugDialog dialog) {
|
||||||
|
dialog.setShowPattern(ShowPattern.ALL_TIME);
|
||||||
|
dialog.show();
|
||||||
|
onItemClickListener = new OnItemClickListener<String>() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(String bean, int position) {
|
||||||
|
dialog.setParams(bean, "剩余:" + position);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});*/
|
||||||
showTime = System.currentTimeMillis();
|
showTime = System.currentTimeMillis();
|
||||||
showType = type;
|
waitRunnableMap.clear();
|
||||||
|
runnableMap.clear();
|
||||||
|
runNowRunnable = null;
|
||||||
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 (model.getShowModel() == OpenAdModel.SHOW_ONE) {
|
if (model.getShowModel() == OpenAdModel.SHOW_ONE) {
|
||||||
if (SpUtil.getInstance().getBooleanValue("open_ad_popup_" + model.getId())) {
|
if (SpUtil.getInstance().getBooleanValue("open_ad_popup_" + model.getId())) {
|
||||||
continue;
|
continue;
|
||||||
@ -122,13 +176,22 @@ public class OpenAdManager {
|
|||||||
|
|
||||||
if (!isShow(model)) {
|
if (!isShow(model)) {
|
||||||
Log.i(TAG, "show: " + model);
|
Log.i(TAG, "show: " + model);
|
||||||
|
if (IS_QUEUE_SHOW) {
|
||||||
|
waitRunnableMap.put(new AdRunnable(model), model.getDelayShowTime());
|
||||||
|
} else {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Log.i(TAG, "show: 循环完毕,调用next");
|
||||||
|
if (IS_QUEUE_SHOW) {
|
||||||
|
onItemClickListener.onItemClick("接口返回需要展示的弹窗数:", waitRunnableMap.size());
|
||||||
|
next();
|
||||||
|
}
|
||||||
Log.i(TAG, "------------------------------");
|
Log.i(TAG, "------------------------------");
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -144,6 +207,9 @@ public class OpenAdManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
runnableMap.clear();
|
runnableMap.clear();
|
||||||
|
if (runNowRunnable != null && runNowRunnable.get() != null) {
|
||||||
|
handler.removeCallbacks(runNowRunnable.get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized boolean isShow(OpenAdModel type) {
|
private synchronized boolean isShow(OpenAdModel type) {
|
||||||
@ -153,11 +219,45 @@ public class OpenAdManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getNowType() {
|
||||||
|
Activity lastActivity = AppManager.getInstance().getLastActivity();
|
||||||
|
if (lastActivity == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (AppManager.getInstance().isLiveActivity()) {
|
||||||
|
return TYPE_LIVE;
|
||||||
|
} else if (AppManager.getInstance().isMainActivity()) {
|
||||||
|
return TYPE_HOME;
|
||||||
|
}
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void next() {
|
||||||
|
Log.i(TAG, "next: 剩余数" + waitRunnableMap.size());
|
||||||
|
if (waitRunnableMap.isEmpty()) return;
|
||||||
|
for (AdRunnable next : waitRunnableMap.keySet()) {
|
||||||
|
Log.i(TAG, "next: " + next.model);
|
||||||
|
if (next.model.getType() == getNowType()) {
|
||||||
|
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);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private class AdRunnable implements Runnable {
|
private class AdRunnable implements Runnable {
|
||||||
OpenAdModel model;
|
OpenAdModel model;
|
||||||
|
AdRunnable runnable;
|
||||||
|
|
||||||
public AdRunnable(OpenAdModel model) {
|
public AdRunnable(OpenAdModel model) {
|
||||||
this.model = model;
|
this.model = model;
|
||||||
|
this.runnable = this;
|
||||||
|
runNowRunnable = new WeakReference<>(this);
|
||||||
runnableMap.put(model.getId(), this);
|
runnableMap.put(model.getId(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,23 +270,55 @@ public class OpenAdManager {
|
|||||||
Log.i(TAG, "run: " + model);
|
Log.i(TAG, "run: " + model);
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
ToastUtil.showDebug("model为空");
|
ToastUtil.showDebug("model为空");
|
||||||
|
if (onItemClickListener != null) {
|
||||||
|
onItemClickListener.onItemClick("", -2);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!model.isInTime()) {
|
if (!model.isInTime()) {
|
||||||
ToastUtil.showDebug("不在展示时间内:" + model.getStartTime() + "|" + model.getEndTime());
|
ToastUtil.showDebug("不在展示时间内:" + model.getStartTime() + "|" + model.getEndTime());
|
||||||
|
if (onItemClickListener != null) {
|
||||||
|
onItemClickListener.onItemClick("", -2);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isShow(model)) {
|
if (isShow(model)) {
|
||||||
ToastUtil.showDebug(model.getId() + "|model展示过了");
|
ToastUtil.showDebug(model.getId() + "|model展示过了");
|
||||||
|
if (onItemClickListener != null) {
|
||||||
|
onItemClickListener.onItemClick("", -2);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (model.getType() != showType) {
|
if (model.getType() != showType) {
|
||||||
|
if (onItemClickListener != null) {
|
||||||
|
onItemClickListener.onItemClick("", -2);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isShow(model)) {
|
if (isShow(model)) {
|
||||||
Log.i(TAG, "展示过:" + model);
|
Log.i(TAG, "展示过:" + model);
|
||||||
|
if (onItemClickListener != null) {
|
||||||
|
onItemClickListener.onItemClick("", -2);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (model.getType() == OpenAdModel.TYPE_HOME && !AppManager.getInstance().isMainActivity()) {
|
||||||
|
Log.i(TAG, "首页类型弹窗,但当前不是首页");
|
||||||
|
if (onItemClickListener != null) {
|
||||||
|
onItemClickListener.onItemClick("", -2);
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (model.getType() == TYPE_LIVE && !AppManager.getInstance().isLiveActivity()) {
|
||||||
|
Log.i(TAG, "直播类型弹窗,但当前不是直播");
|
||||||
|
if (onItemClickListener != null) {
|
||||||
|
onItemClickListener.onItemClick("", -2);
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
showMap.put(model.getId(), true);
|
showMap.put(model.getId(), true);
|
||||||
if (model.getShowModel() == OpenAdModel.SHOW_DIY) {
|
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));
|
||||||
@ -194,12 +326,44 @@ public class OpenAdManager {
|
|||||||
showMap.remove(model.getId());
|
showMap.remove(model.getId());
|
||||||
}
|
}
|
||||||
if (model.getModel() == OpenAdModel.MODEL_BOTTOM) {
|
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 + " id = " + model.getId());
|
||||||
|
if (IS_QUEUE_SHOW) {
|
||||||
|
removeList(bean);
|
||||||
|
if (position == 0) {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
}
|
||||||
}).showDialog();
|
}).showDialog();
|
||||||
} else {
|
} else {
|
||||||
new OpenAdCenterDialogPopup(CommonAppContext.getTopActivity(), model).setListener((bean, position) -> {
|
new OpenAdCenterDialogPopup(AppManager.getInstance().getLastActivity(), model).setListener((bean, position) -> {
|
||||||
|
Log.i(TAG, "run: 弹框回调:" + position + " id = " + model.getId());
|
||||||
|
if (IS_QUEUE_SHOW) {
|
||||||
|
removeList(bean);
|
||||||
|
if (position == 0) {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
}
|
||||||
}).showDialog();
|
}).showDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void removeList(OpenAdModel model) {
|
||||||
|
Log.i(TAG, "removeList: " + model);
|
||||||
|
for (AdRunnable next : waitRunnableMap.keySet()) {
|
||||||
|
if (next.model.getId() == model.getId()) {
|
||||||
|
waitRunnableMap.remove(next);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class AdListComparator implements Comparator<OpenAdModel> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(OpenAdModel openAdModel, OpenAdModel t1) {
|
||||||
|
return openAdModel.getSort() - t1.getSort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package com.yunbao.common.utils;
|
package com.yunbao.common.utils;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.yunbao.common.BuildConfig;
|
import com.yunbao.common.BuildConfig;
|
||||||
|
import com.yunbao.common.manager.OpenAdManager;
|
||||||
|
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
@ -36,18 +38,40 @@ public class AppManager {
|
|||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return getLastActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity getLiveActivity() {
|
public Activity getLiveActivity() {
|
||||||
for (Activity activity : activityStack) {
|
for (Activity activity : activityStack) {
|
||||||
if (activity.getClass().getSimpleName().contains("LiveAudienceActivity")) {
|
if (activity.getClass().getSimpleName().contains("LiveActivity")) {
|
||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
activityStack.clear();
|
||||||
|
OpenAdManager.getInstance().clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMainActivity() {
|
||||||
|
Activity lastActivity = getLastActivity();
|
||||||
|
if (lastActivity == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return lastActivity.getClass().getSimpleName().contains("MainActivity");
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO 首页类型没展示完进直播间会不展示直播间的。
|
||||||
|
public boolean isLiveActivity() {
|
||||||
|
Activity lastActivity = getLastActivity();
|
||||||
|
if (lastActivity == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return lastActivity.getClass().getSimpleName().contains("LiveAudienceActivity");
|
||||||
|
}
|
||||||
|
|
||||||
public static class SingleApp {
|
public static class SingleApp {
|
||||||
public static AppManager INSTANCE = new AppManager();
|
public static AppManager INSTANCE = new AppManager();
|
||||||
}
|
}
|
||||||
@ -59,6 +83,10 @@ public class AppManager {
|
|||||||
if (activityStack == null) {
|
if (activityStack == null) {
|
||||||
activityStack = new Stack<Activity>();
|
activityStack = new Stack<Activity>();
|
||||||
}
|
}
|
||||||
|
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>class com.yunbao.main.activity.MsgAddressBookActivity
|
||||||
|
if (getActivity(activity.getClass()) != null) {
|
||||||
|
activityStack.remove(getActivity(activity.getClass()));
|
||||||
|
}
|
||||||
activityStack.add(activity);
|
activityStack.add(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package com.yunbao.common.views;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@ -44,6 +45,7 @@ public class APKUpdateCustomPopup extends CenterPopupView {
|
|||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
private Activity mContext;
|
private Activity mContext;
|
||||||
private boolean mInside;
|
private boolean mInside;
|
||||||
|
private DialogInterface.OnDismissListener onDismissListener;
|
||||||
|
|
||||||
public APKUpdateCustomPopup(@NonNull Activity context, boolean inside) {
|
public APKUpdateCustomPopup(@NonNull Activity context, boolean inside) {
|
||||||
super(context);
|
super(context);
|
||||||
@ -57,6 +59,11 @@ public class APKUpdateCustomPopup extends CenterPopupView {
|
|||||||
return R.layout.apk_update_custom_popup;
|
return R.layout.apk_update_custom_popup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public APKUpdateCustomPopup setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
|
||||||
|
this.onDismissListener = onDismissListener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
// 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑
|
// 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate() {
|
protected void onCreate() {
|
||||||
@ -69,6 +76,14 @@ public class APKUpdateCustomPopup extends CenterPopupView {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDismiss() {
|
||||||
|
super.onDismiss();
|
||||||
|
if (onDismissListener != null) {
|
||||||
|
onDismissListener.onDismiss(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void initView() {
|
private void initView() {
|
||||||
if (!mInside) {
|
if (!mInside) {
|
||||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 0 && APKManager.get().getAPKGoogleIsUp() == 1) {
|
if (CommonAppConfig.IS_GOOGLE_PLAY == 0 && APKManager.get().getAPKGoogleIsUp() == 1) {
|
||||||
|
@ -5,16 +5,19 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<ImageView
|
<LinearLayout
|
||||||
android:id="@+id/img"
|
android:id="@+id/content_layout"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:scaleType="fitXY"
|
android:orientation="vertical"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:adjustViewBounds="true"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:srcCompat="@mipmap/background_gift_wall" />
|
app:srcCompat="@mipmap/background_gift_wall">
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/close"
|
android:id="@+id/close"
|
||||||
@ -22,7 +25,7 @@
|
|||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:layout_marginEnd="14dp"
|
android:layout_marginEnd="14dp"
|
||||||
android:layout_marginBottom="12dp"
|
android:layout_marginBottom="12dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/img"
|
app:layout_constraintBottom_toTopOf="@+id/content_layout"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:srcCompat="@mipmap/ic_open_ad_close" />
|
app:srcCompat="@mipmap/ic_open_ad_close" />
|
||||||
|
|
||||||
|
@ -6,26 +6,28 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<ImageView
|
<LinearLayout
|
||||||
android:id="@+id/img"
|
android:id="@+id/content_layout"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="20dp"
|
|
||||||
android:layout_marginEnd="20dp"
|
|
||||||
android:layout_marginBottom="12dp"
|
android:layout_marginBottom="12dp"
|
||||||
android:scaleType="fitCenter"
|
android:orientation="vertical"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/close"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/close"
|
android:id="@+id/close"
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:layout_marginBottom="202dp"
|
android:layout_marginTop="24dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintEnd_toEndOf="@+id/content_layout"
|
||||||
app:layout_constraintEnd_toEndOf="@+id/img"
|
app:layout_constraintStart_toStartOf="@+id/content_layout"
|
||||||
app:layout_constraintStart_toStartOf="@+id/img"
|
app:layout_constraintTop_toBottomOf="@+id/content_layout"
|
||||||
app:srcCompat="@mipmap/ic_open_ad_close" />
|
app:srcCompat="@mipmap/ic_open_ad_close" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -4,8 +4,8 @@ ext {
|
|||||||
buildToolsVersion: "29.0.2",
|
buildToolsVersion: "29.0.2",
|
||||||
minSdkVersion : 21,
|
minSdkVersion : 21,
|
||||||
targetSdkVersion : 33,
|
targetSdkVersion : 33,
|
||||||
versionCode : 473,
|
versionCode : 474,
|
||||||
versionName : "6.6.8"
|
versionName : "6.7.8"
|
||||||
]
|
]
|
||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
//正式、
|
//正式、
|
||||||
@ -13,6 +13,8 @@ ext {
|
|||||||
// 测试
|
// 测试
|
||||||
serverHost : "https://ceshi.yaoulive.com",
|
serverHost : "https://ceshi.yaoulive.com",
|
||||||
|
|
||||||
|
buildTime : new Date().format("MM-dd HH:mm", TimeZone.getTimeZone("GMT+8")),
|
||||||
|
|
||||||
//百度语音识别
|
//百度语音识别
|
||||||
|
|
||||||
baiduAppId : "23774720",
|
baiduAppId : "23774720",
|
||||||
@ -21,10 +23,10 @@ ext {
|
|||||||
baiduAppSecretKey: "nEVSgmuGpU0pjPr6VleEGGAl0hzGW52S",
|
baiduAppSecretKey: "nEVSgmuGpU0pjPr6VleEGGAl0hzGW52S",
|
||||||
|
|
||||||
// true表示谷歌支付 false 0 链接包 1 谷歌包 2华为包 3 samsung包
|
// true表示谷歌支付 false 0 链接包 1 谷歌包 2华为包 3 samsung包
|
||||||
isGooglePlay : 0,
|
isGooglePlay : 1,
|
||||||
//是否上报异常日志
|
//是否上报异常日志
|
||||||
isUploadLog : true,
|
isUploadLog : true,
|
||||||
//是否打包成插件包模式
|
//是否打包成插件包模式
|
||||||
isPluginModel : true,
|
isPluginModel : false,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,10 @@ org.gradle.configureondemand=true
|
|||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
|
|
||||||
#systemProp.http.proxyHost=127.0.0.1
|
systemProp.http.proxyHost=127.0.0.1
|
||||||
#systemProp.https.proxyHost=127.0.0.1
|
systemProp.https.proxyHost=127.0.0.1
|
||||||
#systemProp.https.proxyPort=10809
|
systemProp.https.proxyPort=10809
|
||||||
#systemProp.http.proxyPort=10809
|
systemProp.http.proxyPort=10809
|
||||||
|
|
||||||
|
|
||||||
#android.enableR8.fullMode=true
|
#android.enableR8.fullMode=true
|
@ -15,6 +15,7 @@ import android.util.Log;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
@ -27,8 +28,10 @@ import com.alibaba.fastjson.JSONArray;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.blankj.utilcode.util.GsonUtils;
|
import com.blankj.utilcode.util.GsonUtils;
|
||||||
import com.lzf.easyfloat.EasyFloat;
|
import com.lzf.easyfloat.EasyFloat;
|
||||||
|
import com.lzf.easyfloat.enums.ShowPattern;
|
||||||
import com.lzf.easyfloat.permission.PermissionUtils;
|
import com.lzf.easyfloat.permission.PermissionUtils;
|
||||||
import com.lzf.easyfloat.utils.LifecycleUtils;
|
import com.lzf.easyfloat.utils.LifecycleUtils;
|
||||||
|
import com.yunbao.common.dialog.DebugDialog;
|
||||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||||
import com.yunbao.common.utils.MobclickAgent;
|
import com.yunbao.common.utils.MobclickAgent;
|
||||||
import com.yunbao.common.CommonAppConfig;
|
import com.yunbao.common.CommonAppConfig;
|
||||||
@ -115,6 +118,7 @@ import com.yunbao.live.socket.SocketSwChatUtil;
|
|||||||
import com.yunbao.live.socket.SocketSwClient;
|
import com.yunbao.live.socket.SocketSwClient;
|
||||||
import com.yunbao.live.socket.SocketSendBean;
|
import com.yunbao.live.socket.SocketSendBean;
|
||||||
import com.yunbao.live.utils.LiveImDeletUtil;
|
import com.yunbao.live.utils.LiveImDeletUtil;
|
||||||
|
import com.yunbao.live.utils.LiveTextRender;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
@ -333,6 +337,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
|||||||
loading.setVisibility(View.GONE);
|
loading.setVisibility(View.GONE);
|
||||||
enterRoomLeaveHandler.post(enterRoomLeaveRunnable);
|
enterRoomLeaveHandler.post(enterRoomLeaveRunnable);
|
||||||
OpenAdManager.getInstance().show(OpenAdManager.TYPE_LIVE, LiveGuardInfo.isGuard(mLiveGuardInfo));
|
OpenAdManager.getInstance().show(OpenAdManager.TYPE_LIVE, LiveGuardInfo.isGuard(mLiveGuardInfo));
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
final Runnable loadTimeoutRunnableGone = new Runnable() {
|
final Runnable loadTimeoutRunnableGone = new Runnable() {
|
||||||
@ -341,6 +346,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
|||||||
loading.setVisibility(View.GONE);
|
loading.setVisibility(View.GONE);
|
||||||
enterRoomLeaveHandler.post(enterRoomLeaveRunnable);
|
enterRoomLeaveHandler.post(enterRoomLeaveRunnable);
|
||||||
//ToastUtil.show(mContext.getString(R.string.net_error) + " :500");//异常下播,等待加载时间过了后弹出
|
//ToastUtil.show(mContext.getString(R.string.net_error) + " :500");//异常下播,等待加载时间过了后弹出
|
||||||
|
OpenAdManager.getInstance().show(OpenAdManager.TYPE_LIVE, LiveGuardInfo.isGuard(mLiveGuardInfo));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import android.app.NotificationChannel;
|
|||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@ -224,7 +225,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
|||||||
SWAuManager.get().initRtcEngine(this);
|
SWAuManager.get().initRtcEngine(this);
|
||||||
ActivityCompat.postponeEnterTransition(this);
|
ActivityCompat.postponeEnterTransition(this);
|
||||||
ConversationIMListManager.get(this);
|
ConversationIMListManager.get(this);
|
||||||
OpenAdManager.getInstance();
|
|
||||||
//在请求一下这个接口给我后台版本号
|
//在请求一下这个接口给我后台版本号
|
||||||
CommonHttpUtil.getConfig(mContext, new CommonCallback<ConfigBean>() {
|
CommonHttpUtil.getConfig(mContext, new CommonCallback<ConfigBean>() {
|
||||||
@Override
|
@Override
|
||||||
@ -363,6 +363,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
OpenAdManager.getInstance().show(OpenAdManager.TYPE_HOME, false);
|
||||||
if (mTabButtonGroup.getCurPosition() != position) {
|
if (mTabButtonGroup.getCurPosition() != position) {
|
||||||
System.err.println("重连IM:" + IMLoginManager.isLogin(mContext));
|
System.err.println("重连IM:" + IMLoginManager.isLogin(mContext));
|
||||||
if (!IMLoginManager.isLogin(mContext)) {
|
if (!IMLoginManager.isLogin(mContext)) {
|
||||||
@ -845,7 +846,15 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
|||||||
if (!APKManager.get().getApkVerNew()) {
|
if (!APKManager.get().getApkVerNew()) {
|
||||||
new XPopup.Builder(mContext).isDestroyOnDismiss(true).dismissOnBackPressed(false) // 按返回键是否关闭弹窗,默认为true
|
new XPopup.Builder(mContext).isDestroyOnDismiss(true).dismissOnBackPressed(false) // 按返回键是否关闭弹窗,默认为true
|
||||||
.dismissOnTouchOutside(false) // 点击外部是否关闭弹窗,默认为true
|
.dismissOnTouchOutside(false) // 点击外部是否关闭弹窗,默认为true
|
||||||
.asCustom(new APKUpdateCustomPopup(mContext, false)).show();
|
.asCustom(
|
||||||
|
new APKUpdateCustomPopup(mContext, false)
|
||||||
|
.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialogInterface) {
|
||||||
|
requestBonus();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
).show();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
requestBonus();
|
requestBonus();
|
||||||
@ -855,6 +864,10 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initAdOpenWindows() {
|
||||||
|
OpenAdManager.getInstance().show(OpenAdManager.TYPE_HOME, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 填写邀请码
|
* 填写邀请码
|
||||||
*/
|
*/
|
||||||
@ -885,14 +898,21 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
|||||||
* 签到奖励
|
* 签到奖励
|
||||||
*/
|
*/
|
||||||
SigninDialog fragment;
|
SigninDialog fragment;
|
||||||
|
boolean isRequestBonus = false;
|
||||||
|
|
||||||
private void requestBonus() {
|
private void requestBonus() {
|
||||||
|
|
||||||
fragment = new SigninDialog();
|
fragment = new SigninDialog();
|
||||||
MainHttpUtil.requestNewBonus(new HttpCallback() {
|
MainHttpUtil.requestNewBonus(new HttpCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(int code, String msg, String[] info) {
|
public void onError() {
|
||||||
|
super.onError();
|
||||||
|
isRequestBonus = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(int code, String msg, String[] info) {
|
||||||
|
isRequestBonus = true;
|
||||||
if (info.length > 0) {
|
if (info.length > 0) {
|
||||||
JSONObject obj = JSON.parseObject(info[0]);
|
JSONObject obj = JSON.parseObject(info[0]);
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
@ -901,14 +921,24 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
|||||||
bundle.putString("send_exp", obj.getString("send_exp"));
|
bundle.putString("send_exp", obj.getString("send_exp"));
|
||||||
bundle.putString("sign_day", obj.getString("sign_day"));
|
bundle.putString("sign_day", obj.getString("sign_day"));
|
||||||
fragment.setArguments(bundle);
|
fragment.setArguments(bundle);
|
||||||
|
fragment.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialogInterface) {
|
||||||
|
initAdOpenWindows();
|
||||||
|
}
|
||||||
|
});
|
||||||
if (!getSupportFragmentManager().isStateSaved()) {
|
if (!getSupportFragmentManager().isStateSaved()) {
|
||||||
fragment.show(getSupportFragmentManager(), "SigninDialog");
|
fragment.show(getSupportFragmentManager(), "SigninDialog");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
initAdOpenWindows();
|
||||||
}
|
}
|
||||||
if (obj != null && obj.containsKey("msg_zdy_send") && obj.containsKey("msg_zdy_send_text")) {
|
if (obj != null && obj.containsKey("msg_zdy_send") && obj.containsKey("msg_zdy_send_text")) {
|
||||||
Log.e("MainActivity333", info[0]);
|
Log.e("MainActivity333", info[0]);
|
||||||
NoviceInstructorManager.get(mContext).getNetNoviceInstructor(info[0]);
|
NoviceInstructorManager.get(mContext).getNetNoviceInstructor(info[0]);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
initAdOpenWindows();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -942,6 +972,9 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
|||||||
NoviceInstructorManager.get(mContext).getNoviceInstructor();
|
NoviceInstructorManager.get(mContext).getNoviceInstructor();
|
||||||
NoviceInstructorManager.get(mContext).checktHomeZdyPop();
|
NoviceInstructorManager.get(mContext).checktHomeZdyPop();
|
||||||
initAnchorRecommendBanner();
|
initAnchorRecommendBanner();
|
||||||
|
if (isRequestBonus) {
|
||||||
|
initAdOpenWindows();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1140,7 +1173,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
|||||||
if (EasyFloat.isShow("LiveFloatView")) {
|
if (EasyFloat.isShow("LiveFloatView")) {
|
||||||
EasyFloat.dismiss("LiveFloatView", true);
|
EasyFloat.dismiss("LiveFloatView", true);
|
||||||
}
|
}
|
||||||
OpenAdManager.getInstance().reset();
|
OpenAdManager.getInstance().close();
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.yunbao.main.dialog;
|
|||||||
import static com.yunbao.common.utils.RouteUtil.PATH_REWARD;
|
import static com.yunbao.common.utils.RouteUtil.PATH_REWARD;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -20,12 +21,18 @@ import com.yunbao.main.R;
|
|||||||
|
|
||||||
public class SigninDialog extends AbsDialogFragment {
|
public class SigninDialog extends AbsDialogFragment {
|
||||||
TextView gold, sign_day;
|
TextView gold, sign_day;
|
||||||
|
private DialogInterface.OnDismissListener onDismissListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutId() {
|
protected int getLayoutId() {
|
||||||
return R.layout.signin_dialog;
|
return R.layout.signin_dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SigninDialog setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
|
||||||
|
this.onDismissListener = onDismissListener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getDialogStyle() {
|
protected int getDialogStyle() {
|
||||||
return R.style.dialog;
|
return R.style.dialog;
|
||||||
@ -79,4 +86,12 @@ public class SigninDialog extends AbsDialogFragment {
|
|||||||
|
|
||||||
sign_day.setText(String.format(getString(R.string.this_month), bundle.getString("sign_day")));
|
sign_day.setText(String.format(getString(R.string.this_month), bundle.getString("sign_day")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialog) {
|
||||||
|
super.onDismiss(dialog);
|
||||||
|
if (onDismissListener != null) {
|
||||||
|
onDismissListener.onDismiss(dialog);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -567,7 +567,6 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
OpenAdManager.getInstance().show(OpenAdManager.TYPE_HOME, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user