GithubHelp home page GithubHelp logo

agilie / ads-and-payment-demo-app Goto Github PK

View Code? Open in Web Editor NEW
0.0 10.0 0.0 353 KB

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.

Kotlin 100.00%

ads-and-payment-demo-app's Introduction

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.

ads-and-payment-demo-app's People

Contributors

evgendndz avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.