├── .github
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── .gitignore
├── .idea
├── encodings.xml
├── kotlinc.xml
└── vcs.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── smarteist
│ │ └── imageslider
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── smarteist
│ │ │ └── imageslider
│ │ │ ├── MainActivity.java
│ │ │ ├── Model
│ │ │ └── SliderItem.java
│ │ │ └── SliderAdapterExample.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── bg_overlay.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── oh_look_at_this.gif
│ │ └── puma_offer.jpg
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── image_slider_layout_item.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── smarteist
│ └── imageslider
│ └── ExampleUnitTest.java
├── autoimageslider
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── smarteist
│ │ └── autoimageslider
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── smarteist
│ │ │ └── autoimageslider
│ │ │ ├── IndicatorView
│ │ │ ├── IndicatorManager.java
│ │ │ ├── PageIndicatorView.java
│ │ │ ├── animation
│ │ │ │ ├── AnimationManager.java
│ │ │ │ ├── controller
│ │ │ │ │ ├── AnimationController.java
│ │ │ │ │ └── ValueController.java
│ │ │ │ ├── data
│ │ │ │ │ ├── AnimationValue.java
│ │ │ │ │ ├── Value.java
│ │ │ │ │ └── type
│ │ │ │ │ │ ├── ColorAnimationValue.java
│ │ │ │ │ │ ├── DropAnimationValue.java
│ │ │ │ │ │ ├── FillAnimationValue.java
│ │ │ │ │ │ ├── ScaleAnimationValue.java
│ │ │ │ │ │ ├── SlideAnimationValue.java
│ │ │ │ │ │ ├── SwapAnimationValue.java
│ │ │ │ │ │ ├── ThinWormAnimationValue.java
│ │ │ │ │ │ └── WormAnimationValue.java
│ │ │ │ └── type
│ │ │ │ │ ├── BaseAnimation.java
│ │ │ │ │ ├── ColorAnimation.java
│ │ │ │ │ ├── DropAnimation.java
│ │ │ │ │ ├── FillAnimation.java
│ │ │ │ │ ├── IndicatorAnimationType.java
│ │ │ │ │ ├── ScaleAnimation.java
│ │ │ │ │ ├── ScaleDownAnimation.java
│ │ │ │ │ ├── SlideAnimation.java
│ │ │ │ │ ├── SwapAnimation.java
│ │ │ │ │ ├── ThinWormAnimation.java
│ │ │ │ │ └── WormAnimation.java
│ │ │ ├── draw
│ │ │ │ ├── DrawManager.java
│ │ │ │ ├── controller
│ │ │ │ │ ├── AttributeController.java
│ │ │ │ │ ├── DrawController.java
│ │ │ │ │ └── MeasureController.java
│ │ │ │ ├── data
│ │ │ │ │ ├── Indicator.java
│ │ │ │ │ ├── Orientation.java
│ │ │ │ │ ├── PositionSavedState.java
│ │ │ │ │ └── RtlMode.java
│ │ │ │ └── drawer
│ │ │ │ │ ├── Drawer.java
│ │ │ │ │ └── type
│ │ │ │ │ ├── BaseDrawer.java
│ │ │ │ │ ├── BasicDrawer.java
│ │ │ │ │ ├── ColorDrawer.java
│ │ │ │ │ ├── DropDrawer.java
│ │ │ │ │ ├── FillDrawer.java
│ │ │ │ │ ├── ScaleDownDrawer.java
│ │ │ │ │ ├── ScaleDrawer.java
│ │ │ │ │ ├── SlideDrawer.java
│ │ │ │ │ ├── SwapDrawer.java
│ │ │ │ │ ├── ThinWormDrawer.java
│ │ │ │ │ └── WormDrawer.java
│ │ │ └── utils
│ │ │ │ ├── CoordinatesUtils.java
│ │ │ │ ├── DensityUtils.java
│ │ │ │ └── IdUtils.java
│ │ │ ├── InfiniteAdapter
│ │ │ └── InfinitePagerAdapter.java
│ │ │ ├── SliderAnimations.java
│ │ │ ├── SliderPager.java
│ │ │ ├── SliderView.java
│ │ │ ├── SliderViewAdapter.java
│ │ │ └── Transformations
│ │ │ ├── AntiClockSpinTransformation.java
│ │ │ ├── Clock_SpinTransformation.java
│ │ │ ├── CubeInDepthTransformation.java
│ │ │ ├── CubeInRotationTransformation.java
│ │ │ ├── CubeInScalingTransformation.java
│ │ │ ├── CubeOutDepthTransformation.java
│ │ │ ├── CubeOutRotationTransformation.java
│ │ │ ├── CubeOutScalingTransformation.java
│ │ │ ├── DepthTransformation.java
│ │ │ ├── FadeTransformation.java
│ │ │ ├── FanTransformation.java
│ │ │ ├── FidgetSpinTransformation.java
│ │ │ ├── GateTransformation.java
│ │ │ ├── HingeTransformation.java
│ │ │ ├── HorizontalFlipTransformation.java
│ │ │ ├── PopTransformation.java
│ │ │ ├── SimpleTransformation.java
│ │ │ ├── SpinnerTransformation.java
│ │ │ ├── TossTransformation.java
│ │ │ ├── VerticalFlipTransformation.java
│ │ │ ├── VerticalShutTransformation.java
│ │ │ └── ZoomOutTransformation.java
│ └── res
│ │ └── values
│ │ ├── attrs.xml
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── smarteist
│ └── autoimageslider
│ └── ExampleUnitTest.java
├── build.gradle
├── gif
├── 0.gif
├── 4.gif
├── 7.gif
└── 8.gif
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/libraries
5 | /.idea/modules.xml
6 | /.idea/workspace.xml
7 | .DS_Store
8 | /build
9 | /captures
10 | .externalNativeBuild
11 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId "com.smarteist.imageslider"
7 | minSdkVersion 15
8 | targetSdkVersion 28
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(include: ['*.jar'], dir: 'libs')
23 | implementation 'androidx.appcompat:appcompat:1.0.2'
24 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
25 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
26 | testImplementation 'junit:junit:4.12'
27 | implementation 'com.github.bumptech.glide:glide:4.9.0'
28 | annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
29 | androidTestImplementation 'androidx.test:runner:1.1.1'
30 | implementation 'androidx.cardview:cardview:1.0.0'
31 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
32 | implementation project(':autoimageslider')
33 | }
34 |
--------------------------------------------------------------------------------
/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
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/smarteist/imageslider/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.imageslider;
2 |
3 | import android.content.Context;
4 | import androidx.test.InstrumentationRegistry;
5 | import androidx.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.smarteist.imageslider", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/smarteist/imageslider/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.imageslider;
2 |
3 | import android.graphics.Color;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 | import android.view.View;
7 |
8 | import androidx.appcompat.app.AppCompatActivity;
9 |
10 | import com.smarteist.autoimageslider.IndicatorView.PageIndicatorView;
11 | import com.smarteist.autoimageslider.IndicatorView.animation.type.IndicatorAnimationType;
12 | import com.smarteist.autoimageslider.IndicatorView.draw.controller.DrawController;
13 | import com.smarteist.autoimageslider.SliderAnimations;
14 | import com.smarteist.autoimageslider.SliderView;
15 | import com.smarteist.imageslider.Model.SliderItem;
16 |
17 | import java.util.ArrayList;
18 | import java.util.List;
19 |
20 | public class MainActivity extends AppCompatActivity {
21 |
22 | SliderView sliderView;
23 | private SliderAdapterExample adapter;
24 |
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_main);
29 |
30 | sliderView = findViewById(R.id.imageSlider);
31 |
32 |
33 | adapter = new SliderAdapterExample(this);
34 | sliderView.setSliderAdapter(adapter);
35 | sliderView.setIndicatorAnimation(IndicatorAnimationType.WORM); //set indicator animation by using SliderLayout.IndicatorAnimations. :WORM or THIN_WORM or COLOR or DROP or FILL or NONE or SCALE or SCALE_DOWN or SLIDE and SWAP!!
36 | sliderView.setSliderTransformAnimation(SliderAnimations.SIMPLETRANSFORMATION);
37 | sliderView.setAutoCycleDirection(SliderView.AUTO_CYCLE_DIRECTION_BACK_AND_FORTH);
38 | sliderView.setIndicatorSelectedColor(Color.WHITE);
39 | sliderView.setIndicatorUnselectedColor(Color.GRAY);
40 | sliderView.setScrollTimeInSec(3);
41 | sliderView.setAutoCycle(true);
42 | sliderView.startAutoCycle();
43 |
44 |
45 | sliderView.setOnIndicatorClickListener(new DrawController.ClickListener() {
46 | @Override
47 | public void onIndicatorClicked(int position) {
48 | Log.i("GGG", "onIndicatorClicked: " + sliderView.getCurrentPagePosition());
49 | }
50 | });
51 |
52 | }
53 |
54 | public void renewItems(View view) {
55 | List sliderItemList = new ArrayList<>();
56 | //dummy data
57 | for (int i = 0; i < 5; i++) {
58 | SliderItem sliderItem = new SliderItem();
59 | sliderItem.setDescription("Slider Item " + i);
60 | if (i % 2 == 0) {
61 | sliderItem.setImageUrl("https://images.pexels.com/photos/929778/pexels-photo-929778.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260");
62 | } else {
63 | sliderItem.setImageUrl("https://images.pexels.com/photos/747964/pexels-photo-747964.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260");
64 | }
65 | sliderItemList.add(sliderItem);
66 | }
67 | adapter.renewItems(sliderItemList);
68 | }
69 |
70 | public void removeLastItem(View view) {
71 | if (adapter.getCount() - 1 >= 0)
72 | adapter.deleteItem(adapter.getCount() - 1);
73 | }
74 |
75 | public void addNewItem(View view) {
76 | SliderItem sliderItem = new SliderItem();
77 | sliderItem.setDescription("Slider Item Added Manually");
78 | sliderItem.setImageUrl("https://images.pexels.com/photos/929778/pexels-photo-929778.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260");
79 | adapter.addItem(sliderItem);
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/app/src/main/java/com/smarteist/imageslider/Model/SliderItem.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.imageslider.Model;
2 |
3 | public class SliderItem {
4 |
5 | private String description;
6 | private String imageUrl;
7 |
8 | public String getDescription() {
9 | return description;
10 | }
11 |
12 | public void setDescription(String description) {
13 | this.description = description;
14 | }
15 |
16 | public String getImageUrl() {
17 | return imageUrl;
18 | }
19 |
20 | public void setImageUrl(String imageUrl) {
21 | this.imageUrl = imageUrl;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/smarteist/imageslider/SliderAdapterExample.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.imageslider;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 | import android.widget.Toast;
11 | import com.bumptech.glide.Glide;
12 | import com.smarteist.autoimageslider.SliderViewAdapter;
13 | import com.smarteist.imageslider.Model.SliderItem;
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | public class SliderAdapterExample extends
18 | SliderViewAdapter {
19 |
20 | private Context context;
21 | private List mSliderItems = new ArrayList<>();
22 |
23 | public SliderAdapterExample(Context context) {
24 | this.context = context;
25 | }
26 |
27 | public void renewItems(List sliderItems) {
28 | this.mSliderItems = sliderItems;
29 | notifyDataSetChanged();
30 | }
31 |
32 | public void deleteItem(int position) {
33 | this.mSliderItems.remove(position);
34 | notifyDataSetChanged();
35 | }
36 |
37 | public void addItem(SliderItem sliderItem) {
38 | this.mSliderItems.add(sliderItem);
39 | notifyDataSetChanged();
40 | }
41 |
42 | @Override
43 | public SliderAdapterVH onCreateViewHolder(ViewGroup parent) {
44 | View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.image_slider_layout_item, null);
45 | return new SliderAdapterVH(inflate);
46 | }
47 |
48 | @Override
49 | public void onBindViewHolder(SliderAdapterVH viewHolder, final int position) {
50 |
51 | SliderItem sliderItem = mSliderItems.get(position);
52 |
53 | viewHolder.textViewDescription.setText(sliderItem.getDescription());
54 | viewHolder.textViewDescription.setTextSize(16);
55 | viewHolder.textViewDescription.setTextColor(Color.WHITE);
56 | Glide.with(viewHolder.itemView)
57 | .load(sliderItem.getImageUrl())
58 | .fitCenter()
59 | .into(viewHolder.imageViewBackground);
60 |
61 | viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
62 | @Override
63 | public void onClick(View v) {
64 | Toast.makeText(context, "This is item in position " + position, Toast.LENGTH_SHORT).show();
65 | }
66 | });
67 | }
68 |
69 | @Override
70 | public int getCount() {
71 | //slider view count could be dynamic size
72 | return mSliderItems.size();
73 | }
74 |
75 | class SliderAdapterVH extends SliderViewAdapter.ViewHolder {
76 |
77 | View itemView;
78 | ImageView imageViewBackground;
79 | ImageView imageGifContainer;
80 | TextView textViewDescription;
81 |
82 | public SliderAdapterVH(View itemView) {
83 | super(itemView);
84 | imageViewBackground = itemView.findViewById(R.id.iv_auto_image_slider);
85 | imageGifContainer = itemView.findViewById(R.id.iv_gif_container);
86 | textViewDescription = itemView.findViewById(R.id.tv_auto_image_slider);
87 | this.itemView = itemView;
88 | }
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_overlay.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
8 |
--------------------------------------------------------------------------------
/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/oh_look_at_this.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smarteist/Android-Image-Slider/66b747be678ae1186e73e487539aa7f22f5cb9fd/app/src/main/res/drawable/oh_look_at_this.gif
--------------------------------------------------------------------------------
/app/src/main/res/drawable/puma_offer.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smarteist/Android-Image-Slider/66b747be678ae1186e73e487539aa7f22f5cb9fd/app/src/main/res/drawable/puma_offer.jpg
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
33 |
34 |
35 |
36 |
42 |
43 |
48 |
49 |
54 |
55 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/image_slider_layout_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
15 |
21 |
22 |
23 |
29 |
30 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smarteist/Android-Image-Slider/66b747be678ae1186e73e487539aa7f22f5cb9fd/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smarteist/Android-Image-Slider/66b747be678ae1186e73e487539aa7f22f5cb9fd/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smarteist/Android-Image-Slider/66b747be678ae1186e73e487539aa7f22f5cb9fd/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smarteist/Android-Image-Slider/66b747be678ae1186e73e487539aa7f22f5cb9fd/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smarteist/Android-Image-Slider/66b747be678ae1186e73e487539aa7f22f5cb9fd/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smarteist/Android-Image-Slider/66b747be678ae1186e73e487539aa7f22f5cb9fd/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smarteist/Android-Image-Slider/66b747be678ae1186e73e487539aa7f22f5cb9fd/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smarteist/Android-Image-Slider/66b747be678ae1186e73e487539aa7f22f5cb9fd/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smarteist/Android-Image-Slider/66b747be678ae1186e73e487539aa7f22f5cb9fd/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smarteist/Android-Image-Slider/66b747be678ae1186e73e487539aa7f22f5cb9fd/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ImageSlider
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/smarteist/imageslider/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.imageslider;
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 | }
--------------------------------------------------------------------------------
/autoimageslider/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/autoimageslider/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 |
4 | ext {
5 |
6 | bintrayRepo = 'android'
7 | bintrayName = 'androidautoimageslider'
8 |
9 | publishedGroupId = 'com.github.smarteist'
10 | libraryName = 'autoimageslider'
11 | artifact = 'autoimageslider'
12 |
13 | libraryDescription = 'Simple, android image slider'
14 |
15 | siteUrl = 'https://github.com/smarteist'
16 | gitUrl = 'https://github.com/smarteist/android-image-slider.git'
17 |
18 | libraryVersion = '1.4.0'
19 | organization = 'smarteistbintray' // if you push to organization's repository.
20 | developerId = 'smarteist'
21 | developerName = 'Ali Hosseini'
22 | developerEmail = 'ali.hosseini.sr@gmail.com'
23 |
24 | licenseName = 'The Apache Software License, Version 2.0'
25 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
26 | allLicenses = ["Apache-2.0"]
27 |
28 | }
29 |
30 | android {
31 | compileSdkVersion 29
32 |
33 | defaultConfig {
34 | minSdkVersion 15
35 | targetSdkVersion 29
36 | versionCode 5
37 | versionName "1.3.9"
38 |
39 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
40 |
41 | }
42 |
43 | buildTypes {
44 | release {
45 | minifyEnabled false
46 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
47 | }
48 | }
49 |
50 | }
51 |
52 | // Add a new configuration to hold your dependencies
53 | configurations {
54 | libConfig
55 | }
56 |
57 | dependencies {
58 | implementation fileTree(include: ['*.jar'], dir: 'libs')
59 | //noinspection GradleCompatible
60 | implementation 'androidx.appcompat:appcompat:1.1.0'
61 | testImplementation 'junit:junit:4.12'
62 | androidTestImplementation 'androidx.test:runner:1.2.0'
63 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
64 |
65 | }
66 |
67 | task copyLibs(type: Copy) {
68 | from configurations.libConfig
69 | into 'libs'
70 | }
71 |
72 | apply from: 'https://raw.githubusercontent.com/smarteist/bintrayUpload/master/install.gradle'
73 | apply from: 'https://raw.githubusercontent.com/smarteist/bintrayUpload/master/bintray.gradle'
74 |
--------------------------------------------------------------------------------
/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
22 |
--------------------------------------------------------------------------------
/autoimageslider/src/androidTest/java/com/smarteist/autoimageslider/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider;
2 |
3 | import android.content.Context;
4 | import androidx.test.InstrumentationRegistry;
5 | import androidx.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.smarteist.autoimageslider.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/IndicatorManager.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView;
2 |
3 | import androidx.annotation.Nullable;
4 | import com.smarteist.autoimageslider.IndicatorView.animation.AnimationManager;
5 | import com.smarteist.autoimageslider.IndicatorView.animation.controller.ValueController;
6 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
7 | import com.smarteist.autoimageslider.IndicatorView.draw.DrawManager;
8 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
9 |
10 | public class IndicatorManager implements ValueController.UpdateListener {
11 |
12 | private DrawManager drawManager;
13 | private AnimationManager animationManager;
14 | private Listener listener;
15 |
16 | interface Listener {
17 | void onIndicatorUpdated();
18 | }
19 |
20 | IndicatorManager(@Nullable Listener listener) {
21 | this.listener = listener;
22 | this.drawManager = new DrawManager();
23 | this.animationManager = new AnimationManager(drawManager.indicator(), this);
24 | }
25 |
26 | public AnimationManager animate() {
27 | return animationManager;
28 | }
29 |
30 | public Indicator indicator() {
31 | return drawManager.indicator();
32 | }
33 |
34 | public DrawManager drawer() {
35 | return drawManager;
36 | }
37 |
38 | @Override
39 | public void onValueUpdated(@Nullable Value value) {
40 | drawManager.updateValue(value);
41 | if (listener != null) {
42 | listener.onIndicatorUpdated();
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/AnimationManager.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import com.smarteist.autoimageslider.IndicatorView.animation.controller.AnimationController;
6 | import com.smarteist.autoimageslider.IndicatorView.animation.controller.ValueController;
7 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
8 |
9 |
10 | public class AnimationManager {
11 |
12 | private AnimationController animationController;
13 |
14 | public AnimationManager(@NonNull Indicator indicator, @NonNull ValueController.UpdateListener listener) {
15 | this.animationController = new AnimationController(indicator, listener);
16 | }
17 |
18 | public void basic() {
19 | if (animationController != null) {
20 | animationController.end();
21 | animationController.basic();
22 | }
23 | }
24 |
25 | public void interactive(float progress) {
26 | if (animationController != null) {
27 | animationController.interactive(progress);
28 | }
29 | }
30 |
31 | public void end() {
32 | if (animationController != null) {
33 | animationController.end();
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/controller/ValueController.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.controller;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.annotation.Nullable;
5 |
6 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
7 | import com.smarteist.autoimageslider.IndicatorView.animation.type.*;
8 |
9 | public class ValueController {
10 |
11 | private ColorAnimation colorAnimation;
12 | private ScaleAnimation scaleAnimation;
13 | private WormAnimation wormAnimation;
14 | private SlideAnimation slideAnimation;
15 | private FillAnimation fillAnimation;
16 | private ThinWormAnimation thinWormAnimation;
17 | private DropAnimation dropAnimation;
18 | private SwapAnimation swapAnimation;
19 | private ScaleDownAnimation scaleDownAnimation;
20 |
21 | private UpdateListener updateListener;
22 |
23 | public interface UpdateListener {
24 | void onValueUpdated(@Nullable Value value);
25 | }
26 |
27 | public ValueController(@Nullable UpdateListener listener) {
28 | updateListener = listener;
29 | }
30 |
31 | @NonNull
32 | public ColorAnimation color() {
33 | if (colorAnimation == null) {
34 | colorAnimation = new ColorAnimation(updateListener);
35 | }
36 |
37 | return colorAnimation;
38 | }
39 |
40 | @NonNull
41 | public ScaleAnimation scale() {
42 | if (scaleAnimation == null) {
43 | scaleAnimation = new ScaleAnimation(updateListener);
44 | }
45 |
46 | return scaleAnimation;
47 | }
48 |
49 | @NonNull
50 | public WormAnimation worm() {
51 | if (wormAnimation == null) {
52 | wormAnimation = new WormAnimation(updateListener);
53 | }
54 |
55 | return wormAnimation;
56 | }
57 |
58 | @NonNull
59 | public SlideAnimation slide() {
60 | if (slideAnimation == null) {
61 | slideAnimation = new SlideAnimation(updateListener);
62 | }
63 |
64 | return slideAnimation;
65 | }
66 |
67 | @NonNull
68 | public FillAnimation fill() {
69 | if (fillAnimation == null) {
70 | fillAnimation = new FillAnimation(updateListener);
71 | }
72 |
73 | return fillAnimation;
74 | }
75 |
76 | @NonNull
77 | public ThinWormAnimation thinWorm() {
78 | if (thinWormAnimation == null) {
79 | thinWormAnimation = new ThinWormAnimation(updateListener);
80 | }
81 |
82 | return thinWormAnimation;
83 | }
84 |
85 | @NonNull
86 | public DropAnimation drop() {
87 | if (dropAnimation == null) {
88 | dropAnimation = new DropAnimation(updateListener);
89 | }
90 |
91 | return dropAnimation;
92 | }
93 |
94 | @NonNull
95 | public SwapAnimation swap() {
96 | if (swapAnimation == null) {
97 | swapAnimation = new SwapAnimation(updateListener);
98 | }
99 |
100 | return swapAnimation;
101 | }
102 |
103 | @NonNull
104 | public ScaleDownAnimation scaleDown() {
105 | if (scaleDownAnimation == null) {
106 | scaleDownAnimation = new ScaleDownAnimation(updateListener);
107 | }
108 |
109 | return scaleDownAnimation;
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/data/AnimationValue.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.data;
2 |
3 | import androidx.annotation.NonNull;
4 | import com.smarteist.autoimageslider.IndicatorView.animation.data.type.*;
5 |
6 | public class AnimationValue {
7 |
8 | private ColorAnimationValue colorAnimationValue;
9 | private ScaleAnimationValue scaleAnimationValue;
10 | private WormAnimationValue wormAnimationValue;
11 | private FillAnimationValue fillAnimationValue;
12 | private ThinWormAnimationValue thinWormAnimationValue;
13 | private DropAnimationValue dropAnimationValue;
14 | private SwapAnimationValue swapAnimationValue;
15 |
16 | @NonNull
17 | public ColorAnimationValue getColorAnimationValue() {
18 | if (colorAnimationValue == null) {
19 | colorAnimationValue = new ColorAnimationValue();
20 | }
21 | return colorAnimationValue;
22 | }
23 |
24 | @NonNull
25 | public ScaleAnimationValue getScaleAnimationValue() {
26 | if (scaleAnimationValue == null) {
27 | scaleAnimationValue = new ScaleAnimationValue();
28 | }
29 | return scaleAnimationValue;
30 | }
31 |
32 | @NonNull
33 | public WormAnimationValue getWormAnimationValue() {
34 | if (wormAnimationValue == null) {
35 | wormAnimationValue = new WormAnimationValue();
36 | }
37 | return wormAnimationValue;
38 | }
39 |
40 | @NonNull
41 | public FillAnimationValue getFillAnimationValue() {
42 | if (fillAnimationValue == null) {
43 | fillAnimationValue = new FillAnimationValue();
44 | }
45 | return fillAnimationValue;
46 | }
47 |
48 | @NonNull
49 | public ThinWormAnimationValue getThinWormAnimationValue() {
50 | if (thinWormAnimationValue == null) {
51 | thinWormAnimationValue = new ThinWormAnimationValue();
52 | }
53 | return thinWormAnimationValue;
54 | }
55 |
56 | @NonNull
57 | public DropAnimationValue getDropAnimationValue() {
58 | if (dropAnimationValue == null) {
59 | dropAnimationValue = new DropAnimationValue();
60 | }
61 | return dropAnimationValue;
62 | }
63 |
64 | @NonNull
65 | public SwapAnimationValue getSwapAnimationValue() {
66 | if (swapAnimationValue == null) {
67 | swapAnimationValue = new SwapAnimationValue();
68 | }
69 | return swapAnimationValue;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/data/Value.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.data;
2 |
3 | public interface Value {/*empty*/}
4 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/data/type/ColorAnimationValue.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.data.type;
2 |
3 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
4 |
5 | public class ColorAnimationValue implements Value {
6 |
7 | private int color;
8 | private int colorReverse;
9 |
10 | public int getColor() {
11 | return color;
12 | }
13 |
14 | public void setColor(int color) {
15 | this.color = color;
16 | }
17 |
18 | public int getColorReverse() {
19 | return colorReverse;
20 | }
21 |
22 | public void setColorReverse(int colorReverse) {
23 | this.colorReverse = colorReverse;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/data/type/DropAnimationValue.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.data.type;
2 |
3 |
4 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
5 |
6 | public class DropAnimationValue implements Value {
7 |
8 | private int width;
9 | private int height;
10 | private int radius;
11 |
12 | public int getWidth() {
13 | return width;
14 | }
15 |
16 | public void setWidth(int width) {
17 | this.width = width;
18 | }
19 |
20 | public int getHeight() {
21 | return height;
22 | }
23 |
24 | public void setHeight(int height) {
25 | this.height = height;
26 | }
27 |
28 | public int getRadius() {
29 | return radius;
30 | }
31 |
32 | public void setRadius(int radius) {
33 | this.radius = radius;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/data/type/FillAnimationValue.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.data.type;
2 |
3 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
4 |
5 | public class FillAnimationValue extends ColorAnimationValue implements Value {
6 |
7 | private int radius;
8 | private int radiusReverse;
9 |
10 | private int stroke;
11 | private int strokeReverse;
12 |
13 | public int getRadius() {
14 | return radius;
15 | }
16 |
17 | public void setRadius(int radius) {
18 | this.radius = radius;
19 | }
20 |
21 | public int getRadiusReverse() {
22 | return radiusReverse;
23 | }
24 |
25 | public void setRadiusReverse(int radiusReverse) {
26 | this.radiusReverse = radiusReverse;
27 | }
28 |
29 | public int getStroke() {
30 | return stroke;
31 | }
32 |
33 | public void setStroke(int stroke) {
34 | this.stroke = stroke;
35 | }
36 |
37 | public int getStrokeReverse() {
38 | return strokeReverse;
39 | }
40 |
41 | public void setStrokeReverse(int strokeReverse) {
42 | this.strokeReverse = strokeReverse;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/data/type/ScaleAnimationValue.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.data.type;
2 |
3 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
4 |
5 | public class ScaleAnimationValue extends ColorAnimationValue implements Value {
6 |
7 | private int radius;
8 | private int radiusReverse;
9 |
10 | public int getRadius() {
11 | return radius;
12 | }
13 |
14 | public void setRadius(int radius) {
15 | this.radius = radius;
16 | }
17 |
18 | public int getRadiusReverse() {
19 | return radiusReverse;
20 | }
21 |
22 | public void setRadiusReverse(int radiusReverse) {
23 | this.radiusReverse = radiusReverse;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/data/type/SlideAnimationValue.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.data.type;
2 |
3 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
4 |
5 | public class SlideAnimationValue implements Value {
6 |
7 | private int coordinate;
8 |
9 | public int getCoordinate() {
10 | return coordinate;
11 | }
12 |
13 | public void setCoordinate(int coordinate) {
14 | this.coordinate = coordinate;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/data/type/SwapAnimationValue.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.data.type;
2 |
3 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
4 |
5 | public class SwapAnimationValue implements Value {
6 |
7 | private int coordinate;
8 | private int coordinateReverse;
9 |
10 | public int getCoordinate() {
11 | return coordinate;
12 | }
13 |
14 | public void setCoordinate(int coordinate) {
15 | this.coordinate = coordinate;
16 | }
17 |
18 | public int getCoordinateReverse() {
19 | return coordinateReverse;
20 | }
21 |
22 | public void setCoordinateReverse(int coordinateReverse) {
23 | this.coordinateReverse = coordinateReverse;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/data/type/ThinWormAnimationValue.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.data.type;
2 |
3 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
4 |
5 | public class ThinWormAnimationValue extends WormAnimationValue implements Value {
6 |
7 | private int height;
8 |
9 | public int getHeight() {
10 | return height;
11 | }
12 |
13 | public void setHeight(int height) {
14 | this.height = height;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/data/type/WormAnimationValue.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.data.type;
2 |
3 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
4 |
5 | public class WormAnimationValue implements Value {
6 |
7 | private int rectStart;
8 | private int rectEnd;
9 |
10 | public int getRectStart() {
11 | return rectStart;
12 | }
13 |
14 | public void setRectStart(int rectStartEdge) {
15 | this.rectStart = rectStartEdge;
16 | }
17 |
18 | public int getRectEnd() {
19 | return rectEnd;
20 | }
21 |
22 | public void setRectEnd(int rectEnd) {
23 | this.rectEnd = rectEnd;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/type/BaseAnimation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.type;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ValueAnimator;
5 | import androidx.annotation.NonNull;
6 | import androidx.annotation.Nullable;
7 | import com.smarteist.autoimageslider.IndicatorView.animation.controller.ValueController;
8 |
9 | public abstract class BaseAnimation {
10 |
11 | public static final int DEFAULT_ANIMATION_TIME = 350;
12 | protected long animationDuration = DEFAULT_ANIMATION_TIME;
13 |
14 | protected ValueController.UpdateListener listener;
15 | protected T animator;
16 |
17 | public BaseAnimation(@Nullable ValueController.UpdateListener listener) {
18 | this.listener = listener;
19 | animator = createAnimator();
20 | }
21 |
22 | @NonNull
23 | public abstract T createAnimator();
24 |
25 | public abstract BaseAnimation progress(float progress);
26 |
27 | public BaseAnimation duration(long duration) {
28 | animationDuration = duration;
29 |
30 | if (animator instanceof ValueAnimator) {
31 | animator.setDuration(animationDuration);
32 | }
33 |
34 | return this;
35 | }
36 |
37 | public void start() {
38 | if (animator != null && !animator.isRunning()) {
39 | animator.start();
40 | }
41 | }
42 |
43 | public void end() {
44 | if (animator != null && animator.isStarted()) {
45 | animator.end();
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/type/ColorAnimation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.type;
2 |
3 | import android.animation.ArgbEvaluator;
4 | import android.animation.PropertyValuesHolder;
5 | import android.animation.ValueAnimator;
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 | import android.view.animation.AccelerateDecelerateInterpolator;
9 | import com.smarteist.autoimageslider.IndicatorView.animation.controller.ValueController;
10 | import com.smarteist.autoimageslider.IndicatorView.animation.data.type.ColorAnimationValue;
11 |
12 | public class ColorAnimation extends BaseAnimation {
13 |
14 | public static final String DEFAULT_UNSELECTED_COLOR = "#33ffffff";
15 | public static final String DEFAULT_SELECTED_COLOR = "#ffffff";
16 |
17 | static final String ANIMATION_COLOR_REVERSE = "ANIMATION_COLOR_REVERSE";
18 | static final String ANIMATION_COLOR = "ANIMATION_COLOR";
19 |
20 | private ColorAnimationValue value;
21 |
22 | int colorStart;
23 | int colorEnd;
24 |
25 | public ColorAnimation(@Nullable ValueController.UpdateListener listener) {
26 | super(listener);
27 | value = new ColorAnimationValue();
28 | }
29 |
30 | @NonNull
31 | @Override
32 | public ValueAnimator createAnimator() {
33 | ValueAnimator animator = new ValueAnimator();
34 | animator.setDuration(BaseAnimation.DEFAULT_ANIMATION_TIME);
35 | animator.setInterpolator(new AccelerateDecelerateInterpolator());
36 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
37 | @Override
38 | public void onAnimationUpdate(ValueAnimator animation) {
39 | onAnimateUpdated(animation);
40 | }
41 | });
42 |
43 | return animator;
44 | }
45 |
46 | @Override
47 | public ColorAnimation progress(float progress) {
48 | if (animator != null) {
49 | long playTime = (long) (progress * animationDuration);
50 |
51 | if (animator.getValues() != null && animator.getValues().length > 0) {
52 | animator.setCurrentPlayTime(playTime);
53 | }
54 | }
55 |
56 | return this;
57 | }
58 |
59 | @NonNull
60 | public ColorAnimation with(int colorStart, int colorEnd) {
61 | if (animator != null && hasChanges(colorStart, colorEnd)) {
62 |
63 | this.colorStart = colorStart;
64 | this.colorEnd = colorEnd;
65 |
66 | PropertyValuesHolder colorHolder = createColorPropertyHolder(false);
67 | PropertyValuesHolder reverseColorHolder = createColorPropertyHolder(true);
68 |
69 | animator.setValues(colorHolder, reverseColorHolder);
70 | }
71 |
72 | return this;
73 | }
74 |
75 | PropertyValuesHolder createColorPropertyHolder(boolean isReverse) {
76 | String propertyName;
77 | int colorStart;
78 | int colorEnd;
79 |
80 | if (isReverse) {
81 | propertyName = ANIMATION_COLOR_REVERSE;
82 | colorStart = this.colorEnd;
83 | colorEnd = this.colorStart;
84 |
85 | } else {
86 | propertyName = ANIMATION_COLOR;
87 | colorStart = this.colorStart;
88 | colorEnd = this.colorEnd;
89 | }
90 |
91 | PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, colorStart, colorEnd);
92 | holder.setEvaluator(new ArgbEvaluator());
93 |
94 | return holder;
95 | }
96 |
97 | @SuppressWarnings("RedundantIfStatement")
98 | private boolean hasChanges(int colorStart, int colorEnd) {
99 | if (this.colorStart != colorStart) {
100 | return true;
101 | }
102 |
103 | if (this.colorEnd != colorEnd) {
104 | return true;
105 | }
106 |
107 | return false;
108 | }
109 |
110 | private void onAnimateUpdated(@NonNull ValueAnimator animation) {
111 | int color = (int) animation.getAnimatedValue(ANIMATION_COLOR);
112 | int colorReverse = (int) animation.getAnimatedValue(ANIMATION_COLOR_REVERSE);
113 |
114 | value.setColor(color);
115 | value.setColorReverse(colorReverse);
116 |
117 | if (listener != null) {
118 | listener.onValueUpdated(value);
119 | }
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/type/DropAnimation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.type;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorSet;
5 | import android.animation.ValueAnimator;
6 | import androidx.annotation.NonNull;
7 | import android.view.animation.AccelerateDecelerateInterpolator;
8 | import com.smarteist.autoimageslider.IndicatorView.animation.controller.ValueController;
9 | import com.smarteist.autoimageslider.IndicatorView.animation.data.type.DropAnimationValue;
10 |
11 | public class DropAnimation extends BaseAnimation {
12 |
13 | private int widthStart;
14 | private int widthEnd;
15 | private int heightStart;
16 | private int heightEnd;
17 | private int radius;
18 |
19 | private enum AnimationType {Width, Height, Radius}
20 |
21 | private DropAnimationValue value;
22 |
23 | public DropAnimation(@NonNull ValueController.UpdateListener listener) {
24 | super(listener);
25 | value = new DropAnimationValue();
26 | }
27 |
28 | @NonNull
29 | @Override
30 | public AnimatorSet createAnimator() {
31 | AnimatorSet animator = new AnimatorSet();
32 | animator.setInterpolator(new AccelerateDecelerateInterpolator());
33 |
34 | return animator;
35 | }
36 |
37 | @Override
38 | public DropAnimation progress(float progress) {
39 | if (animator != null) {
40 | long playTimeLeft = (long) (progress * animationDuration);
41 | boolean isReverse = false;
42 |
43 | for (Animator anim : animator.getChildAnimations()) {
44 | ValueAnimator animator = (ValueAnimator) anim;
45 | long animDuration = animator.getDuration();
46 | long currPlayTime = playTimeLeft;
47 |
48 | if (isReverse) {
49 | currPlayTime -= animDuration;
50 | }
51 |
52 | if (currPlayTime < 0) {
53 | continue;
54 |
55 | } else if (currPlayTime >= animDuration) {
56 | currPlayTime = animDuration;
57 | }
58 |
59 | if (animator.getValues() != null && animator.getValues().length > 0) {
60 | animator.setCurrentPlayTime(currPlayTime);
61 | }
62 |
63 | if (!isReverse && animDuration >= animationDuration) {
64 | isReverse = true;
65 | }
66 | }
67 | }
68 |
69 | return this;
70 | }
71 |
72 | @Override
73 | public DropAnimation duration(long duration) {
74 | super.duration(duration);
75 | return this;
76 | }
77 |
78 | @SuppressWarnings("UnnecessaryLocalVariable")
79 | public DropAnimation with(int widthStart, int widthEnd, int heightStart, int heightEnd, int radius) {
80 | if (hasChanges(widthStart, widthEnd, heightStart, heightEnd, radius)) {
81 | animator = createAnimator();
82 |
83 | this.widthStart = widthStart;
84 | this.widthEnd = widthEnd;
85 | this.heightStart = heightStart;
86 | this.heightEnd = heightEnd;
87 | this.radius = radius;
88 |
89 | int fromRadius = radius;
90 | int toRadius = (int) (radius / 1.5);
91 | long halfDuration = animationDuration / 2;
92 |
93 | ValueAnimator widthAnimator = createValueAnimation(widthStart, widthEnd, animationDuration, AnimationType.Width);
94 | ValueAnimator heightForwardAnimator = createValueAnimation(heightStart, heightEnd, halfDuration, AnimationType.Height);
95 | ValueAnimator radiusForwardAnimator = createValueAnimation(fromRadius, toRadius, halfDuration, AnimationType.Radius);
96 |
97 | ValueAnimator heightBackwardAnimator = createValueAnimation(heightEnd, heightStart, halfDuration, AnimationType.Height);
98 | ValueAnimator radiusBackwardAnimator = createValueAnimation(toRadius, fromRadius, halfDuration, AnimationType.Radius);
99 |
100 | animator.play(heightForwardAnimator)
101 | .with(radiusForwardAnimator)
102 | .with(widthAnimator)
103 | .before(heightBackwardAnimator)
104 | .before(radiusBackwardAnimator);
105 | }
106 |
107 | return this;
108 | }
109 |
110 | private ValueAnimator createValueAnimation(int fromValue, int toValue, long duration, final AnimationType type) {
111 | ValueAnimator anim = ValueAnimator.ofInt(fromValue, toValue);
112 | anim.setInterpolator(new AccelerateDecelerateInterpolator());
113 | anim.setDuration(duration);
114 | anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
115 | @Override
116 | public void onAnimationUpdate(ValueAnimator animation) {
117 | onAnimatorUpdate(animation, type);
118 | }
119 | });
120 |
121 | return anim;
122 | }
123 |
124 | private void onAnimatorUpdate(@NonNull ValueAnimator animation, @NonNull AnimationType type) {
125 | int frameValue = (int) animation.getAnimatedValue();
126 |
127 | switch (type) {
128 | case Width:
129 | value.setWidth(frameValue);
130 | break;
131 |
132 | case Height:
133 | value.setHeight(frameValue);
134 | break;
135 |
136 | case Radius:
137 | value.setRadius(frameValue);
138 | break;
139 | }
140 |
141 | if (listener != null) {
142 | listener.onValueUpdated(value);
143 | }
144 | }
145 |
146 | @SuppressWarnings("RedundantIfStatement")
147 | private boolean hasChanges(int widthStart, int widthEnd, int heightStart, int heightEnd, int radius) {
148 | if (this.widthStart != widthStart) {
149 | return true;
150 | }
151 |
152 | if (this.widthEnd != widthEnd) {
153 | return true;
154 | }
155 |
156 | if (this.heightStart != heightStart) {
157 | return true;
158 | }
159 |
160 | if (this.heightEnd != heightEnd) {
161 | return true;
162 | }
163 |
164 | if (this.radius != radius) {
165 | return true;
166 | }
167 |
168 | return false;
169 | }
170 |
171 | }
172 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/type/FillAnimation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.type;
2 |
3 | import android.animation.IntEvaluator;
4 | import android.animation.PropertyValuesHolder;
5 | import android.animation.ValueAnimator;
6 | import androidx.annotation.NonNull;
7 | import android.view.animation.AccelerateDecelerateInterpolator;
8 | import com.smarteist.autoimageslider.IndicatorView.animation.controller.ValueController;
9 | import com.smarteist.autoimageslider.IndicatorView.animation.data.type.FillAnimationValue;
10 |
11 | public class FillAnimation extends ColorAnimation {
12 |
13 | private static final String ANIMATION_RADIUS_REVERSE = "ANIMATION_RADIUS_REVERSE";
14 | private static final String ANIMATION_RADIUS = "ANIMATION_RADIUS";
15 |
16 | private static final String ANIMATION_STROKE_REVERSE = "ANIMATION_STROKE_REVERSE";
17 | private static final String ANIMATION_STROKE = "ANIMATION_STROKE";
18 |
19 | public static final int DEFAULT_STROKE_DP = 1;
20 | private FillAnimationValue value;
21 |
22 | private int radius;
23 | private int stroke;
24 |
25 | public FillAnimation(@NonNull ValueController.UpdateListener listener) {
26 | super(listener);
27 | value = new FillAnimationValue();
28 | }
29 |
30 | @NonNull
31 | @Override
32 | public ValueAnimator createAnimator() {
33 | ValueAnimator animator = new ValueAnimator();
34 | animator.setDuration(BaseAnimation.DEFAULT_ANIMATION_TIME);
35 | animator.setInterpolator(new AccelerateDecelerateInterpolator());
36 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
37 | @Override
38 | public void onAnimationUpdate(ValueAnimator animation) {
39 | onAnimateUpdated(animation);
40 | }
41 | });
42 |
43 | return animator;
44 | }
45 |
46 | @NonNull
47 | public FillAnimation with(int colorStart, int colorEnd, int radius, int stroke) {
48 | if (animator != null && hasChanges(colorStart, colorEnd, radius, stroke)) {
49 |
50 | this.colorStart = colorStart;
51 | this.colorEnd = colorEnd;
52 |
53 | this.radius = radius;
54 | this.stroke = stroke;
55 |
56 | PropertyValuesHolder colorHolder = createColorPropertyHolder(false);
57 | PropertyValuesHolder reverseColorHolder = createColorPropertyHolder(true);
58 |
59 | PropertyValuesHolder radiusHolder = createRadiusPropertyHolder(false);
60 | PropertyValuesHolder radiusReverseHolder = createRadiusPropertyHolder(true);
61 |
62 | PropertyValuesHolder strokeHolder = createStrokePropertyHolder(false);
63 | PropertyValuesHolder strokeReverseHolder = createStrokePropertyHolder(true);
64 |
65 | animator.setValues(
66 | colorHolder,
67 | reverseColorHolder,
68 |
69 | radiusHolder,
70 | radiusReverseHolder,
71 |
72 | strokeHolder,
73 | strokeReverseHolder);
74 | }
75 |
76 | return this;
77 | }
78 |
79 | @NonNull
80 | private PropertyValuesHolder createRadiusPropertyHolder(boolean isReverse) {
81 | String propertyName;
82 | int startRadiusValue;
83 | int endRadiusValue;
84 |
85 | if (isReverse) {
86 | propertyName = ANIMATION_RADIUS_REVERSE;
87 | startRadiusValue = radius / 2;
88 | endRadiusValue = radius;
89 | } else {
90 | propertyName = ANIMATION_RADIUS;
91 | startRadiusValue = radius;
92 | endRadiusValue = radius / 2;
93 | }
94 |
95 | PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startRadiusValue, endRadiusValue);
96 | holder.setEvaluator(new IntEvaluator());
97 |
98 | return holder;
99 | }
100 |
101 | @NonNull
102 | private PropertyValuesHolder createStrokePropertyHolder(boolean isReverse) {
103 | String propertyName;
104 | int startStrokeValue;
105 | int endStrokeValue;
106 |
107 | if (isReverse) {
108 | propertyName = ANIMATION_STROKE_REVERSE;
109 | startStrokeValue = radius;
110 | endStrokeValue = 0;
111 | } else {
112 | propertyName = ANIMATION_STROKE;
113 | startStrokeValue = 0;
114 | endStrokeValue = radius;
115 | }
116 |
117 | PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startStrokeValue, endStrokeValue);
118 | holder.setEvaluator(new IntEvaluator());
119 |
120 | return holder;
121 | }
122 |
123 | private void onAnimateUpdated(@NonNull ValueAnimator animation) {
124 | int color = (int) animation.getAnimatedValue(ANIMATION_COLOR);
125 | int colorReverse = (int) animation.getAnimatedValue(ANIMATION_COLOR_REVERSE);
126 |
127 | int radius = (int) animation.getAnimatedValue(ANIMATION_RADIUS);
128 | int radiusReverse = (int) animation.getAnimatedValue(ANIMATION_RADIUS_REVERSE);
129 |
130 | int stroke = (int) animation.getAnimatedValue(ANIMATION_STROKE);
131 | int strokeReverse = (int) animation.getAnimatedValue(ANIMATION_STROKE_REVERSE);
132 |
133 | value.setColor(color);
134 | value.setColorReverse(colorReverse);
135 |
136 | value.setRadius(radius);
137 | value.setRadiusReverse(radiusReverse);
138 |
139 | value.setStroke(stroke);
140 | value.setStrokeReverse(strokeReverse);
141 |
142 | if (listener != null) {
143 | listener.onValueUpdated(value);
144 | }
145 | }
146 |
147 | @SuppressWarnings("RedundantIfStatement")
148 | private boolean hasChanges(int colorStart, int colorEnd, int radiusValue, int strokeValue) {
149 | if (this.colorStart != colorStart) {
150 | return true;
151 | }
152 |
153 | if (this.colorEnd != colorEnd) {
154 | return true;
155 | }
156 |
157 | if (radius != radiusValue) {
158 | return true;
159 | }
160 |
161 | if (stroke != strokeValue) {
162 | return true;
163 | }
164 |
165 | return false;
166 | }
167 | }
168 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/type/IndicatorAnimationType.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.type;
2 |
3 | public enum IndicatorAnimationType {NONE, COLOR, SCALE, WORM, SLIDE, FILL, THIN_WORM, DROP, SWAP, SCALE_DOWN}
4 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/type/ScaleAnimation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.type;
2 |
3 | import android.animation.IntEvaluator;
4 | import android.animation.PropertyValuesHolder;
5 | import android.animation.ValueAnimator;
6 | import androidx.annotation.NonNull;
7 | import android.view.animation.AccelerateDecelerateInterpolator;
8 | import com.smarteist.autoimageslider.IndicatorView.animation.controller.ValueController;
9 | import com.smarteist.autoimageslider.IndicatorView.animation.data.type.ScaleAnimationValue;
10 |
11 | public class ScaleAnimation extends ColorAnimation {
12 |
13 | public static final float DEFAULT_SCALE_FACTOR = 0.7f;
14 | public static final float MIN_SCALE_FACTOR = 0.3f;
15 | public static final float MAX_SCALE_FACTOR = 1;
16 |
17 | static final String ANIMATION_SCALE_REVERSE = "ANIMATION_SCALE_REVERSE";
18 | static final String ANIMATION_SCALE = "ANIMATION_SCALE";
19 |
20 | int radius;
21 | float scaleFactor;
22 |
23 | private ScaleAnimationValue value;
24 |
25 | public ScaleAnimation(@NonNull ValueController.UpdateListener listener) {
26 | super(listener);
27 | value = new ScaleAnimationValue();
28 | }
29 |
30 | @NonNull
31 | @Override
32 | public ValueAnimator createAnimator() {
33 | ValueAnimator animator = new ValueAnimator();
34 | animator.setDuration(BaseAnimation.DEFAULT_ANIMATION_TIME);
35 | animator.setInterpolator(new AccelerateDecelerateInterpolator());
36 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
37 | @Override
38 | public void onAnimationUpdate(ValueAnimator animation) {
39 | onAnimateUpdated(animation);
40 | }
41 | });
42 |
43 | return animator;
44 | }
45 |
46 | @NonNull
47 | public ScaleAnimation with(int colorStart, int colorEnd, int radius, float scaleFactor) {
48 | if (animator != null && hasChanges(colorStart, colorEnd, radius, scaleFactor)) {
49 |
50 | this.colorStart = colorStart;
51 | this.colorEnd = colorEnd;
52 |
53 | this.radius = radius;
54 | this.scaleFactor = scaleFactor;
55 |
56 | PropertyValuesHolder colorHolder = createColorPropertyHolder(false);
57 | PropertyValuesHolder reverseColorHolder = createColorPropertyHolder(true);
58 |
59 | PropertyValuesHolder scaleHolder = createScalePropertyHolder(false);
60 | PropertyValuesHolder scaleReverseHolder = createScalePropertyHolder(true);
61 |
62 | animator.setValues(colorHolder, reverseColorHolder, scaleHolder, scaleReverseHolder);
63 | }
64 |
65 | return this;
66 | }
67 |
68 | private void onAnimateUpdated(@NonNull ValueAnimator animation) {
69 | int color = (int) animation.getAnimatedValue(ANIMATION_COLOR);
70 | int colorReverse = (int) animation.getAnimatedValue(ANIMATION_COLOR_REVERSE);
71 |
72 | int radius = (int) animation.getAnimatedValue(ANIMATION_SCALE);
73 | int radiusReverse = (int) animation.getAnimatedValue(ANIMATION_SCALE_REVERSE);
74 |
75 | value.setColor(color);
76 | value.setColorReverse(colorReverse);
77 |
78 | value.setRadius(radius);
79 | value.setRadiusReverse(radiusReverse);
80 |
81 | if (listener != null) {
82 | listener.onValueUpdated(value);
83 | }
84 | }
85 |
86 | @NonNull
87 | protected PropertyValuesHolder createScalePropertyHolder(boolean isReverse) {
88 | String propertyName;
89 | int startRadiusValue;
90 | int endRadiusValue;
91 |
92 | if (isReverse) {
93 | propertyName = ANIMATION_SCALE_REVERSE;
94 | startRadiusValue = radius;
95 | endRadiusValue = (int) (radius * scaleFactor);
96 | } else {
97 | propertyName = ANIMATION_SCALE;
98 | startRadiusValue = (int) (radius * scaleFactor);
99 | endRadiusValue = radius;
100 | }
101 |
102 | PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startRadiusValue, endRadiusValue);
103 | holder.setEvaluator(new IntEvaluator());
104 |
105 | return holder;
106 | }
107 |
108 | @SuppressWarnings("RedundantIfStatement")
109 | private boolean hasChanges(int colorStart, int colorEnd, int radiusValue, float scaleFactorValue) {
110 | if (this.colorStart != colorStart) {
111 | return true;
112 | }
113 |
114 | if (this.colorEnd != colorEnd) {
115 | return true;
116 | }
117 |
118 | if (radius != radiusValue) {
119 | return true;
120 | }
121 |
122 | if (scaleFactor != scaleFactorValue) {
123 | return true;
124 | }
125 |
126 | return false;
127 | }
128 | }
129 |
130 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/type/ScaleDownAnimation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.type;
2 |
3 | import android.animation.IntEvaluator;
4 | import android.animation.PropertyValuesHolder;
5 | import androidx.annotation.NonNull;
6 | import com.smarteist.autoimageslider.IndicatorView.animation.controller.ValueController;
7 |
8 | public class ScaleDownAnimation extends ScaleAnimation {
9 |
10 | public ScaleDownAnimation(@NonNull ValueController.UpdateListener listener) {
11 | super(listener);
12 | }
13 |
14 | @NonNull
15 | @Override
16 | protected PropertyValuesHolder createScalePropertyHolder(boolean isReverse) {
17 | String propertyName;
18 | int startRadiusValue;
19 | int endRadiusValue;
20 |
21 | if (isReverse) {
22 | propertyName = ANIMATION_SCALE_REVERSE;
23 | startRadiusValue = (int) (radius * scaleFactor);
24 | endRadiusValue = radius;
25 | } else {
26 | propertyName = ANIMATION_SCALE;
27 | startRadiusValue = radius;
28 | endRadiusValue = (int) (radius * scaleFactor);
29 | }
30 |
31 | PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startRadiusValue, endRadiusValue);
32 | holder.setEvaluator(new IntEvaluator());
33 |
34 | return holder;
35 | }
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/type/SlideAnimation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.type;
2 |
3 | import android.animation.IntEvaluator;
4 | import android.animation.PropertyValuesHolder;
5 | import android.animation.ValueAnimator;
6 | import androidx.annotation.NonNull;
7 | import android.view.animation.AccelerateDecelerateInterpolator;
8 | import com.smarteist.autoimageslider.IndicatorView.animation.controller.ValueController;
9 | import com.smarteist.autoimageslider.IndicatorView.animation.data.type.SlideAnimationValue;
10 |
11 | public class SlideAnimation extends BaseAnimation {
12 |
13 | private static final String ANIMATION_COORDINATE = "ANIMATION_COORDINATE";
14 | private static final int COORDINATE_NONE = -1;
15 |
16 | private SlideAnimationValue value;
17 | private int coordinateStart = COORDINATE_NONE;
18 | private int coordinateEnd = COORDINATE_NONE;
19 |
20 | public SlideAnimation(@NonNull ValueController.UpdateListener listener) {
21 | super(listener);
22 | value = new SlideAnimationValue();
23 | }
24 |
25 | @NonNull
26 | @Override
27 | public ValueAnimator createAnimator() {
28 | ValueAnimator animator = new ValueAnimator();
29 | animator.setDuration(BaseAnimation.DEFAULT_ANIMATION_TIME);
30 | animator.setInterpolator(new AccelerateDecelerateInterpolator());
31 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
32 | @Override
33 | public void onAnimationUpdate(ValueAnimator animation) {
34 | onAnimateUpdated(animation);
35 | }
36 | });
37 |
38 | return animator;
39 | }
40 |
41 | @Override
42 | public SlideAnimation progress(float progress) {
43 | if (animator != null) {
44 | long playTime = (long) (progress * animationDuration);
45 |
46 | if (animator.getValues() != null && animator.getValues().length > 0) {
47 | animator.setCurrentPlayTime(playTime);
48 | }
49 | }
50 |
51 | return this;
52 | }
53 |
54 | @NonNull
55 | public SlideAnimation with(int coordinateStart, int coordinateEnd) {
56 | if (animator != null && hasChanges(coordinateStart, coordinateEnd)) {
57 |
58 | this.coordinateStart = coordinateStart;
59 | this.coordinateEnd = coordinateEnd;
60 |
61 | PropertyValuesHolder holder = createSlidePropertyHolder();
62 | animator.setValues(holder);
63 | }
64 |
65 | return this;
66 | }
67 |
68 | private PropertyValuesHolder createSlidePropertyHolder() {
69 | PropertyValuesHolder holder = PropertyValuesHolder.ofInt(ANIMATION_COORDINATE, coordinateStart, coordinateEnd);
70 | holder.setEvaluator(new IntEvaluator());
71 |
72 | return holder;
73 | }
74 |
75 | private void onAnimateUpdated(@NonNull ValueAnimator animation) {
76 | int coordinate = (int) animation.getAnimatedValue(ANIMATION_COORDINATE);
77 | value.setCoordinate(coordinate);
78 |
79 | if (listener != null) {
80 | listener.onValueUpdated(value);
81 | }
82 | }
83 |
84 | @SuppressWarnings("RedundantIfStatement")
85 | private boolean hasChanges(int coordinateStart, int coordinateEnd) {
86 | if (this.coordinateStart != coordinateStart) {
87 | return true;
88 | }
89 |
90 | if (this.coordinateEnd != coordinateEnd) {
91 | return true;
92 | }
93 |
94 | return false;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/type/SwapAnimation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.type;
2 |
3 | import android.animation.IntEvaluator;
4 | import android.animation.PropertyValuesHolder;
5 | import android.animation.ValueAnimator;
6 | import androidx.annotation.NonNull;
7 | import android.view.animation.AccelerateDecelerateInterpolator;
8 | import com.smarteist.autoimageslider.IndicatorView.animation.controller.ValueController;
9 | import com.smarteist.autoimageslider.IndicatorView.animation.data.type.SwapAnimationValue;
10 |
11 | public class SwapAnimation extends BaseAnimation {
12 |
13 | private static final String ANIMATION_COORDINATE = "ANIMATION_COORDINATE";
14 | private static final String ANIMATION_COORDINATE_REVERSE = "ANIMATION_COORDINATE_REVERSE";
15 | private static final int COORDINATE_NONE = -1;
16 |
17 | private int coordinateStart = COORDINATE_NONE;
18 | private int coordinateEnd = COORDINATE_NONE;
19 |
20 | private SwapAnimationValue value;
21 |
22 | public SwapAnimation(@NonNull ValueController.UpdateListener listener) {
23 | super(listener);
24 | value = new SwapAnimationValue();
25 | }
26 |
27 | @NonNull
28 | @Override
29 | public ValueAnimator createAnimator() {
30 | ValueAnimator animator = new ValueAnimator();
31 | animator.setDuration(BaseAnimation.DEFAULT_ANIMATION_TIME);
32 | animator.setInterpolator(new AccelerateDecelerateInterpolator());
33 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
34 | @Override
35 | public void onAnimationUpdate(ValueAnimator animation) {
36 | onAnimateUpdated(animation);
37 | }
38 | });
39 |
40 | return animator;
41 | }
42 |
43 | @Override
44 | public SwapAnimation progress(float progress) {
45 | if (animator != null) {
46 | long playTime = (long) (progress * animationDuration);
47 |
48 | if (animator.getValues() != null && animator.getValues().length > 0) {
49 | animator.setCurrentPlayTime(playTime);
50 | }
51 | }
52 |
53 | return this;
54 | }
55 |
56 | @NonNull
57 | public SwapAnimation with(int coordinateStart, int coordinateEnd) {
58 | if (animator != null && hasChanges(coordinateStart, coordinateEnd)) {
59 | this.coordinateStart = coordinateStart;
60 | this.coordinateEnd = coordinateEnd;
61 |
62 | PropertyValuesHolder holder = createColorPropertyHolder(ANIMATION_COORDINATE, coordinateStart, coordinateEnd);
63 | PropertyValuesHolder holderReverse = createColorPropertyHolder(ANIMATION_COORDINATE_REVERSE, coordinateEnd, coordinateStart);
64 | animator.setValues(holder, holderReverse);
65 | }
66 |
67 | return this;
68 | }
69 |
70 | private PropertyValuesHolder createColorPropertyHolder(String propertyName, int startValue, int endValue) {
71 | PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startValue, endValue);
72 | holder.setEvaluator(new IntEvaluator());
73 |
74 | return holder;
75 | }
76 |
77 | private void onAnimateUpdated(@NonNull ValueAnimator animation) {
78 | int coordinate = (int) animation.getAnimatedValue(ANIMATION_COORDINATE);
79 | int coordinateReverse = (int) animation.getAnimatedValue(ANIMATION_COORDINATE_REVERSE);
80 |
81 | value.setCoordinate(coordinate);
82 | value.setCoordinateReverse(coordinateReverse);
83 |
84 | if (listener != null) {
85 | listener.onValueUpdated(value);
86 | }
87 | }
88 |
89 | @SuppressWarnings("RedundantIfStatement")
90 | private boolean hasChanges(int coordinateStart, int coordinateEnd) {
91 | if (this.coordinateStart != coordinateStart) {
92 | return true;
93 | }
94 |
95 | if (this.coordinateEnd != coordinateEnd) {
96 | return true;
97 | }
98 |
99 | return false;
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/type/ThinWormAnimation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.type;
2 |
3 | import android.animation.ValueAnimator;
4 | import androidx.annotation.NonNull;
5 | import android.view.animation.AccelerateDecelerateInterpolator;
6 | import com.smarteist.autoimageslider.IndicatorView.animation.controller.ValueController;
7 | import com.smarteist.autoimageslider.IndicatorView.animation.data.type.ThinWormAnimationValue;
8 |
9 | public class ThinWormAnimation extends WormAnimation {
10 |
11 | private ThinWormAnimationValue value;
12 |
13 | public ThinWormAnimation(@NonNull ValueController.UpdateListener listener) {
14 | super(listener);
15 | value = new ThinWormAnimationValue();
16 | }
17 |
18 | @Override
19 | public ThinWormAnimation duration(long duration) {
20 | super.duration(duration);
21 | return this;
22 | }
23 |
24 | @Override
25 | public WormAnimation with(int coordinateStart, int coordinateEnd, int radius, boolean isRightSide) {
26 | if (hasChanges(coordinateStart, coordinateEnd, radius, isRightSide)) {
27 | animator = createAnimator();
28 |
29 | this.coordinateStart = coordinateStart;
30 | this.coordinateEnd = coordinateEnd;
31 |
32 | this.radius = radius;
33 | this.isRightSide = isRightSide;
34 |
35 | int height = radius * 2;
36 | rectLeftEdge = coordinateStart - radius;
37 | rectRightEdge = coordinateStart + radius;
38 |
39 | value.setRectStart(rectLeftEdge);
40 | value.setRectEnd(rectRightEdge);
41 | value.setHeight(height);
42 |
43 | RectValues rec = createRectValues(isRightSide);
44 | long sizeDuration = (long) (animationDuration * 0.8);
45 | long reverseDelay = (long) (animationDuration * 0.2);
46 |
47 | long heightDuration = (long) (animationDuration * 0.5);
48 | long reverseHeightDelay = (long) (animationDuration * 0.5);
49 |
50 | ValueAnimator straightAnimator = createWormAnimator(rec.fromX, rec.toX, sizeDuration, false, value);
51 | ValueAnimator reverseAnimator = createWormAnimator(rec.reverseFromX, rec.reverseToX, sizeDuration, true, value);
52 | reverseAnimator.setStartDelay(reverseDelay);
53 |
54 | ValueAnimator straightHeightAnimator = createHeightAnimator(height, radius, heightDuration);
55 | ValueAnimator reverseHeightAnimator = createHeightAnimator(radius, height, heightDuration);
56 | reverseHeightAnimator.setStartDelay(reverseHeightDelay);
57 |
58 | animator.playTogether(straightAnimator, reverseAnimator, straightHeightAnimator, reverseHeightAnimator);
59 | }
60 | return this;
61 | }
62 |
63 | private ValueAnimator createHeightAnimator(int fromHeight, int toHeight, long duration) {
64 | ValueAnimator anim = ValueAnimator.ofInt(fromHeight, toHeight);
65 | anim.setInterpolator(new AccelerateDecelerateInterpolator());
66 | anim.setDuration(duration);
67 | anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
68 | @Override
69 | public void onAnimationUpdate(ValueAnimator animation) {
70 | onAnimateUpdated(animation);
71 | }
72 | });
73 |
74 | return anim;
75 | }
76 |
77 | private void onAnimateUpdated(@NonNull ValueAnimator animation) {
78 | value.setHeight((int) animation.getAnimatedValue());
79 |
80 | if (listener != null) {
81 | listener.onValueUpdated(value);
82 | }
83 | }
84 |
85 | @Override
86 | public ThinWormAnimation progress(float progress) {
87 | if (animator != null) {
88 | long progressDuration = (long) (progress * animationDuration);
89 | int size = animator.getChildAnimations().size();
90 |
91 | for (int i = 0; i < size; i++) {
92 | ValueAnimator anim = (ValueAnimator) animator.getChildAnimations().get(i);
93 |
94 | long setDuration = progressDuration - anim.getStartDelay();
95 | long duration = anim.getDuration();
96 |
97 | if (setDuration > duration) {
98 | setDuration = duration;
99 |
100 | } else if (setDuration < 0) {
101 | setDuration = 0;
102 | }
103 |
104 | if (i == size - 1 && setDuration <= 0) {
105 | continue;
106 | }
107 |
108 | if (anim.getValues() != null && anim.getValues().length > 0) {
109 | anim.setCurrentPlayTime(setDuration);
110 | }
111 | }
112 | }
113 |
114 | return this;
115 | }
116 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/animation/type/WormAnimation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.animation.type;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorSet;
5 | import android.animation.ValueAnimator;
6 | import androidx.annotation.NonNull;
7 | import android.view.animation.AccelerateDecelerateInterpolator;
8 | import com.smarteist.autoimageslider.IndicatorView.animation.controller.ValueController;
9 | import com.smarteist.autoimageslider.IndicatorView.animation.data.type.WormAnimationValue;
10 |
11 | public class WormAnimation extends BaseAnimation {
12 |
13 | int coordinateStart;
14 | int coordinateEnd;
15 |
16 | int radius;
17 | boolean isRightSide;
18 |
19 | int rectLeftEdge;
20 | int rectRightEdge;
21 |
22 | private WormAnimationValue value;
23 |
24 | public WormAnimation(@NonNull ValueController.UpdateListener listener) {
25 | super(listener);
26 | value = new WormAnimationValue();
27 | }
28 |
29 | @NonNull
30 | @Override
31 | public AnimatorSet createAnimator() {
32 | AnimatorSet animator = new AnimatorSet();
33 | animator.setInterpolator(new AccelerateDecelerateInterpolator());
34 |
35 | return animator;
36 | }
37 |
38 | @Override
39 | public WormAnimation duration(long duration) {
40 | super.duration(duration);
41 | return this;
42 | }
43 |
44 | public WormAnimation with(int coordinateStart, int coordinateEnd, int radius, boolean isRightSide) {
45 | if (hasChanges(coordinateStart, coordinateEnd, radius, isRightSide)) {
46 | animator = createAnimator();
47 |
48 | this.coordinateStart = coordinateStart;
49 | this.coordinateEnd = coordinateEnd;
50 |
51 | this.radius = radius;
52 | this.isRightSide = isRightSide;
53 |
54 | rectLeftEdge = coordinateStart - radius;
55 | rectRightEdge = coordinateStart + radius;
56 |
57 | value.setRectStart(rectLeftEdge);
58 | value.setRectEnd(rectRightEdge);
59 |
60 | RectValues rect = createRectValues(isRightSide);
61 | long duration = animationDuration / 2;
62 |
63 | ValueAnimator straightAnimator = createWormAnimator(rect.fromX, rect.toX, duration, false, value);
64 | ValueAnimator reverseAnimator = createWormAnimator(rect.reverseFromX, rect.reverseToX, duration, true, value);
65 | animator.playSequentially(straightAnimator, reverseAnimator);
66 | }
67 | return this;
68 | }
69 |
70 | @Override
71 | public WormAnimation progress(float progress) {
72 | if (animator == null) {
73 | return this;
74 | }
75 |
76 | long progressDuration = (long) (progress * animationDuration);
77 | for (Animator anim : animator.getChildAnimations()) {
78 | ValueAnimator animator = (ValueAnimator) anim;
79 | long duration = animator.getDuration();
80 | long setDuration = progressDuration;
81 |
82 | if (setDuration > duration) {
83 | setDuration = duration;
84 | }
85 |
86 | animator.setCurrentPlayTime(setDuration);
87 | progressDuration -= setDuration;
88 | }
89 |
90 | return this;
91 | }
92 |
93 | ValueAnimator createWormAnimator(
94 | int fromValue,
95 | int toValue,
96 | long duration,
97 | final boolean isReverse,
98 | final WormAnimationValue value) {
99 |
100 | ValueAnimator anim = ValueAnimator.ofInt(fromValue, toValue);
101 | anim.setInterpolator(new AccelerateDecelerateInterpolator());
102 | anim.setDuration(duration);
103 | anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
104 | @Override
105 | public void onAnimationUpdate(ValueAnimator animation) {
106 | onAnimateUpdated(value, animation, isReverse);
107 | }
108 | });
109 |
110 | return anim;
111 | }
112 |
113 | private void onAnimateUpdated(@NonNull WormAnimationValue value, @NonNull ValueAnimator animation, final boolean isReverse) {
114 | int rectEdge = (int) animation.getAnimatedValue();
115 |
116 | if (isRightSide) {
117 | if (!isReverse) {
118 | value.setRectEnd(rectEdge);
119 | } else {
120 | value.setRectStart(rectEdge);
121 | }
122 |
123 | } else {
124 | if (!isReverse) {
125 | value.setRectStart(rectEdge);
126 | } else {
127 | value.setRectEnd(rectEdge);
128 | }
129 | }
130 |
131 | if (listener != null) {
132 | listener.onValueUpdated(value);
133 | }
134 | }
135 |
136 | @SuppressWarnings("RedundantIfStatement")
137 | boolean hasChanges(int coordinateStart, int coordinateEnd, int radius, boolean isRightSide) {
138 | if (this.coordinateStart != coordinateStart) {
139 | return true;
140 | }
141 |
142 | if (this.coordinateEnd != coordinateEnd) {
143 | return true;
144 | }
145 |
146 | if (this.radius != radius) {
147 | return true;
148 | }
149 |
150 | if (this.isRightSide != isRightSide) {
151 | return true;
152 | }
153 |
154 | return false;
155 | }
156 |
157 | @NonNull
158 | RectValues createRectValues(boolean isRightSide) {
159 | int fromX;
160 | int toX;
161 |
162 | int reverseFromX;
163 | int reverseToX;
164 |
165 | if (isRightSide) {
166 | fromX = coordinateStart + radius;
167 | toX = coordinateEnd + radius;
168 |
169 | reverseFromX = coordinateStart - radius;
170 | reverseToX = coordinateEnd - radius;
171 |
172 | } else {
173 | fromX = coordinateStart - radius;
174 | toX = coordinateEnd - radius;
175 |
176 | reverseFromX = coordinateStart + radius;
177 | reverseToX = coordinateEnd + radius;
178 | }
179 |
180 | return new RectValues(fromX, toX, reverseFromX, reverseToX);
181 | }
182 |
183 | class RectValues {
184 |
185 | final int fromX;
186 | final int toX;
187 |
188 | final int reverseFromX;
189 | final int reverseToX;
190 |
191 | RectValues(int fromX, int toX, int reverseFromX, int reverseToX) {
192 | this.fromX = fromX;
193 | this.toX = toX;
194 |
195 | this.reverseFromX = reverseFromX;
196 | this.reverseToX = reverseToX;
197 | }
198 | }
199 | }
200 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/DrawManager.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import androidx.annotation.NonNull;
6 | import androidx.annotation.Nullable;
7 | import android.util.AttributeSet;
8 | import android.util.Pair;
9 | import android.view.MotionEvent;
10 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
11 | import com.smarteist.autoimageslider.IndicatorView.draw.controller.AttributeController;
12 | import com.smarteist.autoimageslider.IndicatorView.draw.controller.DrawController;
13 | import com.smarteist.autoimageslider.IndicatorView.draw.controller.MeasureController;
14 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
15 |
16 | public class DrawManager {
17 |
18 | private Indicator indicator;
19 | private DrawController drawController;
20 | private MeasureController measureController;
21 | private AttributeController attributeController;
22 |
23 | public DrawManager() {
24 | this.indicator = new Indicator();
25 | this.drawController = new DrawController(indicator);
26 | this.measureController = new MeasureController();
27 | this.attributeController = new AttributeController(indicator);
28 | }
29 |
30 | @NonNull
31 | public Indicator indicator() {
32 | if (indicator == null) {
33 | indicator = new Indicator();
34 | }
35 |
36 | return indicator;
37 | }
38 |
39 | public void setClickListener(@Nullable DrawController.ClickListener listener) {
40 | drawController.setClickListener(listener);
41 | }
42 |
43 | public void touch(@Nullable MotionEvent event) {
44 | drawController.touch(event);
45 | }
46 |
47 | public void updateValue(@Nullable Value value) {
48 | drawController.updateValue(value);
49 | }
50 |
51 | public void draw(@NonNull Canvas canvas) {
52 | drawController.draw(canvas);
53 | }
54 |
55 | public Pair measureViewSize(int widthMeasureSpec, int heightMeasureSpec) {
56 | return measureController.measureViewSize(indicator, widthMeasureSpec, heightMeasureSpec);
57 | }
58 |
59 | public void initAttributes(@NonNull Context context, @Nullable AttributeSet attrs) {
60 | attributeController.init(context, attrs);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/controller/AttributeController.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.controller;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Color;
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 | import android.util.AttributeSet;
9 | import android.view.View;
10 | import com.smarteist.autoimageslider.IndicatorView.utils.DensityUtils;
11 | import com.smarteist.autoimageslider.IndicatorView.animation.type.*;
12 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
13 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Orientation;;
14 | import com.smarteist.autoimageslider.IndicatorView.draw.data.RtlMode;
15 | import com.smarteist.autoimageslider.R;;
16 |
17 | public class AttributeController {
18 |
19 | private Indicator indicator;
20 |
21 | public AttributeController(@NonNull Indicator indicator) {
22 | this.indicator = indicator;
23 | }
24 |
25 | public void init(@NonNull Context context, @Nullable AttributeSet attrs) {
26 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.PageIndicatorView, 0, 0);
27 | initCountAttribute(typedArray);
28 | initColorAttribute(typedArray);
29 | initAnimationAttribute(typedArray);
30 | initSizeAttribute(typedArray);
31 | typedArray.recycle();
32 | }
33 |
34 | private void initCountAttribute(@NonNull TypedArray typedArray) {
35 | int viewPagerId = typedArray.getResourceId(R.styleable.PageIndicatorView_piv_viewPager, View.NO_ID);
36 | boolean autoVisibility = typedArray.getBoolean(R.styleable.PageIndicatorView_piv_autoVisibility, true);
37 | boolean dynamicCount = typedArray.getBoolean(R.styleable.PageIndicatorView_piv_dynamicCount, false);
38 | int count = typedArray.getInt(R.styleable.PageIndicatorView_piv_count, Indicator.COUNT_NONE);
39 |
40 | if (count == Indicator.COUNT_NONE) {
41 | count = Indicator.DEFAULT_COUNT;
42 | }
43 |
44 | int position = typedArray.getInt(R.styleable.PageIndicatorView_piv_select, 0);
45 | if (position < 0) {
46 | position = 0;
47 | } else if (count > 0 && position > count - 1) {
48 | position = count - 1;
49 | }
50 |
51 | indicator.setViewPagerId(viewPagerId);
52 | indicator.setAutoVisibility(autoVisibility);
53 | indicator.setDynamicCount(dynamicCount);
54 | indicator.setCount(count);
55 |
56 | indicator.setSelectedPosition(position);
57 | indicator.setSelectingPosition(position);
58 | indicator.setLastSelectedPosition(position);
59 | }
60 |
61 |
62 | private void initColorAttribute(@NonNull TypedArray typedArray) {
63 | int unselectedColor = typedArray.getColor(R.styleable.PageIndicatorView_piv_unselectedColor, Color.parseColor(ColorAnimation.DEFAULT_UNSELECTED_COLOR));
64 | int selectedColor = typedArray.getColor(R.styleable.PageIndicatorView_piv_selectedColor, Color.parseColor(ColorAnimation.DEFAULT_SELECTED_COLOR));
65 |
66 | indicator.setUnselectedColor(unselectedColor);
67 | indicator.setSelectedColor(selectedColor);
68 | }
69 |
70 | private void initAnimationAttribute(@NonNull TypedArray typedArray) {
71 | boolean interactiveAnimation = typedArray.getBoolean(R.styleable.PageIndicatorView_piv_interactiveAnimation, false);
72 | int animationDuration = typedArray.getInt(R.styleable.PageIndicatorView_piv_animationDuration, BaseAnimation.DEFAULT_ANIMATION_TIME);
73 | if (animationDuration < 0) {
74 | animationDuration = 0;
75 | }
76 |
77 | int animIndex = typedArray.getInt(R.styleable.PageIndicatorView_piv_animationType, IndicatorAnimationType.NONE.ordinal());
78 | IndicatorAnimationType animationType = getAnimationType(animIndex);
79 |
80 | int rtlIndex = typedArray.getInt(R.styleable.PageIndicatorView_piv_rtl_mode, RtlMode.Off.ordinal());
81 | RtlMode rtlMode = getRtlMode(rtlIndex);
82 |
83 | indicator.setAnimationDuration(animationDuration);
84 | indicator.setInteractiveAnimation(interactiveAnimation);
85 | indicator.setAnimationType(animationType);
86 | indicator.setRtlMode(rtlMode);
87 | }
88 |
89 | private void initSizeAttribute(@NonNull TypedArray typedArray) {
90 | int orientationIndex = typedArray.getInt(R.styleable.PageIndicatorView_piv_orientation, Orientation.HORIZONTAL.ordinal());
91 | Orientation orientation;
92 |
93 | if (orientationIndex == 0) {
94 | orientation = Orientation.HORIZONTAL;
95 | } else {
96 | orientation = Orientation.VERTICAL;
97 | }
98 |
99 | int radius = (int) typedArray.getDimension(R.styleable.PageIndicatorView_piv_radius, DensityUtils.dpToPx(Indicator.DEFAULT_RADIUS_DP));
100 | if (radius < 0) {
101 | radius = 0;
102 | }
103 |
104 | int padding = (int) typedArray.getDimension(R.styleable.PageIndicatorView_piv_padding, DensityUtils.dpToPx(Indicator.DEFAULT_PADDING_DP));
105 | if (padding < 0) {
106 | padding = 0;
107 | }
108 |
109 | float scaleFactor = typedArray.getFloat(R.styleable.PageIndicatorView_piv_scaleFactor, ScaleAnimation.DEFAULT_SCALE_FACTOR);
110 | if (scaleFactor < ScaleAnimation.MIN_SCALE_FACTOR) {
111 | scaleFactor = ScaleAnimation.MIN_SCALE_FACTOR;
112 |
113 | } else if (scaleFactor > ScaleAnimation.MAX_SCALE_FACTOR) {
114 | scaleFactor = ScaleAnimation.MAX_SCALE_FACTOR;
115 | }
116 |
117 | int stroke = (int) typedArray.getDimension(R.styleable.PageIndicatorView_piv_strokeWidth, DensityUtils.dpToPx(FillAnimation.DEFAULT_STROKE_DP));
118 | if (stroke > radius) {
119 | stroke = radius;
120 | }
121 |
122 | if (indicator.getAnimationType() != IndicatorAnimationType.FILL) {
123 | stroke = 0;
124 | }
125 |
126 | indicator.setRadius(radius);
127 | indicator.setOrientation(orientation);
128 | indicator.setPadding(padding);
129 | indicator.setScaleFactor(scaleFactor);
130 | indicator.setStroke(stroke);
131 | }
132 |
133 | private IndicatorAnimationType getAnimationType(int index) {
134 | switch (index) {
135 | case 0:
136 | return IndicatorAnimationType.NONE;
137 | case 1:
138 | return IndicatorAnimationType.COLOR;
139 | case 2:
140 | return IndicatorAnimationType.SCALE;
141 | case 3:
142 | return IndicatorAnimationType.WORM;
143 | case 4:
144 | return IndicatorAnimationType.SLIDE;
145 | case 5:
146 | return IndicatorAnimationType.FILL;
147 | case 6:
148 | return IndicatorAnimationType.THIN_WORM;
149 | case 7:
150 | return IndicatorAnimationType.DROP;
151 | case 8:
152 | return IndicatorAnimationType.SWAP;
153 | case 9:
154 | return IndicatorAnimationType.SCALE_DOWN;
155 | }
156 |
157 | return IndicatorAnimationType.NONE;
158 | }
159 |
160 | public static RtlMode getRtlMode(int index) {
161 | switch (index) {
162 | case 0:
163 | return RtlMode.On;
164 | case 1:
165 | return RtlMode.Off;
166 | case 2:
167 | return RtlMode.Auto;
168 | }
169 |
170 | return RtlMode.Auto;
171 | }
172 |
173 | }
174 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/controller/DrawController.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.controller;
2 |
3 | import android.graphics.Canvas;
4 | import androidx.annotation.NonNull;
5 | import androidx.annotation.Nullable;
6 | import android.view.MotionEvent;
7 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
8 | import com.smarteist.autoimageslider.IndicatorView.animation.type.IndicatorAnimationType;
9 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
10 | import com.smarteist.autoimageslider.IndicatorView.draw.drawer.Drawer;
11 | import com.smarteist.autoimageslider.IndicatorView.utils.CoordinatesUtils;
12 |
13 | public class DrawController {
14 |
15 | private Value value;
16 | private Drawer drawer;
17 | private Indicator indicator;
18 | private ClickListener listener;
19 |
20 | public interface ClickListener {
21 |
22 | void onIndicatorClicked(int position);
23 | }
24 |
25 | public DrawController(@NonNull Indicator indicator) {
26 | this.indicator = indicator;
27 | this.drawer = new Drawer(indicator);
28 | }
29 |
30 | public void updateValue(@Nullable Value value) {
31 | this.value = value;
32 | }
33 |
34 | public void setClickListener(@Nullable ClickListener listener) {
35 | this.listener = listener;
36 | }
37 |
38 | public void touch(@Nullable MotionEvent event) {
39 | if (event == null) {
40 | return;
41 | }
42 |
43 | switch (event.getAction()) {
44 | case MotionEvent.ACTION_UP:
45 | onIndicatorTouched(event.getX(), event.getY());
46 | break;
47 | default:
48 | }
49 | }
50 |
51 | private void onIndicatorTouched(float x, float y) {
52 | if (listener != null) {
53 | int position = CoordinatesUtils.getPosition(indicator, x, y);
54 | if (position >= 0) {
55 | listener.onIndicatorClicked(position);
56 | }
57 | }
58 | }
59 |
60 | public void draw(@NonNull Canvas canvas) {
61 | int count = indicator.getCount();
62 |
63 | for (int position = 0; position < count; position++) {
64 | int coordinateX = CoordinatesUtils.getXCoordinate(indicator, position);
65 | int coordinateY = CoordinatesUtils.getYCoordinate(indicator, position);
66 | drawIndicator(canvas, position, coordinateX, coordinateY);
67 | }
68 | }
69 |
70 | private void drawIndicator(
71 | @NonNull Canvas canvas,
72 | int position,
73 | int coordinateX,
74 | int coordinateY) {
75 |
76 | boolean interactiveAnimation = indicator.isInteractiveAnimation();
77 | int selectedPosition = indicator.getSelectedPosition();
78 | int selectingPosition = indicator.getSelectingPosition();
79 | int lastSelectedPosition = indicator.getLastSelectedPosition();
80 |
81 | boolean selectedItem = !interactiveAnimation && (position == selectedPosition || position == lastSelectedPosition);
82 | boolean selectingItem = interactiveAnimation && (position == selectedPosition || position == selectingPosition);
83 | boolean isSelectedItem = selectedItem | selectingItem;
84 | drawer.setup(position, coordinateX, coordinateY);
85 |
86 | if (value != null && isSelectedItem) {
87 | drawWithAnimation(canvas);
88 | } else {
89 | drawer.drawBasic(canvas, isSelectedItem);
90 | }
91 | }
92 |
93 | private void drawWithAnimation(@NonNull Canvas canvas) {
94 | IndicatorAnimationType animationType = indicator.getAnimationType();
95 | switch (animationType) {
96 | case NONE:
97 | drawer.drawBasic(canvas, true);
98 | break;
99 |
100 | case COLOR:
101 | drawer.drawColor(canvas, value);
102 | break;
103 |
104 | case SCALE:
105 | drawer.drawScale(canvas, value);
106 | break;
107 |
108 | case WORM:
109 | drawer.drawWorm(canvas, value);
110 | break;
111 |
112 | case SLIDE:
113 | drawer.drawSlide(canvas, value);
114 | break;
115 |
116 | case FILL:
117 | drawer.drawFill(canvas, value);
118 | break;
119 |
120 | case THIN_WORM:
121 | drawer.drawThinWorm(canvas, value);
122 | break;
123 |
124 | case DROP:
125 | drawer.drawDrop(canvas, value);
126 | break;
127 |
128 | case SWAP:
129 | drawer.drawSwap(canvas, value);
130 | break;
131 |
132 | case SCALE_DOWN:
133 | drawer.drawScaleDown(canvas, value);
134 | break;
135 | }
136 | }
137 | }
138 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/controller/MeasureController.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.controller;
2 |
3 | import androidx.annotation.NonNull;
4 | import android.util.Pair;
5 | import android.view.View;
6 | import com.smarteist.autoimageslider.IndicatorView.animation.type.IndicatorAnimationType;
7 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
8 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Orientation;
9 |
10 | public class MeasureController {
11 |
12 | public Pair measureViewSize(@NonNull Indicator indicator, int widthMeasureSpec, int heightMeasureSpec) {
13 | int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
14 | int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
15 |
16 | int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
17 | int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
18 |
19 | int count = indicator.getCount();
20 | int radius = indicator.getRadius();
21 | int stroke = indicator.getStroke();
22 |
23 | int padding = indicator.getPadding();
24 | int paddingLeft = indicator.getPaddingLeft();
25 | int paddingTop = indicator.getPaddingTop();
26 | int paddingRight = indicator.getPaddingRight();
27 | int paddingBottom = indicator.getPaddingBottom();
28 |
29 | int circleDiameterPx = radius * 2;
30 | int desiredWidth = 0;
31 | int desiredHeight = 0;
32 |
33 | int width;
34 | int height;
35 |
36 | Orientation orientation = indicator.getOrientation();
37 | if (count != 0) {
38 | int diameterSum = circleDiameterPx * count;
39 | int strokeSum = (stroke * 2) * count;
40 |
41 | int paddingSum = padding * (count - 1);
42 | int w = diameterSum + strokeSum + paddingSum;
43 | int h = circleDiameterPx + stroke;
44 |
45 | if (orientation == Orientation.HORIZONTAL) {
46 | desiredWidth = w;
47 | desiredHeight = h;
48 |
49 | } else {
50 | desiredWidth = h;
51 | desiredHeight = w;
52 | }
53 | }
54 |
55 | if (indicator.getAnimationType() == IndicatorAnimationType.DROP) {
56 | if (orientation == Orientation.HORIZONTAL) {
57 | desiredHeight *= 2;
58 | } else {
59 | desiredWidth *= 2;
60 | }
61 | }
62 |
63 | int horizontalPadding = paddingLeft + paddingRight;
64 | int verticalPadding = paddingTop + paddingBottom;
65 |
66 | if (orientation == Orientation.HORIZONTAL) {
67 | desiredWidth += horizontalPadding;
68 | desiredHeight += verticalPadding;
69 |
70 | } else {
71 | desiredWidth += horizontalPadding;
72 | desiredHeight += verticalPadding;
73 | }
74 |
75 | if (widthMode == View.MeasureSpec.EXACTLY) {
76 | width = widthSize;
77 | } else if (widthMode == View.MeasureSpec.AT_MOST) {
78 | width = Math.min(desiredWidth, widthSize);
79 | } else {
80 | width = desiredWidth;
81 | }
82 |
83 | if (heightMode == View.MeasureSpec.EXACTLY) {
84 | height = heightSize;
85 | } else if (heightMode == View.MeasureSpec.AT_MOST) {
86 | height = Math.min(desiredHeight, heightSize);
87 | } else {
88 | height = desiredHeight;
89 | }
90 |
91 | if (width < 0) {
92 | width = 0;
93 | }
94 |
95 | if (height < 0) {
96 | height = 0;
97 | }
98 |
99 | indicator.setWidth(width);
100 | indicator.setHeight(height);
101 |
102 | return new Pair<>(width, height);
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/data/Indicator.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.data;
2 |
3 | import androidx.annotation.NonNull;
4 | import android.view.View;
5 | import com.smarteist.autoimageslider.IndicatorView.animation.type.IndicatorAnimationType;
6 |
7 | public class Indicator {
8 |
9 | public static final int DEFAULT_COUNT = 3;
10 | public static final int MIN_COUNT = 1;
11 | public static final int COUNT_NONE = -1;
12 |
13 | public static final int DEFAULT_RADIUS_DP = 6;
14 | public static final int DEFAULT_PADDING_DP = 8;
15 |
16 | private int height;
17 | private int width;
18 | private int radius;
19 |
20 | private int padding;
21 | private int paddingLeft;
22 | private int paddingTop;
23 | private int paddingRight;
24 | private int paddingBottom;
25 |
26 | private int stroke; //For "Fill" animation only
27 | private float scaleFactor; //For "Scale" animation only
28 |
29 | private int unselectedColor;
30 | private int selectedColor;
31 |
32 | private boolean interactiveAnimation;
33 | private boolean autoVisibility;
34 | private boolean dynamicCount;
35 |
36 | private long animationDuration;
37 | private int count = DEFAULT_COUNT;
38 |
39 | private int selectedPosition;
40 | private int selectingPosition;
41 | private int lastSelectedPosition;
42 |
43 | private int viewPagerId = View.NO_ID;
44 |
45 | private Orientation orientation;
46 | private IndicatorAnimationType animationType;
47 | private RtlMode rtlMode;
48 |
49 | public int getHeight() {
50 | return height;
51 | }
52 |
53 | public void setHeight(int height) {
54 | this.height = height;
55 | }
56 |
57 | public int getWidth() {
58 | return width;
59 | }
60 |
61 | public void setWidth(int width) {
62 | this.width = width;
63 | }
64 |
65 | public int getRadius() {
66 | return radius;
67 | }
68 |
69 | public void setRadius(int radius) {
70 | this.radius = radius;
71 | }
72 |
73 | public int getPadding() {
74 | return padding;
75 | }
76 |
77 | public void setPadding(int padding) {
78 | this.padding = padding;
79 | }
80 |
81 | public int getPaddingLeft() {
82 | return paddingLeft;
83 | }
84 |
85 | public void setPaddingLeft(int paddingLeft) {
86 | this.paddingLeft = paddingLeft;
87 | }
88 |
89 | public int getPaddingTop() {
90 | return paddingTop;
91 | }
92 |
93 | public void setPaddingTop(int paddingTop) {
94 | this.paddingTop = paddingTop;
95 | }
96 |
97 | public int getPaddingRight() {
98 | return paddingRight;
99 | }
100 |
101 | public void setPaddingRight(int paddingRight) {
102 | this.paddingRight = paddingRight;
103 | }
104 |
105 | public int getPaddingBottom() {
106 | return paddingBottom;
107 | }
108 |
109 | public void setPaddingBottom(int paddingBottom) {
110 | this.paddingBottom = paddingBottom;
111 | }
112 |
113 | public int getStroke() {
114 | return stroke;
115 | }
116 |
117 | public void setStroke(int stroke) {
118 | this.stroke = stroke;
119 | }
120 |
121 | public float getScaleFactor() {
122 | return scaleFactor;
123 | }
124 |
125 | public void setScaleFactor(float scaleFactor) {
126 | this.scaleFactor = scaleFactor;
127 | }
128 |
129 | public int getUnselectedColor() {
130 | return unselectedColor;
131 | }
132 |
133 | public void setUnselectedColor(int unselectedColor) {
134 | this.unselectedColor = unselectedColor;
135 | }
136 |
137 | public int getSelectedColor() {
138 | return selectedColor;
139 | }
140 |
141 | public void setSelectedColor(int selectedColor) {
142 | this.selectedColor = selectedColor;
143 | }
144 |
145 | public boolean isInteractiveAnimation() {
146 | return interactiveAnimation;
147 | }
148 |
149 | public void setInteractiveAnimation(boolean interactiveAnimation) {
150 | this.interactiveAnimation = interactiveAnimation;
151 | }
152 |
153 | public boolean isAutoVisibility() {
154 | return autoVisibility;
155 | }
156 |
157 | public void setAutoVisibility(boolean autoVisibility) {
158 | this.autoVisibility = autoVisibility;
159 | }
160 |
161 | public boolean isDynamicCount() {
162 | return dynamicCount;
163 | }
164 |
165 | public void setDynamicCount(boolean dynamicCount) {
166 | this.dynamicCount = dynamicCount;
167 | }
168 |
169 | public long getAnimationDuration() {
170 | return animationDuration;
171 | }
172 |
173 | public void setAnimationDuration(long animationDuration) {
174 | this.animationDuration = animationDuration;
175 | }
176 |
177 | public int getSelectedPosition() {
178 | return selectedPosition;
179 | }
180 |
181 | public void setSelectedPosition(int selectedPosition) {
182 | this.selectedPosition = selectedPosition;
183 | }
184 |
185 | public int getSelectingPosition() {
186 | return selectingPosition;
187 | }
188 |
189 | public void setSelectingPosition(int selectingPosition) {
190 | this.selectingPosition = selectingPosition;
191 | }
192 |
193 | public int getLastSelectedPosition() {
194 | return lastSelectedPosition;
195 | }
196 |
197 | public void setLastSelectedPosition(int lastSelectedPosition) {
198 | this.lastSelectedPosition = lastSelectedPosition;
199 | }
200 |
201 | public int getCount() {
202 | return count;
203 | }
204 |
205 | public void setCount(int count) {
206 | this.count = count;
207 | }
208 |
209 | @NonNull
210 | public Orientation getOrientation() {
211 | if (orientation == null) {
212 | orientation = Orientation.HORIZONTAL;
213 | }
214 | return orientation;
215 | }
216 |
217 | public void setOrientation(Orientation orientation) {
218 | this.orientation = orientation;
219 | }
220 |
221 | @NonNull
222 | public IndicatorAnimationType getAnimationType() {
223 | if (animationType == null) {
224 | animationType = IndicatorAnimationType.NONE;
225 | }
226 | return animationType;
227 | }
228 |
229 | public void setAnimationType(IndicatorAnimationType animationType) {
230 | this.animationType = animationType;
231 | }
232 |
233 | @NonNull
234 | public RtlMode getRtlMode() {
235 | if (rtlMode == null) {
236 | rtlMode = RtlMode.Off;
237 | }
238 | return rtlMode;
239 | }
240 |
241 | public void setRtlMode(RtlMode rtlMode) {
242 | this.rtlMode = rtlMode;
243 | }
244 |
245 | public int getViewPagerId() {
246 | return viewPagerId;
247 | }
248 |
249 | public void setViewPagerId(int viewPagerId) {
250 | this.viewPagerId = viewPagerId;
251 | }
252 | }
253 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/data/Orientation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.data;
2 |
3 | public enum Orientation {HORIZONTAL, VERTICAL}
4 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/data/PositionSavedState.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.data;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 | import android.view.View;
6 |
7 | public class PositionSavedState extends View.BaseSavedState {
8 |
9 | private int selectedPosition;
10 | private int selectingPosition;
11 | private int lastSelectedPosition;
12 |
13 | public PositionSavedState(Parcelable superState) {
14 | super(superState);
15 | }
16 |
17 | private PositionSavedState(Parcel in) {
18 | super(in);
19 | this.selectedPosition = in.readInt();
20 | this.selectingPosition = in.readInt();
21 | this.lastSelectedPosition = in.readInt();
22 | }
23 |
24 | public int getSelectedPosition() {
25 | return selectedPosition;
26 | }
27 |
28 | public void setSelectedPosition(int selectedPosition) {
29 | this.selectedPosition = selectedPosition;
30 | }
31 |
32 | public int getSelectingPosition() {
33 | return selectingPosition;
34 | }
35 |
36 | public void setSelectingPosition(int selectingPosition) {
37 | this.selectingPosition = selectingPosition;
38 | }
39 |
40 | public int getLastSelectedPosition() {
41 | return lastSelectedPosition;
42 | }
43 |
44 | public void setLastSelectedPosition(int lastSelectedPosition) {
45 | this.lastSelectedPosition = lastSelectedPosition;
46 | }
47 |
48 | @Override
49 | public void writeToParcel(Parcel out, int flags) {
50 | super.writeToParcel(out, flags);
51 | out.writeInt(this.selectedPosition);
52 | out.writeInt(this.selectingPosition);
53 | out.writeInt(this.lastSelectedPosition);
54 | }
55 |
56 | public static final Creator CREATOR = new Creator() {
57 | public PositionSavedState createFromParcel(Parcel in) {
58 | return new PositionSavedState(in);
59 | }
60 |
61 | public PositionSavedState[] newArray(int size) {
62 | return new PositionSavedState[size];
63 | }
64 | };
65 | }
66 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/data/RtlMode.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.data;
2 |
3 | public enum RtlMode {On, Off, Auto}
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/drawer/Drawer.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.drawer;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import androidx.annotation.NonNull;
6 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
7 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
8 | import com.smarteist.autoimageslider.IndicatorView.draw.drawer.type.*;
9 |
10 | public class Drawer {
11 |
12 | private BasicDrawer basicDrawer;
13 | private ColorDrawer colorDrawer;
14 | private ScaleDrawer scaleDrawer;
15 | private WormDrawer wormDrawer;
16 | private SlideDrawer slideDrawer;
17 | private FillDrawer fillDrawer;
18 | private ThinWormDrawer thinWormDrawer;
19 | private DropDrawer dropDrawer;
20 | private SwapDrawer swapDrawer;
21 | private ScaleDownDrawer scaleDownDrawer;
22 |
23 | private int position;
24 | private int coordinateX;
25 | private int coordinateY;
26 |
27 | public Drawer(@NonNull Indicator indicator) {
28 | Paint paint = new Paint();
29 | paint.setStyle(Paint.Style.FILL);
30 | paint.setAntiAlias(true);
31 |
32 | basicDrawer = new BasicDrawer(paint, indicator);
33 | colorDrawer = new ColorDrawer(paint, indicator);
34 | scaleDrawer = new ScaleDrawer(paint, indicator);
35 | wormDrawer = new WormDrawer(paint, indicator);
36 | slideDrawer = new SlideDrawer(paint, indicator);
37 | fillDrawer = new FillDrawer(paint, indicator);
38 | thinWormDrawer = new ThinWormDrawer(paint, indicator);
39 | dropDrawer = new DropDrawer(paint, indicator);
40 | swapDrawer = new SwapDrawer(paint, indicator);
41 | scaleDownDrawer = new ScaleDownDrawer(paint, indicator);
42 | }
43 |
44 | public void setup(int position, int coordinateX, int coordinateY) {
45 | this.position = position;
46 | this.coordinateX = coordinateX;
47 | this.coordinateY = coordinateY;
48 | }
49 |
50 | public void drawBasic(@NonNull Canvas canvas, boolean isSelectedItem) {
51 | if (colorDrawer != null) {
52 | basicDrawer.draw(canvas, position, isSelectedItem, coordinateX, coordinateY);
53 | }
54 | }
55 |
56 | public void drawColor(@NonNull Canvas canvas, @NonNull Value value) {
57 | if (colorDrawer != null) {
58 | colorDrawer.draw(canvas, value, position, coordinateX, coordinateY);
59 | }
60 | }
61 |
62 | public void drawScale(@NonNull Canvas canvas, @NonNull Value value) {
63 | if (scaleDrawer != null) {
64 | scaleDrawer.draw(canvas, value, position, coordinateX, coordinateY);
65 | }
66 | }
67 |
68 | public void drawWorm(@NonNull Canvas canvas, @NonNull Value value) {
69 | if (wormDrawer != null) {
70 | wormDrawer.draw(canvas, value, coordinateX, coordinateY);
71 | }
72 | }
73 |
74 | public void drawSlide(@NonNull Canvas canvas, @NonNull Value value) {
75 | if (slideDrawer != null) {
76 | slideDrawer.draw(canvas, value, coordinateX, coordinateY);
77 | }
78 | }
79 |
80 | public void drawFill(@NonNull Canvas canvas, @NonNull Value value) {
81 | if (fillDrawer != null) {
82 | fillDrawer.draw(canvas, value, position, coordinateX, coordinateY);
83 | }
84 | }
85 |
86 | public void drawThinWorm(@NonNull Canvas canvas, @NonNull Value value) {
87 | if (thinWormDrawer != null) {
88 | thinWormDrawer.draw(canvas, value, coordinateX, coordinateY);
89 | }
90 | }
91 |
92 | public void drawDrop(@NonNull Canvas canvas, @NonNull Value value) {
93 | if (dropDrawer != null) {
94 | dropDrawer.draw(canvas, value, coordinateX, coordinateY);
95 | }
96 | }
97 |
98 | public void drawSwap(@NonNull Canvas canvas, @NonNull Value value) {
99 | if (swapDrawer != null) {
100 | swapDrawer.draw(canvas, value, position, coordinateX, coordinateY);
101 | }
102 | }
103 |
104 | public void drawScaleDown(@NonNull Canvas canvas, @NonNull Value value) {
105 | if (scaleDownDrawer != null) {
106 | scaleDownDrawer.draw(canvas, value, position, coordinateX, coordinateY);
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/drawer/type/BaseDrawer.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.drawer.type;
2 |
3 | import android.graphics.Paint;
4 | import androidx.annotation.NonNull;
5 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
6 |
7 | class BaseDrawer {
8 |
9 | Paint paint;
10 | Indicator indicator;
11 |
12 | BaseDrawer(@NonNull Paint paint, @NonNull Indicator indicator) {
13 | this.paint = paint;
14 | this.indicator = indicator;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/drawer/type/BasicDrawer.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.drawer.type;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import androidx.annotation.NonNull;
6 | import com.smarteist.autoimageslider.IndicatorView.animation.type.IndicatorAnimationType;
7 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
8 |
9 | public class BasicDrawer extends BaseDrawer {
10 |
11 | private Paint strokePaint;
12 |
13 | public BasicDrawer(@NonNull Paint paint, @NonNull Indicator indicator) {
14 | super(paint, indicator);
15 |
16 | strokePaint = new Paint();
17 | strokePaint.setStyle(Paint.Style.STROKE);
18 | strokePaint.setAntiAlias(true);
19 | strokePaint.setStrokeWidth(indicator.getStroke());
20 | }
21 |
22 | public void draw(
23 | @NonNull Canvas canvas,
24 | int position,
25 | boolean isSelectedItem,
26 | int coordinateX,
27 | int coordinateY) {
28 |
29 | float radius = indicator.getRadius();
30 | int strokePx = indicator.getStroke();
31 | float scaleFactor = indicator.getScaleFactor();
32 |
33 | int selectedColor = indicator.getSelectedColor();
34 | int unselectedColor = indicator.getUnselectedColor();
35 | int selectedPosition = indicator.getSelectedPosition();
36 | IndicatorAnimationType animationType = indicator.getAnimationType();
37 |
38 | if (animationType == IndicatorAnimationType.SCALE && !isSelectedItem) {
39 | radius *= scaleFactor;
40 |
41 | } else if (animationType == IndicatorAnimationType.SCALE_DOWN && isSelectedItem) {
42 | radius *= scaleFactor;
43 | }
44 |
45 | int color = unselectedColor;
46 | if (position == selectedPosition) {
47 | color = selectedColor;
48 | }
49 |
50 | Paint paint;
51 | if (animationType == IndicatorAnimationType.FILL && position != selectedPosition) {
52 | paint = strokePaint;
53 | paint.setStrokeWidth(strokePx);
54 | } else {
55 | paint = this.paint;
56 | }
57 |
58 | paint.setColor(color);
59 | canvas.drawCircle(coordinateX, coordinateY, radius, paint);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/drawer/type/ColorDrawer.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.drawer.type;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import androidx.annotation.NonNull;
6 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
7 | import com.smarteist.autoimageslider.IndicatorView.animation.data.type.ColorAnimationValue;
8 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
9 |
10 | public class ColorDrawer extends BaseDrawer {
11 |
12 | public ColorDrawer(@NonNull Paint paint, @NonNull Indicator indicator) {
13 | super(paint, indicator);
14 | }
15 |
16 | public void draw(@NonNull Canvas canvas,
17 | @NonNull Value value,
18 | int position,
19 | int coordinateX,
20 | int coordinateY) {
21 |
22 | if (!(value instanceof ColorAnimationValue)) {
23 | return;
24 | }
25 |
26 | ColorAnimationValue v = (ColorAnimationValue) value;
27 | float radius = indicator.getRadius();
28 | int color = indicator.getSelectedColor();
29 |
30 | int selectedPosition = indicator.getSelectedPosition();
31 | int selectingPosition = indicator.getSelectingPosition();
32 | int lastSelectedPosition = indicator.getLastSelectedPosition();
33 |
34 | if (indicator.isInteractiveAnimation()) {
35 | if (position == selectingPosition) {
36 | color = v.getColor();
37 |
38 | } else if (position == selectedPosition) {
39 | color = v.getColorReverse();
40 | }
41 |
42 | } else {
43 | if (position == selectedPosition) {
44 | color = v.getColor();
45 |
46 | } else if (position == lastSelectedPosition) {
47 | color = v.getColorReverse();
48 | }
49 | }
50 |
51 | paint.setColor(color);
52 | canvas.drawCircle(coordinateX, coordinateY, radius, paint);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/drawer/type/DropDrawer.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.drawer.type;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import androidx.annotation.NonNull;
6 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
7 | import com.smarteist.autoimageslider.IndicatorView.animation.data.type.DropAnimationValue;
8 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
9 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Orientation;
10 |
11 | public class DropDrawer extends BaseDrawer {
12 |
13 | public DropDrawer(@NonNull Paint paint, @NonNull Indicator indicator) {
14 | super(paint, indicator);
15 | }
16 |
17 | public void draw(
18 | @NonNull Canvas canvas,
19 | @NonNull Value value,
20 | int coordinateX,
21 | int coordinateY) {
22 |
23 | if (!(value instanceof DropAnimationValue)) {
24 | return;
25 | }
26 |
27 | DropAnimationValue v = (DropAnimationValue) value;
28 | int unselectedColor = indicator.getUnselectedColor();
29 | int selectedColor = indicator.getSelectedColor();
30 | float radius = indicator.getRadius();
31 |
32 | paint.setColor(unselectedColor);
33 | canvas.drawCircle(coordinateX, coordinateY, radius, paint);
34 |
35 | paint.setColor(selectedColor);
36 | if (indicator.getOrientation() == Orientation.HORIZONTAL) {
37 | canvas.drawCircle(v.getWidth(), v.getHeight(), v.getRadius(), paint);
38 | } else {
39 | canvas.drawCircle(v.getHeight(), v.getWidth(), v.getRadius(), paint);
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/drawer/type/FillDrawer.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.drawer.type;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import androidx.annotation.NonNull;
6 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
7 | import com.smarteist.autoimageslider.IndicatorView.animation.data.type.FillAnimationValue;
8 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
9 |
10 | public class FillDrawer extends BaseDrawer {
11 |
12 | private Paint strokePaint;
13 |
14 | public FillDrawer(@NonNull Paint paint, @NonNull Indicator indicator) {
15 | super(paint, indicator);
16 |
17 | strokePaint = new Paint();
18 | strokePaint.setStyle(Paint.Style.STROKE);
19 | strokePaint.setAntiAlias(true);
20 | }
21 |
22 | public void draw(
23 | @NonNull Canvas canvas,
24 | @NonNull Value value,
25 | int position,
26 | int coordinateX,
27 | int coordinateY) {
28 |
29 | if (!(value instanceof FillAnimationValue)) {
30 | return;
31 | }
32 |
33 | FillAnimationValue v = (FillAnimationValue) value;
34 | int color = indicator.getUnselectedColor();
35 | float radius = indicator.getRadius();
36 | int stroke = indicator.getStroke();
37 |
38 | int selectedPosition = indicator.getSelectedPosition();
39 | int selectingPosition = indicator.getSelectingPosition();
40 | int lastSelectedPosition = indicator.getLastSelectedPosition();
41 |
42 | if (indicator.isInteractiveAnimation()) {
43 | if (position == selectingPosition) {
44 | color = v.getColor();
45 | radius = v.getRadius();
46 | stroke = v.getStroke();
47 |
48 | } else if (position == selectedPosition) {
49 | color = v.getColorReverse();
50 | radius = v.getRadiusReverse();
51 | stroke = v.getStrokeReverse();
52 | }
53 |
54 | } else {
55 | if (position == selectedPosition) {
56 | color = v.getColor();
57 | radius = v.getRadius();
58 | stroke = v.getStroke();
59 |
60 | } else if (position == lastSelectedPosition) {
61 | color = v.getColorReverse();
62 | radius = v.getRadiusReverse();
63 | stroke = v.getStrokeReverse();
64 | }
65 | }
66 |
67 | strokePaint.setColor(color);
68 | strokePaint.setStrokeWidth(indicator.getStroke());
69 | canvas.drawCircle(coordinateX, coordinateY, indicator.getRadius(), strokePaint);
70 |
71 | strokePaint.setStrokeWidth(stroke);
72 | canvas.drawCircle(coordinateX, coordinateY, radius, strokePaint);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/drawer/type/ScaleDownDrawer.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.drawer.type;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import androidx.annotation.NonNull;
6 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
7 | import com.smarteist.autoimageslider.IndicatorView.animation.data.type.ScaleAnimationValue;
8 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
9 |
10 | public class ScaleDownDrawer extends BaseDrawer {
11 |
12 | public ScaleDownDrawer(@NonNull Paint paint, @NonNull Indicator indicator) {
13 | super(paint, indicator);
14 | }
15 |
16 | public void draw(
17 | @NonNull Canvas canvas,
18 | @NonNull Value value,
19 | int position,
20 | int coordinateX,
21 | int coordinateY) {
22 |
23 | if (!(value instanceof ScaleAnimationValue)) {
24 | return;
25 | }
26 |
27 | ScaleAnimationValue v = (ScaleAnimationValue) value;
28 | float radius = indicator.getRadius();
29 | int color = indicator.getSelectedColor();
30 |
31 | int selectedPosition = indicator.getSelectedPosition();
32 | int selectingPosition = indicator.getSelectingPosition();
33 | int lastSelectedPosition = indicator.getLastSelectedPosition();
34 |
35 | if (indicator.isInteractiveAnimation()) {
36 | if (position == selectingPosition) {
37 | radius = v.getRadius();
38 | color = v.getColor();
39 |
40 | } else if (position == selectedPosition) {
41 | radius = v.getRadiusReverse();
42 | color = v.getColorReverse();
43 | }
44 |
45 | } else {
46 | if (position == selectedPosition) {
47 | radius = v.getRadius();
48 | color = v.getColor();
49 |
50 | } else if (position == lastSelectedPosition) {
51 | radius = v.getRadiusReverse();
52 | color = v.getColorReverse();
53 | }
54 | }
55 |
56 | paint.setColor(color);
57 | canvas.drawCircle(coordinateX, coordinateY, radius, paint);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/drawer/type/ScaleDrawer.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.drawer.type;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import androidx.annotation.NonNull;
6 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
7 | import com.smarteist.autoimageslider.IndicatorView.animation.data.type.ScaleAnimationValue;
8 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
9 |
10 | public class ScaleDrawer extends BaseDrawer {
11 |
12 | public ScaleDrawer(@NonNull Paint paint, @NonNull Indicator indicator) {
13 | super(paint, indicator);
14 | }
15 |
16 | public void draw(
17 | @NonNull Canvas canvas,
18 | @NonNull Value value,
19 | int position,
20 | int coordinateX,
21 | int coordinateY) {
22 |
23 | if (!(value instanceof ScaleAnimationValue)) {
24 | return;
25 | }
26 |
27 | ScaleAnimationValue v = (ScaleAnimationValue) value;
28 | float radius = indicator.getRadius();
29 | int color = indicator.getSelectedColor();
30 |
31 | int selectedPosition = indicator.getSelectedPosition();
32 | int selectingPosition = indicator.getSelectingPosition();
33 | int lastSelectedPosition = indicator.getLastSelectedPosition();
34 |
35 | if (indicator.isInteractiveAnimation()) {
36 | if (position == selectingPosition) {
37 | radius = v.getRadius();
38 | color = v.getColor();
39 |
40 | } else if (position == selectedPosition) {
41 | radius = v.getRadiusReverse();
42 | color = v.getColorReverse();
43 | }
44 |
45 | } else {
46 | if (position == selectedPosition) {
47 | radius = v.getRadius();
48 | color = v.getColor();
49 |
50 | } else if (position == lastSelectedPosition) {
51 | radius = v.getRadiusReverse();
52 | color = v.getColorReverse();
53 | }
54 | }
55 |
56 | paint.setColor(color);
57 | canvas.drawCircle(coordinateX, coordinateY, radius, paint);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/drawer/type/SlideDrawer.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.drawer.type;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import androidx.annotation.NonNull;
6 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
7 | import com.smarteist.autoimageslider.IndicatorView.animation.data.type.SlideAnimationValue;
8 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
9 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Orientation;
10 |
11 | public class SlideDrawer extends BaseDrawer {
12 |
13 | public SlideDrawer(@NonNull Paint paint, @NonNull Indicator indicator) {
14 | super(paint, indicator);
15 | }
16 |
17 | public void draw(
18 | @NonNull Canvas canvas,
19 | @NonNull Value value,
20 | int coordinateX,
21 | int coordinateY) {
22 |
23 | if (!(value instanceof SlideAnimationValue)) {
24 | return;
25 | }
26 |
27 | SlideAnimationValue v = (SlideAnimationValue) value;
28 | int coordinate = v.getCoordinate();
29 | int unselectedColor = indicator.getUnselectedColor();
30 | int selectedColor = indicator.getSelectedColor();
31 | int radius = indicator.getRadius();
32 |
33 | paint.setColor(unselectedColor);
34 | canvas.drawCircle(coordinateX, coordinateY, radius, paint);
35 |
36 | paint.setColor(selectedColor);
37 | if (indicator.getOrientation() == Orientation.HORIZONTAL) {
38 | canvas.drawCircle(coordinate, coordinateY, radius, paint);
39 | } else {
40 | canvas.drawCircle(coordinateX, coordinate, radius, paint);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/drawer/type/SwapDrawer.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.drawer.type;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import androidx.annotation.NonNull;
6 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
7 | import com.smarteist.autoimageslider.IndicatorView.animation.data.type.SwapAnimationValue;
8 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
9 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Orientation;
10 |
11 | public class SwapDrawer extends BaseDrawer {
12 |
13 | public SwapDrawer(@NonNull Paint paint, @NonNull Indicator indicator) {
14 | super(paint, indicator);
15 | }
16 |
17 | public void draw(
18 | @NonNull Canvas canvas,
19 | @NonNull Value value,
20 | int position,
21 | int coordinateX,
22 | int coordinateY) {
23 |
24 | if (!(value instanceof SwapAnimationValue)) {
25 | return;
26 | }
27 |
28 | SwapAnimationValue v = (SwapAnimationValue) value;
29 | int selectedColor = indicator.getSelectedColor();
30 | int unselectedColor = indicator.getUnselectedColor();
31 | int radius = indicator.getRadius();
32 |
33 | int selectedPosition = indicator.getSelectedPosition();
34 | int selectingPosition = indicator.getSelectingPosition();
35 | int lastSelectedPosition = indicator.getLastSelectedPosition();
36 |
37 | int coordinate = v.getCoordinate();
38 | int color = unselectedColor;
39 |
40 | if (indicator.isInteractiveAnimation()) {
41 | if (position == selectingPosition) {
42 | coordinate = v.getCoordinate();
43 | color = selectedColor;
44 |
45 | } else if (position == selectedPosition) {
46 | coordinate = v.getCoordinateReverse();
47 | color = unselectedColor;
48 | }
49 |
50 | } else {
51 | if (position == lastSelectedPosition) {
52 | coordinate = v.getCoordinate();
53 | color = selectedColor;
54 |
55 | } else if (position == selectedPosition) {
56 | coordinate = v.getCoordinateReverse();
57 | color = unselectedColor;
58 | }
59 | }
60 |
61 | paint.setColor(color);
62 | if (indicator.getOrientation() == Orientation.HORIZONTAL) {
63 | canvas.drawCircle(coordinate, coordinateY, radius, paint);
64 | } else {
65 | canvas.drawCircle(coordinateX, coordinate, radius, paint);
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/drawer/type/ThinWormDrawer.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.drawer.type;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import androidx.annotation.NonNull;
6 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
7 | import com.smarteist.autoimageslider.IndicatorView.animation.data.type.ThinWormAnimationValue;
8 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
9 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Orientation;
10 |
11 | public class ThinWormDrawer extends WormDrawer {
12 |
13 | public ThinWormDrawer(@NonNull Paint paint, @NonNull Indicator indicator) {
14 | super(paint, indicator);
15 | }
16 |
17 | public void draw(
18 | @NonNull Canvas canvas,
19 | @NonNull Value value,
20 | int coordinateX,
21 | int coordinateY) {
22 |
23 | if (!(value instanceof ThinWormAnimationValue)) {
24 | return;
25 | }
26 |
27 | ThinWormAnimationValue v = (ThinWormAnimationValue) value;
28 | int rectStart = v.getRectStart();
29 | int rectEnd = v.getRectEnd();
30 | int height = v.getHeight() / 2;
31 |
32 | int radius = indicator.getRadius();
33 | int unselectedColor = indicator.getUnselectedColor();
34 | int selectedColor = indicator.getSelectedColor();
35 |
36 | if (indicator.getOrientation() == Orientation.HORIZONTAL) {
37 | rect.left = rectStart;
38 | rect.right = rectEnd;
39 | rect.top = coordinateY - height;
40 | rect.bottom = coordinateY + height;
41 |
42 | } else {
43 | rect.left = coordinateX - height;
44 | rect.right = coordinateX + height;
45 | rect.top = rectStart;
46 | rect.bottom = rectEnd;
47 | }
48 |
49 | paint.setColor(unselectedColor);
50 | canvas.drawCircle(coordinateX, coordinateY, radius, paint);
51 |
52 | paint.setColor(selectedColor);
53 | canvas.drawRoundRect(rect, radius, radius, paint);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/draw/drawer/type/WormDrawer.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.draw.drawer.type;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.RectF;
6 | import androidx.annotation.NonNull;
7 | import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
8 | import com.smarteist.autoimageslider.IndicatorView.animation.data.type.WormAnimationValue;
9 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
10 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Orientation;
11 |
12 | public class WormDrawer extends BaseDrawer {
13 |
14 | public RectF rect;
15 |
16 | public WormDrawer(@NonNull Paint paint, @NonNull Indicator indicator) {
17 | super(paint, indicator);
18 | rect = new RectF();
19 | }
20 |
21 | public void draw(
22 | @NonNull Canvas canvas,
23 | @NonNull Value value,
24 | int coordinateX,
25 | int coordinateY) {
26 |
27 | if (!(value instanceof WormAnimationValue)) {
28 | return;
29 | }
30 |
31 | WormAnimationValue v = (WormAnimationValue) value;
32 | int rectStart = v.getRectStart();
33 | int rectEnd = v.getRectEnd();
34 |
35 | int radius = indicator.getRadius();
36 | int unselectedColor = indicator.getUnselectedColor();
37 | int selectedColor = indicator.getSelectedColor();
38 |
39 | if (indicator.getOrientation() == Orientation.HORIZONTAL) {
40 | rect.left = rectStart;
41 | rect.right = rectEnd;
42 | rect.top = coordinateY - radius;
43 | rect.bottom = coordinateY + radius;
44 |
45 | } else {
46 | rect.left = coordinateX - radius;
47 | rect.right = coordinateX + radius;
48 | rect.top = rectStart;
49 | rect.bottom = rectEnd;
50 | }
51 |
52 | paint.setColor(unselectedColor);
53 | canvas.drawCircle(coordinateX, coordinateY, radius, paint);
54 |
55 | paint.setColor(selectedColor);
56 | canvas.drawRoundRect(rect, radius, radius, paint);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/utils/CoordinatesUtils.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.utils;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.annotation.Nullable;
5 | import android.util.Pair;
6 | import com.smarteist.autoimageslider.IndicatorView.animation.type.IndicatorAnimationType;
7 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
8 | import com.smarteist.autoimageslider.IndicatorView.draw.data.Orientation;
9 |
10 | public class CoordinatesUtils {
11 |
12 | @SuppressWarnings("UnnecessaryLocalVariable")
13 | public static int getCoordinate(@Nullable Indicator indicator, int position) {
14 | if (indicator == null) {
15 | return 0;
16 | }
17 |
18 | if (indicator.getOrientation() == Orientation.HORIZONTAL) {
19 | return getXCoordinate(indicator, position);
20 | } else {
21 | return getYCoordinate(indicator, position);
22 | }
23 | }
24 |
25 | @SuppressWarnings("UnnecessaryLocalVariable")
26 | public static int getXCoordinate(@Nullable Indicator indicator, int position) {
27 | if (indicator == null) {
28 | return 0;
29 | }
30 |
31 | int coordinate;
32 | if (indicator.getOrientation() == Orientation.HORIZONTAL) {
33 | coordinate = getHorizontalCoordinate(indicator, position);
34 | } else {
35 | coordinate = getVerticalCoordinate(indicator);
36 | }
37 |
38 | coordinate += indicator.getPaddingLeft();
39 | return coordinate;
40 | }
41 |
42 | public static int getYCoordinate(@Nullable Indicator indicator, int position) {
43 | if (indicator == null) {
44 | return 0;
45 | }
46 |
47 | int coordinate;
48 | if (indicator.getOrientation() == Orientation.HORIZONTAL) {
49 | coordinate = getVerticalCoordinate(indicator);
50 | } else {
51 | coordinate = getHorizontalCoordinate(indicator, position);
52 | }
53 |
54 | coordinate += indicator.getPaddingTop();
55 | return coordinate;
56 | }
57 |
58 | @SuppressWarnings("SuspiciousNameCombination")
59 | public static int getPosition(@Nullable Indicator indicator, float x, float y) {
60 | if (indicator == null) {
61 | return -1;
62 | }
63 |
64 | float lengthCoordinate;
65 | float heightCoordinate;
66 |
67 | if (indicator.getOrientation() == Orientation.HORIZONTAL) {
68 | lengthCoordinate = x;
69 | heightCoordinate = y;
70 | } else {
71 | lengthCoordinate = y;
72 | heightCoordinate = x;
73 | }
74 |
75 | return getFitPosition(indicator, lengthCoordinate, heightCoordinate);
76 | }
77 |
78 | private static int getFitPosition(@NonNull Indicator indicator, float lengthCoordinate, float heightCoordinate) {
79 | int count = indicator.getCount();
80 | int radius = indicator.getRadius();
81 | int stroke = indicator.getStroke();
82 | int padding = indicator.getPadding();
83 |
84 | int height = indicator.getOrientation() == Orientation.HORIZONTAL ? indicator.getHeight() : indicator.getWidth();
85 | int length = 0;
86 |
87 | for (int i = 0; i < count; i++) {
88 | int indicatorPadding = i > 0 ? padding : padding / 2;
89 | int startValue = length;
90 |
91 | length += radius * 2 + (stroke / 2) + indicatorPadding;
92 | int endValue = length;
93 |
94 | boolean fitLength = lengthCoordinate >= startValue && lengthCoordinate <= endValue;
95 | boolean fitHeight = heightCoordinate >= 0 && heightCoordinate <= height;
96 |
97 | if (fitLength && fitHeight) {
98 | return i;
99 | }
100 | }
101 |
102 | return -1;
103 | }
104 |
105 | private static int getHorizontalCoordinate(@NonNull Indicator indicator, int position) {
106 | int count = indicator.getCount();
107 | int radius = indicator.getRadius();
108 | int stroke = indicator.getStroke();
109 | int padding = indicator.getPadding();
110 |
111 | int coordinate = 0;
112 | for (int i = 0; i < count; i++) {
113 | coordinate += radius + (stroke / 2);
114 |
115 | if (position == i) {
116 | return coordinate;
117 | }
118 |
119 | coordinate += radius + padding + (stroke / 2);
120 | }
121 |
122 | if (indicator.getAnimationType() == IndicatorAnimationType.DROP) {
123 | coordinate += radius * 2;
124 | }
125 |
126 | return coordinate;
127 | }
128 |
129 | private static int getVerticalCoordinate(@NonNull Indicator indicator) {
130 | int radius = indicator.getRadius();
131 | int coordinate;
132 |
133 | if (indicator.getAnimationType() == IndicatorAnimationType.DROP) {
134 | coordinate = radius * 3;
135 | } else {
136 | coordinate = radius;
137 | }
138 |
139 | return coordinate;
140 | }
141 |
142 | public static Pair getProgress(@NonNull Indicator indicator, int position, float positionOffset, boolean isRtl) {
143 | int count = indicator.getCount();
144 | int selectedPosition = indicator.getSelectedPosition();
145 |
146 | if (isRtl) {
147 | position = (count - 1) - position;
148 | }
149 |
150 | if (position < 0) {
151 | position = 0;
152 |
153 | } else if (position > count - 1) {
154 | position = count - 1;
155 | }
156 |
157 | boolean isRightOverScrolled = position > selectedPosition;
158 | boolean isLeftOverScrolled;
159 |
160 | if (isRtl) {
161 | isLeftOverScrolled = position - 1 < selectedPosition;
162 | } else {
163 | isLeftOverScrolled = position + 1 < selectedPosition;
164 | }
165 |
166 | if (isRightOverScrolled || isLeftOverScrolled) {
167 | selectedPosition = position;
168 | indicator.setSelectedPosition(selectedPosition);
169 | }
170 |
171 | boolean slideToRightSide = selectedPosition == position && positionOffset != 0;
172 | int selectingPosition;
173 | float selectingProgress;
174 |
175 | if (slideToRightSide) {
176 | selectingPosition = isRtl ? position - 1 : position + 1;
177 | selectingProgress = positionOffset;
178 |
179 | } else {
180 | selectingPosition = position;
181 | selectingProgress = 1 - positionOffset;
182 | }
183 |
184 | if (selectingProgress > 1) {
185 | selectingProgress = 1;
186 |
187 | } else if (selectingProgress < 0) {
188 | selectingProgress = 0;
189 | }
190 |
191 | return new Pair<>(selectingPosition, selectingProgress);
192 | }
193 | }
194 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/utils/DensityUtils.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.utils;
2 |
3 | import android.content.res.Resources;
4 | import android.util.TypedValue;
5 |
6 | public class DensityUtils {
7 |
8 | public static int dpToPx(int dp) {
9 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, Resources.getSystem().getDisplayMetrics());
10 | }
11 |
12 | public static int pxToDp(float px) {
13 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, px, Resources.getSystem().getDisplayMetrics());
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/IndicatorView/utils/IdUtils.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.IndicatorView.utils;
2 |
3 | import android.os.Build;
4 | import android.view.View;
5 |
6 | import java.util.concurrent.atomic.AtomicInteger;
7 |
8 | public class IdUtils {
9 |
10 | private static final AtomicInteger nextGeneratedId = new AtomicInteger(1);
11 |
12 | public static int generateViewId(){
13 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
14 | return generateId();
15 | } else {
16 | return View.generateViewId();
17 | }
18 | }
19 |
20 | /**
21 | * Generate a value suitable for use in #setId(int).
22 | * This value will not collide with ID values generated at build time by aapt for R.id.
23 | *
24 | * @return a generated ID value
25 | */
26 | private static int generateId() {
27 | for (; ; ) {
28 | final int result = nextGeneratedId.get();
29 | // aapt-generated IDs have the high byte nonzero; clamp to the range under that.
30 | int newValue = result + 1;
31 | if (newValue > 0x00FFFFFF) newValue = 1; // Roll over to 1, not 0.
32 | if (nextGeneratedId.compareAndSet(result, newValue)) {
33 | return result;
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/InfiniteAdapter/InfinitePagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.InfiniteAdapter;
2 |
3 | import android.database.DataSetObserver;
4 | import android.os.Parcelable;
5 | import android.util.Log;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | import androidx.annotation.NonNull;
10 | import androidx.viewpager.widget.PagerAdapter;
11 |
12 | import com.smarteist.autoimageslider.SliderViewAdapter;
13 |
14 |
15 | /**
16 | * Its just a wrapper adapter class for providing infinite behavior
17 | * for slider.
18 | */
19 | public class InfinitePagerAdapter extends PagerAdapter {
20 |
21 | // Warning: it should be an even number.
22 | public static final int INFINITE_SCROLL_LIMIT = 32400;
23 | private static final String TAG = "InfinitePagerAdapter";
24 | private SliderViewAdapter adapter;
25 |
26 | public InfinitePagerAdapter(SliderViewAdapter adapter) {
27 | this.adapter = adapter;
28 | }
29 |
30 | public PagerAdapter getRealAdapter() {
31 | return this.adapter;
32 | }
33 |
34 | @Override
35 | public int getCount() {
36 | if (getRealCount() < 1) {
37 | return 0;
38 | }
39 | // warning: infinite scroller actually is not infinite!
40 | // very big number will be cause memory problems.
41 | return getRealCount() * INFINITE_SCROLL_LIMIT;
42 | }
43 |
44 | /**
45 | * @return the {@link #getCount()} result of the wrapped adapter
46 | */
47 | public int getRealCount() {
48 | try {
49 | return getRealAdapter().getCount();
50 | } catch (Exception e) {
51 | return 0;
52 | }
53 | }
54 |
55 |
56 | /**
57 | * @param item real position of item
58 | * @return virtual mid point
59 | */
60 | public int getMiddlePosition(int item) {
61 | int midpoint = Math.max(0, getRealCount()) * (InfinitePagerAdapter.INFINITE_SCROLL_LIMIT / 2);
62 | return item + midpoint;
63 | }
64 |
65 | @NonNull
66 | @Override
67 | public Object instantiateItem(ViewGroup container, int virtualPosition) {
68 | // prevent division by zer
69 | if (getRealCount() < 1) {
70 | return adapter.instantiateItem(container, 0);
71 | }
72 | //Log.i(TAG, "instantiateItem: real virtualPosition: " + virtualPosition);
73 | //Log.i(TAG, "instantiateItem: virtual virtualPosition: " + virtualPosition);
74 |
75 | // only expose virtual virtualPosition to the inner adapter
76 | return adapter.instantiateItem(container, getRealPosition(virtualPosition));
77 | }
78 |
79 | @Override
80 | public void destroyItem(ViewGroup container, int virtualPosition, Object object) {
81 | // prevent division by zero
82 | if (getRealCount() < 1) {
83 | adapter.destroyItem(container, 0, object);
84 | return;
85 | }
86 | //Log.i(TAG, "destroyItem: real position: " + position);
87 | //Log.i(TAG, "destroyItem: virtual position: " + virtualPosition);
88 |
89 | // only expose virtual position to the inner adapter
90 | adapter.destroyItem(container, getRealPosition(virtualPosition), object);
91 | }
92 |
93 | @Override
94 | public void startUpdate(ViewGroup container) {
95 | adapter.startUpdate(container);
96 | }
97 |
98 | /*
99 | * Delegate rest of methods directly to the inner adapter.
100 | */
101 | @Override
102 | public void finishUpdate(ViewGroup container) {
103 | adapter.finishUpdate(container);
104 | }
105 |
106 | @Override
107 | public boolean isViewFromObject(View view, Object object) {
108 | return adapter.isViewFromObject(view, object);
109 | }
110 |
111 | @Override
112 | public void restoreState(Parcelable bundle, ClassLoader classLoader) {
113 | adapter.restoreState(bundle, classLoader);
114 | }
115 |
116 | @Override
117 | public Parcelable saveState() {
118 | return adapter.saveState();
119 | }
120 |
121 | @Override
122 | public CharSequence getPageTitle(int virtualPosition) {
123 | return adapter.getPageTitle(getRealPosition(virtualPosition));
124 | }
125 |
126 | @Override
127 | public float getPageWidth(int position) {
128 | return adapter.getPageWidth(position);
129 | }
130 |
131 | @Override
132 | public void setPrimaryItem(ViewGroup container, int position, Object object) {
133 | adapter.setPrimaryItem(container, position, object);
134 | }
135 |
136 | @Override
137 | public void unregisterDataSetObserver(DataSetObserver observer) {
138 | adapter.unregisterDataSetObserver(observer);
139 | }
140 |
141 | @Override
142 | public void registerDataSetObserver(DataSetObserver observer) {
143 | adapter.registerDataSetObserver(observer);
144 | }
145 |
146 | @Override
147 | public int getItemPosition(Object object) {
148 | return adapter.getItemPosition(object);
149 | }
150 |
151 | public int getRealPosition(int virtualPosition) {
152 | if (getRealCount() > 0) {
153 | return virtualPosition % getRealCount();
154 | }
155 | return 0;
156 | }
157 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/SliderAnimations.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider;
2 |
3 | public enum SliderAnimations {
4 | ANTICLOCKSPINTRANSFORMATION,
5 | CLOCK_SPINTRANSFORMATION,
6 | CUBEINDEPTHTRANSFORMATION,
7 | CUBEINROTATIONTRANSFORMATION,
8 | CUBEINSCALINGTRANSFORMATION,
9 | CUBEOUTDEPTHTRANSFORMATION,
10 | CUBEOUTROTATIONTRANSFORMATION,
11 | CUBEOUTSCALINGTRANSFORMATION,
12 | DEPTHTRANSFORMATION,
13 | FADETRANSFORMATION,
14 | FANTRANSFORMATION,
15 | FIDGETSPINTRANSFORMATION,
16 | GATETRANSFORMATION,
17 | HINGETRANSFORMATION,
18 | HORIZONTALFLIPTRANSFORMATION,
19 | POPTRANSFORMATION,
20 | SIMPLETRANSFORMATION,
21 | SPINNERTRANSFORMATION,
22 | TOSSTRANSFORMATION,
23 | VERTICALFLIPTRANSFORMATION,
24 | VERTICALSHUTTRANSFORMATION,
25 | ZOOMOUTTRANSFORMATION
26 | }
27 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/SliderViewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.viewpager.widget.PagerAdapter;
5 |
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | import java.util.LinkedList;
10 | import java.util.Queue;
11 |
12 |
13 | public abstract class SliderViewAdapter extends PagerAdapter {
14 |
15 | private DataSetListener dataSetListener;
16 |
17 | //Default View holder class
18 | public static abstract class ViewHolder {
19 | public final View itemView;
20 |
21 | public ViewHolder(View itemView) {
22 | this.itemView = itemView;
23 | }
24 | }
25 |
26 | private Queue destroyedItems = new LinkedList<>();
27 |
28 | @NonNull
29 | @Override
30 | public Object instantiateItem(@NonNull ViewGroup container, int position) {
31 | VH viewHolder = destroyedItems.poll();
32 | if (viewHolder == null) {
33 | viewHolder = onCreateViewHolder(container);
34 | }
35 | // Re-add existing view before rendering so that we can make change inside getView()
36 | container.addView(viewHolder.itemView);
37 | onBindViewHolder(viewHolder, position);
38 |
39 | return viewHolder;
40 | }
41 |
42 | @Override
43 | public final void destroyItem(ViewGroup container, int position, @NonNull Object object) {
44 | container.removeView(((VH) object).itemView);
45 | destroyedItems.add((VH) object);
46 | }
47 |
48 | @Override
49 | public final boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
50 | return ((VH) object).itemView == view;
51 | }
52 |
53 | @Override
54 | public int getItemPosition(Object object) {
55 | return POSITION_NONE;
56 | }
57 |
58 | @Override
59 | public void notifyDataSetChanged() {
60 | super.notifyDataSetChanged();
61 | if (this.dataSetListener != null) {
62 | dataSetListener.dataSetChanged();
63 | }
64 | }
65 |
66 | /**
67 | * Create a new view holder
68 | *
69 | * @param parent wrapper view
70 | * @return view holder
71 | */
72 | public abstract VH onCreateViewHolder(ViewGroup parent);
73 |
74 | /**
75 | * Bind data at position into viewHolder
76 | *
77 | * @param viewHolder item view holder
78 | * @param position item position
79 | */
80 | public abstract void onBindViewHolder(VH viewHolder, int position);
81 |
82 | void dataSetChangedListener(SliderViewAdapter.DataSetListener dataSetListener) {
83 | this.dataSetListener = dataSetListener;
84 | }
85 |
86 | interface DataSetListener {
87 | void dataSetChanged();
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/AntiClockSpinTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 |
5 | import android.view.View;
6 |
7 | public class AntiClockSpinTransformation implements SliderPager.PageTransformer {
8 | @Override
9 | public void transformPage(View page, float position) {
10 |
11 | page.setTranslationX(-position * page.getWidth());
12 |
13 | if (Math.abs(position) < 0.5){
14 | page.setVisibility(View.VISIBLE);
15 | page.setScaleX(1-Math.abs(position));
16 | page.setScaleY(1-Math.abs(position));
17 | }
18 | else if (Math.abs(position) > 0.5){
19 | page.setVisibility(View.GONE);
20 | }
21 |
22 | if (position < -1){ // [-Infinity,-1)
23 | // This page is way off-screen to the left.
24 | page.setAlpha(0);
25 |
26 | }
27 | else if (position <= 0){ // [-1,0]
28 | page.setAlpha(1);
29 | page.setRotation(360*(1-Math.abs(position)));
30 |
31 | }
32 | else if (position <= 1){ // (0,1]
33 | page.setAlpha(1);
34 | page.setRotation(-360*(1-Math.abs(position)));
35 |
36 | }
37 | else { // (1,+Infinity]
38 | // This page is way off-screen to the right.
39 | page.setAlpha(0);
40 |
41 | }
42 |
43 |
44 | }
45 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/Clock_SpinTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 |
5 | import android.view.View;
6 |
7 | public class Clock_SpinTransformation implements SliderPager.PageTransformer {
8 | @Override
9 | public void transformPage(View page, float position) {
10 |
11 | page.setTranslationX(-position * page.getWidth());
12 |
13 | if (Math.abs(position) <= 0.5) {
14 | page.setVisibility(View.VISIBLE);
15 | page.setScaleX(1 - Math.abs(position));
16 | page.setScaleY(1 - Math.abs(position));
17 | } else if (Math.abs(position) > 0.5) {
18 | page.setVisibility(View.GONE);
19 | }
20 |
21 |
22 | if (position < -1){ // [-Infinity,-1)
23 | // This page is way off-screen to the left.
24 | page.setAlpha(0);
25 |
26 | }
27 | else if (position <= 0) { // [-1,0]
28 | page.setAlpha(1);
29 | page.setRotation(360 * Math.abs(position));
30 |
31 | }
32 | else if (position <= 1) { // (0,1]
33 | page.setAlpha(1);
34 | page.setRotation(-360 * Math.abs(position));
35 |
36 | }
37 | else { // (1,+Infinity]
38 | // This page is way off-screen to the right.
39 | page.setAlpha(0);
40 |
41 | }
42 |
43 |
44 | }
45 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/CubeInDepthTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 | import android.view.View;
5 |
6 | public class CubeInDepthTransformation implements SliderPager.PageTransformer {
7 | @Override
8 | public void transformPage(View page, float position) {
9 | page.setCameraDistance(20000);
10 |
11 |
12 | if (position < -1){
13 | page.setAlpha(0);
14 | }
15 | else if (position <= 0){
16 | page.setAlpha(1);
17 | page.setPivotX(page.getWidth());
18 | page.setRotationY(90*Math.abs(position));
19 | }
20 | else if (position <= 1){
21 | page.setAlpha(1);
22 | page.setPivotX(0);
23 | page.setRotationY(-90*Math.abs(position));
24 | }
25 | else{
26 | page.setAlpha(0);
27 | }
28 |
29 |
30 |
31 | if (Math.abs(position) <= 0.5){
32 | page.setScaleY(Math.max(.4f,1-Math.abs(position)));
33 | }
34 | else if (Math.abs(position) <= 1){
35 | page.setScaleY(Math.max(.4f,1-Math.abs(position)));
36 |
37 | }
38 |
39 |
40 | }
41 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/CubeInRotationTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 |
5 | import android.view.View;
6 |
7 | public class CubeInRotationTransformation implements SliderPager.PageTransformer{
8 | @Override
9 | public void transformPage(View page, float position) {
10 |
11 | page.setCameraDistance(20000);
12 |
13 |
14 | if (position < -1){ // [-Infinity,-1)
15 | // This page is way off-screen to the left.
16 | page.setAlpha(0);
17 |
18 | }
19 | else if (position <= 0){ // [-1,0]
20 | page.setAlpha(1);
21 | page.setPivotX(page.getWidth());
22 | page.setRotationY(90*Math.abs(position));
23 |
24 | }
25 | else if (position <= 1){ // (0,1]
26 | page.setAlpha(1);
27 | page.setPivotX(0);
28 | page.setRotationY(-90*Math.abs(position));
29 |
30 | }
31 | else{ // (1,+Infinity]
32 | // This page is way off-screen to the right.
33 | page.setAlpha(0);
34 |
35 | }
36 |
37 |
38 | }
39 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/CubeInScalingTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import android.view.View;
4 |
5 | import com.smarteist.autoimageslider.SliderPager;
6 |
7 | public class CubeInScalingTransformation implements SliderPager.PageTransformer {
8 | @Override
9 | public void transformPage(View page, float position) {
10 | page.setCameraDistance(20000);
11 |
12 |
13 | if (position < -1){ // [-Infinity,-1)
14 | // This page is way off-screen to the left.
15 | page.setAlpha(0);
16 |
17 | }
18 | else if (position <= 0){ // [-1,0]
19 | page.setAlpha(1);
20 | page.setPivotX(page.getWidth());
21 | page.setRotationY(90*Math.abs(position));
22 |
23 | }
24 | else if (position <= 1){ // (0,1]
25 | page.setAlpha(1);
26 | page.setPivotX(0);
27 | page.setRotationY(-90*Math.abs(position));
28 |
29 | }
30 | else{ // (1,+Infinity]
31 | // This page is way off-screen to the right.
32 | page.setAlpha(0);
33 |
34 | }
35 |
36 |
37 |
38 | if (Math.abs(position) <= 0.5){
39 | page.setScaleY(Math.max(.4f,1-Math.abs(position)));
40 | }
41 | else if (Math.abs(position) <= 1){
42 | page.setScaleY(Math.max(.4f,Math.abs(position)));
43 |
44 | }
45 |
46 |
47 | }
48 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/CubeOutDepthTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 | import android.view.View;
5 |
6 | public class CubeOutDepthTransformation implements SliderPager.PageTransformer {
7 | @Override
8 | public void transformPage(View page, float position) {
9 |
10 | if (position < -1){ // [-Infinity,-1)
11 | // This page is way off-screen to the left.
12 | page.setAlpha(0);
13 |
14 | }
15 | else if (position <= 0) { // [-1,0]
16 | page.setAlpha(1);
17 | page.setPivotX(page.getWidth());
18 | page.setRotationY(-90 * Math.abs(position));
19 |
20 | }
21 | else if (position <= 1){ // (0,1]
22 | page.setAlpha(1);
23 | page.setPivotX(0);
24 | page.setRotationY(90 * Math.abs(position));
25 |
26 | }
27 | else { // (1,+Infinity]
28 | // This page is way off-screen to the right.
29 | page.setAlpha(0);
30 |
31 | }
32 |
33 |
34 |
35 | if (Math.abs(position) <= 0.5){
36 | page.setScaleY(Math.max(0.4f,1-Math.abs(position)));
37 | }
38 | else if (Math.abs(position) <= 1){
39 | page.setScaleY(Math.max(0.4f,1-Math.abs(position)));
40 | }
41 |
42 |
43 | }
44 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/CubeOutRotationTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 | import android.view.View;
5 |
6 | public class CubeOutRotationTransformation implements SliderPager.PageTransformer {
7 | @Override
8 | public void transformPage(View page, float position) {
9 |
10 | if (position < -1){ // [-Infinity,-1)
11 | // This page is way off-screen to the left.
12 | page.setAlpha(0);
13 |
14 | }
15 | else if (position <= 0) { // [-1,0]
16 | page.setAlpha(1);
17 | page.setPivotX(page.getWidth());
18 | page.setRotationY(-90 * Math.abs(position));
19 |
20 | }
21 | else if (position <= 1){ // (0,1]
22 | page.setAlpha(1);
23 | page.setPivotX(0);
24 | page.setRotationY(90 * Math.abs(position));
25 |
26 | }
27 | else { // (1,+Infinity]
28 | // This page is way off-screen to the right.
29 | page.setAlpha(0);
30 |
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/CubeOutScalingTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 | import android.view.View;
5 |
6 | public class CubeOutScalingTransformation implements SliderPager.PageTransformer{
7 | @Override
8 | public void transformPage(View page, float position) {
9 |
10 | if (position < -1){ // [-Infinity,-1)
11 | // This page is way off-screen to the left.
12 | page.setAlpha(0);
13 |
14 | }
15 | else if (position <= 0) { // [-1,0]
16 | page.setAlpha(1);
17 | page.setPivotX(page.getWidth());
18 | page.setRotationY(-90 * Math.abs(position));
19 |
20 | }
21 | else if (position <= 1){ // (0,1]
22 | page.setAlpha(1);
23 | page.setPivotX(0);
24 | page.setRotationY(90 * Math.abs(position));
25 |
26 | }
27 | else { // (1,+Infinity]
28 | // This page is way off-screen to the right.
29 | page.setAlpha(0);
30 |
31 | }
32 |
33 |
34 |
35 | if (Math.abs(position) <= 0.5){
36 | page.setScaleY(Math.max(0.4f,1-Math.abs(position)));
37 | }
38 | else if (Math.abs(position) <= 1){
39 | page.setScaleY(Math.max(0.4f,Math.abs(position)));
40 | }
41 |
42 |
43 | }
44 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/DepthTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 | import android.view.View;
5 |
6 | public class DepthTransformation implements SliderPager.PageTransformer{
7 | @Override
8 | public void transformPage(View page, float position) {
9 |
10 | if (position < -1){ // [-Infinity,-1)
11 | // This page is way off-screen to the left.
12 | page.setAlpha(0);
13 |
14 | }
15 | else if (position <= 0){ // [-1,0]
16 | page.setAlpha(1);
17 | page.setTranslationX(0);
18 | page.setScaleX(1);
19 | page.setScaleY(1);
20 |
21 | }
22 | else if (position <= 1){ // (0,1]
23 | page.setTranslationX(-position*page.getWidth());
24 | page.setAlpha(1-Math.abs(position));
25 | page.setScaleX(1-Math.abs(position));
26 | page.setScaleY(1-Math.abs(position));
27 |
28 | }
29 | else { // (1,+Infinity]
30 | // This page is way off-screen to the right.
31 | page.setAlpha(0);
32 |
33 | }
34 |
35 |
36 | }
37 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/FadeTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 | import android.view.View;
5 |
6 | public class FadeTransformation implements SliderPager.PageTransformer{
7 | @Override
8 | public void transformPage(View view, float position) {
9 |
10 | view.setTranslationX(-position*view.getWidth());
11 |
12 | // Page is not an immediate sibling, just make transparent
13 | if(position < -1 || position > 1) {
14 | view.setAlpha(0);
15 | }
16 | // Page is sibling to left or right
17 | else if (position <= 0 || position <= 1) {
18 |
19 | // Calculate alpha. Position is decimal in [-1,0] or [0,1]
20 | float alpha = (position <= 0) ? position + 1 : 1 - position;
21 | view.setAlpha(alpha);
22 |
23 | }
24 | // Page is active, make fully visible
25 | else if (position == 0) {
26 | view.setAlpha(1);
27 | }
28 |
29 |
30 |
31 | }
32 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/FanTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 | import android.view.View;
5 |
6 | public class FanTransformation implements SliderPager.PageTransformer{
7 | @Override
8 | public void transformPage(View page, float position) {
9 |
10 | page.setTranslationX(-position*page.getWidth());
11 | page.setPivotX(0);
12 | page.setPivotY(page.getHeight()/2);
13 | page.setCameraDistance(20000);
14 |
15 | if (position < -1){ // [-Infinity,-1)
16 | // This page is way off-screen to the left.
17 | page.setAlpha(0);
18 |
19 | }
20 | else if (position <= 0){ // [-1,0]
21 | page.setAlpha(1);
22 | page.setRotationY(-120*Math.abs(position));
23 | }
24 | else if (position <= 1){ // (0,1]
25 | page.setAlpha(1);
26 | page.setRotationY(120*Math.abs(position));
27 |
28 | }
29 | else { // (1,+Infinity]
30 | // This page is way off-screen to the right.
31 | page.setAlpha(0);
32 |
33 | }
34 |
35 |
36 | }
37 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/FidgetSpinTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 | import android.view.View;
5 |
6 | public class FidgetSpinTransformation implements SliderPager.PageTransformer {
7 | @Override
8 | public void transformPage(View page, float position) {
9 |
10 | page.setTranslationX(-position * page.getWidth());
11 |
12 | if (Math.abs(position) < 0.5) {
13 | page.setVisibility(View.VISIBLE);
14 | page.setScaleX(1 - Math.abs(position));
15 | page.setScaleY(1 - Math.abs(position));
16 | } else if (Math.abs(position) > 0.5) {
17 | page.setVisibility(View.GONE);
18 | }
19 |
20 |
21 |
22 | if (position < -1){ // [-Infinity,-1)
23 | // This page is way off-screen to the left.
24 | page.setAlpha(0);
25 |
26 | }
27 | else if (position <= 0) { // [-1,0]
28 | page.setAlpha(1);
29 | page.setRotation(36000*(Math.abs(position)*Math.abs(position)*Math.abs(position)*Math.abs(position)*Math.abs(position)*Math.abs(position)*Math.abs(position)));
30 |
31 | }else if (position <= 1){ // (0,1]
32 | page.setAlpha(1);
33 | page.setRotation(-36000 *(Math.abs(position)*Math.abs(position)*Math.abs(position)*Math.abs(position)*Math.abs(position)*Math.abs(position)*Math.abs(position)));
34 |
35 | }
36 | else { // (1,+Infinity]
37 | // This page is way off-screen to the right.
38 | page.setAlpha(0);
39 |
40 | }
41 |
42 |
43 | }
44 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/GateTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 |
5 | import android.view.View;
6 |
7 | public class GateTransformation implements SliderPager.PageTransformer{
8 |
9 | private String TAG = "GateAnimationn";
10 | @Override
11 | public void transformPage(View page, float position) {
12 |
13 | page.setTranslationX(-position*page.getWidth());
14 |
15 |
16 |
17 | if (position<-1){ // [-Infinity,-1)
18 | // This page is way off-screen to the left.
19 | page.setAlpha(0);
20 |
21 | }
22 | else if (position<=0){ // [-1,0]
23 | page.setAlpha(1);
24 | page.setPivotX(0);
25 | page.setRotationY(90*Math.abs(position));
26 |
27 | }
28 | else if (position <=1){ // (0,1]
29 | page.setAlpha(1);
30 | page.setPivotX(page.getWidth());
31 | page.setRotationY(-90*Math.abs(position));
32 |
33 | }else { // (1,+Infinity]
34 | // This page is way off-screen to the right.
35 | page.setAlpha(0);
36 |
37 | }
38 |
39 |
40 | }
41 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/HingeTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 | import android.view.View;
5 |
6 | public class HingeTransformation implements SliderPager.PageTransformer{
7 | @Override
8 | public void transformPage(View page, float position) {
9 |
10 | page.setTranslationX(-position*page.getWidth());
11 | page.setPivotX(0);
12 | page.setPivotY(0);
13 |
14 |
15 | if (position < -1){ // [-Infinity,-1)
16 | // This page is way off-screen to the left.
17 | page.setAlpha(0);
18 |
19 | }
20 | else if (position <= 0){ // [-1,0]
21 | page.setRotation(90*Math.abs(position));
22 | page.setAlpha(1-Math.abs(position));
23 |
24 | }
25 | else if (position <= 1){ // (0,1]
26 | page.setRotation(0);
27 | page.setAlpha(1);
28 |
29 | }
30 | else { // (1,+Infinity]
31 | // This page is way off-screen to the right.
32 | page.setAlpha(0);
33 |
34 | }
35 |
36 |
37 | }
38 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/HorizontalFlipTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 | import android.util.Log;
5 | import android.view.View;
6 |
7 | public class HorizontalFlipTransformation implements SliderPager.PageTransformer {
8 | @Override
9 | public void transformPage(View page, float position) {
10 |
11 | page.setTranslationX(-position*page.getWidth());
12 | page.setCameraDistance(20000);
13 |
14 | if (position < 0.5 && position > -0.5){
15 | page.setVisibility(View.VISIBLE);
16 | }
17 | else {
18 | page.setVisibility(View.INVISIBLE);
19 | }
20 |
21 |
22 |
23 | if (position < -1){ // [-Infinity,-1)
24 | // This page is way off-screen to the left.
25 | page.setAlpha(0);
26 |
27 | }
28 | else if (position <= 0 ){ // [-1,0]
29 | page.setAlpha(1);
30 | page.setRotationX(180*(1-Math.abs(position)+1));
31 | Log.e("HORIZONTAL", "position <= 0 " + (180 * (1 - Math.abs(position) + 1)));
32 |
33 | }
34 | else if (position <= 1){ // (0,1]
35 | page.setAlpha(1);
36 | page.setRotationX(-180*(1-Math.abs(position)+1));
37 | Log.e("HORIZONTAL", "position <= 1 " + (-180 * (1 - Math.abs(position) + 1)));
38 |
39 | }
40 | else { // (1,+Infinity]
41 | // This page is way off-screen to the right.
42 | page.setAlpha(0);
43 |
44 | }
45 |
46 |
47 | }
48 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/PopTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 | import android.view.View;
5 |
6 | public class PopTransformation implements SliderPager.PageTransformer {
7 | @Override
8 | public void transformPage(View page, float position) {
9 |
10 | page.setTranslationX(-position * page.getWidth());
11 |
12 | if (Math.abs(position) < 0.5) {
13 | page.setVisibility(View.VISIBLE);
14 | page.setScaleX(1 - Math.abs(position));
15 | page.setScaleY(1 - Math.abs(position));
16 | } else if (Math.abs(position) > 0.5) {
17 | page.setVisibility(View.GONE);
18 | }
19 |
20 |
21 | }
22 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/SimpleTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 | import android.view.View;
5 |
6 | public class SimpleTransformation implements SliderPager.PageTransformer {
7 | @Override
8 | public void transformPage(View page, float position) {
9 |
10 | }
11 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/SpinnerTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 | import android.view.View;
5 |
6 | public class SpinnerTransformation implements SliderPager.PageTransformer {
7 | @Override
8 | public void transformPage(View page, float position) {
9 |
10 | page.setTranslationX(-position * page.getWidth());
11 | page.setCameraDistance(12000);
12 |
13 | if (position < 0.5 && position > -0.5) {
14 | page.setVisibility(View.VISIBLE);
15 | } else {
16 | page.setVisibility(View.INVISIBLE);
17 | }
18 |
19 |
20 |
21 | if (position < -1){ // [-Infinity,-1)
22 | // This page is way off-screen to the left.
23 | page.setAlpha(0);
24 |
25 | }
26 | else if (position <= 0) { // [-1,0]
27 | page.setAlpha(1);
28 | page.setRotationY(900 *(1-Math.abs(position)+1));
29 |
30 | }
31 | else if (position <= 1) { // (0,1]
32 | page.setAlpha(1);
33 | page.setRotationY(-900 *(1-Math.abs(position)+1));
34 |
35 | }
36 | else { // (1,+Infinity]
37 | // This page is way off-screen to the right.
38 | page.setAlpha(0);
39 |
40 | }
41 |
42 |
43 | }
44 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/TossTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 | import android.view.View;
5 |
6 | public class TossTransformation implements SliderPager.PageTransformer {
7 | @Override
8 | public void transformPage(View page, float position) {
9 |
10 | page.setTranslationX(-position * page.getWidth());
11 | page.setCameraDistance(20000);
12 |
13 |
14 | if (position < 0.5 && position > -0.5) {
15 | page.setVisibility(View.VISIBLE);
16 |
17 | } else {
18 | page.setVisibility(View.INVISIBLE);
19 |
20 | }
21 |
22 |
23 | if (position < -1) { // [-Infinity,-1)
24 | // This page is way off-screen to the left.
25 | page.setAlpha(0);
26 |
27 | }
28 | else if (position <= 0) { // [-1,0]
29 | page.setAlpha(1);
30 | page.setScaleX(Math.max(0.4f, (1 - Math.abs(position))));
31 | page.setScaleY(Math.max(0.4f, (1 - Math.abs(position))));
32 | page.setRotationX(1080 * (1 - Math.abs(position) + 1));
33 | page.setTranslationY(-1000*Math.abs(position));
34 |
35 | }
36 | else if (position <= 1) { // (0,1]
37 | page.setAlpha(1);
38 | page.setScaleX(Math.max(0.4f, (1-Math.abs(position))));
39 | page.setScaleY(Math.max(0.4f, (1-Math.abs(position))));
40 | page.setRotationX(-1080 * (1 - Math.abs(position) + 1));
41 | page.setTranslationY(-1000*Math.abs(position));
42 |
43 | }
44 | else { // (1,+Infinity]
45 | // This page is way off-screen to the right.
46 | page.setAlpha(0);
47 |
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/VerticalFlipTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 | import android.view.View;
5 |
6 | public class VerticalFlipTransformation implements SliderPager.PageTransformer {
7 | @Override
8 | public void transformPage(View page, float position) {
9 |
10 | page.setTranslationX(-position * page.getWidth());
11 | page.setCameraDistance(12000);
12 |
13 | if (position < 0.5 && position > -0.5) {
14 | page.setVisibility(View.VISIBLE);
15 | } else {
16 | page.setVisibility(View.INVISIBLE);
17 | }
18 |
19 |
20 |
21 | if (position < -1){ // [-Infinity,-1)
22 | // This page is way off-screen to the left.
23 | page.setAlpha(0);
24 |
25 | }
26 | else if (position <= 0) { // [-1,0]
27 | page.setAlpha(1);
28 | page.setRotationY(180 *(1-Math.abs(position)+1));
29 |
30 | }
31 | else if (position <= 1) { // (0,1]
32 | page.setAlpha(1);
33 | page.setRotationY(-180 *(1-Math.abs(position)+1));
34 |
35 | }
36 | else { // (1,+Infinity]
37 | // This page is way off-screen to the right.
38 | page.setAlpha(0);
39 |
40 | }
41 |
42 |
43 | }
44 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/VerticalShutTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 | import android.view.View;
5 |
6 | public class VerticalShutTransformation implements SliderPager.PageTransformer{
7 | @Override
8 | public void transformPage(View page, float position) {
9 |
10 | page.setTranslationX(-position*page.getWidth());
11 | page.setCameraDistance(999999999);
12 |
13 | if (position < 0.5 && position > -0.5){
14 | page.setVisibility(View.VISIBLE);
15 | }
16 | else {
17 | page.setVisibility(View.INVISIBLE);
18 | }
19 |
20 |
21 |
22 | if (position < -1){ // [-Infinity,-1)
23 | // This page is way off-screen to the left.
24 | page.setAlpha(0);
25 |
26 | }
27 | else if (position <= 0 ){ // [-1,0]
28 | page.setAlpha(1);
29 | page.setRotationX(180*(1-Math.abs(position)+1));
30 |
31 | }
32 | else if (position <= 1){ // (0,1]
33 | page.setAlpha(1);
34 | page.setRotationX(-180*(1-Math.abs(position)+1));
35 |
36 | }
37 | else { // (1,+Infinity]
38 | // This page is way off-screen to the right.
39 | page.setAlpha(0);
40 |
41 | }
42 |
43 |
44 | }
45 | }
--------------------------------------------------------------------------------
/autoimageslider/src/main/java/com/smarteist/autoimageslider/Transformations/ZoomOutTransformation.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.autoimageslider.Transformations;
2 |
3 | import com.smarteist.autoimageslider.SliderPager;
4 | import android.view.View;
5 |
6 | public class ZoomOutTransformation implements SliderPager.PageTransformer {
7 |
8 | private static final float MIN_SCALE = 0.65f;
9 | private static final float MIN_ALPHA = 0.3f;
10 |
11 | @Override
12 | public void transformPage(View page, float position) {
13 |
14 | if (position <-1){ // [-Infinity,-1)
15 | // This page is way off-screen to the left.
16 | page.setAlpha(0);
17 |
18 | }
19 | else if (position <=1){ // [-1,1]
20 |
21 | page.setScaleX(Math.max(MIN_SCALE,1-Math.abs(position)));
22 | page.setScaleY(Math.max(MIN_SCALE,1-Math.abs(position)));
23 | page.setAlpha(Math.max(MIN_ALPHA,1-Math.abs(position)));
24 |
25 | }
26 | else { // (1,+Infinity]
27 | // This page is way off-screen to the right.
28 | page.setAlpha(0);
29 |
30 | }
31 |
32 |
33 | }
34 | }
--------------------------------------------------------------------------------
/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 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/autoimageslider/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AutoImageSlider
3 |
4 |
--------------------------------------------------------------------------------
/autoimageslider/src/test/java/com/smarteist/autoimageslider/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.smarteist.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:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 |
4 | buildscript {
5 |
6 | repositories {
7 | google()
8 | jcenter()
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:4.0.0'
12 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
13 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
14 |
15 | // NOTE: Do not place your application dependencies here; they belong
16 | // in the individual module build.gradle files
17 | }
18 | }
19 |
20 | allprojects {
21 | repositories {
22 | google()
23 | jcenter()
24 | }
25 | }
26 |
27 | task clean(type: Delete) {
28 | delete rootProject.buildDir
29 | }
30 |
--------------------------------------------------------------------------------
/gif/0.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smarteist/Android-Image-Slider/66b747be678ae1186e73e487539aa7f22f5cb9fd/gif/0.gif
--------------------------------------------------------------------------------
/gif/4.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smarteist/Android-Image-Slider/66b747be678ae1186e73e487539aa7f22f5cb9fd/gif/4.gif
--------------------------------------------------------------------------------
/gif/7.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smarteist/Android-Image-Slider/66b747be678ae1186e73e487539aa7f22f5cb9fd/gif/7.gif
--------------------------------------------------------------------------------
/gif/8.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smarteist/Android-Image-Slider/66b747be678ae1186e73e487539aa7f22f5cb9fd/gif/8.gif
--------------------------------------------------------------------------------
/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 | android.enableJetifier=true
10 | android.useAndroidX=true
11 | org.gradle.jvmargs=-Xmx1536m
12 | # When configured, Gradle will run in incubating parallel mode.
13 | # This option should only be used with decoupled projects. More details, visit
14 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
15 | # org.gradle.parallel=true
16 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smarteist/Android-Image-Slider/66b747be678ae1186e73e487539aa7f22f5cb9fd/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Jun 11 18:51:38 IRDT 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':autoimageslider'
--------------------------------------------------------------------------------