Code Monkey home page Code Monkey logo

adslib's Introduction

AdsLib

This project contains library for easy implementation of ad mob according to ad policies.

implementation

Add flowing in maven { url 'https://jitpack.io' }

then following line in app gradle

implementation 'com.github.tariqzia7523:AdsLib:1.0.1'

Usage

you can refer to MainActivity in sample project first of all set orignal id and ad count on splash using following code,orignal id will only be called on release version

    val mySharedPref = MySharedPref(this)
    mySharedPref.bannerID = "orignal_banner_id"
    mySharedPref.rewardID = "orignal_reward_id"
    mySharedPref.nativeID = "orignal_native_id"
    mySharedPref.interID = "orignal_interstitial_id"
    mySharedPref.appOpenID = "orignal_app_opn_id"
    AddInitilizer.adCounter = 0
    //ad count refers to show interstial ad after these number of clicks

make a global variable

addInitilizer = AddInitilizer(applicationContext,this, BuildConfig.DEBUG){ // on add close call back will run in this fun

         val tag = it // this is the tag passed while displaying ad calling
         // now place checks and use it for further call


     }
     
 by passing interface will start loading interstitial ad
 or pass null if interstitial ad is not required for the activity
 // addInitilizer = AddInitilizer(applicationContext,this,null)
 
  //loading banner
    addInitilizer.loadBanner(findViewById(R.id.banner_container))

    // pass three paramenters for loading asnd displaying native add templateView, placeholder text, and ad container
    addInitilizer.loadNativeAdd(findViewById(R.id.nativeTemplateView),findViewById(R.id.temp_add_text),findViewById(R.id.add_container))

    // or if add loading is required,that will be displayed later then call
    //addInitilizer.loadNativeAdd(null,null,null)
    //for displaying native add call
    //addInitilizer.setnativeAddOnView(findViewById(R.id.nativeTemplateView))

    findViewById<View>(R.id.show_intestial).setOnClickListener {
        if(!addInitilizer.showInterstailAdd("Any tag")){
            // TODO actual task
        }
    }
    
    use following code in layouts
    
      <RelativeLayout
    android:id="@+id/add_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/gnt_outline_shape"
    android:minHeight="@dimen/_130sdp"
    android:layout_marginLeft="@dimen/_10sdp"
    android:layout_marginRight="@dimen/_10sdp"
    android:layout_marginTop="@dimen/_10sdp"
    android:layout_alignParentBottom="true">

    <com.module.ads.TemplateView
        android:id="@+id/nativeTemplateView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="gone"
        app:gnt_template_type="@layout/gnt_small_template_view" />

    <TextView
        android:id="@+id/temp_add_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="@string/ad_will_display_hare" />
</RelativeLayout>

you can use app:gnt_template_type="@layout/gnt_small_template_view" or app:gnt_template_type="@layout/gnt_medium_template_view"

you can also use TemplateView sepratly

<com.module.ads.TemplateView android:id="@+id/nativeTemplateView" android:layout_width="match_parent" android:layout_height="wrap_content" android:visibility="gone" android:background="@drawable/gnt_outline_shape" app:gnt_template_type="@layout/gnt_medium_template_view"/>

to add open app add following line of code in Application class oncreate method val appOpenManager = AppOpenManager(this, MySharedPref(this), BuildConfig.DEBUG)

InApp purcheses

project has in app purcheses to remove ad calls use following method. addInitilizer.goAddFree()

Showing ad in list (RecylerView)

val list = ArrayList()

    val myAdapterForAppList = MyAdapter(this@MainActivity, list)

    val admobNativeAdAdapter: AdmobNativeAdAdapter = AdmobNativeAdAdapter.Builder.with( this@MainActivity, myAdapterForAppList, "small", BuildConfig.DEBUG).adItemInterval(8).setContext(this@MainActivity).build()

    recylerView.layoutManager = LinearLayoutManager(this@MainActivity)

   recylerView.adapter = admobNativeAdAdapter

adslib's People

Contributors

tariqzia7523 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.