Class DynamicAdUtils
java.lang.Object
com.pranavpandey.android.dynamic.ads.util.DynamicAdUtils
Helper class to perform ads related operations.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final float
Factor to calculate the acceptable ad size. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.android.gms.ads.AdSize
Returns the ad size for the supplied activity.static com.google.android.gms.ads.AdSize
Returns the ad size for the supplied activity and container.static int
getAppOpenAdOrientation
(Context activity) Returns the orientation for the app open ad.static boolean
isOnlyStore
(com.google.android.gms.ads.nativead.NativeAd nativeAd) Checks whether the ad has only the store data.static void
Set drawable for the image view and manage its visibility according to the data.static void
Set rating value for the rating bar.static void
set
(TextView textView, CharSequence text) Set text for the text view and manage its visibility according to the data.static void
setEnabled
(View view, boolean enabled) Set a view enabled or disabled.static void
setVisibility
(View view, int visibility) Set visibility for the view.
-
Field Details
-
AD_SIZE_FACTOR
public static final float AD_SIZE_FACTORFactor to calculate the acceptable ad size.- See Also:
-
-
Constructor Details
-
DynamicAdUtils
public DynamicAdUtils()
-
-
Method Details
-
getAdSize
@NonNull public static com.google.android.gms.ads.AdSize getAdSize(@Nullable Context activity, @Nullable View container) Returns the ad size for the supplied activity and container.- Parameters:
activity
- The activity to calculate the ad size.container
- The ad container to be used.- Returns:
- The ad size for the supplied activity and container.
- See Also:
-
AdSize.FLUID
-
getAdSize
Returns the ad size for the supplied activity.- Parameters:
activity
- The activity to calculate the ad size.- Returns:
- The ad size for the supplied activity.
- See Also:
-
getAppOpenAdOrientation
Returns the orientation for the app open ad.- Parameters:
activity
- The activity to retrieve the screen orientation.- Returns:
- The orientation for the app open ad.
- See Also:
-
AppOpenAd.APP_OPEN_AD_ORIENTATION_PORTRAIT
AppOpenAd.APP_OPEN_AD_ORIENTATION_LANDSCAPE
-
isOnlyStore
Checks whether the ad has only the store data.- Parameters:
nativeAd
- The ad to be checked.- Returns:
true
if the ad has only the store data.
-
set
Set drawable for the image view and manage its visibility according to the data.- Parameters:
imageView
- The image view to set the drawable.drawable
- The drawable to be set.
-
set
Set text for the text view and manage its visibility according to the data.- Parameters:
textView
- The text view to set the text.text
- The text to be set.
-
set
Set rating value for the rating bar.- Parameters:
ratingBar
- The rating bar to set the rating.rating
- The rating value to be set.
-
setVisibility
Set visibility for the view.- Parameters:
view
- The view to set the visibility.visibility
- The visibility to be set.
-
setEnabled
Set a view enabled or disabled.- Parameters:
view
- The view to be enabled or disabled.enabled
-true
to enable the view.
-