@@ -27,6 +27,7 @@ import android.view.Gravity
27
27
import android.view.LayoutInflater
28
28
import android.view.ViewGroup
29
29
import android.widget.FrameLayout
30
+ import android.widget.ImageView
30
31
import androidx.core.view.ViewCompat
31
32
import androidx.fragment.app.Fragment
32
33
import androidx.fragment.app.FragmentActivity
@@ -111,6 +112,7 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
111
112
}
112
113
}
113
114
115
+
114
116
/* *
115
117
* Add Image Fragment
116
118
* @param drawable Drawable Type Image
@@ -122,7 +124,18 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
122
124
}
123
125
124
126
/* *
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
126
139
* @param drawables Drawables ArrayList
127
140
*/
128
141
fun addDrawableFragments (drawables : ArrayList <Drawable >) {
@@ -133,6 +146,20 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
133
146
}
134
147
}
135
148
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
+
136
163
/* *
137
164
* Add Image Fragment
138
165
* @param bitmap Bitmap Type Image
@@ -143,6 +170,17 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
143
170
slideActionAdapter!! .addFragment(imageFragment)
144
171
}
145
172
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
+
146
184
/* *
147
185
* Add Bitmap Fragments
148
186
* @param bitmaps Bitmap ArrayList
@@ -155,6 +193,19 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
155
193
}
156
194
}
157
195
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
+
158
209
/* *
159
210
* Add Fragment
160
211
* @param fragment New Fragment
@@ -275,7 +326,7 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
275
326
autoSlideHandler!! .postDelayed(object : Runnable {
276
327
override fun run () {
277
328
if (slideActionAdapter != null && autoSlideEnabled) {
278
- if (viewPager.currentItem < slideActionAdapter!! .itemCount) {
329
+ if (viewPager.currentItem < slideActionAdapter!! .itemCount - 1 ) {
279
330
viewPager.currentItem = viewPager.currentItem + 1
280
331
}
281
332
else {
@@ -290,7 +341,6 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
290
341
else {
291
342
if (autoSlideHandler != null ) {
292
343
autoSlideHandler!! .removeCallbacksAndMessages(null )
293
- autoSlideHandler = null
294
344
}
295
345
}
296
346
}
@@ -299,7 +349,7 @@ class SlideActionLayout @JvmOverloads constructor(context: Context, attrs: Attri
299
349
* Get Current State of Auto Slide
300
350
* @return Enabled or Disabled Auto Slide
301
351
*/
302
- fun getEnableAutoSlide (): Boolean = autoSlideEnabled
352
+ fun isEnableAutoSlide (): Boolean = autoSlideEnabled
303
353
304
354
/* *
305
355
* Check Initial
0 commit comments