diff --git a/viewpagerdotsindicator-sample/build.gradle b/viewpagerdotsindicator-sample/build.gradle
index 39796bc..baf70ac 100644
--- a/viewpagerdotsindicator-sample/build.gradle
+++ b/viewpagerdotsindicator-sample/build.gradle
@@ -41,5 +41,5 @@ dependencies {
}
implementation project(':viewpagerdotsindicator')
-// implementation 'com.tbuonomo.andrui:viewpagerdotsindicator:2.1.2'
+// implementation 'com.tbuonomo.andrui:viewpagerdotsindicator:4.0'
}
diff --git a/viewpagerdotsindicator/src/main/AndroidManifest.xml b/viewpagerdotsindicator/src/main/AndroidManifest.xml
index f6547c3..569406a 100644
--- a/viewpagerdotsindicator/src/main/AndroidManifest.xml
+++ b/viewpagerdotsindicator/src/main/AndroidManifest.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/viewpagerdotsindicator/src/main/java/com/tbuonomo/viewpagerdotsindicator/BaseDotsIndicator.kt b/viewpagerdotsindicator/src/main/java/com/tbuonomo/viewpagerdotsindicator/BaseDotsIndicator.kt
index 29e8089..5046596 100644
--- a/viewpagerdotsindicator/src/main/java/com/tbuonomo/viewpagerdotsindicator/BaseDotsIndicator.kt
+++ b/viewpagerdotsindicator/src/main/java/com/tbuonomo/viewpagerdotsindicator/BaseDotsIndicator.kt
@@ -3,6 +3,8 @@ package com.tbuonomo.viewpagerdotsindicator
import android.content.Context
import android.database.DataSetObserver
import android.graphics.Color
+import android.os.Build.VERSION
+import android.os.Build.VERSION_CODES
import android.util.AttributeSet
import android.util.TypedValue
import android.view.View
@@ -303,4 +305,13 @@ abstract class BaseDotsIndicator @JvmOverloads constructor(context: Context,
protected val ViewPager2?.isEmpty: Boolean
get() = this != null && this.adapter != null &&
adapter!!.itemCount == 0
+
+ override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
+ super.onLayout(changed, left, top, right, bottom)
+ if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1 && layoutDirection == View.LAYOUT_DIRECTION_RTL) {
+ layoutDirection = View.LAYOUT_DIRECTION_LTR
+ rotation = 180f
+ requestLayout()
+ }
+ }
}
\ No newline at end of file
diff --git a/viewpagerdotsindicator/src/main/java/com/tbuonomo/viewpagerdotsindicator/DotsIndicator.kt b/viewpagerdotsindicator/src/main/java/com/tbuonomo/viewpagerdotsindicator/DotsIndicator.kt
index e4df584..37b8610 100644
--- a/viewpagerdotsindicator/src/main/java/com/tbuonomo/viewpagerdotsindicator/DotsIndicator.kt
+++ b/viewpagerdotsindicator/src/main/java/com/tbuonomo/viewpagerdotsindicator/DotsIndicator.kt
@@ -2,8 +2,11 @@ package com.tbuonomo.viewpagerdotsindicator
import android.animation.ArgbEvaluator
import android.content.Context
+import android.os.Build.VERSION
+import android.os.Build.VERSION_CODES
import android.util.AttributeSet
import android.view.LayoutInflater
+import android.view.View
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import android.widget.ImageView
import android.widget.LinearLayout
@@ -66,6 +69,11 @@ class DotsIndicator @JvmOverloads constructor(context: Context, attrs: Attribute
val dot = LayoutInflater.from(context).inflate(R.layout.dot_layout, this, false)
val imageView = dot.findViewById(R.id.dot)
val params = imageView.layoutParams as RelativeLayout.LayoutParams
+
+ if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
+ dot.layoutDirection = View.LAYOUT_DIRECTION_LTR
+ }
+
params.height = dotsSize.toInt()
params.width = params.height
params.setMargins(dotsSpacing.toInt(), 0, dotsSpacing.toInt(), 0)
diff --git a/viewpagerdotsindicator/src/main/java/com/tbuonomo/viewpagerdotsindicator/SpringDotsIndicator.kt b/viewpagerdotsindicator/src/main/java/com/tbuonomo/viewpagerdotsindicator/SpringDotsIndicator.kt
index a2b2771..4832911 100644
--- a/viewpagerdotsindicator/src/main/java/com/tbuonomo/viewpagerdotsindicator/SpringDotsIndicator.kt
+++ b/viewpagerdotsindicator/src/main/java/com/tbuonomo/viewpagerdotsindicator/SpringDotsIndicator.kt
@@ -2,6 +2,8 @@ package com.tbuonomo.viewpagerdotsindicator
import android.content.Context
import android.graphics.drawable.GradientDrawable
+import android.os.Build.VERSION
+import android.os.Build.VERSION_CODES
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
@@ -12,7 +14,6 @@ import android.widget.LinearLayout.HORIZONTAL
import android.widget.RelativeLayout
import androidx.dynamicanimation.animation.SpringAnimation
import androidx.dynamicanimation.animation.SpringForce
-import androidx.viewpager.widget.ViewPager.OnPageChangeListener
import com.tbuonomo.viewpagerdotsindicator.BaseDotsIndicator.Type.SPRING
class SpringDotsIndicator @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null,
@@ -112,6 +113,10 @@ class SpringDotsIndicator @JvmOverloads constructor(context: Context, attrs: Att
private fun buildDot(stroke: Boolean): ViewGroup {
val dot = LayoutInflater.from(context).inflate(R.layout.spring_dot_layout, this,
false) as ViewGroup
+ if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
+ dot.layoutDirection = View.LAYOUT_DIRECTION_LTR
+ }
+
val dotView = dot.findViewById(R.id.spring_dot)
dotView.setBackgroundResource(
if (stroke) R.drawable.spring_dot_stroke_background else R.drawable.spring_dot_background)
@@ -145,22 +150,6 @@ class SpringDotsIndicator @JvmOverloads constructor(context: Context, attrs: Att
setUpDotBackground(true, dots[index])
}
- fun buildOnPageChangedListener2(): OnPageChangeListener {
- return object : OnPageChangeListener {
- override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
- val globalPositionOffsetPixels = position * (dotsSize + dotsSpacing * 2) + (dotsSize + dotsSpacing * 2) *
- positionOffset
- val indicatorTranslationX = globalPositionOffsetPixels + dotsStrokeWidth / 2f
- dotIndicatorSpring?.spring?.finalPosition = indicatorTranslationX
- dotIndicatorSpring?.animateToFinalPosition(indicatorTranslationX)
- }
-
- override fun onPageSelected(position: Int) {}
-
- override fun onPageScrollStateChanged(state: Int) {}
- };
- }
-
override fun buildOnPageChangedListener(): OnPageChangeListenerHelper {
return object : OnPageChangeListenerHelper() {
diff --git a/viewpagerdotsindicator/src/main/java/com/tbuonomo/viewpagerdotsindicator/WormDotsIndicator.kt b/viewpagerdotsindicator/src/main/java/com/tbuonomo/viewpagerdotsindicator/WormDotsIndicator.kt
index b2e390e..e65b835 100644
--- a/viewpagerdotsindicator/src/main/java/com/tbuonomo/viewpagerdotsindicator/WormDotsIndicator.kt
+++ b/viewpagerdotsindicator/src/main/java/com/tbuonomo/viewpagerdotsindicator/WormDotsIndicator.kt
@@ -2,6 +2,8 @@ package com.tbuonomo.viewpagerdotsindicator
import android.content.Context
import android.graphics.drawable.GradientDrawable
+import android.os.Build.VERSION
+import android.os.Build.VERSION_CODES
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
@@ -116,6 +118,9 @@ class WormDotsIndicator @JvmOverloads constructor(context: Context, attrs: Attri
private fun buildDot(stroke: Boolean): ViewGroup {
val dot = LayoutInflater.from(context).inflate(R.layout.worm_dot_layout, this,
false) as ViewGroup
+ if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
+ dot.layoutDirection = View.LAYOUT_DIRECTION_LTR
+ }
val dotImageView = dot.findViewById(R.id.worm_dot)
dotImageView.setBackgroundResource(
if (stroke) R.drawable.worm_dot_stroke_background else R.drawable.worm_dot_background)