Commit 92d381f9 authored by mengcuiguang's avatar mengcuiguang

添加猎豹接口,优化启动白屏

parent d565501d
...@@ -179,7 +179,7 @@ dependencies { ...@@ -179,7 +179,7 @@ dependencies {
// 三方接入 // 三方接入
// leakcanary // leakcanary
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4' // debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'
// 极光推送 // 极光推送
implementation 'cn.jiguang.sdk:jpush:3.6.6' implementation 'cn.jiguang.sdk:jpush:3.6.6'
implementation 'cn.jiguang.sdk:jcore:2.3.8' implementation 'cn.jiguang.sdk:jcore:2.3.8'
......
...@@ -6,6 +6,7 @@ import android.os.Build; ...@@ -6,6 +6,7 @@ import android.os.Build;
import android.text.TextUtils; import android.text.TextUtils;
import android.webkit.WebView; import android.webkit.WebView;
import androidx.annotation.NonNull;
import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.multidex.MultiDex; import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication; import androidx.multidex.MultiDexApplication;
...@@ -14,6 +15,7 @@ import com.bun.miitmdid.core.JLibrary; ...@@ -14,6 +15,7 @@ import com.bun.miitmdid.core.JLibrary;
import com.component.dly.xzzq_ywsdk.YwSDK; import com.component.dly.xzzq_ywsdk.YwSDK;
import com.mints.goodmoney.common.Constant; import com.mints.goodmoney.common.Constant;
import com.mints.goodmoney.manager.LiebaoManager; import com.mints.goodmoney.manager.LiebaoManager;
import com.mints.goodmoney.manager.MiitHelper;
import com.mints.goodmoney.manager.OaidManager; import com.mints.goodmoney.manager.OaidManager;
import com.mints.goodmoney.manager.TtCsjAdManager; import com.mints.goodmoney.manager.TtCsjAdManager;
import com.mints.goodmoney.manager.UserManager; import com.mints.goodmoney.manager.UserManager;
...@@ -90,7 +92,7 @@ public class MintsApplication extends MultiDexApplication { ...@@ -90,7 +92,7 @@ public class MintsApplication extends MultiDexApplication {
*/ */
private void thirdConfig() { private void thirdConfig() {
// 移动安全联盟 oaid // 移动安全联盟 oaid
initOaid(); initMiitHelper();
//Android 9 or above must be set //Android 9 or above must be set
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
...@@ -132,6 +134,26 @@ public class MintsApplication extends MultiDexApplication { ...@@ -132,6 +134,26 @@ public class MintsApplication extends MultiDexApplication {
// BxmManager.INSTANCE.initBxm(this); // BxmManager.INSTANCE.initBxm(this);
} }
private MiitHelper.AppIdsUpdater appIdsUpdater = new MiitHelper.AppIdsUpdater() {
@Override
public void OnIdsAvalid(@NonNull String ids) {
OAID = ids;
}
};
/**
* 移动安装联盟 获取OAID等设备标识符
*/
private void initMiitHelper() {
try {
MiitHelper miitHelper = new MiitHelper(appIdsUpdater);
miitHelper.getDeviceIds(getApplicationContext());
} catch (Exception e) {
e.printStackTrace();
LogUtil.e(e);
}
}
/** /**
* 移动安装联盟 获取OAID等设备标识符 * 移动安装联盟 获取OAID等设备标识符
*/ */
......
package com.mints.goodmoney.manager;
import android.content.Context;
import android.util.Log;
import androidx.annotation.NonNull;
import com.bun.miitmdid.core.ErrorCode;
import com.bun.miitmdid.core.MdidSdk;
import com.bun.miitmdid.core.MdidSdkHelper;
import com.bun.supplier.IIdentifierListener;
import com.bun.supplier.IdSupplier;
import com.mints.goodmoney.MintsApplication;
/**
* Created by zheng on 2019/8/22.
*/
public class MiitHelper implements IIdentifierListener {
private AppIdsUpdater _listener;
public MiitHelper(AppIdsUpdater callback) {
_listener = callback;
}
public void getDeviceIds(Context cxt) {
long timeb = System.currentTimeMillis();
int nres = CallFromReflect(cxt);
// int nres=DirectCall(cxt);
long timee = System.currentTimeMillis();
long offset = timee - timeb;
// if (nres == ErrorCode.INIT_ERROR_DEVICE_NOSUPPORT) {//1008612 不支持的设备
// MintsApplication.setIsSupportOaid(false, nres);
// } else if (nres == ErrorCode.INIT_ERROR_LOAD_CONFIGFILE) {//1008613 加载配置文件出错
// MintsApplication.setIsSupportOaid(false, nres);
// } else if (nres == ErrorCode.INIT_ERROR_MANUFACTURER_NOSUPPORT) {//1008611 不支持的设备厂商
// MintsApplication.setIsSupportOaid(false, nres);
// } else if (nres == ErrorCode.INIT_ERROR_RESULT_DELAY) {//1008614 获取接口是异步的,结果会在回调中返回,回调执行的回调可能在工作线程
// //TODO 这种情况,还不清楚怎么解决呢。暂且先返false
// MintsApplication.setIsSupportOaid(false, nres);
// } else if (nres == ErrorCode.INIT_HELPER_CALL_ERROR) {//1008615 反射调用出错
// MintsApplication.setIsSupportOaid(false, nres);
// }
Log.d(getClass().getSimpleName(), "return value: " + String.valueOf(nres));
}
/*
* 通过反射调用,解决android 9以后的类加载升级,导至找不到so中的方法
*
* */
private int CallFromReflect(Context cxt) {
return MdidSdkHelper.InitSdk(cxt, true, this);
}
/*
* 直接java调用,如果这样调用,在android 9以前没有题,在android 9以后会抛找不到so方法的异常
* 解决办法是和JLibrary.InitEntry(cxt),分开调用,比如在A类中调用JLibrary.InitEntry(cxt),在B类中调用MdidSdk的方法
* A和B不能存在直接和间接依赖关系,否则也会报错
*
* */
private int DirectCall(Context cxt) {
MdidSdk sdk = new MdidSdk();
return sdk.InitSdk(cxt, this);
}
@Override
public void OnSupport(boolean isSupport, IdSupplier _supplier) {
if (_supplier == null) {
return;
}
/* String oaid=_supplier.getOaid();
String vaid=_supplier.getVAID();
String aaid=_supplier.getAAID();
String udid=_supplier.getUDID();
StringBuilder builder=new StringBuilder();
builder.append("support: ").append(isSupport?"true":"false").append("\n");
builder.append("UDID: ").append(udid).append("\n");
builder.append("OAID: ").append(oaid).append("\n");
builder.append("VAID: ").append(vaid).append("\n");
builder.append("AAID: ").append(aaid).append("\n");
String idstext=builder.toString();*/
// MintsApplication.setIsSupportOaid(isSupport);
String oaid = _supplier.getOAID();
// _supplier.shutDown(); //关闭接口
if (_listener != null) {
_listener.OnIdsAvalid(oaid);
}
}
public interface AppIdsUpdater {
void OnIdsAvalid(@NonNull String ids);
}
}
...@@ -78,7 +78,8 @@ public class GamePresenter extends BasePresenter<GameView> { ...@@ -78,7 +78,8 @@ public class GamePresenter extends BasePresenter<GameView> {
switch (code) { switch (code) {
case 200://成功 case 200://成功
if (data != null) { if (data != null) {
view.gameInfo(0, 0, 0); JsonObject gameMsg = data.getAsJsonObject("msg");
view.gameInfo(gameMsg.get("needSecods").getAsInt(), gameMsg.get("coin").getAsInt(), gameMsg.get("completeSeconds").getAsInt());
} }
break; break;
} }
......
...@@ -83,17 +83,10 @@ class EraseActivity : BaseActivity(), View.OnClickListener{ ...@@ -83,17 +83,10 @@ class EraseActivity : BaseActivity(), View.OnClickListener{
*/ */
private fun loadTurnUrl() { private fun loadTurnUrl() {
getTurnUrl() getTurnUrl()
blEarseWebview.setOnTouchListener(object : View.OnTouchListener {
override fun onTouch(v: View?, event: MotionEvent): Boolean {
return event.action == MotionEvent.ACTION_MOVE
}
})
blEarseWebview.setDefaultHandler(DefaultHandler()) blEarseWebview.setDefaultHandler(DefaultHandler())
blEarseWebview.setWebChromeClient(WebChromeClient()) blEarseWebview.setWebChromeClient(WebChromeClient())
blEarseWebview.setOnLongClickListener(OnLongClickListener { true }) blEarseWebview.setOnLongClickListener(OnLongClickListener { true })
//注册监听方法当js中调用callHandler方法时会调用此方法(handlerName必须和js中相同)
blEarseWebview.registerHandler("getEraseResult", BridgeHandler { data, function -> blEarseWebview.registerHandler("getEraseResult", BridgeHandler { data, function ->
//{"title":"40金币","coin":40,"key":"t4"}
val turntableBean: TurntableBean = JsonUtil.parseJson(data, TurntableBean::class.java) val turntableBean: TurntableBean = JsonUtil.parseJson(data, TurntableBean::class.java)
if (turntableBean != null) { if (turntableBean != null) {
val bundle = Bundle() val bundle = Bundle()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment