|
|
@@ -7,6 +7,7 @@ import android.net.Uri;
|
|
|
import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.StrictMode;
|
|
|
+import android.support.annotation.RequiresApi;
|
|
|
import android.support.multidex.MultiDex;
|
|
|
import android.support.multidex.MultiDexApplication;
|
|
|
import android.text.TextUtils;
|
|
|
@@ -69,13 +70,16 @@ import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
|
|
import com.tencent.smtt.sdk.QbSdk;
|
|
|
import com.stmsdk.AbsTMSConfig;
|
|
|
import com.stmsdk.TMSDKContext;
|
|
|
+import com.tencent.smtt.sdk.WebView;
|
|
|
import com.umeng.commonsdk.UMConfigure;
|
|
|
import com.umeng.socialize.PlatformConfig;
|
|
|
import com.youmi.android.offer.YmConfig;
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
import org.xutils.x;
|
|
|
+
|
|
|
import java.lang.ref.WeakReference;
|
|
|
+
|
|
|
import cn.jpush.android.api.JPushInterface;
|
|
|
import io.reactivex.plugins.RxJavaPlugins;
|
|
|
import ren.yale.android.cachewebviewlib.WebViewCacheInterceptor;
|
|
|
@@ -83,6 +87,8 @@ import ren.yale.android.cachewebviewlib.WebViewCacheInterceptorInst;
|
|
|
import ren.yale.android.cachewebviewlib.config.CacheExtensionConfig;
|
|
|
import tv.danmaku.ijk.media.exo2.Exo2PlayerManager;
|
|
|
|
|
|
+import static com.sheep.gamegroup.util.AppUtil.getCurProcessName;
|
|
|
+
|
|
|
/**
|
|
|
* Created by kemllor on 2017/12/21.
|
|
|
*/
|
|
|
@@ -93,8 +99,6 @@ public class SheepApp extends MultiDexApplication {
|
|
|
public ConnectAddress connectAddress;
|
|
|
private WeakReference<Activity> activityRef;
|
|
|
|
|
|
- public int screenDensity;
|
|
|
-
|
|
|
private NetComponent netComponent;
|
|
|
private boolean isShowQB;
|
|
|
private boolean isInitMidong = false;
|
|
|
@@ -199,10 +203,11 @@ public class SheepApp extends MultiDexApplication {
|
|
|
public void onCreate() {
|
|
|
// configStrictMode();
|
|
|
super.onCreate();
|
|
|
- if (AppUtil.isMainProcess(this)) {
|
|
|
- mSheepApp = this;
|
|
|
+ initWebViewDataDirectory(this);
|
|
|
+ if (AppUtil.isMainProcess(this) || AppUtil.isWebProcess(this)) {
|
|
|
boolean isNotSupport = Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR1;
|
|
|
ContextHolder.setContext(this);
|
|
|
+ mSheepApp = this;
|
|
|
connectAddress = ConnectAddress.sheep.getDefaultConnectAddress();
|
|
|
if (!isNotSupport) {
|
|
|
registerActivityLifecycleCallbacks(activityLifecycleCallbacks);
|
|
|
@@ -221,9 +226,7 @@ public class SheepApp extends MultiDexApplication {
|
|
|
}*/
|
|
|
|
|
|
/*Rx兜底策略*/
|
|
|
- RxJavaPlugins.setErrorHandler(throwable -> {
|
|
|
- Log.e("RxThrowable", throwable.getMessage());
|
|
|
- });
|
|
|
+ RxJavaPlugins.setErrorHandler(throwable -> Log.e("RxThrowable", throwable.getMessage()));
|
|
|
|
|
|
/*点客广告SDK接入*/
|
|
|
TMSDKContext.setTMSDKLogEnable(BuildConfig.DEBUG);
|
|
|
@@ -236,15 +239,26 @@ public class SheepApp extends MultiDexApplication {
|
|
|
|
|
|
/*三方广告SDK接入,游可盈、优投等*/
|
|
|
initThirdAd();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //屏幕dp获取
|
|
|
- screenDensity = getResources().getDisplayMetrics().densityDpi;
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 为webView设置目录后缀
|
|
|
+ *
|
|
|
+ * @param context
|
|
|
+ */
|
|
|
+ public static void initWebViewDataDirectory(Context context) {
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
|
+ String processName = getProcessName();
|
|
|
+ if (!context.getPackageName().equals(processName)) {//判断是否是默认进程名称
|
|
|
+ WebView.setDataDirectorySuffix(processName);
|
|
|
+ android.webkit.WebView.setDataDirectorySuffix(processName);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//初始化三方广告SDK
|
|
|
- private void initThirdAd(){
|
|
|
+ private void initThirdAd() {
|
|
|
SheepApp.getInstance().getNetComponent()
|
|
|
.getApiService()
|
|
|
.commonConfig("third_ad")
|
|
|
@@ -260,7 +274,7 @@ public class SheepApp extends MultiDexApplication {
|
|
|
public void onNext(BaseMessage baseMessage) {
|
|
|
ThirdAdsConfigEntity thirdAdsConfigEntity = baseMessage.getData(ThirdAdsConfigEntity.class);
|
|
|
initYKYAd(thirdAdsConfigEntity.getYkyConfig().getAppid());
|
|
|
- initYTAd(thirdAdsConfigEntity.getYtConfig().getAppid(),thirdAdsConfigEntity.getYtConfig().getAd_id());
|
|
|
+ initYTAd(thirdAdsConfigEntity.getYtConfig().getAppid(), thirdAdsConfigEntity.getYtConfig().getAd_id());
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -298,7 +312,7 @@ public class SheepApp extends MultiDexApplication {
|
|
|
}
|
|
|
|
|
|
//加载优投广告
|
|
|
- private void initYTAd(String appId,String adId) {
|
|
|
+ private void initYTAd(String appId, String adId) {
|
|
|
JasmineEngine.getInstance(this).init(
|
|
|
appId,
|
|
|
Integer.parseInt(adId),
|