├── .gitignore
├── .idea
├── .name
├── appInsightsSettings.xml
├── compiler.xml
├── deploymentTargetDropDown.xml
├── gradle.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── kotlinc.xml
├── migrations.xml
├── misc.xml
├── vcs.xml
└── workspace.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle.kts
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── codebyashish
│ │ └── autoimageslider
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── codebyashish
│ │ │ └── autoimageslider
│ │ │ └── MainActivity.kt
│ └── res
│ │ ├── drawable
│ │ ├── ashish_text_bg.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── ic_launcher_foreground.xml
│ │ └── icon_face.png
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── values-night
│ │ └── themes.xml
│ │ ├── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ │ └── xml
│ │ ├── backup_rules.xml
│ │ └── data_extraction_rules.xml
│ └── test
│ └── java
│ └── com
│ └── codebyashish
│ └── autoimageslider
│ └── ExampleUnitTest.kt
├── autoimageslider
├── .gitignore
├── build.gradle.kts
├── consumer-rules.pro
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── codebyashish
│ │ └── autoimageslider
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── codebyashish
│ │ │ └── autoimageslider
│ │ │ ├── Adapter
│ │ │ └── ViewAdapter.java
│ │ │ ├── Animation
│ │ │ ├── BackgroundToForeground.kt
│ │ │ ├── CubeIn.kt
│ │ │ ├── CubeOut.kt
│ │ │ ├── DepthSlide.kt
│ │ │ ├── FidgetSpinner.kt
│ │ │ ├── FlipHorizontal.kt
│ │ │ ├── FlipVertical.kt
│ │ │ ├── ForegroundToBackground.kt
│ │ │ ├── Gate.kt
│ │ │ ├── RotateDown.kt
│ │ │ ├── RotateUp.kt
│ │ │ ├── Toss.kt
│ │ │ ├── ZoomIn.kt
│ │ │ └── ZoomOut.kt
│ │ │ ├── AutoImageSlider.kt
│ │ │ ├── Enums
│ │ │ ├── ImageActionTypes.kt
│ │ │ ├── ImageAnimationTypes.kt
│ │ │ └── ImageScaleType.kt
│ │ │ ├── ExceptionsClass.kt
│ │ │ ├── Interfaces
│ │ │ └── ItemsListener.kt
│ │ │ ├── Models
│ │ │ └── ImageSlidesModel.kt
│ │ │ ├── PageScroller.kt
│ │ │ └── PicassoTransformation.kt
│ └── res
│ │ ├── drawable
│ │ ├── indicator_selected_dash.xml
│ │ ├── indicator_selected_dot.xml
│ │ ├── indicator_unselected_dash.xml
│ │ ├── indicator_unselected_dot.xml
│ │ ├── placeholder_default_loading.jpg
│ │ ├── placeholder_image_failed.jpg
│ │ └── text_background.xml
│ │ ├── layout
│ │ ├── item_pager.xml
│ │ └── layout_slider_image.xml
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── codebyashish
│ └── autoimageslider
│ └── ExampleUnitTest.java
├── build.gradle.kts
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── local.properties
├── preview.gif
└── settings.gradle.kts
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 |
17 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | AutoImageSlider
--------------------------------------------------------------------------------
/.idea/appInsightsSettings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
44 |
45 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/deploymentTargetDropDown.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/migrations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 | 1685611455301
185 |
186 |
187 | 1685611455301
188 |
189 |
190 |
191 | 1710938037650
192 |
193 |
194 |
195 | 1710938037650
196 |
197 |
198 |
199 | 1710938158070
200 |
201 |
202 |
203 | 1710938158070
204 |
205 |
206 |
207 |
208 |
209 |
210 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Ashish Dangi
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Auto-Image-Slider-Android
2 | Android auto image slide library. Compatible for Java and Kotlin,
3 |
4 | [](https://jitpack.io/#dangiashish/Auto-Image-Slider)
5 | [](https://developer.android.com/tools/sdkmanager)
6 | [](https://www.java.com/)
7 | [](https://kotlinlang.org/)
8 | [](https://app.netlify.com/sites/androidimageslider/deploys)
9 |
10 |
11 |
12 |
16 |
17 |
18 | ### Gradle
19 |
20 | Add repository in your `build.gradle` (project-level) file :
21 | ```gradle
22 | allprojects {
23 | repositories {
24 | ...
25 | maven { url 'https://jitpack.io' }
26 | }
27 | }
28 | ```
29 | ##### OR
30 | in your `settings.gradle`
31 |
32 | ```gradle
33 | dependencyResolutionManagement {
34 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
35 | repositories {
36 | ...
37 | maven { url "https://jitpack.io" }
38 | }
39 | }
40 | ```
41 | in your `settings.gradle.kts`
42 | ```gradle
43 | dependencyResolutionManagement {
44 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
45 | repositories {
46 | maven ( url ="https://jitpack.io" )
47 | }
48 | }
49 | ```
50 | ### Add dependency :
51 |
52 | Add dependency in your `build.gradle` (module-level) file :
53 |
54 | ```groovy
55 | dependencies{
56 |
57 | implementation 'com.github.dangiashish:Auto-Image-Slider:1.0.6'
58 | }
59 | ```
60 | ### Code Snippets :
61 |
62 | #### XML
63 | ```groovy
64 |
77 | ```
78 |
79 | #### All Params
80 |
81 | ```groovy
82 | app:ais_auto_sliding="true" // Auto slide animation - true | false
83 |
84 | app:ais_corner_radius="10" // Widget Corner Radius - 0 | ....(n)
85 |
86 | app:ais_indicator_align="@string/center" // Dots Indicator Alignment - { LEFT | CENTER | RIGHT }
87 |
88 | app:ais_dots_visible="true" // Dots visibiliy - { true | false }
89 |
90 | app:ais_time_interval="1000" // Slide interval in milliseconds
91 |
92 | app:ais_slide_delay="2000" // Sliding delay by 2 seconds
93 |
94 | app:ais_placeholder="@drawable/placeholder.png" // any placeholder image untill real image load
95 |
96 | app:ais_exception_image="@drawable/error.png" // any error or failure image if image could not load
97 |
98 | app:ais_title_background="@drawable/custom_background.xml" // any custom drawable as text background
99 |
100 | app:ais_text_align="LEFT" // text/title alignment - { LEFT | CENTER | RIGHT }
101 |
102 | app:ais_title_color="@color/white" // assign any color to title
103 | ```
104 |
105 | #### Kotlin
106 | ```groovy
107 | class MainActivity : AppCompatActivity() , ItemsListener {
108 |
109 | // declare a variable for ItemListener
110 | private var listener : ItemsListener? = null
111 |
112 | override fun onCreate(savedInstanceState: Bundle?) {
113 | super.onCreate(savedInstanceState)
114 | setContentView(R.layout.activity_main)
115 |
116 | // initialization of the listener
117 | listener = this
118 |
119 | // create an imageArrayList which extend ImageSlideModel class
120 | val autoImageList : ArrayList = ArrayList()
121 |
122 | // find and initialize ImageSlider
123 | val autoImageSlider = findViewById(R.id.autoImageSlider)
124 |
125 | // add some imagees or titles (text) inside the imagesArrayList
126 | autoImageList.add(ImageSlidesModel("https://picsum.photos/id/237/200/300", "First image"))
127 | autoImageList.add(ImageSlidesModel("https://picsum.photos/id/238/200/300", ""))
128 | autoImageList.add(ImageSlidesModel("https://picsum.photos/id/239/200/300", "Third image"))
129 |
130 | // set the added images inside the AutoImageSlider
131 | autoImageSlider.setImageList(autoImageList, ImageScaleType.FIT)
132 |
133 | // set any default animation or custom animation (setSlideAnimation(ImageAnimationTypes.ZOOM_IN))
134 | autoImageSlider.setDefaultAnimation()
135 |
136 | // handle click event on item click
137 | autoImageSlider.onItemClickListener(listener)
138 |
139 | }
140 |
141 | override fun onItemChanged(position: Int) {
142 | // do what you want on item change event
143 | }
144 |
145 | override fun onTouched(actionTypes: ImageActionTypes?, position: Int) {
146 | // do what you want on item touch event
147 | }
148 |
149 | override fun onItemClicked(position: Int) {
150 | // do what you want on click event
151 | }
152 | }
153 | ```
154 |
155 | #### Java
156 | ```groovy
157 | public class MainActivity extends AppCompatActivity implements ItemsListener {
158 |
159 | // declare a variable for ItemListener
160 | private ItemsListener listener;
161 |
162 | @Override
163 | protected void onCreate(Bundle savedInstanceState) {
164 | super.onCreate(savedInstanceState);
165 | setContentView(R.layout.activity_main);
166 |
167 | // initialization of the listener
168 | listener = this;
169 |
170 | // create an imageArrayList which extend ImageSlideModel class
171 | ArrayList autoImageList = new ArrayList<>();
172 |
173 | // find and initialize ImageSlider
174 | AutoImageSlider autoImageSlider = findViewById(R.id.autoImageSlider);
175 |
176 | // add some imagees or titles (text) inside the imagesArrayList
177 | autoImageList.add(new ImageSlidesModel("https://picsum.photos/id/237/200/300", "First image"));
178 | autoImageList.add(new ImageSlidesModel("https://picsum.photos/id/238/200/300", ""));
179 | autoImageList.add(new ImageSlidesModel("https://picsum.photos/id/239/200/300", "Third image"));
180 |
181 | // set the added images inside the AutoImageSlider
182 | autoImageSlider.setImageList(autoImageList, ImageScaleType.FIT);
183 |
184 | // set any default animation or custom animation (setSlideAnimation(ImageAnimationTypes.ZOOM_IN))
185 | autoImageSlider.setDefaultAnimation();
186 |
187 | // handle click event on item click
188 | autoImageSlider.setOnItemClickListener(listener);
189 | }
190 |
191 | @Override
192 | public void onItemChanged(int position) {
193 | // Do what you want on item change event
194 | }
195 |
196 | @Override
197 | public void onTouched(ImageActionTypes actionTypes, int position) {
198 | // Do what you want on item touch event
199 | }
200 |
201 | @Override
202 | public void onItemClicked(int position) {
203 | // Do what you want on click event
204 | }
205 | }
206 | ```
207 |
208 | ### Licence
209 | ```
210 | MIT License
211 |
212 | Copyright (c) 2023 Ashish Dangi
213 |
214 | Permission is hereby granted, free of charge, to any person obtaining a copy
215 | of this software and associated documentation files (the "Software"), to deal
216 | in the Software without restriction, including without limitation the rights
217 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
218 | copies of the Software, and to permit persons to whom the Software is
219 | furnished to do so, subject to the following conditions:
220 |
221 | The above copyright notice and this permission notice shall be included in all
222 | copies or substantial portions of the Software.
223 |
224 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
225 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
226 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
227 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
228 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
229 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
230 | SOFTWARE.
231 | ```
232 |
233 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.application")
3 | id("org.jetbrains.kotlin.android")
4 | id("maven-publish")
5 |
6 |
7 | }
8 |
9 | android {
10 | namespace = "com.codebyashish.autoimageslider"
11 | compileSdk = 34
12 |
13 | defaultConfig {
14 | applicationId = "com.codebyashish.autoimageslider"
15 | minSdk = 24
16 | targetSdk = 33
17 | versionCode = 1
18 | versionName = "1.0"
19 |
20 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
21 |
22 | multiDexEnabled = true
23 | }
24 |
25 | buildTypes {
26 | release {
27 | isMinifyEnabled = false
28 | proguardFiles(
29 | getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
30 | )
31 | multiDexEnabled = true
32 | }
33 | getByName("debug") {
34 | multiDexEnabled = true
35 | }
36 | }
37 | compileOptions {
38 | sourceCompatibility = JavaVersion.VERSION_17
39 | targetCompatibility = JavaVersion.VERSION_17
40 | }
41 | kotlinOptions {
42 | jvmTarget = "17"
43 | }
44 |
45 |
46 | composeOptions {
47 | kotlinCompilerExtensionVersion = "1.4.5"
48 | }
49 | /* packaging {
50 | resources {
51 | excludes.add("/META-INF/{AL2.0,LGPL2.1}")
52 | }
53 | }*/
54 |
55 | }
56 |
57 | dependencies {
58 | implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
59 | implementation("com.squareup.picasso:picasso:2.71828")
60 | implementation("androidx.core:core-ktx:1.10.1")
61 | implementation("androidx.multidex:multidex:2.0.1")
62 | implementation("androidx.appcompat:appcompat:1.6.1")
63 | implementation("com.github.dangiashish:StyledCardView:1.0.0")
64 | implementation("com.google.android.material:material:1.9.0")
65 | implementation("androidx.constraintlayout:constraintlayout:2.1.4")
66 | implementation(project(mapOf("path" to ":autoimageslider")))
67 | testImplementation("junit:junit:4.13.2")
68 | androidTestImplementation("androidx.test.ext:junit:1.1.5")
69 | androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
70 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/codebyashish/autoimageslider/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.codebyashish.imageslider", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
18 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/codebyashish/autoimageslider/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider
2 |
3 | import android.content.Intent
4 | import android.net.Uri
5 | import android.os.Bundle
6 | import androidx.appcompat.app.AppCompatActivity
7 | import com.codebyashish.autoimageslider.Enums.ImageActionTypes
8 | import com.codebyashish.autoimageslider.Enums.ImageAnimationTypes
9 | import com.codebyashish.autoimageslider.Enums.ImageScaleType
10 | import com.codebyashish.autoimageslider.Interfaces.ItemsListener
11 | import com.codebyashish.autoimageslider.Models.ImageSlidesModel
12 |
13 |
14 | class MainActivity : AppCompatActivity(), ItemsListener {
15 |
16 |
17 | private lateinit var listener: ItemsListener
18 | var autoImageList = ArrayList()
19 | private lateinit var autoImageSlider: AutoImageSlider
20 |
21 |
22 | override fun onCreate(savedInstanceState: Bundle?) {
23 | super.onCreate(savedInstanceState)
24 | setContentView(R.layout.activity_main)
25 |
26 |
27 | autoImageSlider = findViewById(R.id.autoImageSlider)
28 | try {
29 | autoImageList.add(
30 | ImageSlidesModel(
31 | R.drawable.ic_launcher_foreground, "https://google.com", "Face",
32 | ImageScaleType.FIT
33 | )
34 | )
35 | autoImageList.add(
36 | ImageSlidesModel(
37 | "",
38 | "https://google.com",
39 | "title 2",
40 | ImageScaleType.FIT
41 | )
42 | )
43 | autoImageSlider.setImageList(autoImageList, ImageScaleType.FIT)
44 | autoImageSlider.setSlideAnimation(ImageAnimationTypes.ZOOM_IN)
45 | } catch (e: ExceptionsClass) {
46 | e.printStackTrace()
47 | }
48 | autoImageSlider.onItemClickListener(this)
49 | }
50 |
51 | override fun onItemChanged(position: Int) {
52 |
53 | }
54 |
55 | override fun onTouched(actionTypes: ImageActionTypes?, position: Int) {
56 |
57 | }
58 |
59 | override fun onItemClicked(position: Int) {
60 | val model = autoImageList[position]
61 | val intent = Intent(Intent.ACTION_VIEW, Uri.parse(model.clickUrl))
62 | intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
63 | startActivity(intent)
64 | }
65 |
66 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ashish_text_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon_face.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dangiashish/Auto-Image-Slider/d82bcc1da4feccccb8aae074f8ce1fd1af1f4152/app/src/main/res/drawable/icon_face.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dangiashish/Auto-Image-Slider/d82bcc1da4feccccb8aae074f8ce1fd1af1f4152/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dangiashish/Auto-Image-Slider/d82bcc1da4feccccb8aae074f8ce1fd1af1f4152/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dangiashish/Auto-Image-Slider/d82bcc1da4feccccb8aae074f8ce1fd1af1f4152/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dangiashish/Auto-Image-Slider/d82bcc1da4feccccb8aae074f8ce1fd1af1f4152/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dangiashish/Auto-Image-Slider/d82bcc1da4feccccb8aae074f8ce1fd1af1f4152/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dangiashish/Auto-Image-Slider/d82bcc1da4feccccb8aae074f8ce1fd1af1f4152/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dangiashish/Auto-Image-Slider/d82bcc1da4feccccb8aae074f8ce1fd1af1f4152/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dangiashish/Auto-Image-Slider/d82bcc1da4feccccb8aae074f8ce1fd1af1f4152/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dangiashish/Auto-Image-Slider/d82bcc1da4feccccb8aae074f8ce1fd1af1f4152/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dangiashish/Auto-Image-Slider/d82bcc1da4feccccb8aae074f8ce1fd1af1f4152/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FF000000
4 | #FFFFFFFF
5 |
6 |
7 | #FBFBFB
8 | #ff9e9e9e
9 | #7F000000
10 | #FFFFFF
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Android Image Slider
3 | dash
4 | dot
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/app/src/test/java/com/codebyashish/autoimageslider/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/autoimageslider/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/autoimageslider/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 |
3 |
4 | id("com.android.library")
5 | id("org.jetbrains.kotlin.android")
6 | id("maven-publish")
7 | }
8 |
9 | android {
10 | namespace = "com.codebyashish.autoimageslider"
11 | compileSdk = 33
12 | defaultConfig {
13 | minSdk = 24
14 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
15 | consumerProguardFiles("consumer-rules.pro")
16 | multiDexEnabled = true
17 | }
18 |
19 | buildTypes {
20 | release {
21 | isMinifyEnabled = false
22 | proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
23 | multiDexEnabled = true
24 | }
25 | getByName("debug") {
26 | multiDexEnabled = true
27 | }
28 | }
29 | compileOptions {
30 | sourceCompatibility = JavaVersion.VERSION_17
31 | targetCompatibility = JavaVersion.VERSION_17
32 | }
33 |
34 | kotlinOptions {
35 | jvmTarget = "17"
36 | }
37 | publishing {
38 | singleVariant("release") {
39 | withSourcesJar()
40 | withJavadocJar()
41 | }
42 | }
43 |
44 |
45 | }
46 |
47 | dependencies {
48 | implementation("com.squareup.picasso:picasso:2.71828")
49 | implementation("androidx.appcompat:appcompat:1.6.1")
50 | implementation("androidx.multidex:multidex:2.0.1")
51 | implementation("com.google.android.material:material:1.9.0")
52 | testImplementation("junit:junit:4.13.2")
53 | androidTestImplementation("androidx.test.ext:junit:1.1.5")
54 | androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
55 | }
56 |
57 | publishing {
58 | publications {
59 | register("release") {
60 | groupId = "com.codebyashish"
61 | artifactId = "autoimageslider"
62 | version = "1.0.5"
63 |
64 | afterEvaluate {
65 | from(components["release"])
66 | }
67 | }
68 | }
69 | }
70 |
71 |
72 |
--------------------------------------------------------------------------------
/autoimageslider/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dangiashish/Auto-Image-Slider/d82bcc1da4feccccb8aae074f8ce1fd1af1f4152/autoimageslider/consumer-rules.pro
--------------------------------------------------------------------------------
/autoimageslider/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/autoimageslider/src/androidTest/java/com/codebyashish/autoimageslider/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 | assertEquals("com.codebyashish.autoimageslider.test", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Adapter/ViewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Adapter;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.util.Log;
6 | import android.view.Gravity;
7 | import android.view.LayoutInflater;
8 | import android.view.MotionEvent;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.ImageView;
12 | import android.widget.LinearLayout;
13 | import android.widget.RelativeLayout;
14 | import android.widget.TextView;
15 |
16 | import androidx.annotation.NonNull;
17 | import androidx.viewpager.widget.PagerAdapter;
18 |
19 | import com.codebyashish.autoimageslider.Enums.ImageActionTypes;
20 | import com.codebyashish.autoimageslider.Enums.ImageScaleType;
21 | import com.codebyashish.autoimageslider.ExceptionsClass;
22 | import com.codebyashish.autoimageslider.Interfaces.ItemsListener;
23 | import com.codebyashish.autoimageslider.Models.ImageSlidesModel;
24 | import com.codebyashish.autoimageslider.PicassoTransformation;
25 | import com.codebyashish.autoimageslider.R;
26 | import com.squareup.picasso.Picasso;
27 | import com.squareup.picasso.RequestCreator;
28 |
29 | import java.util.ArrayList;
30 |
31 | public class ViewAdapter extends PagerAdapter {
32 |
33 | private ArrayList imageSlidesModelArrayList;
34 | private View view;
35 | private ImageView ivImage;
36 | private TextView tvTitle, tvDesc;
37 | private LinearLayout textBackgroundLayout;
38 | private Context context;
39 | private int radius;
40 | private int ivErrorImage;
41 | private int placeHolder;
42 | private int titleBackground;
43 | private ImageScaleType scaleType;
44 | ItemsListener listener;
45 | private String textAlign;
46 | private int titleColor, descColor;
47 | private long currentTouchTime = 0;
48 | private long lastTouchTime = 0;
49 |
50 | public ViewAdapter(Context context, ArrayList arrayList, int cornerRadius,
51 | int errorImage, int placeholder, int titleBackground, String textAlign, int titleColor, int descriptionColor, ItemsListener listener) {
52 | this.context = context;
53 | this.imageSlidesModelArrayList = arrayList;
54 | this.radius = cornerRadius;
55 | this.ivErrorImage = errorImage;
56 | this.placeHolder = placeholder;
57 | this.titleBackground = titleBackground;
58 | this.textAlign = textAlign;
59 | this.titleColor = titleColor;
60 | this.descColor = descriptionColor;
61 | this.listener = listener;
62 | }
63 |
64 | public ViewAdapter(Context context, ArrayList arrayList, int cornerRadius,
65 | int errorImage, int placeholder, int titleBackground, ImageScaleType scaleType, String textAlign, int titleColor, int descriptionColor
66 | , ItemsListener listener) {
67 | this.context = context;
68 | this.imageSlidesModelArrayList = arrayList;
69 | this.radius = cornerRadius;
70 | this.ivErrorImage = errorImage;
71 | this.placeHolder = placeholder;
72 | this.titleBackground = titleBackground;
73 | this.textAlign = textAlign;
74 | this.titleColor = titleColor;
75 | this.descColor = descriptionColor;
76 | this.scaleType = scaleType;
77 | this.listener = listener;
78 | }
79 |
80 |
81 | @Override
82 | public int getCount() {
83 | return imageSlidesModelArrayList.size();
84 | }
85 |
86 | @Override
87 | public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
88 | return view == object;
89 | }
90 |
91 | @Override
92 | public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
93 | container.removeView((RelativeLayout) object);
94 | }
95 |
96 | @SuppressLint("ClickableViewAccessibility")
97 | @NonNull
98 | @Override
99 | public Object instantiateItem(@NonNull ViewGroup container, int position) {
100 | view = LayoutInflater.from(context).inflate(R.layout.item_pager, container, false);
101 | ImageSlidesModel model = imageSlidesModelArrayList.get(position);
102 | ivImage = view.findViewById(R.id.ivImage);
103 | tvTitle = view.findViewById(R.id.tvTitle);
104 | tvDesc = view.findViewById(R.id.tvDesc);
105 | textBackgroundLayout = view.findViewById(R.id.llBackground);
106 | tvTitle.setTextColor(titleColor);
107 | tvDesc.setTextColor(descColor);
108 |
109 | tvTitle.setSelected(true);
110 | tvDesc.setSelected(true);
111 | textBackgroundLayout.setVisibility(View.GONE);
112 |
113 | if (model.getTitle() != null && !model.getTitle().equals("")) {
114 | textBackgroundLayout.setVisibility(View.VISIBLE);
115 | tvTitle.setText(model.getTitle());
116 | textBackgroundLayout.setBackgroundResource(titleBackground);
117 | tvTitle.setGravity(getGravityFromAlign(textAlign));
118 | textBackgroundLayout.setGravity(getGravityFromAlign(textAlign));
119 | tvDesc.setVisibility(View.GONE);
120 | } else if (model.getDescription() != null && !model.getDescription().equals("")) {
121 | textBackgroundLayout.setVisibility(View.VISIBLE);
122 | tvDesc.setText(model.getTitle());
123 | textBackgroundLayout.setBackgroundResource(titleBackground);
124 | tvDesc.setGravity(getGravityFromAlign(textAlign));
125 | textBackgroundLayout.setGravity(getGravityFromAlign(textAlign));
126 | } else if ((model.getTitle() != null && !model.getTitle().equals("")) && ((model.getDescription() != null) && !model.getDescription().equals(""))) {
127 | tvTitle.setText(model.getTitle());
128 | textBackgroundLayout.setVisibility(View.VISIBLE);
129 | tvDesc.setText(model.getTitle());
130 | textBackgroundLayout.setBackgroundResource(titleBackground);
131 | tvDesc.setGravity(getGravityFromAlign(textAlign));
132 | textBackgroundLayout.setGravity(getGravityFromAlign(textAlign));
133 | } else {
134 | textBackgroundLayout.setVisibility(View.INVISIBLE);
135 | }
136 |
137 | Log.i("TAG", model.getTitle() + " " + model.getImgUrl() + " " + model.getDescription());
138 | Log.i("TAG", model.getTitle() + " " + model.getImgPath() + " " + model.getDescription());
139 |
140 | RequestCreator picasso = null;
141 | if (model.getImgUrl() != null) {
142 | if (model.getImgUrl().equals("")){
143 | picasso = Picasso.get().load(R.drawable.placeholder_image_failed);
144 | } else {
145 | picasso = Picasso.get().load(model.getImgUrl());
146 | }
147 | } else {
148 | picasso = Picasso.get().load(model.getImgPath());
149 | }
150 |
151 | if (scaleType != null) {
152 | if (model.getImageScaleType() == ImageScaleType.FIT || scaleType == ImageScaleType.FIT) {
153 | picasso.fit();
154 | } else if (model.getImageScaleType() == ImageScaleType.CENTER_CROP || scaleType == ImageScaleType.CENTER_CROP) {
155 | picasso.fit().centerCrop();
156 | } else if (model.getImageScaleType() == ImageScaleType.CENTER_INSIDE || scaleType == ImageScaleType.CENTER_INSIDE) {
157 | picasso.fit().centerInside();
158 | }
159 | }
160 |
161 | picasso.transform(new PicassoTransformation(radius, 0, PicassoTransformation.CornerType.ALL)).placeholder(placeHolder)
162 | .error(ivErrorImage).into(ivImage);
163 |
164 | container.addView(view);
165 |
166 | ivImage.setOnClickListener(v -> {
167 | if (listener != null) {
168 | if (model.getClickUrl() != null && model.getImgUrl() != null) {
169 | listener.onItemClicked(position);
170 | }
171 | if (model.getClickUrl() != null && model.getImgPath() != 0) {
172 | listener.onItemClicked(position);
173 | }
174 | }
175 | });
176 |
177 | if (listener != null) {
178 | ivImage.setOnTouchListener((v, event) -> {
179 | switch (event.getAction()) {
180 | case MotionEvent.ACTION_MOVE:
181 | listener.onTouched(ImageActionTypes.MOVE, position);
182 | break;
183 | case MotionEvent.ACTION_DOWN:
184 | listener.onTouched(ImageActionTypes.DOWN, position);
185 | break;
186 | case MotionEvent.ACTION_UP:
187 | listener.onTouched(ImageActionTypes.UP, position);
188 | break;
189 | }
190 | return false;
191 | });
192 | }
193 |
194 | return view;
195 |
196 | }
197 |
198 | public void setItemClickListener(ItemsListener itemChangeListener) {
199 | this.listener = itemChangeListener;
200 | }
201 |
202 | public void setItemChangeListener(ItemsListener itemChangeListener) {
203 | this.listener = itemChangeListener;
204 | }
205 |
206 | public void setItemTouchListener(ItemsListener itemChangeListener) {
207 | this.listener = itemChangeListener;
208 | }
209 |
210 | public void setItemDoubleTapListener(ItemsListener itemChangeListener) {
211 | this.listener = itemChangeListener;
212 | }
213 |
214 | public int getGravityFromAlign(String textAlign) {
215 | switch (textAlign) {
216 | case "RIGHT":
217 | return Gravity.END;
218 | case "CENTER":
219 | return Gravity.CENTER;
220 | default:
221 | return Gravity.START;
222 | }
223 | }
224 | }
225 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Animation/BackgroundToForeground.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Animation
2 |
3 | import android.view.View
4 | import androidx.viewpager.widget.ViewPager.PageTransformer
5 | import kotlin.math.abs
6 | import kotlin.math.min
7 |
8 |
9 | class BackgroundToForeground: PageTransformer {
10 |
11 | override fun transformPage(view: View, position: Float) {
12 | val height: Float = view.height.toFloat()
13 | val width: Float = view.width.toFloat()
14 | val scale: Float = min(if (position < 0) 1f else abs(1f - position), 1f)
15 |
16 | view.scaleX = scale
17 | view.scaleY = scale
18 | view.pivotX = width * 0.5f
19 | view.pivotY = height * 0.5f
20 | view.translationX = if (position < 0) width * position else -width * position * 0.25f
21 | }
22 |
23 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Animation/CubeIn.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Animation
2 |
3 | import android.view.View
4 | import androidx.viewpager.widget.ViewPager.PageTransformer
5 |
6 | class CubeIn: PageTransformer {
7 |
8 | override fun transformPage(view: View, position: Float) {
9 | view.pivotX = if (position > 0) 0f else view.width.toFloat()
10 | view.pivotY = 0f
11 | view.rotationY = -90f * position
12 | }
13 |
14 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Animation/CubeOut.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Animation
2 |
3 | import android.view.View
4 | import androidx.viewpager.widget.ViewPager.PageTransformer
5 |
6 |
7 | class CubeOut: PageTransformer {
8 | override fun transformPage(view: View, position: Float) {
9 | view.pivotX = if (position < 0f) view.width.toFloat() else 0f
10 | view.pivotY = view.height * 0.5f
11 | view.rotationY = 90f * position
12 | }
13 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Animation/DepthSlide.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Animation
2 |
3 | import android.view.View
4 | import androidx.viewpager.widget.ViewPager.PageTransformer
5 | import kotlin.math.abs
6 |
7 |
8 | class DepthSlide: PageTransformer {
9 | private val MIN_SCALE = 0.75f
10 | override fun transformPage(view: View, position: Float) {
11 | val pageWidth: Int = view.width
12 |
13 | when {
14 | position < -1 -> {
15 | view.alpha = 0f
16 | }
17 | position <= 0 -> {
18 | view.alpha = 1f
19 | view.translationX = 0f
20 | view.scaleX = 1f
21 | view.scaleY = 1f
22 | }
23 | position <= 1 -> {
24 | view.alpha = 1 - position
25 |
26 | view.translationX = pageWidth * -position
27 |
28 | val scaleFactor: Float = (MIN_SCALE
29 | + (1 - MIN_SCALE) * (1 - abs(position)))
30 | view.scaleX = scaleFactor
31 | view.scaleY = scaleFactor
32 | }
33 | else -> {
34 | view.alpha = 0f
35 | }
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Animation/FidgetSpinner.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Animation
2 |
3 | import android.view.View
4 | import androidx.viewpager.widget.ViewPager.PageTransformer
5 | import kotlin.math.abs
6 |
7 | class FidgetSpinner: PageTransformer {
8 |
9 | override fun transformPage(view: View, position: Float) {
10 | view.translationX = -position * view.width
11 |
12 | if(abs(position) < 0.5){
13 | view.visibility = View.VISIBLE
14 | view.scaleX = 1 - abs(position)
15 | view.scaleY = 1 - abs(position)
16 | } else if(abs(position) > 0.5){
17 | view.visibility = View.GONE
18 | }
19 |
20 | when {
21 | position < -1 -> {
22 | view.alpha = 0f
23 | }
24 | position <= 0 -> {
25 | view.alpha = 1f
26 | view.rotation = 36000 * (abs(position) * abs(position) * abs(position) * abs(position) * abs(position) * abs(position) * abs(position))
27 | }
28 | position <= 1 -> {
29 | view.alpha = 1f
30 | view.rotation = -36000 * (abs(position) * abs(position) * abs(position) * abs(position) * abs(position) * abs(position) * abs(position))
31 | }
32 | else -> {
33 | view.alpha = 0f
34 | }
35 | }
36 |
37 | }
38 |
39 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Animation/FlipHorizontal.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Animation
2 |
3 | import android.view.View
4 | import androidx.viewpager.widget.ViewPager.PageTransformer
5 |
6 |
7 | class FlipHorizontal: PageTransformer {
8 | override fun transformPage(view: View, position: Float) {
9 | val rotation: Float = 180f * position
10 |
11 | view.alpha = if (rotation > 90f || rotation < -90f) 0f else 1f
12 | view.pivotX = view.width * 0.5f
13 | view.pivotY = view.height * 0.5f
14 | view.rotationY = rotation
15 | }
16 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Animation/FlipVertical.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Animation
2 |
3 | import android.view.View
4 | import androidx.viewpager.widget.ViewPager.PageTransformer
5 |
6 | class FlipVertical: PageTransformer {
7 | override fun transformPage(view: View, position: Float) {
8 | val rotation: Float = -180f * position
9 |
10 | view.alpha = if (rotation > 90f || rotation < -90f) 0f else 1f
11 | view.pivotX = view.width * 0.5f
12 | view.pivotY = view.height * 0.5f
13 | view.rotationX = rotation
14 | }
15 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Animation/ForegroundToBackground.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Animation
2 |
3 | import android.view.View
4 | import androidx.viewpager.widget.ViewPager.PageTransformer
5 | import kotlin.math.abs
6 | import kotlin.math.min
7 |
8 | class ForegroundToBackground: PageTransformer {
9 |
10 | override fun transformPage(view: View, position: Float) {
11 | val height: Float = view.height.toFloat()
12 | val width: Float = view.width.toFloat()
13 | val scale: Float = min(if (position > 0) 1f else abs(1f + position), 1f)
14 |
15 | view.scaleX = scale
16 | view.scaleY = scale
17 | view.pivotX = width * 0.5f
18 | view.pivotY = height * 0.5f
19 | view.translationX = if (position > 0) width * position else -width * position * 0.25f
20 | }
21 |
22 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Animation/Gate.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Animation
2 |
3 | import android.view.View
4 | import androidx.viewpager.widget.ViewPager.PageTransformer
5 | import kotlin.math.abs
6 |
7 | class Gate: PageTransformer {
8 |
9 | override fun transformPage(view: View, position: Float) {
10 | view.translationX = -position * view.width
11 |
12 | when {
13 | position < -1 -> {
14 | view.alpha = 0f
15 | }
16 | position <= 0 -> {
17 | view.alpha = 1f
18 | view.pivotX = 0f
19 | view.rotationY = 90 * abs(position)
20 | }
21 | position <= 1 -> {
22 | view.alpha = 1f
23 | view.pivotX = view.width.toFloat()
24 | view.rotationY = -90 * abs(position)
25 | }
26 | else -> {
27 | view.alpha = 0f
28 | }
29 | }
30 | }
31 |
32 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Animation/RotateDown.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Animation
2 |
3 | import android.view.View
4 | import androidx.viewpager.widget.ViewPager.PageTransformer
5 |
6 |
7 | class RotateDown: PageTransformer {
8 |
9 | override fun transformPage(view: View, position: Float) {
10 | val width = view.width
11 | val rotation = -15f * position
12 |
13 | view.pivotX = width * 0.5f
14 | view.pivotY = 0f
15 | view.translationX = 0f
16 | view.rotation = rotation
17 | }
18 |
19 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Animation/RotateUp.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Animation
2 |
3 | import android.view.View
4 | import androidx.viewpager.widget.ViewPager.PageTransformer
5 |
6 | class RotateUp: PageTransformer {
7 |
8 | override fun transformPage(view: View, position: Float) {
9 | val width = view.width
10 | val height = view.height
11 | val rotation = -15f * position * -1.25f
12 |
13 | view.pivotX = width * 0.5f
14 | view.pivotY = height.toFloat()
15 | view.rotation = rotation
16 | }
17 |
18 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Animation/Toss.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Animation
2 |
3 | import android.view.View
4 | import androidx.viewpager.widget.ViewPager.PageTransformer
5 | import kotlin.math.abs
6 | import kotlin.math.max
7 |
8 | class Toss: PageTransformer {
9 |
10 | override fun transformPage(view: View, position: Float) {
11 | view.translationX = -position * view.width
12 | view.cameraDistance = 20000f
13 |
14 | if(position < 0.5 && position > -0.5){
15 | view.visibility = View.VISIBLE
16 | } else {
17 | view.visibility = View.INVISIBLE
18 | }
19 |
20 | when {
21 | position < -1 -> {
22 | view.alpha = 0f
23 | }
24 | position <= 0 -> {
25 | view.alpha = 1f
26 | view.scaleX = max(0.4f, 1 - abs(position))
27 | view.scaleY = max(0.4f, 1 - abs(position))
28 | view.rotationX = 1080 * ( 1 - abs(position) + 1)
29 | view.translationY = -1000 * abs(position)
30 | }
31 | position <= 1 -> {
32 | view.alpha = 1f
33 | view.scaleX = max(0.4f, 1 - abs(position))
34 | view.scaleY = max(0.4f, 1 - abs(position))
35 | view.rotationX = -1080 * ( 1 - abs(position) + 1)
36 | view.translationY = -1000 * abs(position)
37 | }
38 | else -> {
39 | view.alpha = 0f
40 | }
41 | }
42 | }
43 |
44 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Animation/ZoomIn.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Animation
2 |
3 | import android.view.View
4 | import androidx.viewpager.widget.ViewPager.PageTransformer
5 | import kotlin.math.abs
6 |
7 |
8 | class ZoomIn: PageTransformer {
9 |
10 | override fun transformPage(view: View, positon: Float) {
11 | val scale: Float = if (positon < 0) positon + 1f else abs(1f - positon)
12 | view.scaleX = scale
13 | view.scaleY = scale
14 | view.pivotX = view.width * 0.5f
15 | view.pivotY = view.height * 0.5f
16 | view.alpha = if (positon < -1f || positon > 1f) 0f else 1f - (scale - 1f)
17 | }
18 |
19 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Animation/ZoomOut.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Animation
2 |
3 | import android.view.View
4 | import androidx.viewpager.widget.ViewPager.PageTransformer
5 | import kotlin.math.abs
6 | import kotlin.math.max
7 |
8 | class ZoomOut: PageTransformer {
9 |
10 | private val MIN_SCALE = 0.85f
11 | private val MIN_ALPHA = 0.5f
12 |
13 | override fun transformPage(view: View, position: Float) {
14 | val pageWidth: Int = view.width
15 | val pageHeight: Int = view.height
16 |
17 | when {
18 | position < -1 -> {
19 | view.alpha = 0f
20 | }
21 | position <= 1 -> {
22 | val scaleFactor = max(MIN_SCALE, 1 - abs(position))
23 | val vertMargin = pageHeight * (1 - scaleFactor) / 2
24 | val horzMargin = pageWidth * (1 - scaleFactor) / 2
25 | if (position < 0) {
26 | view.translationX = horzMargin - vertMargin / 2
27 | } else {
28 | view.translationX = -horzMargin + vertMargin / 2
29 | }
30 | view.scaleX = scaleFactor
31 | view.scaleY = scaleFactor
32 | view.alpha = MIN_ALPHA +
33 | (scaleFactor - MIN_SCALE) /
34 | (1 - MIN_SCALE) * (1 - MIN_ALPHA)
35 | }
36 | else -> {
37 | view.alpha = 0f
38 | }
39 | }
40 | }
41 |
42 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/AutoImageSlider.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider
2 |
3 | import android.content.Context
4 | import android.os.Handler
5 | import android.util.AttributeSet
6 | import android.util.Log
7 | import android.view.Gravity
8 | import android.view.LayoutInflater
9 | import android.view.View
10 | import android.widget.ImageView
11 | import android.widget.LinearLayout
12 | import android.widget.RelativeLayout
13 | import androidx.core.content.ContextCompat
14 | import androidx.viewpager.widget.ViewPager
15 | import androidx.viewpager.widget.ViewPager.OnPageChangeListener
16 | import com.codebyashish.autoimageslider.Adapter.ViewAdapter
17 | import com.codebyashish.autoimageslider.Animation.BackgroundToForeground
18 | import com.codebyashish.autoimageslider.Animation.CubeIn
19 | import com.codebyashish.autoimageslider.Animation.CubeOut
20 | import com.codebyashish.autoimageslider.Animation.DepthSlide
21 | import com.codebyashish.autoimageslider.Animation.FidgetSpinner
22 | import com.codebyashish.autoimageslider.Animation.FlipHorizontal
23 | import com.codebyashish.autoimageslider.Animation.FlipVertical
24 | import com.codebyashish.autoimageslider.Animation.ForegroundToBackground
25 | import com.codebyashish.autoimageslider.Animation.Gate
26 | import com.codebyashish.autoimageslider.Animation.RotateDown
27 | import com.codebyashish.autoimageslider.Animation.RotateUp
28 | import com.codebyashish.autoimageslider.Animation.Toss
29 | import com.codebyashish.autoimageslider.Animation.ZoomIn
30 | import com.codebyashish.autoimageslider.Animation.ZoomOut
31 | import com.codebyashish.autoimageslider.Enums.ImageAnimationTypes
32 | import com.codebyashish.autoimageslider.Enums.ImageScaleType
33 | import com.codebyashish.autoimageslider.Interfaces.ItemsListener
34 | import com.codebyashish.autoimageslider.Models.ImageSlidesModel
35 | import java.util.Timer
36 | import java.util.TimerTask
37 |
38 | class AutoImageSlider @JvmOverloads constructor(
39 | var mContext: Context,
40 | var attributeSet: AttributeSet? = null,
41 | defStyleAttr: Int = 0
42 | ) : RelativeLayout(
43 | mContext, attributeSet, defStyleAttr
44 | ) {
45 | private val viewPager: ViewPager
46 | private val pagerDots: LinearLayout
47 | private var viewAdapter: ViewAdapter? = null
48 | private lateinit var dotsImages: Array
49 | private var currentPage = 0
50 | private var imageCount = 0
51 | private var cornerRadius = 0
52 | private var period: Long = 0
53 | private var delay: Long = 0
54 | private var autoCycle = false
55 | private var selectedDot = 0
56 | private var unselectedDot = 0
57 | private var errorImage = 0
58 | private var placeholder = 0
59 | private var titleBackground = 0
60 | private val indicatorStyle: String? = null
61 | private var textAlign: String? = "LEFT"
62 | private var indicatorAlign: String? = "CENTER"
63 | private var swipeTimer = Timer()
64 | private val listener: ItemsListener? = null
65 | private val itemChangeListener: ItemsListener? = null
66 | private var touchListener: ItemsListener? = null
67 | private var itemClickListener: ItemsListener? = null
68 | private val dotsVisible: Boolean
69 | private var titleColor = resources.getColor(android.R.color.white)
70 | private var descriptionColor = resources.getColor(android.R.color.white)
71 | private val defaultBackground = R.drawable.text_background
72 | private val view: View
73 | var defStyleAttr = 0
74 | var defStyleRes = 0
75 |
76 | init {
77 | view = LayoutInflater.from(getContext()).inflate(R.layout.layout_slider_image, this, true)
78 | viewPager = findViewById(R.id.view_pager)
79 | pagerDots = findViewById(R.id.pager_dots)
80 | val typedArray = getContext().theme.obtainStyledAttributes(
81 | attributeSet, R.styleable.AutoImageSlider, defStyleAttr, defStyleRes
82 | )
83 | cornerRadius = typedArray.getInt(R.styleable.AutoImageSlider_ais_corner_radius, 1)
84 | period = typedArray.getInt(R.styleable.AutoImageSlider_ais_time_interval, 1000).toLong()
85 | delay = typedArray.getInt(R.styleable.AutoImageSlider_ais_slide_delay, 1000).toLong()
86 | autoCycle = typedArray.getBoolean(R.styleable.AutoImageSlider_ais_auto_sliding, false)
87 | placeholder = typedArray.getResourceId(
88 | R.styleable.AutoImageSlider_ais_placeholder,
89 | R.drawable.placeholder_default_loading
90 | )
91 | errorImage = typedArray.getResourceId(
92 | R.styleable.AutoImageSlider_ais_exception_image,
93 | R.drawable.placeholder_image_failed
94 | )
95 | selectedDot = typedArray.getResourceId(
96 | R.styleable.AutoImageSlider_ais_selected_indicator,
97 | R.drawable.indicator_selected_dash
98 | )
99 | unselectedDot = typedArray.getResourceId(
100 | R.styleable.AutoImageSlider_ais_unselected_indicator,
101 | R.drawable.indicator_unselected_dash
102 | )
103 | if (typedArray.getString(R.styleable.AutoImageSlider_ais_indicator_style) == resources.getString(
104 | R.string.style_dash
105 | )
106 | ) {
107 | selectedDot = typedArray.getResourceId(
108 | R.styleable.AutoImageSlider_ais_selected_indicator,
109 | R.drawable.indicator_selected_dash
110 | )
111 | unselectedDot = typedArray.getResourceId(
112 | R.styleable.AutoImageSlider_ais_unselected_indicator,
113 | R.drawable.indicator_unselected_dash
114 | )
115 | }
116 | if (typedArray.getString(R.styleable.AutoImageSlider_ais_indicator_style) == resources.getString(
117 | R.string.style_dot
118 | )
119 | ) {
120 | selectedDot = typedArray.getResourceId(
121 | R.styleable.AutoImageSlider_ais_selected_indicator,
122 | R.drawable.indicator_selected_dot
123 | )
124 | unselectedDot = typedArray.getResourceId(
125 | R.styleable.AutoImageSlider_ais_unselected_indicator,
126 | R.drawable.indicator_unselected_dot
127 | )
128 | }
129 | titleBackground = typedArray.getResourceId(
130 | R.styleable.AutoImageSlider_ais_title_background,
131 | defaultBackground
132 | )
133 | dotsVisible = typedArray.getBoolean(R.styleable.AutoImageSlider_ais_dots_visible, true)
134 | if (typedArray.getString(R.styleable.AutoImageSlider_ais_text_align) != null) {
135 | textAlign = typedArray.getString(R.styleable.AutoImageSlider_ais_text_align)
136 | }
137 | if (typedArray.getString(R.styleable.AutoImageSlider_ais_indicator_align) != null) {
138 | indicatorAlign = typedArray.getString(R.styleable.AutoImageSlider_ais_indicator_align)
139 | }
140 | if (typedArray.getString(R.styleable.AutoImageSlider_ais_title_color) != null) {
141 | titleColor = typedArray.getString(R.styleable.AutoImageSlider_ais_title_color)!!
142 | .toInt()
143 | }
144 | if (typedArray.getString(R.styleable.AutoImageSlider_ais_description_color) != null) {
145 | descriptionColor =
146 | typedArray.getString(R.styleable.AutoImageSlider_ais_description_color)!!
147 | .toInt()
148 | }
149 | }
150 |
151 | fun setImageList(arrayList: ArrayList) {
152 | viewAdapter = ViewAdapter(
153 | mContext,
154 | arrayList,
155 | cornerRadius,
156 | errorImage,
157 | placeholder,
158 | titleBackground,
159 | textAlign,
160 | titleColor,
161 | descriptionColor,
162 | listener
163 | )
164 | setAdapter(arrayList)
165 | }
166 |
167 | fun setImageList(arrayList: ArrayList, scaleType: ImageScaleType?) {
168 | Log.w("HWLL", "setImageList: ${arrayList}" )
169 |
170 | viewAdapter = ViewAdapter(
171 | mContext,
172 | arrayList,
173 | cornerRadius,
174 | errorImage,
175 | placeholder,
176 | titleBackground,
177 | scaleType,
178 | textAlign,
179 | titleColor,
180 | descriptionColor,
181 | listener
182 | )
183 | setAdapter(arrayList)
184 |
185 |
186 | }
187 |
188 | private fun setAdapter(arrayList: ArrayList) {
189 | viewPager.adapter = viewAdapter
190 | imageCount = arrayList.size
191 | if (arrayList.size != 0) {
192 | if (dotsVisible) {
193 | setupDots(arrayList.size)
194 | }
195 | if (autoCycle) {
196 | startSliding(period)
197 | }
198 | }
199 | }
200 |
201 | fun setDefaultAnimation() {
202 | viewPager.setPageTransformer(true, BackgroundToForeground())
203 | }
204 |
205 | fun startSlider() {}
206 | fun setSlideAnimation(animationType: ImageAnimationTypes?) {
207 | when (animationType) {
208 | ImageAnimationTypes.ZOOM_IN -> viewPager.setPageTransformer(true, ZoomIn())
209 | ImageAnimationTypes.ZOOM_OUT -> viewPager.setPageTransformer(true, ZoomOut())
210 | ImageAnimationTypes.CUBE_IN -> viewPager.setPageTransformer(true, CubeIn())
211 | ImageAnimationTypes.CUBE_OUT -> viewPager.setPageTransformer(true, CubeOut())
212 | ImageAnimationTypes.FLIP_HORIZONTAL -> viewPager.setPageTransformer(
213 | true,
214 | FlipHorizontal()
215 | )
216 |
217 | ImageAnimationTypes.FLIP_VERTICAL -> viewPager.setPageTransformer(true, FlipVertical())
218 | ImageAnimationTypes.ROTATE_UP -> viewPager.setPageTransformer(true, RotateUp())
219 | ImageAnimationTypes.ROTATE_DOWN -> viewPager.setPageTransformer(true, RotateDown())
220 | ImageAnimationTypes.FOREGROUND_TO_BACKGROUND -> viewPager.setPageTransformer(
221 | true,
222 | ForegroundToBackground()
223 | )
224 |
225 | ImageAnimationTypes.BACKGROUND_TO_FOREGROUND -> viewPager.setPageTransformer(
226 | true,
227 | BackgroundToForeground()
228 | )
229 |
230 | ImageAnimationTypes.TOSS -> viewPager.setPageTransformer(true, Toss())
231 | ImageAnimationTypes.GATE -> viewPager.setPageTransformer(true, Gate())
232 | ImageAnimationTypes.FIDGET_SPINNER -> viewPager.setPageTransformer(
233 | true,
234 | FidgetSpinner()
235 | )
236 |
237 | else -> viewPager.setPageTransformer(true, DepthSlide())
238 | }
239 | }
240 |
241 | private fun setupDots(size: Int) {
242 | pagerDots.gravity = getAlignment(indicatorAlign)
243 | pagerDots.removeAllViews()
244 | dotsImages = arrayOfNulls(size)
245 | Log.d("TAG", "" + pagerDots.gravity)
246 | for (i in 0 until size) {
247 | dotsImages[i] = ImageView(mContext)
248 | dotsImages[i]!!.setImageDrawable(
249 | ContextCompat.getDrawable(
250 | mContext, unselectedDot
251 | )
252 | )
253 | val params = LayoutParams(
254 | LinearLayout.LayoutParams.WRAP_CONTENT,
255 | LinearLayout.LayoutParams.WRAP_CONTENT
256 | )
257 | params.setMargins(10, 0, 10, 0)
258 | pagerDots.addView(dotsImages[i], params)
259 | }
260 | dotsImages[0]!!
261 | .setImageDrawable(ContextCompat.getDrawable(mContext, selectedDot))
262 | viewPager.addOnPageChangeListener(object : OnPageChangeListener {
263 | override fun onPageScrolled(
264 | position: Int,
265 | positionOffset: Float,
266 | positionOffsetPixels: Int
267 | ) {
268 | }
269 |
270 | override fun onPageSelected(position: Int) {
271 | currentPage = position
272 | for (dotImage in dotsImages) {
273 | dotImage!!.setImageDrawable(
274 | ContextCompat.getDrawable(
275 | mContext, unselectedDot
276 | )
277 | )
278 | }
279 | dotsImages[position]!!.setImageDrawable(
280 | ContextCompat.getDrawable(
281 | mContext, selectedDot
282 | )
283 | )
284 | itemChangeListener?.onItemChanged(position)
285 | }
286 |
287 | override fun onPageScrollStateChanged(state: Int) {}
288 | })
289 | }
290 |
291 | private fun startSliding(changeableInterval: Long) {
292 | stopSliding()
293 | scheduleTimer(changeableInterval)
294 | }
295 |
296 | private fun stopSliding() {
297 | swipeTimer.cancel()
298 | swipeTimer.purge()
299 | }
300 |
301 | private fun scheduleTimer(period: Long) {
302 | setViewPageScroller(PageScroller(mContext))
303 | val handler = Handler()
304 | val update = Runnable {
305 | if (currentPage == imageCount) {
306 | currentPage = 0
307 | }
308 | viewPager.setCurrentItem(currentPage++, true)
309 | }
310 | swipeTimer = Timer()
311 | swipeTimer.schedule(object : TimerTask() {
312 | override fun run() {
313 | handler.post(update)
314 | }
315 | }, delay, period)
316 | }
317 |
318 | private fun setViewPageScroller(pageScroller: PageScroller?) {
319 | try {
320 | val mScroller = ViewPager::class.java.getDeclaredField("mScroller")
321 | mScroller.isAccessible = true
322 | mScroller[this] = pageScroller
323 | } catch (e: NoSuchFieldException) {
324 | // Handle NoSuchFieldException
325 | } catch (e: IllegalArgumentException) {
326 | // Handle IllegalArgumentException
327 | } catch (e: IllegalAccessException) {
328 | // Handle IllegalAccessException
329 | }
330 | }
331 |
332 | private fun getAlignment(textAlign: String?): Int {
333 | return if (textAlign == "RIGHT") {
334 | Gravity.END
335 | } else if (textAlign == "LEFT") {
336 | Gravity.START
337 | } else {
338 | Gravity.CENTER
339 | }
340 | }
341 |
342 | fun onItemClickListener(listener: ItemsListener?) {
343 | itemClickListener = listener
344 |
345 | viewAdapter?.setItemClickListener(listener)
346 |
347 |
348 | }
349 |
350 | fun onItemChangeListener(listener: ItemsListener?) {
351 | viewAdapter?.setItemClickListener(listener)
352 | }
353 |
354 | fun onItemTouchListener(listener: ItemsListener?) {
355 | touchListener = listener
356 | viewAdapter?.setItemTouchListener(touchListener)
357 | }
358 |
359 | fun onItemDoubleTapListener(listener: ItemsListener?) {
360 | viewAdapter?.setItemDoubleTapListener(listener)
361 | }
362 | }
363 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Enums/ImageActionTypes.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Enums
2 |
3 | enum class ImageActionTypes(value: String) {
4 | DOWN("down"),
5 | UP("up"),
6 | MOVE("move")
7 | }
8 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Enums/ImageAnimationTypes.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Enums
2 |
3 | enum class ImageAnimationTypes(value: String) {
4 | ZOOM_IN("ZoomIn"),
5 | ZOOM_OUT("ZoomOut"),
6 | DEPTH_SLIDE("DepthSlide"),
7 | CUBE_IN("CubeIn"),
8 | CUBE_OUT("CubeOut"),
9 | FLIP_HORIZONTAL("FlipHorizontal"),
10 | FLIP_VERTICAL("FlipVertical"),
11 | FOREGROUND_TO_BACKGROUND("ForegroundToBackground"),
12 | BACKGROUND_TO_FOREGROUND("BackgroundToForeground"),
13 | ROTATE_UP("RotateUp"),
14 | ROTATE_DOWN("Rotate_Down"),
15 | GATE("Gate"),
16 | TOSS("Toss"),
17 | FIDGET_SPINNER("FidgetSpinner")
18 | }
19 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Enums/ImageScaleType.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Enums
2 |
3 | enum class ImageScaleType(val value: String) {
4 | FIT("fit"),
5 | CENTER_CROP("centerCrop"),
6 | CENTER_INSIDE("centerInside")
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/ExceptionsClass.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider
2 |
3 | class ExceptionsClass : Exception {
4 | constructor(message: String?) : super(message)
5 | constructor(message: String?, cause: Throwable?) : super(message, cause)
6 |
7 | var errorCode = 0
8 | private set
9 |
10 | constructor(message: String?, errorCode: Int) : super(message) {
11 | this.errorCode = errorCode
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Interfaces/ItemsListener.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Interfaces
2 |
3 | import com.codebyashish.autoimageslider.Enums.ImageActionTypes
4 |
5 | interface ItemsListener {
6 | fun onItemChanged(position: Int)
7 | fun onTouched(actionTypes: ImageActionTypes?, position: Int)
8 | fun onItemClicked(position: Int)
9 | }
10 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/Models/ImageSlidesModel.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider.Models
2 |
3 | import android.util.Log
4 | import com.codebyashish.autoimageslider.Enums.ImageScaleType
5 | import com.codebyashish.autoimageslider.ExceptionsClass
6 |
7 | class ImageSlidesModel {
8 | var imgPath = 0
9 | var imgUrl: String? = null
10 | var clickUrl: String? = null
11 | var imageScaleType: ImageScaleType? = null
12 | var title: String? = null
13 | var description: String? = null
14 |
15 | /**
16 | * For image paths from drawables
17 | */
18 | constructor(imgPath: Int) {
19 | this.imgPath = imgPath
20 | }
21 |
22 | constructor(imgPath: Int, imageScaleType: ImageScaleType?) {
23 | this.imgPath = imgPath
24 | this.imageScaleType = imageScaleType
25 | }
26 |
27 | constructor(imgPath: Int, imageScaleType: ImageScaleType?, title: String?) {
28 | this.imgPath = imgPath
29 | this.imageScaleType = imageScaleType
30 | this.title = title
31 | }
32 |
33 | constructor(imgPath: Int, title: String?) {
34 | this.imgPath = imgPath
35 | this.title = title
36 | }
37 |
38 | constructor(
39 | imgPath: Int,
40 | imageScaleType: ImageScaleType?,
41 | title: String?,
42 | description: String?
43 | ) {
44 | this.imgPath = imgPath
45 | this.imageScaleType = imageScaleType
46 | this.title = title
47 | this.description = description
48 | }
49 |
50 | constructor(imgPath: Int, clickUrl: String, scaleType: ImageScaleType) {
51 | this.imgPath = imgPath
52 | this.clickUrl = clickUrl
53 | imageScaleType = scaleType
54 | if (!clickUrl.startsWith("https://") && !clickUrl.startsWith("http://")) {
55 | this.clickUrl = "https://"
56 | }
57 | }
58 |
59 | constructor(imgPath: Int, clickUrl: String, title: String, scaleType: ImageScaleType) {
60 | this.imgPath = imgPath
61 | this.clickUrl = clickUrl
62 | this.title = title
63 | imageScaleType = scaleType
64 | if (!clickUrl.startsWith("https://") && !clickUrl.startsWith("http://")) {
65 | this.clickUrl = "https://"
66 | }
67 | }
68 |
69 | /**
70 | * For image paths from urls or internet
71 | */
72 | constructor(imgUrl: String, clickUrl: String, scaleType: ImageScaleType) {
73 | this.imgUrl = imgUrl
74 | this.clickUrl = clickUrl
75 | imageScaleType = scaleType
76 | if (!clickUrl.startsWith("https://") && !clickUrl.startsWith("http://")) {
77 | this.clickUrl = "https://"
78 | }
79 | }
80 |
81 | constructor(imgUrl: String, clickUrl: String, title: String, scaleType: ImageScaleType) {
82 | this.imgUrl = imgUrl
83 | this.clickUrl = clickUrl
84 | this.title = title
85 | imageScaleType = scaleType
86 | if (!clickUrl.startsWith("https://") && !clickUrl.startsWith("http://")) {
87 | this.clickUrl = "https://"
88 | }
89 | }
90 |
91 | constructor(imgUrl: String?) {
92 | this.imgUrl = imgUrl
93 | }
94 |
95 | constructor(imgUrl: String?, imageScaleType: ImageScaleType?) {
96 | this.imgUrl = imgUrl
97 | this.imageScaleType = imageScaleType
98 | }
99 |
100 | constructor(imgUrl: String?, imageScaleType: ImageScaleType?, title: String?) {
101 | this.imgUrl = imgUrl
102 | this.imageScaleType = imageScaleType
103 | this.title = title
104 | }
105 |
106 | constructor(imgUrl: String?, title: String?) {
107 | this.imgUrl = imgUrl
108 | this.title = title
109 | }
110 |
111 | constructor(imgUrl: String?, title: String?, description: String?) {
112 | this.imgUrl = imgUrl
113 | this.title = title
114 | this.description = description
115 | }
116 |
117 | constructor(
118 | imgUrl: String?,
119 | imageScaleType: ImageScaleType?,
120 | title: String?,
121 | description: String?
122 | ) {
123 | this.imgUrl = imgUrl
124 | this.imageScaleType = imageScaleType
125 | this.title = title
126 | this.description = description
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/PageScroller.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider
2 |
3 | import android.content.Context
4 | import android.view.animation.Interpolator
5 | import android.widget.Scroller
6 |
7 | class PageScroller : Scroller {
8 | var fixedDuration = 1000
9 |
10 | constructor(context: Context?) : super(context)
11 | constructor(context: Context?, interpolator: Interpolator?) : super(context, interpolator)
12 | constructor(context: Context?, interpolator: Interpolator?, flywheel: Boolean) : super(
13 | context,
14 | interpolator,
15 | flywheel
16 | )
17 |
18 | override fun startScroll(startX: Int, startY: Int, dx: Int, dy: Int, duration: Int) {
19 | super.startScroll(startX, startY, dx, dy, fixedDuration)
20 | }
21 |
22 | override fun startScroll(startX: Int, startY: Int, dx: Int, dy: Int) {
23 | super.startScroll(startX, startY, dx, dy, fixedDuration)
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/codebyashish/autoimageslider/PicassoTransformation.kt:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider
2 |
3 | import android.graphics.Bitmap
4 | import android.graphics.BitmapShader
5 | import android.graphics.Canvas
6 | import android.graphics.Paint
7 | import android.graphics.RectF
8 | import android.graphics.Shader
9 | import com.squareup.picasso.Transformation
10 |
11 | class PicassoTransformation(radius: Int, margin: Int, private val mCornerType: CornerType) :
12 | Transformation {
13 | private val mRadius: Float
14 | private val mDiameter: Float
15 | private val mMargin: Float
16 |
17 | enum class CornerType {
18 | ALL,
19 | TOP_LEFT,
20 | TOP_RIGHT,
21 | BOTTOM_LEFT,
22 | BOTTOM_RIGHT,
23 | TOP,
24 | BOTTOM,
25 | LEFT,
26 | RIGHT,
27 | OTHER_TOP_LEFT,
28 | OTHER_TOP_RIGHT,
29 | OTHER_BOTTOM_LEFT,
30 | OTHER_BOTTOM_RIGHT,
31 | DIAGONAL_FROM_TOP_LEFT,
32 | DIAGONAL_FROM_TOP_RIGHT
33 | }
34 |
35 | init {
36 | mRadius = radius.toFloat()
37 | mDiameter = (radius * 2).toFloat()
38 | mMargin = margin.toFloat()
39 | }
40 |
41 | override fun transform(source: Bitmap): Bitmap {
42 | val width = source.width
43 | val height = source.height
44 | val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
45 | val canvas = Canvas(bitmap)
46 | val paint = Paint()
47 | paint.isAntiAlias = true
48 | paint.setShader(BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP))
49 | drawRoundRect(canvas, paint, width.toFloat(), height.toFloat())
50 | source.recycle()
51 | return bitmap
52 | }
53 |
54 | private fun drawRoundRect(canvas: Canvas, paint: Paint, width: Float, height: Float) {
55 | val right = width - mMargin
56 | val bottom = height - mMargin
57 | when (mCornerType) {
58 | CornerType.ALL -> canvas.drawRoundRect(
59 | RectF(mMargin, mMargin, right, bottom),
60 | mRadius,
61 | mRadius,
62 | paint
63 | )
64 |
65 | CornerType.TOP_LEFT -> drawTopLeftRoundRect(canvas, paint, right, bottom)
66 | CornerType.TOP_RIGHT -> drawTopRightRoundRect(canvas, paint, right, bottom)
67 | CornerType.BOTTOM_LEFT -> drawBottomLeftRoundRect(canvas, paint, right, bottom)
68 | CornerType.BOTTOM_RIGHT -> drawBottomRightRoundRect(canvas, paint, right, bottom)
69 | CornerType.TOP -> drawTopRoundRect(canvas, paint, right, bottom)
70 | CornerType.BOTTOM -> drawBottomRoundRect(canvas, paint, right, bottom)
71 | CornerType.LEFT -> drawLeftRoundRect(canvas, paint, right, bottom)
72 | CornerType.RIGHT -> drawRightRoundRect(canvas, paint, right, bottom)
73 | CornerType.OTHER_TOP_LEFT -> drawOtherTopLeftRoundRect(canvas, paint, right, bottom)
74 | CornerType.OTHER_TOP_RIGHT -> drawOtherTopRightRoundRect(canvas, paint, right, bottom)
75 | CornerType.OTHER_BOTTOM_LEFT -> drawOtherBottomLeftRoundRect(
76 | canvas,
77 | paint,
78 | right,
79 | bottom
80 | )
81 |
82 | CornerType.OTHER_BOTTOM_RIGHT -> drawOtherBottomRightRoundRect(
83 | canvas,
84 | paint,
85 | right,
86 | bottom
87 | )
88 |
89 | CornerType.DIAGONAL_FROM_TOP_LEFT -> drawDiagonalFromTopLeftRoundRect(
90 | canvas,
91 | paint,
92 | right,
93 | bottom
94 | )
95 |
96 | CornerType.DIAGONAL_FROM_TOP_RIGHT -> drawDiagonalFromTopRightRoundRect(
97 | canvas,
98 | paint,
99 | right,
100 | bottom
101 | )
102 |
103 | else -> canvas.drawRoundRect(
104 | RectF(mMargin, mMargin, right, bottom),
105 | mRadius,
106 | mRadius,
107 | paint
108 | )
109 | }
110 | }
111 |
112 | private fun drawTopLeftRoundRect(canvas: Canvas, paint: Paint, right: Float, bottom: Float) {
113 | canvas.drawRoundRect(
114 | RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter),
115 | mRadius, mRadius, paint
116 | )
117 | canvas.drawRect(RectF(mMargin, mMargin + mRadius, mMargin + mRadius, bottom), paint)
118 | canvas.drawRect(RectF(mMargin + mRadius, mMargin, right, bottom), paint)
119 | }
120 |
121 | private fun drawTopRightRoundRect(canvas: Canvas, paint: Paint, right: Float, bottom: Float) {
122 | canvas.drawRoundRect(
123 | RectF(right - mDiameter, mMargin, right, mMargin + mDiameter), mRadius,
124 | mRadius, paint
125 | )
126 | canvas.drawRect(RectF(mMargin, mMargin, right - mRadius, bottom), paint)
127 | canvas.drawRect(RectF(right - mRadius, mMargin + mRadius, right, bottom), paint)
128 | }
129 |
130 | private fun drawBottomLeftRoundRect(canvas: Canvas, paint: Paint, right: Float, bottom: Float) {
131 | canvas.drawRoundRect(
132 | RectF(mMargin, bottom - mDiameter, mMargin + mDiameter, bottom),
133 | mRadius, mRadius, paint
134 | )
135 | canvas.drawRect(RectF(mMargin, mMargin, mMargin + mDiameter, bottom - mRadius), paint)
136 | canvas.drawRect(RectF(mMargin + mRadius, mMargin, right, bottom), paint)
137 | }
138 |
139 | private fun drawBottomRightRoundRect(
140 | canvas: Canvas,
141 | paint: Paint,
142 | right: Float,
143 | bottom: Float
144 | ) {
145 | canvas.drawRoundRect(
146 | RectF(right - mDiameter, bottom - mDiameter, right, bottom), mRadius,
147 | mRadius, paint
148 | )
149 | canvas.drawRect(RectF(mMargin, mMargin, right - mRadius, bottom), paint)
150 | canvas.drawRect(RectF(right - mRadius, mMargin, right, bottom - mRadius), paint)
151 | }
152 |
153 | private fun drawTopRoundRect(canvas: Canvas, paint: Paint, right: Float, bottom: Float) {
154 | canvas.drawRoundRect(
155 | RectF(mMargin, mMargin, right, mMargin + mDiameter), mRadius, mRadius,
156 | paint
157 | )
158 | canvas.drawRect(RectF(mMargin, mMargin + mRadius, right, bottom), paint)
159 | }
160 |
161 | private fun drawBottomRoundRect(canvas: Canvas, paint: Paint, right: Float, bottom: Float) {
162 | canvas.drawRoundRect(
163 | RectF(mMargin, bottom - mDiameter, right, bottom), mRadius, mRadius,
164 | paint
165 | )
166 | canvas.drawRect(RectF(mMargin, mMargin, right, bottom - mRadius), paint)
167 | }
168 |
169 | private fun drawLeftRoundRect(canvas: Canvas, paint: Paint, right: Float, bottom: Float) {
170 | canvas.drawRoundRect(
171 | RectF(mMargin, mMargin, mMargin + mDiameter, bottom), mRadius, mRadius,
172 | paint
173 | )
174 | canvas.drawRect(RectF(mMargin + mRadius, mMargin, right, bottom), paint)
175 | }
176 |
177 | private fun drawRightRoundRect(canvas: Canvas, paint: Paint, right: Float, bottom: Float) {
178 | canvas.drawRoundRect(
179 | RectF(right - mDiameter, mMargin, right, bottom), mRadius, mRadius,
180 | paint
181 | )
182 | canvas.drawRect(RectF(mMargin, mMargin, right - mRadius, bottom), paint)
183 | }
184 |
185 | private fun drawOtherTopLeftRoundRect(
186 | canvas: Canvas,
187 | paint: Paint,
188 | right: Float,
189 | bottom: Float
190 | ) {
191 | canvas.drawRoundRect(
192 | RectF(mMargin, bottom - mDiameter, right, bottom), mRadius, mRadius,
193 | paint
194 | )
195 | canvas.drawRoundRect(
196 | RectF(right - mDiameter, mMargin, right, bottom), mRadius, mRadius,
197 | paint
198 | )
199 | canvas.drawRect(RectF(mMargin, mMargin, right - mRadius, bottom - mRadius), paint)
200 | }
201 |
202 | private fun drawOtherTopRightRoundRect(
203 | canvas: Canvas,
204 | paint: Paint,
205 | right: Float,
206 | bottom: Float
207 | ) {
208 | canvas.drawRoundRect(
209 | RectF(mMargin, mMargin, mMargin + mDiameter, bottom), mRadius, mRadius,
210 | paint
211 | )
212 | canvas.drawRoundRect(
213 | RectF(mMargin, bottom - mDiameter, right, bottom), mRadius, mRadius,
214 | paint
215 | )
216 | canvas.drawRect(RectF(mMargin + mRadius, mMargin, right, bottom - mRadius), paint)
217 | }
218 |
219 | private fun drawOtherBottomLeftRoundRect(
220 | canvas: Canvas,
221 | paint: Paint,
222 | right: Float,
223 | bottom: Float
224 | ) {
225 | canvas.drawRoundRect(
226 | RectF(mMargin, mMargin, right, mMargin + mDiameter), mRadius, mRadius,
227 | paint
228 | )
229 | canvas.drawRoundRect(
230 | RectF(right - mDiameter, mMargin, right, bottom), mRadius, mRadius,
231 | paint
232 | )
233 | canvas.drawRect(RectF(mMargin, mMargin + mRadius, right - mRadius, bottom), paint)
234 | }
235 |
236 | private fun drawOtherBottomRightRoundRect(
237 | canvas: Canvas, paint: Paint, right: Float,
238 | bottom: Float
239 | ) {
240 | canvas.drawRoundRect(
241 | RectF(mMargin, mMargin, right, mMargin + mDiameter), mRadius, mRadius,
242 | paint
243 | )
244 | canvas.drawRoundRect(
245 | RectF(mMargin, mMargin, mMargin + mDiameter, bottom), mRadius, mRadius,
246 | paint
247 | )
248 | canvas.drawRect(RectF(mMargin + mRadius, mMargin + mRadius, right, bottom), paint)
249 | }
250 |
251 | private fun drawDiagonalFromTopLeftRoundRect(
252 | canvas: Canvas, paint: Paint, right: Float,
253 | bottom: Float
254 | ) {
255 | canvas.drawRoundRect(
256 | RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter),
257 | mRadius, mRadius, paint
258 | )
259 | canvas.drawRoundRect(
260 | RectF(right - mDiameter, bottom - mDiameter, right, bottom), mRadius,
261 | mRadius, paint
262 | )
263 | canvas.drawRect(RectF(mMargin, mMargin + mRadius, right - mDiameter, bottom), paint)
264 | canvas.drawRect(RectF(mMargin + mDiameter, mMargin, right, bottom - mRadius), paint)
265 | }
266 |
267 | private fun drawDiagonalFromTopRightRoundRect(
268 | canvas: Canvas, paint: Paint, right: Float,
269 | bottom: Float
270 | ) {
271 | canvas.drawRoundRect(
272 | RectF(right - mDiameter, mMargin, right, mMargin + mDiameter), mRadius,
273 | mRadius, paint
274 | )
275 | canvas.drawRoundRect(
276 | RectF(mMargin, bottom - mDiameter, mMargin + mDiameter, bottom),
277 | mRadius, mRadius, paint
278 | )
279 | canvas.drawRect(RectF(mMargin, mMargin, right - mRadius, bottom - mRadius), paint)
280 | canvas.drawRect(RectF(mMargin + mRadius, mMargin + mRadius, right, bottom), paint)
281 | }
282 |
283 | override fun key(): String {
284 | return ("RoundedTransformation(radius=" + mRadius + ", margin=" + mMargin + ", diameter="
285 | + mDiameter + ", cornerType=" + mCornerType.name + ")")
286 | }
287 | }
288 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/res/drawable/indicator_selected_dash.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/res/drawable/indicator_selected_dot.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/res/drawable/indicator_unselected_dash.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/res/drawable/indicator_unselected_dot.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/res/drawable/placeholder_default_loading.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dangiashish/Auto-Image-Slider/d82bcc1da4feccccb8aae074f8ce1fd1af1f4152/autoimageslider/src/main/res/drawable/placeholder_default_loading.jpg
--------------------------------------------------------------------------------
/autoimageslider/src/main/res/drawable/placeholder_image_failed.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dangiashish/Auto-Image-Slider/d82bcc1da4feccccb8aae074f8ce1fd1af1f4152/autoimageslider/src/main/res/drawable/placeholder_image_failed.jpg
--------------------------------------------------------------------------------
/autoimageslider/src/main/res/drawable/text_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/res/layout/item_pager.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
26 |
27 |
38 |
39 |
50 |
51 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/res/layout/layout_slider_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
23 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FF000000
4 | #FFFFFFFF
5 |
6 |
7 | #FBFBFB
8 | #ff9e9e9e
9 | #7F000000
10 | #FFFFFF
11 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Android Image Slider
3 | LEFT
4 | RIGHT
5 | CENTER
6 | dash
7 | dot
8 |
--------------------------------------------------------------------------------
/autoimageslider/src/test/java/com/codebyashish/autoimageslider/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.codebyashish.autoimageslider;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 |
2 |
3 | plugins {
4 | id("com.android.application") version "8.2.0" apply false
5 | id("com.android.library") version "8.1.0" apply false
6 | id("org.jetbrains.kotlin.android") version "1.8.20" apply false
7 | }
8 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | android.enableJetifier=true
19 | # Kotlin code style for this project: "official" or "obsolete":
20 | kotlin.code.style=official
21 | # Enables namespacing of each library's R class so that its R class includes only the
22 | # resources declared in the library itself and none from the library's dependencies,
23 | # thereby reducing the size of the R class for that library
24 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dangiashish/Auto-Image-Slider/d82bcc1da4feccccb8aae074f8ce1fd1af1f4152/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Nov 06 10:43:37 IST 2023
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file should *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | sdk.dir=E\:\\Android\\Sdk
--------------------------------------------------------------------------------
/preview.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dangiashish/Auto-Image-Slider/d82bcc1da4feccccb8aae074f8ce1fd1af1f4152/preview.gif
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | gradlePluginPortal()
6 | maven( url = "https://jitpack.io")
7 | }
8 | }
9 | dependencyResolutionManagement {
10 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
11 | repositories {
12 | google()
13 | mavenCentral()
14 | maven( url = "https://jitpack.io")
15 | }
16 | }
17 |
18 | rootProject.name = "AutoImageSlider"
19 | include(":app")
20 | include(":autoimageslider")
21 |
--------------------------------------------------------------------------------