Commit c8b17f94 authored by Li's avatar Li

[李俊岐] 优化广告

parent 7dfa89af
...@@ -25,9 +25,6 @@ import com.ym.library.utils.* ...@@ -25,9 +25,6 @@ import com.ym.library.utils.*
object MainDialog { object MainDialog {
var adView: Any? = null
fun showBottomDialog( fun showBottomDialog(
layout: Int, layout: Int,
activity: Context, activity: Context,
...@@ -35,9 +32,6 @@ object MainDialog { ...@@ -35,9 +32,6 @@ object MainDialog {
animation: Int, animation: Int,
gravity: Int gravity: Int
): View { ): View {
adView = null
val mDialogView = View.inflate(activity, layout, null) val mDialogView = View.inflate(activity, layout, null)
setHeadDialog.setContentView(mDialogView) setHeadDialog.setContentView(mDialogView)
val window = setHeadDialog.window val window = setHeadDialog.window
...@@ -73,17 +67,10 @@ object MainDialog { ...@@ -73,17 +67,10 @@ object MainDialog {
0, 0,
Gravity.CENTER Gravity.CENTER
) )
val layoutAd = mDialogView?.findViewById<FrameLayout>(R.id.layout_get_drop_ad2) val layoutAd = mDialogView?.findViewById<FrameLayout>(R.id.layout_feed_ad)
AdUtils.showFeedAd(activity, "receive_redPack_double_click", layoutAd) AdUtils.showFeedAd(activity, "receive_redPack_double_click", layoutAd)
mDialog.setOnDismissListener(object : DialogInterface.OnDismissListener {
override fun onDismiss(p0: DialogInterface?) {
onDestroy()
AdUtils.loadFeedCacheAdToCache(activity)
}
})
mDialogView.findViewById<ImageView>(R.id.lv_get_drop_close2).setOnClickListener { mDialogView.findViewById<ImageView>(R.id.lv_get_drop_close2).setOnClickListener {
EventUtils.onEvent("click_close_receive_redPack_dialog", "点击关闭领取红包弹窗") EventUtils.onEvent("click_close_receive_redPack_dialog", "点击关闭领取红包弹窗")
mDialog.dismiss() mDialog.dismiss()
...@@ -132,7 +119,7 @@ object MainDialog { ...@@ -132,7 +119,7 @@ object MainDialog {
val ivGetDropBg = mDialogView?.findViewById<ImageView>(R.id.iv_get_drop_bg) val ivGetDropBg = mDialogView?.findViewById<ImageView>(R.id.iv_get_drop_bg)
val ivtitle = mDialogView?.findViewById<ImageView>(R.id.id_img_title) val ivtitle = mDialogView?.findViewById<ImageView>(R.id.id_img_title)
val tvGetDropCount = mDialogView?.findViewById<TextView>(R.id.tv_get_drop_count) val tvGetDropCount = mDialogView?.findViewById<TextView>(R.id.tv_get_drop_count)
val layoutAd = mDialogView?.findViewById<FrameLayout>(R.id.layout_get_drop_ad) val layoutAd = mDialogView?.findViewById<FrameLayout>(R.id.layout_feed_ad)
val llcontent2 = mDialogView?.findViewById<LinearLayout>(R.id.id_ll_content_2) val llcontent2 = mDialogView?.findViewById<LinearLayout>(R.id.id_ll_content_2)
val ivGetDropBg2 = mDialogView?.findViewById<ImageView>(R.id.iv_get_drop_bg2) val ivGetDropBg2 = mDialogView?.findViewById<ImageView>(R.id.iv_get_drop_bg2)
val tvGetDropCount2 = mDialogView?.findViewById<TextView>(R.id.tv_get_drop_count2) val tvGetDropCount2 = mDialogView?.findViewById<TextView>(R.id.tv_get_drop_count2)
...@@ -192,13 +179,6 @@ object MainDialog { ...@@ -192,13 +179,6 @@ object MainDialog {
mDialog.dismiss() mDialog.dismiss()
} }
mDialog.setOnDismissListener(object : DialogInterface.OnDismissListener {
override fun onDismiss(p0: DialogInterface?) {
onDestroy()
AdUtils.loadFeedCacheAdToCache(context)
}
})
mDialog.setCanceledOnTouchOutside(false) mDialog.setCanceledOnTouchOutside(false)
mDialog.setCancelable(false) mDialog.setCancelable(false)
if(context.isFinishing){ if(context.isFinishing){
...@@ -265,7 +245,7 @@ object MainDialog { ...@@ -265,7 +245,7 @@ object MainDialog {
val ivGetDropBg = mDialogView?.findViewById<ImageView>(R.id.iv_get_drop_bg) val ivGetDropBg = mDialogView?.findViewById<ImageView>(R.id.iv_get_drop_bg)
val ivtitle = mDialogView?.findViewById<ImageView>(R.id.id_img_title) val ivtitle = mDialogView?.findViewById<ImageView>(R.id.id_img_title)
val tvGetDropCount = mDialogView?.findViewById<TextView>(R.id.tv_get_drop_count) val tvGetDropCount = mDialogView?.findViewById<TextView>(R.id.tv_get_drop_count)
val layoutAd = mDialogView?.findViewById<FrameLayout>(R.id.layout_get_drop_ad) val layoutAd = mDialogView?.findViewById<FrameLayout>(R.id.layout_feed_ad)
val llcontent2 = mDialogView?.findViewById<LinearLayout>(R.id.id_ll_content_2) val llcontent2 = mDialogView?.findViewById<LinearLayout>(R.id.id_ll_content_2)
val ivGetDropBg2 = mDialogView?.findViewById<ImageView>(R.id.iv_get_drop_bg2) val ivGetDropBg2 = mDialogView?.findViewById<ImageView>(R.id.iv_get_drop_bg2)
val tvGetDropCount2 = mDialogView?.findViewById<TextView>(R.id.tv_get_drop_count2) val tvGetDropCount2 = mDialogView?.findViewById<TextView>(R.id.tv_get_drop_count2)
...@@ -330,22 +310,6 @@ object MainDialog { ...@@ -330,22 +310,6 @@ object MainDialog {
AdUtils.showFeedAd((context as Activity), adType, layoutAd) AdUtils.showFeedAd((context as Activity), adType, layoutAd)
// AdManager.loadFeedAd(
// ADConfig.AD_IMG_FADE,
// activity,
// ZXADSizeConfig(
// Utils.px2dip(PhoneUtils.getScreenWidth(activity).toFloat()) - 56,
// ((Utils.px2dip(activity.windowManager?.defaultDisplay?.width!!.toFloat()) - 56) * 0.66).toInt()
// ),
// layouAd
// )
mDialog.setOnDismissListener(object : DialogInterface.OnDismissListener {
override fun onDismiss(p0: DialogInterface?) {
onDestroy()
AdUtils.loadFeedCacheAdToCache(context)
}
})
mDialog.setCanceledOnTouchOutside(false) mDialog.setCanceledOnTouchOutside(false)
mDialog.setCancelable(false) mDialog.setCancelable(false)
if(context.isFinishing){ if(context.isFinishing){
...@@ -383,7 +347,7 @@ object MainDialog { ...@@ -383,7 +347,7 @@ object MainDialog {
val tv_coin = mDialogView?.findViewById<TextView>(R.id.tv_coin) val tv_coin = mDialogView?.findViewById<TextView>(R.id.tv_coin)
val tv_accelerator = mDialogView?.findViewById<TextView>(R.id.tv_accelerator) val tv_accelerator = mDialogView?.findViewById<TextView>(R.id.tv_accelerator)
val layoutAd = mDialogView?.findViewById<FrameLayout>(R.id.layout_get_drop_ad) val layoutAd = mDialogView?.findViewById<FrameLayout>(R.id.layout_feed_ad)
for (entity in results) { for (entity in results) {
//1种子 2金币 3加速剂 //1种子 2金币 3加速剂
...@@ -416,13 +380,6 @@ object MainDialog { ...@@ -416,13 +380,6 @@ object MainDialog {
AdUtils.showFeedAd((context as Activity), "welfare_openbox", layoutAd) AdUtils.showFeedAd((context as Activity), "welfare_openbox", layoutAd)
mDialog.setOnDismissListener(object : DialogInterface.OnDismissListener {
override fun onDismiss(p0: DialogInterface?) {
onDestroy()
AdUtils.loadFeedCacheAdToCache((context as Activity))
}
})
mDialog.setCanceledOnTouchOutside(false) mDialog.setCanceledOnTouchOutside(false)
mDialog.setCancelable(false) mDialog.setCancelable(false)
if(context.isFinishing){ if(context.isFinishing){
...@@ -621,7 +578,7 @@ object MainDialog { ...@@ -621,7 +578,7 @@ object MainDialog {
Gravity.CENTER Gravity.CENTER
) )
EventUtils.onEvent("show_cloud_speed_up_dialog", "云朵加速弹窗") EventUtils.onEvent("show_cloud_speed_up_dialog", "云朵加速弹窗")
val layoutAd = mDialogView?.findViewById<FrameLayout>(R.id.layout_get_drop_ad) val layoutAd = mDialogView?.findViewById<FrameLayout>(R.id.layout_feed_ad)
AdUtils.showFeedAd(activity, "cloud_speed_bigimage", layoutAd) AdUtils.showFeedAd(activity, "cloud_speed_bigimage", layoutAd)
mDialogView.findViewById<TextView>(R.id.id_tv_speed_time)?.text = "所有土地获得${speedtime}分钟加速" mDialogView.findViewById<TextView>(R.id.id_tv_speed_time)?.text = "所有土地获得${speedtime}分钟加速"
mDialogView.findViewById<TextView>(R.id.id_cloud_speed_num)?.text = mDialogView.findViewById<TextView>(R.id.id_cloud_speed_num)?.text =
...@@ -635,13 +592,7 @@ object MainDialog { ...@@ -635,13 +592,7 @@ object MainDialog {
onClickListener.onClick(it) onClickListener.onClick(it)
mDialog.dismiss() mDialog.dismiss()
} }
mDialog.setOnDismissListener(object : DialogInterface.OnDismissListener {
override fun onDismiss(p0: DialogInterface?) {
onDestroy()
AdUtils.loadFeedCacheAdToCache(activity)
}
})
mDialog?.setCanceledOnTouchOutside(false) mDialog?.setCanceledOnTouchOutside(false)
mDialog?.setCancelable(false) mDialog?.setCancelable(false)
if(activity.isFinishing){ if(activity.isFinishing){
...@@ -665,7 +616,7 @@ object MainDialog { ...@@ -665,7 +616,7 @@ object MainDialog {
Gravity.CENTER Gravity.CENTER
) )
EventUtils.onEvent("show_clean_worm_dialog", "除虫弹窗") EventUtils.onEvent("show_clean_worm_dialog", "除虫弹窗")
val layoutAd = mDialogView?.findViewById<FrameLayout>(R.id.layout_get_drop_ad) val layoutAd = mDialogView?.findViewById<FrameLayout>(R.id.layout_feed_ad)
AdUtils.showFeedAd(activity, "clean_worm", layoutAd) AdUtils.showFeedAd(activity, "clean_worm", layoutAd)
mDialogView.findViewById<ImageView>(R.id.id_img_close_clean_worm).setOnClickListener { mDialogView.findViewById<ImageView>(R.id.id_img_close_clean_worm).setOnClickListener {
mDialog.dismiss() mDialog.dismiss()
...@@ -676,12 +627,7 @@ object MainDialog { ...@@ -676,12 +627,7 @@ object MainDialog {
onClickListener.onClick(it) onClickListener.onClick(it)
mDialog.dismiss() mDialog.dismiss()
} }
mDialog.setOnDismissListener(object : DialogInterface.OnDismissListener {
override fun onDismiss(p0: DialogInterface?) {
onDestroy()
AdUtils.loadFeedCacheAdToCache(activity)
}
})
mDialog?.setCanceledOnTouchOutside(false) mDialog?.setCanceledOnTouchOutside(false)
mDialog?.setCancelable(false) mDialog?.setCancelable(false)
if(activity.isFinishing){ if(activity.isFinishing){
...@@ -709,7 +655,7 @@ object MainDialog { ...@@ -709,7 +655,7 @@ object MainDialog {
0, 0,
Gravity.CENTER Gravity.CENTER
) )
val layoutAd = mDialogView?.findViewById<FrameLayout>(R.id.layout_get_drop_ad) val layoutAd = mDialogView?.findViewById<FrameLayout>(R.id.layout_feed_ad)
AdUtils.showFeedAd(activity, "seed_not_enough_bigimage", layoutAd) AdUtils.showFeedAd(activity, "seed_not_enough_bigimage", layoutAd)
mDialogView.findViewById<TextView>(R.id.id_tv_seed_price)?.text = "$seedPrice" mDialogView.findViewById<TextView>(R.id.id_tv_seed_price)?.text = "$seedPrice"
mDialogView.findViewById<TextView>(R.id.id_tv_seed_video_num)?.text = mDialogView.findViewById<TextView>(R.id.id_tv_seed_video_num)?.text =
...@@ -731,12 +677,7 @@ object MainDialog { ...@@ -731,12 +677,7 @@ object MainDialog {
receiveSeedOnClickListener.onClick(it) receiveSeedOnClickListener.onClick(it)
mDialog.dismiss() mDialog.dismiss()
} }
mDialog.setOnDismissListener(object : DialogInterface.OnDismissListener {
override fun onDismiss(p0: DialogInterface?) {
onDestroy()
AdUtils.loadFeedCacheAdToCache(activity)
}
})
mDialog?.setCanceledOnTouchOutside(false) mDialog?.setCanceledOnTouchOutside(false)
mDialog?.setCancelable(false) mDialog?.setCancelable(false)
if(activity.isFinishing){ if(activity.isFinishing){
...@@ -764,13 +705,4 @@ object MainDialog { ...@@ -764,13 +705,4 @@ object MainDialog {
} }
} }
fun onDestroy() {
if (adView != null) {
if (adView is NativeExpressADView) {
(adView as NativeExpressADView)?.destroy()
} else if (adView is TTNativeExpressAd) {
(adView as TTNativeExpressAd)?.destroy()
}
}
}
} }
\ No newline at end of file
...@@ -113,15 +113,6 @@ ...@@ -113,15 +113,6 @@
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
<FrameLayout <include layout="@layout/layout_base_feed_ad"/>
android:id="@+id/layout_get_drop_ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_40"
android:layout_marginBottom="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_5"
android:background="@color/white"
android:visibility="gone" />
</LinearLayout> </LinearLayout>
...@@ -166,17 +166,7 @@ ...@@ -166,17 +166,7 @@
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
<FrameLayout <include layout="@layout/layout_base_feed_ad"/>
android:id="@+id/layout_get_drop_ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_40"
android:layout_marginBottom="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_5"
android:background="@color/white"
android:visibility="gone" />
</LinearLayout> </LinearLayout>
......
...@@ -111,16 +111,7 @@ ...@@ -111,16 +111,7 @@
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
<FrameLayout <include layout="@layout/layout_base_feed_ad"/>
android:id="@+id/layout_get_drop_ad2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_40"
android:layout_marginRight="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_10"
android:background="@color/white"
android:visibility="gone" />
</LinearLayout> </LinearLayout>
......
...@@ -166,17 +166,7 @@ ...@@ -166,17 +166,7 @@
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
<FrameLayout <include layout="@layout/layout_base_feed_ad"/>
android:id="@+id/layout_get_drop_ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_40"
android:layout_marginBottom="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_5"
android:background="@color/white"
android:visibility="gone" />
</LinearLayout> </LinearLayout>
......
...@@ -126,15 +126,6 @@ ...@@ -126,15 +126,6 @@
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
<FrameLayout <include layout="@layout/layout_base_feed_ad"/>
android:id="@+id/layout_get_drop_ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_40"
android:layout_marginRight="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_10"
android:background="@color/white"
android:visibility="gone" />
</LinearLayout> </LinearLayout>
...@@ -77,15 +77,6 @@ ...@@ -77,15 +77,6 @@
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
<FrameLayout <include layout="@layout/layout_base_feed_ad"/>
android:id="@+id/layout_get_drop_ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_40"
android:layout_marginBottom="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_5"
android:background="@color/white"
android:visibility="gone" />
</LinearLayout> </LinearLayout>
package com.game.luckyfarm;
import com.unity3d.player.*;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
public class UnityPlayerActivity extends Activity
{
protected UnityPlayer mUnityPlayer; // don't change the name of this variable; referenced from native code
// Override this in your custom UnityPlayerActivity to tweak the command line arguments passed to the Unity Android Player
// The command line arguments are passed as a string, separated by spaces
// UnityPlayerActivity calls this from 'onCreate'
// Supported: -force-gles20, -force-gles30, -force-gles31, -force-gles31aep, -force-gles32, -force-gles, -force-vulkan
// See https://docs.unity3d.com/Manual/CommandLineArguments.html
// @param cmdLine the current command line arguments, may be null
// @return the modified command line string or null
protected String updateUnityCommandLineArguments(String cmdLine)
{
return cmdLine;
}
// Setup activity layout
@Override protected void onCreate(Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
String cmdLine = updateUnityCommandLineArguments(getIntent().getStringExtra("unity"));
getIntent().putExtra("unity", cmdLine);
mUnityPlayer = new UnityPlayer(this);
setContentView(mUnityPlayer);
mUnityPlayer.requestFocus();
}
@Override protected void onNewIntent(Intent intent)
{
// To support deep linking, we need to make sure that the client can get access to
// the last sent intent. The clients access this through a JNI api that allows them
// to get the intent set on launch. To update that after launch we have to manually
// replace the intent with the one caught here.
setIntent(intent);
}
// Quit Unity
@Override protected void onDestroy ()
{
mUnityPlayer.destroy();
super.onDestroy();
}
// Pause Unity
@Override protected void onPause()
{
super.onPause();
mUnityPlayer.pause();
}
// Resume Unity
@Override protected void onResume()
{
super.onResume();
mUnityPlayer.resume();
}
@Override protected void onStart()
{
super.onStart();
mUnityPlayer.start();
}
@Override protected void onStop()
{
super.onStop();
mUnityPlayer.stop();
}
// Low Memory Unity
@Override public void onLowMemory()
{
super.onLowMemory();
mUnityPlayer.lowMemory();
}
// Trim Memory Unity
@Override public void onTrimMemory(int level)
{
super.onTrimMemory(level);
if (level == TRIM_MEMORY_RUNNING_CRITICAL)
{
mUnityPlayer.lowMemory();
}
}
// This ensures the layout will be correct.
@Override public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
mUnityPlayer.configurationChanged(newConfig);
}
// Notify Unity of the focus change.
@Override public void onWindowFocusChanged(boolean hasFocus)
{
super.onWindowFocusChanged(hasFocus);
mUnityPlayer.windowFocusChanged(hasFocus);
}
// For some reason the multiple keyevent type is not supported by the ndk.
// Force event injection by overriding dispatchKeyEvent().
@Override public boolean dispatchKeyEvent(KeyEvent event)
{
if (event.getAction() == KeyEvent.ACTION_MULTIPLE)
return mUnityPlayer.injectEvent(event);
return super.dispatchKeyEvent(event);
}
// Pass any events not handled by (unfocused) views straight to UnityPlayer
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { return mUnityPlayer.injectEvent(event); }
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { return mUnityPlayer.injectEvent(event); }
@Override public boolean onTouchEvent(MotionEvent event) { return mUnityPlayer.injectEvent(event); }
/*API12*/ public boolean onGenericMotionEvent(MotionEvent event) { return mUnityPlayer.injectEvent(event); }
}
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="BaseUnityTheme" parent="android:Theme.Material.Light.NoActionBar.Fullscreen">
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">LuckyFarm</string>
<string name="game_view_content_description">Game view</string>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="UnityThemeSelector" parent="BaseUnityTheme">
<item name="android:windowBackground">@android:color/black</item>
</style>
<style name="BaseUnityTheme" parent="android:Theme.Holo.Light.NoActionBar.Fullscreen">
</style>
<style name="UnityThemeSelector.Translucent" parent="@style/UnityThemeSelector">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
</resources>
...@@ -67,7 +67,7 @@ dependencies { ...@@ -67,7 +67,7 @@ dependencies {
api ("com.bx:adsdk:1.3.3"){ api ("com.bx:adsdk:1.3.3"){
exclude group: 'com.google.code.gson' exclude group: 'com.google.code.gson'
} }
api 'com.ym.admodule:admodule:1.0.2.30' api 'com.ym.admodule:admodule:1.0.2.31'
api 'com.airbnb.android:lottie:3.1.0' api 'com.airbnb.android:lottie:3.1.0'
/* api 'androidx.appcompat:appcompat:1.2.0-alpha02' /* api 'androidx.appcompat:appcompat:1.2.0-alpha02'
api 'com.android.support:design:28.0.0' api 'com.android.support:design:28.0.0'
......
...@@ -13,6 +13,7 @@ import com.ym.library.module.StatusEntity ...@@ -13,6 +13,7 @@ import com.ym.library.module.StatusEntity
import com.ym.library.net.BaseObserver import com.ym.library.net.BaseObserver
import com.ym.library.net.GameApiClient import com.ym.library.net.GameApiClient
import com.ym.library.net.RxSchedulers import com.ym.library.net.RxSchedulers
import com.ym.modulecommon.utils.LogUtils
object AdUtils { object AdUtils {
val TAG = "AdUtils" val TAG = "AdUtils"
...@@ -69,28 +70,14 @@ object AdUtils { ...@@ -69,28 +70,14 @@ object AdUtils {
AdManager.showFeedAd( AdManager.showFeedAd(
ADConfig.AD_IMG_FADE, ADConfig.AD_IMG_FADE,
actionName, actionName,
ZXADSizeConfig( ZXADSizeConfig(Utils.px2dip(PhoneUtils.getScreenWidth(activity).toFloat()) - 10, 280),
// Utils.px2dip(PhoneUtils.getScreenWidth(activity).toFloat()) - 40, 280
Utils.px2dip(PhoneUtils.getScreenWidth(activity).toFloat()) - 40,
((Utils.px2dip(activity.windowManager?.defaultDisplay?.width!!.toFloat()) - 40) * 0.66).toInt()
),
activity, activity,
view view
) )
// try {
// view.postDelayed(object :Runnable { view?.postDelayed({
// override fun run() { loadFeedCacheAdToCache(activity)
// if(activity?.isFinishing){ },1500)
// return
// }
//
// activity?.runOnUiThread() {
//
// }
// }
// },0)
// } catch (e: Exception) {
// }
} }
//预加载激励 //预加载激励
...@@ -102,10 +89,7 @@ object AdUtils { ...@@ -102,10 +89,7 @@ object AdUtils {
fun loadFeedCacheAdToCache(activity: Activity) { fun loadFeedCacheAdToCache(activity: Activity) {
AdManager.loadFeedAdToCache( AdManager.loadFeedAdToCache(
ADConfig.AD_IMG_FADE, activity, ZXADSizeConfig( ADConfig.AD_IMG_FADE, activity, ZXADSizeConfig(
// Utils.px2dip(PhoneUtils.getScreenWidth(activity).toFloat()) - 40, 280 Utils.px2dip(PhoneUtils.getScreenWidth(activity).toFloat()) - 10, 280)
Utils.px2dip(PhoneUtils.getScreenWidth(activity).toFloat()) - 40,
((Utils.px2dip(activity.windowManager?.defaultDisplay?.width!!.toFloat()) - 40) * 0.66).toInt()
)
) )
} }
......
...@@ -390,7 +390,7 @@ object CenterDialog : BaseDialog() { ...@@ -390,7 +390,7 @@ object CenterDialog : BaseDialog() {
imgbg.setImageResource(R.drawable.icon_diamand) imgbg.setImageResource(R.drawable.icon_diamand)
} }
val tvGetDropCount = mDialogView?.findViewById<TextView>(R.id.tv_get_count) val tvGetDropCount = mDialogView?.findViewById<TextView>(R.id.tv_get_count)
val layoutAd = mDialogView?.findViewById<FrameLayout>(R.id.layout_ad) val layoutAd = mDialogView?.findViewById<FrameLayout>(R.id.layout_feed_ad)
tvGetDropCount.text = "+${rewardCount}" tvGetDropCount.text = "+${rewardCount}"
AdUtils.showFeedAd(context,actionName,layoutAd) AdUtils.showFeedAd(context,actionName,layoutAd)
...@@ -406,7 +406,6 @@ object CenterDialog : BaseDialog() { ...@@ -406,7 +406,6 @@ object CenterDialog : BaseDialog() {
mDialog?.setOnCancelListener { mDialog?.setOnCancelListener {
listener.onCancel(it) listener.onCancel(it)
AdUtils.loadFeedCacheAdToCache(context)
} }
mDialog?.setCanceledOnTouchOutside(false) mDialog?.setCanceledOnTouchOutside(false)
......
...@@ -106,16 +106,7 @@ ...@@ -106,16 +106,7 @@
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
<FrameLayout <include layout="@layout/layout_base_feed_ad"/>
android:id="@+id/layout_ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="40dp"
android:layout_marginBottom="10dp"
android:layout_marginRight="5dp"
android:background="@color/white"
android:visibility="gone" />
</LinearLayout> </LinearLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_feed_ad"
android:layout_width="match_parent"
android:layout_height="280dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="40dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="10dp"
android:background="@color/white"
android:visibility="gone">
</FrameLayout>
\ No newline at end of file
...@@ -27,11 +27,8 @@ class SettingActivity : BaseActivity() { ...@@ -27,11 +27,8 @@ class SettingActivity : BaseActivity() {
StatusBarUtil.transportStatus(this, resources.getColor(R.color.transparent)) StatusBarUtil.transportStatus(this, resources.getColor(R.color.transparent))
} }
private var adView: Any? = null
override fun init() { override fun init() {
EventUtils.onEvent("show_setting", "设置页面曝光") EventUtils.onEvent("show_setting", "设置页面曝光")
adView = null
if (SettingPreference.getUserInfoData() != null) { if (SettingPreference.getUserInfoData() != null) {
id_tv_id.text = "ID: ${SettingPreference.getUserInfoData().uid}" id_tv_id.text = "ID: ${SettingPreference.getUserInfoData().uid}"
} }
...@@ -79,7 +76,21 @@ class SettingActivity : BaseActivity() { ...@@ -79,7 +76,21 @@ class SettingActivity : BaseActivity() {
updateVersionManager?.checkUpdate(true) updateVersionManager?.checkUpdate(true)
} }
AdUtils.showFeedAd(this,"setting",id_ad_frame_view) AdUtils.showFeedAd(this, "", id_ad_frame_view)
AdManager.showFeedAd(
ADConfig.AD_IMG_FADE,
"setting",
ZXADSizeConfig(Utils.px2dip(PhoneUtils.getScreenWidth(this).toFloat()) - 45, 280),
this,
id_ad_frame_view)
id_ad_frame_view?.postDelayed({
AdManager.loadFeedAdToCache(
ADConfig.AD_IMG_FADE, this, ZXADSizeConfig(
Utils.px2dip(PhoneUtils.getScreenWidth(this).toFloat()) - 45, 280)
)
},1500)
} }
private fun copy() { private fun copy() {
...@@ -106,19 +117,8 @@ class SettingActivity : BaseActivity() { ...@@ -106,19 +117,8 @@ class SettingActivity : BaseActivity() {
override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
MobclickAgent.onPause(this) MobclickAgent.onPause(this)
AdUtils.loadFeedCacheAdToCache(this) AdUtils.loadFeedCacheAdToCache(this)
} }
override fun onDestroy() {
super.onDestroy()
if (adView != null) {
if (adView is NativeExpressADView) {
(adView as NativeExpressADView)?.destroy()
} else if (adView is TTNativeExpressAd) {
(adView as TTNativeExpressAd)?.destroy()
}
}
}
} }
...@@ -40,9 +40,7 @@ ...@@ -40,9 +40,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="40dp" android:paddingTop="40dp"
android:paddingBottom="40dp" android:paddingBottom="40dp">
>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -54,6 +52,7 @@ ...@@ -54,6 +52,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="30dp" android:layout_marginLeft="30dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
android:layout_marginBottom="10dp"
android:background="@drawable/icon_setting_item_bg"> android:background="@drawable/icon_setting_item_bg">
<TextView <TextView
...@@ -78,18 +77,15 @@ ...@@ -78,18 +77,15 @@
android:src="@drawable/icon_setting_copy_btn" /> android:src="@drawable/icon_setting_copy_btn" />
</RelativeLayout> </RelativeLayout>
<FrameLayout <FrameLayout
android:id="@+id/id_ad_frame_view" android:id="@+id/id_ad_frame_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="280dp"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginLeft="30dp" android:layout_marginLeft="30dp"
android:layout_marginTop="14dp" android:layout_marginRight="15dp"
android:layout_marginRight="18dp" android:layout_marginBottom="14dp"
android:layout_marginBottom="20dp" android:visibility="gone" />
android:padding="5dp"
android:visibility="visible" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -257,8 +253,8 @@ ...@@ -257,8 +253,8 @@
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingLeft="16dp" android:paddingLeft="16dp"
android:paddingTop="10dp" android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingRight="20dp" android:paddingRight="20dp"
android:paddingBottom="10dp"
android:text="@string/user_about_us" android:text="@string/user_about_us"
android:textColor="#642D2D" android:textColor="#642D2D"
android:textSize="15sp" /> android:textSize="15sp" />
......
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