Commit 2673e0b7 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 72bf2c61
...@@ -13,6 +13,7 @@ import com.bytedance.sdk.openadsdk.TTAdConstant ...@@ -13,6 +13,7 @@ import com.bytedance.sdk.openadsdk.TTAdConstant
import com.bytedance.sdk.openadsdk.TTAdSdk import com.bytedance.sdk.openadsdk.TTAdSdk
import com.fendasz.moku.planet.exception.MokuException import com.fendasz.moku.planet.exception.MokuException
import com.fendasz.moku.planet.helper.MokuHelper import com.fendasz.moku.planet.helper.MokuHelper
import com.mints.goodmoney.BuildConfig
import com.mints.goodmoney.MintsApplication import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.utils.LogUtil import com.mints.goodmoney.utils.LogUtil
import com.qq.e.comm.managers.GDTADManager import com.qq.e.comm.managers.GDTADManager
...@@ -23,16 +24,16 @@ import kotlinx.android.synthetic.main.activity_layout_xiaoman.* ...@@ -23,16 +24,16 @@ import kotlinx.android.synthetic.main.activity_layout_xiaoman.*
*/ */
object XmManager { object XmManager {
private var placeMateId = ""
private var materialId = ""
private const val ACCESSKEY = "hzq-az_rvkvdy" private const val ACCESSKEY = "hzq-az_rvkvdy"
private const val SECRETKEY = "22FvHjUzvQ516214" private const val SECRETKEY = "22FvHjUzvQ516214"
private var placeMateId = ""
private var materialId = ""
fun initXm(application: Application) { fun initXm(application: Application) {
// //打开日志,上线之前记得关闭
try { try {
// //打开日志,上线之前记得关闭 //打开日志,上线之前记得关闭
AdSdk.setDebug(true); AdSdk.setDebug(BuildConfig.DEBUG)
//初始化 需要在Applicaiton 中 //初始化 需要在Applicaiton 中
AdSdk.init(application, ACCESSKEY, SECRETKEY) AdSdk.init(application, ACCESSKEY, SECRETKEY)
} catch (e: Exception) {//这里应该是小满的异常 } catch (e: Exception) {//这里应该是小满的异常
...@@ -42,8 +43,7 @@ object XmManager { ...@@ -42,8 +43,7 @@ object XmManager {
fun loadMater(placeid: String) { fun loadMater(placeid: String) {
if (TextUtils.isEmpty(placeMateId)) { if (TextUtils.isEmpty(placeMateId)) {
val tm: MaterialTm by lazy { MaterialTm() } MaterialTm().loadMaterialData(UserManager.getInstance().userID, placeid, object : MaterialTm.Callback {
tm!!.loadMaterialData(UserManager.getInstance().userID, placeid, object : MaterialTm.Callback {
//对应PlaceID会有对应的素材 //对应PlaceID会有对应的素材
override fun onSuccess(imgUrl: String, placeMateId2: String, materialId2: String) { override fun onSuccess(imgUrl: String, placeMateId2: String, materialId2: String) {
placeMateId = placeMateId2 placeMateId = placeMateId2
...@@ -59,7 +59,6 @@ object XmManager { ...@@ -59,7 +59,6 @@ object XmManager {
} else { } else {
AdSdk.exposure(UserManager.getInstance().userID, placeid, placeMateId, materialId); AdSdk.exposure(UserManager.getInstance().userID, placeid, placeMateId, materialId);
LogUtil.d("******exposure*********${UserManager.getInstance().userID}******$placeMateId********$materialId****************$placeid**") LogUtil.d("******exposure*********${UserManager.getInstance().userID}******$placeMateId********$materialId****************$placeid**")
} }
} }
...@@ -69,8 +68,10 @@ object XmManager { ...@@ -69,8 +68,10 @@ object XmManager {
* @param view * @param view
*/ */
fun exprotClick(placeid: String) { fun exprotClick(placeid: String) {
AdSdk.click(UserManager.getInstance().userID, placeid, materialId, materialId); if (!TextUtils.isEmpty(placeMateId)) {
LogUtil.d( "******exprotClick*******${UserManager.getInstance().userID}*******$placeMateId********$materialId******$placeid") AdSdk.click(UserManager.getInstance().userID, placeid, materialId, materialId)
LogUtil.d("******exprotClick*******${UserManager.getInstance().userID}*******$placeMateId********$materialId******$placeid")
}
} }
} }
\ No newline at end of file
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