Skip to content

kmcgill88/McPicSlider-Android

Repository files navigation

McPicSlider-Android

Installation

  1. Add the JitPack repository to your build file
allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}
  1. Add the dependency
dependencies {
   compile 'com.github.kmcgill88:McPicSlider-Android:0.1.0'
}

Optionally, declare McPicSliderFullScreenActivity in your Manifest

<activity
    android:name="com.mcgilldevtech.mcpicslider.McPicSliderFullScreenActivity"
    android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen">
</activity>
  1. Add XML
<com.mcgilldevtech.mcpicslider.McViewPager
    android:id="@+id/mcViewPager"
    android:layout_width="match_parent"
    android:layout_height="400dp" />
  1. Write a little code
val mcPicSlider = findViewById<McViewPager>(R.id.mcViewPager)

mcPicSlider.useFullScreen = true // Default: False. If true, you must declare McPicSliderFullScreenActivity in your manifest
mcPicSlider.adapter = McPicSliderAdapterFresco(
      context = this,
      onImageTapped = { position, url ->
          Toast.makeText(this, "You clicked image " + (position + 1), Toast.LENGTH_SHORT).show()
      },
      images = listOf(
          "https://cats.com/scared-kitten.jpg",
          "https://cats.com/hypoallergenic-cat-breeds.jpg",
          "https://cats.com/super-cool-cat.jpg"
      )
)

Author

Kevin McGill, [email protected]

License

McPicSlider-Android is available under the MIT license. See the LICENSE file for more info.