/ads-and-payment-demo-app

The demo application demonstrates the integration of several advertising platforms in a single application and the use of advertising banners in non-standard situations. The application emulates the process of purchasing movie tickets with the ability to choose between available cinemas.

Primary LanguageKotlin

AdsDemoApp

The demo application demonstrates the integration of several advertising platforms in a single application and the use of advertising banners in non-standard situations. The application emulates the process of purchasing movie tickets with the ability to choose between available cinemas.

The following advertising platforms are used:

  1. Using with Google Maps

    Google maps

  2. Using as an element of GridView

    • (Leadbolt)

      GridView element - Leadbolt

    • (Adform)

      GridView element - Adform

  3. Using inside of CoordinatorLayout

    Inside CoordinatorLayout

  4. Handling the back button as a separate event (implemented only for Leadbolt)

Add dependencies

1. Leadbolt

  • To add an SDK to the project, you need to download the .jar file at this link.
  • Put the downloaded file in the libs folder of your application or module.
  • Add a dependency to the build.gradle file of the application / module level:
      implementation fileTree(dir: 'libs', include: ['*.jar'])
      implementation "com.google.android.gms:play-services-base:[actual_version]"
  • More detailed instructions can be found on the link.

2. Adform

  • Add to the build.gradle file of the project level repository:
      allprojects {
          repositories {
              ...
              maven { url "https://github.com/adform/adform-android-sdk/raw/master/releases/" }
          }
      }
  • Add a dependency to the build.gradle file of the application / module level:
      implementation "com.adform.advertising.sdk:advertising-sdk:[actual_version]@aar"
      implementation "com.google.android.gms:play-services-ads:[actual_version]"
  • More detailed instructions can be found on the link.

3. InMobi

Interaction with advertising SDK

An interface AdProvider has been created to interact with various SDK's:

interface AdProvider : LifecycleObserver {

   fun init(context: Context)
   
   fun inflateDefaultBanner(parent: ViewGroup, lifecycleOwner: LifecycleOwner)
   
   fun loadAdForDefaultBanner(lifecycleOwner: LifecycleOwner, observer: Observer<AdLoadingEvent>)
   
   fun inflateBigBanner(parent: ViewGroup, lifecycleOwner: LifecycleOwner)
   
   fun loadAdForBigBanner(lifecycleOwner: LifecycleOwner, observer: Observer<AdLoadingEvent>)

   fun displayFullScreenAd(
       context: Context,
       lifecycleOwner: LifecycleOwner,
       observer: Observer<FullScreenAdEvent>
   )

   fun createGridViewHolder(parent: ViewGroup): AdViewHolder
   
   fun getAdAdapterManager(): AdRecyclerView.AdAdapterManager
   
   fun getAdLayoutManager(): AdRecyclerView.AdLayoutManager
}
  • SDK initialization
    fun init(context: Context)
  • Inflate View, that will contain and display a standard banner ad.
    It adds the created View to the passed parent
    fun inflateDefaultBanner(parent: ViewGroup, lifecycleOwner: LifecycleOwner)
    • LifecycleOwner is used to process the lifecycle methods of the object that caused this method (for example, canceling the loading of advertising data if the user returned to the previous screen).
      Adform also requires calling lifecycle methods for its View.
  • Initializes the loading of ad data.
    Received data is returned to Observer<AdLoadingEvent>
    fun loadAdForDefaultBanner(lifecycleOwner: LifecycleOwner, observer: Observer<AdLoadingEvent>)
  • Inflate View for a "Big Banner", that will contain and display a standard banner ad.
    It adds the created View to the passed parent
    fun inflateBigBanner(parent: ViewGroup, lifecycleOwner: LifecycleOwner)
    • LifecycleOwner is used to process the lifecycle methods of the object that caused this method (for example, canceling the loading of advertising data if the user returned to the previous screen).
      Adform also requires calling lifecycle methods for its View.
    • "Big Banner" is:
      • Adform is an interactive ad with a given height.
      • Leadbolt is a native banner with a height of 300dp.
      • Inmobi there is the implementation of native advertising with given dimensions.
  • Initializes the loading of ad data for a "Big Banner".
    Received data is returned to Observer<AdLoadingEvent>
    fun loadAdForBigBanner(lifecycleOwner: LifecycleOwner, observer: Observer<AdLoadingEvent>)
  • Initializes the display of full-screen advertising.
    Full-screen advertising events are returned to Observer<FullScreenAdEvent> (for example, closing ads, ending downloads, etc.)
    fun displayFullScreenAd(
          context: Context,
          lifecycleOwner: LifecycleOwner,
          observer: Observer<FullScreenAdEvent>
    )
  • Returns an object of the AdViewHolder class that extends RecyclerView.ViewHolder for further use in RecyclerView.Adapter.
    fun createGridViewHolder(parent: ViewGroup): AdViewHolder
  • Returns an object of the AdRecyclerView.AdAdapterManager class that manages the list of data displayed in RecyclerView with the addition of advertisements to this list
    fun getAdAdapterManager(): AdRecyclerView.AdAdapterManager
  • Returns an object of the AdRecyclerView.AdAdapterManager class, which in turn creates a RecyclerView.LayoutManager, which will manage a specific AdProvider implementation for displaying advertisements in RecyclerView.
    For example, for Adform, you need to use built-in mechanisms for displaying advertisements in RecyclerView, but they do not support displaying advertisements in custom View like an item in GridLayoutManager
    fun getAdLayoutManager(): AdRecyclerView.AdLayoutManager

Payment system

For the payment system was used Stripe.