Skip to content

Commit aeaa165

Browse files
Merge pull request #1 from Aftermoon-dev/1.1.0-beta2
Release 1.1.0-beta2
2 parents ac39a18 + 0083bda commit aeaa165

File tree

9 files changed

+108
-33
lines changed

9 files changed

+108
-33
lines changed

.idea/misc.xml

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
<h1 align="center">SlideActionLayout</h1>
22

33
<p align="center">
4-
<a href="https://android-arsenal.com/api?level=16"><img alt="API" src="https://img.shields.io/badge/API-16%2B-brightgreen.svg?style=flat"/></a>
54
<a href="http://www.apache.org/licenses/LICENSE-2.0"><img alt="License" src="https://img.shields.io/github/license/Aftermoon-dev/SlideActionLayout"></a>
6-
<a href="https://github.com/Aftermoon-dev/SlideActionLayout"><img alt="Github Stars" src="https://img.shields.io/github/stars/Aftermoon-dev/SlideActionLayout?style=social"></a>
5+
<a href="https://android-arsenal.com/api?level=16"><img alt="API" src="https://img.shields.io/badge/API-16%2B-brightgreen.svg?style=flat"/></a>
76
<a href="https://jitpack.io/#Aftermoon-dev/SlideActionLayout"><img alt="Jitpack Version" src="https://jitpack.io/v/Aftermoon-dev/SlideActionLayout.svg"></a>
8-
</p>
9-
7+
<a href="https://github.com/Aftermoon-dev/SlideActionLayout/actions/workflows/android.yml"><img alt="Build" src="https://img.shields.io/github/workflow/status/Aftermoon-dev/SlideActionLayout/Android%20CI"></a>
8+
<a href="https://github.com/Aftermoon-dev/SlideActionLayout"><img alt="Github Stars" src="https://img.shields.io/github/stars/Aftermoon-dev/SlideActionLayout?style=social"></a>
109
<p align="center">
1110
Simple SlideView Layout Library with Fragment, ViewPager2 for Android
1211
</p>
1312

1413
# Screenshots
1514
<p align="center">
16-
<img src="https://user-images.githubusercontent.com/3215313/116183122-4dd99d80-a758-11eb-8924-f6d61c33c782.png" width="30%">
17-
<img src="https://user-images.githubusercontent.com/3215313/116183433-ce000300-a758-11eb-8bdf-a2e146ddcb7c.png" width="30%">
18-
<img src="https://user-images.githubusercontent.com/3215313/116183125-4f0aca80-a758-11eb-92ec-51002fe9676a.png" width="30%">
15+
<img src="https://user-images.githubusercontent.com/3215313/147399993-6d3815c9-96e7-4deb-8770-b92b80d7c98d.png" width="30%">
16+
<img src="https://user-images.githubusercontent.com/3215313/147399994-c45ffb1b-52fe-4cfa-a7bf-814d70dc26a6.png" width="30%">
17+
<img src="https://user-images.githubusercontent.com/3215313/147399995-a9e9f177-5606-4430-8a84-17a6f988caf0.png" width="30%">
1918
</p>
2019

2120
# Download
2221

2322
1. Add JitPack Repository to Your Project `build.gradle` File
24-
```
25-
allprojects {
26-
repositories {
27-
...
28-
maven { url 'https://jitpack.io' }
23+
```
24+
allprojects {
25+
repositories {
26+
...
27+
maven { url 'https://jitpack.io' }
28+
}
29+
}
30+
```
31+
2. Add `SlideActionLayout` Dependency to Your Module `build.gradle` File (`VERSION` need change to Last Release Below)
32+
33+
[![](https://jitpack.io/v/Aftermoon-dev/SlideActionLayout.svg)](https://jitpack.io/#Aftermoon-dev/SlideActionLayout)
34+
```
35+
dependencies {
36+
implementation 'com.github.Aftermoon-dev:SlideActionLayout:VERSION'
2937
}
30-
}
31-
```
32-
33-
2. Add `SlideActionLayout` Dependency to Your Module `build.gradle` File ([![](https://jitpack.io/v/Aftermoon-dev/SlideActionLayout.svg)](https://jitpack.io/#Aftermoon-dev/SlideActionLayout))
34-
```
35-
dependencies {
36-
implementation 'com.github.Aftermoon-dev:SlideActionLayout:Tag'
37-
}
38-
```
38+
```
3939

4040
# Usage
4141
Will be Later

SlideActionLayout/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ afterEvaluate {
5050
release(MavenPublication) {
5151
from components.release
5252
groupId = 'com.github.Aftermoon-dev.SlideActionLayout'
53-
version = '1.1.0-beta1'
53+
version = '1.1.0-beta2'
5454
}
5555

5656
debug(MavenPublication) {
5757
from components.debug
5858
groupId = 'com.github.Aftermoon-dev.SlideActionLayout'
59-
version = '1.1.0-beta1'
59+
version = '1.1.0-beta2'
6060
}
6161
}
6262
}

SlideActionLayout/src/main/java/dev/aftermoon/slideactionlayout/SlideActionLayout.kt

+54-4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import android.view.Gravity
2727
import android.view.LayoutInflater
2828
import android.view.ViewGroup
2929
import android.widget.FrameLayout
30+
import android.widget.ImageView
3031
import androidx.core.view.ViewCompat
3132
import androidx.fragment.app.Fragment
3233
import 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

SlideActionLayout/src/main/java/dev/aftermoon/slideactionlayout/createindicator/CreateIndicator.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import android.graphics.Color
2222
import android.graphics.drawable.GradientDrawable
2323
import android.graphics.drawable.LayerDrawable
2424
import android.graphics.drawable.StateListDrawable
25+
import androidx.annotation.ColorInt
2526
import androidx.core.content.ContextCompat
2627
import androidx.core.content.res.ResourcesCompat
2728
import androidx.core.graphics.BlendModeColorFilterCompat
@@ -36,7 +37,7 @@ class CreateIndicator {
3637
* @param selectedColor Selected Circle Fill Color Value (argb)
3738
* @param unselectedColor Unselected Circle Fill Color Value (argb)
3839
*/
39-
fun createCircleIndicator(context: Context, selectedColor: Int, unselectedColor: Int): StateListDrawable {
40+
fun createCircleIndicator(context: Context, @ColorInt selectedColor: Int, @ColorInt unselectedColor: Int): StateListDrawable {
4041
val stateListDrawable = StateListDrawable()
4142

4243
val dotLayout = ResourcesCompat.getDrawable(context.resources, R.drawable.selected_dot, null) as LayerDrawable

SlideActionLayout/src/main/java/dev/aftermoon/slideactionlayout/fragment/ImageFragment.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class ImageFragment: Fragment() {
6969
super.onViewCreated(view, savedInstanceState)
7070
arguments?.let {
7171
bitmap = it.getParcelable("image")
72-
scaleType = it.getSerializable("scaleType") as ImageView.ScaleType
72+
scaleType = it.getSerializable("scaleType") as ImageView.ScaleType?
7373

7474
if(bitmap != null) {
7575
Log.d(this.javaClass.simpleName, "Image Success")

app/src/main/java/dev/aftermoon/slideaction_demo/MainActivity.kt

+16-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616

1717
package dev.aftermoon.slideaction_demo
1818

19-
import android.graphics.Color
2019
import androidx.appcompat.app.AppCompatActivity
2120
import android.os.Bundle
22-
import android.os.Handler
23-
import android.os.Looper
2421
import android.view.Gravity
22+
import android.widget.Button
2523
import androidx.core.content.ContextCompat
2624
import androidx.viewpager2.widget.ViewPager2
2725
import dev.aftermoon.slideactionlayout.SlideActionLayout
@@ -42,5 +40,20 @@ class MainActivity : AppCompatActivity() {
4240
ContextCompat.getDrawable(this, R.drawable.second)?.let { layout.addImageFragment(it) }
4341
ContextCompat.getDrawable(this, R.drawable.third)?.let { layout.addImageFragment(it) }
4442
layout.addFragment(TestFragment())
43+
44+
layout.setAutoSlide(3000, true)
45+
46+
val btn = findViewById<Button>(R.id.btn_autoslide)
47+
48+
btn.setOnClickListener {
49+
if (layout.isEnableAutoSlide()) {
50+
btn.text = getString(R.string.autoslide_on)
51+
layout.setEnableAutoSlide(false)
52+
}
53+
else {
54+
btn.text = getString(R.string.autoslide_off)
55+
layout.setEnableAutoSlide(true)
56+
}
57+
}
4558
}
4659
}

app/src/main/res/layout/activity_main.xml

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@
1010
<dev.aftermoon.slideactionlayout.SlideActionLayout
1111
android:id="@+id/slideactionlayout"
1212
android:layout_width="wrap_content"
13-
android:layout_height="wrap_content">
13+
android:layout_height="500dp">
1414

1515
</dev.aftermoon.slideactionlayout.SlideActionLayout>
16+
17+
<Button
18+
android:id="@+id/btn_autoslide"
19+
android:layout_width="match_parent"
20+
android:layout_height="wrap_content"
21+
android:text="@string/autoslide_off" />
22+
1623
</LinearLayout>

app/src/main/res/values/strings.xml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<resources>
22
<string name="app_name">SlideActionLayout_Demo</string>
3+
<string name="autoslide_on">Enable Auto Slide</string>
4+
<string name="autoslide_off">Disable Auto Slide</string>
35
</resources>

0 commit comments

Comments
 (0)