Skip to content

🪧 Banner is an library for ad view that implements automatic slide effects using ViewPager2.

License

Notifications You must be signed in to change notification settings

KennethSS/Banner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Banner


🪧 Banner is an library for ad view that implements automatic slide effects using ViewPager2.

License

Dependency Gradle

Add below codes to your root build.gradle file (not your module build.gradle file).

allprojects {
  repositories {
      jcenter()
      maven { url "https://jitpack.io" }
  }
}

And add a dependency code to your module's build.gradle file.

dependencies {
implementation 'com.github.KennethSS:Banner:1.0.2'
}

Usage

<com.solar.kenneth.banner.BannerView
  android:id="@+id/banner_view"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  app:ratio_width="18"
  app:ratio_height="13"
  app:infinity="true"
  app:autoScroll="true"/>
bannerView.addBannerViewListener(object: BannerViewListener {
    override fun onBannerBinding(iv: ImageView, banner: Banner) {
      // Something to load for image
    }
  })

UseCase RecyclerView

class RecyclerViewAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
  override fun onViewRecycled(holder: RecyclerView.ViewHolder) {
  if (holder is BannerViewHolder) {
    holder.recycled()
  }
  super.onViewRecycled(holder)
  }
}

class BannerViewHolder(view: View) : RecyclerView.ViewHolder(view) { 
  init {
    bannerView.addBannerViewListener(object: BannerViewListener {
      override fun onBannerBinding(iv: ImageView, banner: Banner) {

      }
    })

    bannerView.setBannerList(lists)
  }

  fun bind() {
    bannerView.startAutoSlide()
  }

  fun recycled() {
    bannerView.stopAutoSlide()
  }
}

About

🪧 Banner is an library for ad view that implements automatic slide effects using ViewPager2.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages