Skip to content

Commit

Permalink
PegUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
goku143u committed Feb 17, 2024
1 parent 85990f8 commit 864e0db
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .gradle/buildOutputCleanup/cache.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Sun Aug 27 00:13:51 PKT 2023
gradle.version=8.3
#Fri Feb 16 22:51:39 PKT 2024
gradle.version=8.5
58 changes: 27 additions & 31 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pegutils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ dependencies {
implementation 'com.google.android.material:material:1.11.0'

// Exif interface (for image rotation)
implementation 'androidx.exifinterface:exifinterface:1.3.6'
implementation 'androidx.exifinterface:exifinterface:1.3.7'

// Navigational Components
implementation 'androidx.navigation:navigation-fragment-ktx:2.7.7'
implementation 'androidx.navigation:navigation-ui-ktx:2.7.7'

// Firebase
implementation 'com.google.firebase:firebase-crashlytics-ktx:18.6.1'
implementation 'com.google.firebase:firebase-analytics-ktx:21.5.0'
implementation 'com.google.firebase:firebase-crashlytics-ktx:18.6.2'
implementation 'com.google.firebase:firebase-analytics-ktx:21.5.1'

// Glide
implementation 'com.github.bumptech.glide:glide:4.16.0'
Expand All @@ -68,7 +68,7 @@ publishing {
release(MavenPublication) {
groupId = 'dev.pegasus.utils'
artifactId = 'utils'
version = '1.0.0-alpha-12'
version = '1.0.0-alpha-13'

afterEvaluate {
from components.release
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.pegasus.utils.extensions.uiComponents

import android.content.res.Resources
import android.os.Handler
import android.view.View
import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout
Expand Down Expand Up @@ -62,4 +63,28 @@ fun ViewPager2.addCarouselEffect(enableZoom: Boolean = true) {
}
}
setPageTransformer(compositePageTransformer)
}

/**
* -> e.g. viewPager2.startAutoScroll(1000)
* @param intervalMillis: Time in milliseconds to change the slide
* @param autoScrollHandler: Pass your own handler to handle scroll
*
* Note: passing same handler will be able to remove scroll
*/

fun ViewPager2.startAutoScroll(autoScrollHandler: Handler, intervalMillis: Long = 3000) {
val autoScrollRunnable = object : Runnable {
override fun run() {
val currentItem = currentItem
val nextItem = if (currentItem == adapter?.itemCount?.minus(1)) 0 else currentItem + 1
this@startAutoScroll.currentItem = nextItem
autoScrollHandler.postDelayed(this, intervalMillis)
}
}
autoScrollHandler.postDelayed(autoScrollRunnable, intervalMillis)
}

fun ViewPager2.stopAutoScroll(handler: Handler) {
handler.removeCallbacksAndMessages(null)
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ dependencyResolutionManagement {
mavenCentral()
}
}
rootProject.name = "peg-utils"
rootProject.name = "Pegasus Utils"
include ':app'
include ':pegutils'

0 comments on commit 864e0db

Please sign in to comment.