@@ -27,6 +27,7 @@ import android.view.Gravity
2727import android.view.LayoutInflater
2828import android.view.ViewGroup
2929import android.widget.FrameLayout
30+ import android.widget.ImageView
3031import androidx.core.view.ViewCompat
3132import androidx.fragment.app.Fragment
3233import androidx.fragment.app.FragmentActivity
@@ -111,6 +112,7 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
111112 }
112113 }
113114
115+
114116 /* *
115117 * Add Image Fragment
116118 * @param drawable Drawable Type Image
@@ -122,7 +124,18 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
122124 }
123125
124126 /* *
125- * Add Fragment Fragments
127+ * Add Image Fragment with Image Scale Type
128+ * @param drawable Drawable Type Image
129+ * @param scaleType ImageView ScaleType
130+ */
131+ fun addImageFragment (drawable : Drawable , scaleType : ImageView .ScaleType ) {
132+ checkInitial()
133+ val imageFragment = ImageFragment .newInstance(drawable, scaleType)
134+ slideActionAdapter!! .addFragment(imageFragment)
135+ }
136+
137+ /* *
138+ * Add Image Fragments
126139 * @param drawables Drawables ArrayList
127140 */
128141 fun addDrawableFragments (drawables : ArrayList <Drawable >) {
@@ -133,6 +146,20 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
133146 }
134147 }
135148
149+
150+ /* *
151+ * Add Image Fragments with Image Scale Type
152+ * @param drawables Drawables ArrayList
153+ * @param scaleType ImageView ScaleType
154+ */
155+ fun addDrawableFragments (drawables : ArrayList <Drawable >, scaleType : ImageView .ScaleType ) {
156+ checkInitial()
157+
158+ for (i in 0 .. drawables.size) {
159+ slideActionAdapter!! .addFragment(ImageFragment .newInstance(drawables[i], scaleType))
160+ }
161+ }
162+
136163 /* *
137164 * Add Image Fragment
138165 * @param bitmap Bitmap Type Image
@@ -143,6 +170,17 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
143170 slideActionAdapter!! .addFragment(imageFragment)
144171 }
145172
173+ /* *
174+ * Add Image Fragment with Image Scale Type
175+ * @param bitmap Bitmap Type Image
176+ * @param scaleType ImageView ScaleType
177+ */
178+ fun addImageFragment (bitmap : Bitmap , scaleType : ImageView .ScaleType ) {
179+ checkInitial()
180+ val imageFragment = ImageFragment .newInstance(bitmap, scaleType)
181+ slideActionAdapter!! .addFragment(imageFragment)
182+ }
183+
146184 /* *
147185 * Add Bitmap Fragments
148186 * @param bitmaps Bitmap ArrayList
@@ -155,6 +193,19 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
155193 }
156194 }
157195
196+ /* *
197+ * Add Bitmap Fragments with Scale Type
198+ * @param bitmaps Bitmap ArrayList
199+ * @param scaleType ImageView ScaleType
200+ */
201+ fun addBitmapFragments (bitmaps : ArrayList <Bitmap >, scaleType : ImageView .ScaleType ) {
202+ checkInitial()
203+
204+ for (i in 0 .. bitmaps.size) {
205+ slideActionAdapter!! .addFragment(ImageFragment .newInstance(bitmaps[i], scaleType))
206+ }
207+ }
208+
158209 /* *
159210 * Add Fragment
160211 * @param fragment New Fragment
@@ -275,7 +326,7 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
275326 autoSlideHandler!! .postDelayed(object : Runnable {
276327 override fun run () {
277328 if (slideActionAdapter != null && autoSlideEnabled) {
278- if (viewPager.currentItem < slideActionAdapter!! .itemCount) {
329+ if (viewPager.currentItem < slideActionAdapter!! .itemCount - 1 ) {
279330 viewPager.currentItem = viewPager.currentItem + 1
280331 }
281332 else {
@@ -290,7 +341,6 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
290341 else {
291342 if (autoSlideHandler != null ) {
292343 autoSlideHandler!! .removeCallbacksAndMessages(null )
293- autoSlideHandler = null
294344 }
295345 }
296346 }
@@ -299,7 +349,7 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
299349 * Get Current State of Auto Slide
300350 * @return Enabled or Disabled Auto Slide
301351 */
302- fun getEnableAutoSlide (): Boolean = autoSlideEnabled
352+ fun isEnableAutoSlide (): Boolean = autoSlideEnabled
303353
304354 /* *
305355 * Check Initial
0 commit comments