Java Code Examples for com.applovin.sdk.AppLovinAdSize#MREC
The following examples show how to use
com.applovin.sdk.AppLovinAdSize#MREC .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppLovinUtils.java From googleads-mobile-android-mediation with Apache License 2.0 | 6 votes |
/** Get the {@link AppLovinAdSize} from a given {@link AdSize} from AdMob. */ @Nullable public static AppLovinAdSize appLovinAdSizeFromAdMobAdSize( @NonNull Context context, @NonNull AdSize adSize) { ArrayList<AdSize> potentials = new ArrayList<>(); potentials.add(AdSize.BANNER); potentials.add(AdSize.LEADERBOARD); potentials.add(AdSize.MEDIUM_RECTANGLE); AdSize closestSize = MediationUtils.findClosestSize(context, adSize, potentials); if (AdSize.BANNER.equals(closestSize)) { return AppLovinAdSize.BANNER; } else if (AdSize.MEDIUM_RECTANGLE.equals(closestSize)) { return AppLovinAdSize.MREC; } else if (AdSize.LEADERBOARD.equals(closestSize)) { return AppLovinAdSize.LEADER; } return null; }
Example 2
Source File: AppLovinCustomEventBanner.java From SDK-Network-Adapters with MIT License | 5 votes |
private AppLovinAdSize appLovinAdSizeFromAdMobAdSize(final AdSize adSize) { final boolean isSmartBanner = ( adSize.getWidth() == AdSize.FULL_WIDTH ) && ( adSize.getHeight() == AdSize.AUTO_HEIGHT ); if ( AdSize.BANNER.equals( adSize ) || AdSize.LARGE_BANNER.equals( adSize ) || isSmartBanner ) { return AppLovinAdSize.BANNER; } else if ( AdSize.MEDIUM_RECTANGLE.equals( adSize ) ) { return AppLovinAdSize.MREC; } else if ( AdSize.LEADERBOARD.equals( adSize ) ) { return AppLovinAdSize.LEADER; } // This is not a one of AdMob's predefined size else { // Assume fluid width, and check for height with offset tolerance final int offset = Math.abs( BANNER_STANDARD_HEIGHT - adSize.getHeight() ); if ( offset <= BANNER_HEIGHT_OFFSET_TOLERANCE ) { return AppLovinAdSize.BANNER; } } return null; }
Example 3
Source File: AppLovinCustomEventBanner.java From SDK-Network-Adapters with MIT License | 4 votes |
private AppLovinAdSize appLovinAdSizeFromLocalExtras(final Map<String, Object> localExtras) { // Handle trivial case if ( localExtras == null || localExtras.isEmpty() ) { log( ERROR, "No serverExtras provided" ); return null; } try { final int width = (Integer) localExtras.get( AD_WIDTH_KEY ); final int height = (Integer) localExtras.get( AD_HEIGHT_KEY ); // We have valid dimensions if ( width > 0 && height > 0 ) { log( DEBUG, "Valid width (" + width + ") and height (" + height + ") provided" ); // Assume fluid width, and check for height with offset tolerance final int bannerOffset = Math.abs( BANNER_STANDARD_HEIGHT - height ); final int leaderOffset = Math.abs( LEADER_STANDARD_HEIGHT - height ); if ( bannerOffset <= BANNER_HEIGHT_OFFSET_TOLERANCE ) { return AppLovinAdSize.BANNER; } else if ( leaderOffset <= LEADER_HEIGHT_OFFSET_TOLERANCE ) { return AppLovinAdSize.LEADER; } else if ( height <= AppLovinAdSize.MREC.getHeight() ) { return AppLovinAdSize.MREC; } else { log( ERROR, "Provided dimensions does not meet the dimensions required of banner or mrec ads" ); } } else { log( ERROR, "Invalid width (" + width + ") and height (" + height + ") provided" ); } } catch ( Throwable th ) { log( ERROR, "Encountered error while parsing width and height from serverExtras", th ); } return null; }