forked from organicmaps/organicmaps
[andorid] Fixed ad view registration
This commit is contained in:
parent
e7a1170fc8
commit
6924a723b1
5 changed files with 47 additions and 18 deletions
36
android/src/com/mapswithme/maps/ads/BaseMwmNativeAd.java
Normal file
36
android/src/com/mapswithme/maps/ads/BaseMwmNativeAd.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
package com.mapswithme.maps.ads;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.log.Logger;
|
||||
import com.mapswithme.util.log.LoggerFactory;
|
||||
|
||||
abstract class BaseMwmNativeAd implements MwmNativeAd
|
||||
{
|
||||
private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
|
||||
private static final String TAG = BaseMwmNativeAd.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
public void registerView(@NonNull View bannerView)
|
||||
{
|
||||
View largeAction = bannerView.findViewById(R.id.tv__action_large);
|
||||
if (UiUtils.isVisible(largeAction))
|
||||
{
|
||||
LOGGER.d(TAG, "Register the large action button for '" + getBannerId() + "'");
|
||||
registerViewForInteraction(largeAction);
|
||||
return;
|
||||
}
|
||||
|
||||
View actionSmall = bannerView.findViewById(R.id.tv__action_small);
|
||||
if (UiUtils.isVisible(actionSmall))
|
||||
{
|
||||
LOGGER.d(TAG, "Register the small action button for '" + getBannerId() + "'");
|
||||
registerViewForInteraction(actionSmall);
|
||||
}
|
||||
}
|
||||
|
||||
abstract void registerViewForInteraction(@NonNull View view);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package com.mapswithme.maps.ads;
|
||||
|
||||
abstract class CachedMwmNativeAd implements MwmNativeAd
|
||||
abstract class CachedMwmNativeAd extends BaseMwmNativeAd
|
||||
{
|
||||
private final long mLoadedTime;
|
||||
|
||||
|
|
|
@ -5,10 +5,6 @@ import android.view.View;
|
|||
import android.widget.ImageView;
|
||||
|
||||
import com.facebook.ads.NativeAd;
|
||||
import com.mapswithme.maps.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class FacebookNativeAd extends CachedMwmNativeAd
|
||||
{
|
||||
|
@ -62,12 +58,9 @@ class FacebookNativeAd extends CachedMwmNativeAd
|
|||
}
|
||||
|
||||
@Override
|
||||
public void registerView(@NonNull View bannerView)
|
||||
void registerViewForInteraction(@NonNull View view)
|
||||
{
|
||||
List<View> clickableViews = new ArrayList<>();
|
||||
clickableViews.add(bannerView.findViewById(R.id.tv__action_small));
|
||||
clickableViews.add(bannerView.findViewById(R.id.tv__action_large));
|
||||
mAd.registerViewForInteraction(bannerView, clickableViews);
|
||||
mAd.registerViewForInteraction(view);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.support.annotation.NonNull;
|
|||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.my.target.ads.CustomParams;
|
||||
import com.my.target.nativeads.NativeAd;
|
||||
import com.my.target.nativeads.banners.NativePromoBanner;
|
||||
|
@ -66,10 +65,9 @@ class MyTargetNativeAd extends CachedMwmNativeAd
|
|||
}
|
||||
|
||||
@Override
|
||||
public void registerView(@NonNull View bannerView)
|
||||
void registerViewForInteraction(@NonNull View view)
|
||||
{
|
||||
mAd.registerView(bannerView.findViewById(R.id.tv__action_small));
|
||||
mAd.registerView(bannerView.findViewById(R.id.tv__action_large));
|
||||
mAd.registerView(view);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -174,14 +174,15 @@ final class BannerController
|
|||
|
||||
mOpened = true;
|
||||
setFrameHeight(WRAP_CONTENT);
|
||||
mMessage.setMaxLines(MAX_MESSAGE_LINES);
|
||||
mTitle.setMaxLines(MAX_TITLE_LINES);
|
||||
updateVisibility();
|
||||
if (mCurrentAd != null)
|
||||
{
|
||||
loadIcon(mCurrentAd);
|
||||
Statistics.INSTANCE.trackPPBanner(PP_BANNER_SHOW, mCurrentAd, 1);
|
||||
mCurrentAd.registerView(mFrame);
|
||||
}
|
||||
mMessage.setMaxLines(MAX_MESSAGE_LINES);
|
||||
mTitle.setMaxLines(MAX_TITLE_LINES);
|
||||
updateVisibility();
|
||||
|
||||
}
|
||||
|
||||
|
@ -196,7 +197,8 @@ final class BannerController
|
|||
mMessage.setMaxLines(MIN_MESSAGE_LINES);
|
||||
mTitle.setMaxLines(MIN_TITLE_LINES);
|
||||
updateVisibility();
|
||||
|
||||
if (mCurrentAd != null)
|
||||
mCurrentAd.registerView(mFrame);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue