Skip to content

Commit

Permalink
Merge pull request #142 from smarteist/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
smarteist authored Jun 10, 2020
2 parents 5733cfa + 434e4e2 commit ae6c20b
Show file tree
Hide file tree
Showing 26 changed files with 267 additions and 282 deletions.
22 changes: 7 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,21 @@ This is an amazing image slider for the Android .
You can easily load images with your custom layout, and there are many kinds of amazing animations you can choose.

```groovy
implementation 'com.github.smarteist:autoimageslider:1.3.7'
implementation 'com.github.smarteist:autoimageslider:1.3.8'
```
If you are using appcompat libraries use this one, but please migrate to androidx as soon as you can.
```groovy
implementation 'com.github.smarteist:autoimageslider:1.3.7-appcompat'
implementation 'com.github.smarteist:autoimageslider:1.3.8-appcompat'
```

### New Feautures
* Minor sliderView API improvements.
* Ability to disable infinite mode.
* bug in issue #130 fixed.
* Ability to disable default indicator.

### New Changes
* Auto cycle Bugs fixed.
* Sync state bugs fixed.
* Circular handle completely replaced with infinite wrapper adapter.
because of that the following interface has been replaced with new one.
```CircularSliderHandle.CurrentPageListener```
changed to => `SliderView.OnSliderPageListener`.
* The slider permanently scrolls infinitely, so the following methods have also been deleted.
`sliderView.setCircularHandlerEnabled(boolean enable)`
& its attribute in xml side:
`app:sliderCircularHandlerEnabled="boolean"`
* Auto cycle bugs fixed.
* Swiping debounce implemented.


## Demo
![](https://github.com/smarteist/android-image-slider/blob/master/gif/0.gif)
![](https://github.com/smarteist/android-image-slider/blob/master/gif/8.gif)
Expand Down
11 changes: 5 additions & 6 deletions app/src/main/java/com/smarteist/imageslider/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.smarteist.autoimageslider.IndicatorAnimations;
import com.smarteist.autoimageslider.IndicatorView.PageIndicatorView;
import com.smarteist.autoimageslider.IndicatorView.animation.type.IndicatorAnimationType;
import com.smarteist.autoimageslider.IndicatorView.draw.controller.DrawController;
import com.smarteist.autoimageslider.SliderAnimations;
import com.smarteist.autoimageslider.SliderView;
Expand All @@ -29,12 +28,12 @@ protected void onCreate(Bundle savedInstanceState) {

sliderView = findViewById(R.id.imageSlider);


adapter = new SliderAdapterExample(this);
sliderView.setSliderAdapter(adapter);

sliderView.setIndicatorAnimation(IndicatorAnimations.THIN_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!!
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!!
sliderView.setSliderTransformAnimation(SliderAnimations.SIMPLETRANSFORMATION);
sliderView.setAutoCycleDirection(SliderView.AUTO_CYCLE_DIRECTION_RIGHT);
sliderView.setAutoCycleDirection(SliderView.AUTO_CYCLE_DIRECTION_BACK_AND_FORTH);
sliderView.setIndicatorSelectedColor(Color.WHITE);
sliderView.setIndicatorUnselectedColor(Color.GRAY);
sliderView.setScrollTimeInSec(3);
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
app:sliderAnimationDuration="600"
app:sliderAutoCycleDirection="back_and_forth"
app:sliderIndicatorAnimationDuration="600"
app:sliderIndicatorEnabled="true"
app:sliderIndicatorGravity="center_horizontal|bottom"
app:sliderIndicatorMargin="15dp"
app:sliderIndicatorOrientation="horizontal"
Expand All @@ -40,21 +41,21 @@
android:orientation="vertical">

<Button
android:onClick="addNewItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="addNewItem"
android:text="Add An Item" />

<Button
android:onClick="removeLastItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="removeLastItem"
android:text="Rmove Last Item" />

<Button
android:onClick="renewItems"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="renewItems"
android:text="Renew Items" />

</LinearLayout>
Expand Down
8 changes: 4 additions & 4 deletions autoimageslider/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ext {
siteUrl = 'https://github.com/smarteist'
gitUrl = 'https://github.com/smarteist/android-image-slider.git'

libraryVersion = '1.3.7'
libraryVersion = '1.3.8'
organization = 'smarteistbintray' // if you push to organization's repository.
developerId = 'smarteist'
developerName = 'Ali Hosseini'
Expand All @@ -28,13 +28,13 @@ ext {
}

android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
minSdkVersion 15
targetSdkVersion 28
targetSdkVersion 29
versionCode 5
versionName "1.3.2"
versionName "1.3.8"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import android.view.ViewGroup;
import android.view.ViewParent;

import com.smarteist.autoimageslider.IndicatorView.animation.type.AnimationType;
import com.smarteist.autoimageslider.IndicatorView.animation.type.IndicatorAnimationType;
import com.smarteist.autoimageslider.IndicatorView.animation.type.ScaleAnimation;
import com.smarteist.autoimageslider.IndicatorView.draw.controller.DrawController;
import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
Expand Down Expand Up @@ -327,13 +327,13 @@ public long getAnimationDuration() {
}


public void setAnimationType(@Nullable AnimationType type) {
public void setAnimationType(@Nullable IndicatorAnimationType type) {
manager.onValueUpdated(null);

if (type != null) {
manager.indicator().setAnimationType(type);
} else {
manager.indicator().setAnimationType(AnimationType.NONE);
manager.indicator().setAnimationType(IndicatorAnimationType.NONE);
}
invalidate();
}
Expand Down Expand Up @@ -420,8 +420,8 @@ public void setSelection(int position) {

public void setSelected(int position) {
Indicator indicator = manager.indicator();
AnimationType animationType = indicator.getAnimationType();
indicator.setAnimationType(AnimationType.NONE);
IndicatorAnimationType animationType = indicator.getAnimationType();
indicator.setAnimationType(IndicatorAnimationType.NONE);

setSelection(position);
indicator.setAnimationType(animationType);
Expand Down Expand Up @@ -588,9 +588,9 @@ private void onPageSelect(int position) {

private void onPageScroll(int position, float positionOffset) {
Indicator indicator = manager.indicator();
AnimationType animationType = indicator.getAnimationType();
IndicatorAnimationType animationType = indicator.getAnimationType();
boolean interactiveAnimation = indicator.isInteractiveAnimation();
boolean canSelectIndicator = isViewMeasured() && interactiveAnimation && animationType != AnimationType.NONE;
boolean canSelectIndicator = isViewMeasured() && interactiveAnimation && animationType != IndicatorAnimationType.NONE;

if (!canSelectIndicator) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import androidx.annotation.NonNull;

import com.smarteist.autoimageslider.IndicatorView.animation.type.AnimationType;
import com.smarteist.autoimageslider.IndicatorView.animation.type.IndicatorAnimationType;
import com.smarteist.autoimageslider.IndicatorView.animation.type.BaseAnimation;
import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
import com.smarteist.autoimageslider.IndicatorView.draw.data.Orientation;
Expand Down Expand Up @@ -44,7 +44,7 @@ public void end() {
}

private void animate() {
AnimationType animationType = indicator.getAnimationType();
IndicatorAnimationType animationType = indicator.getAnimationType();
switch (animationType) {
case NONE:
listener.onValueUpdated(null);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.smarteist.autoimageslider.IndicatorView.animation.type;

public enum IndicatorAnimationType {NONE, COLOR, SCALE, WORM, SLIDE, FILL, THIN_WORM, DROP, SWAP, SCALE_DOWN}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import com.smarteist.autoimageslider.IndicatorView.utils.DensityUtils;
import com.smarteist.autoimageslider.IndicatorView.animation.type.*;
Expand Down Expand Up @@ -75,8 +74,8 @@ private void initAnimationAttribute(@NonNull TypedArray typedArray) {
animationDuration = 0;
}

int animIndex = typedArray.getInt(R.styleable.PageIndicatorView_piv_animationType, AnimationType.NONE.ordinal());
AnimationType animationType = getAnimationType(animIndex);
int animIndex = typedArray.getInt(R.styleable.PageIndicatorView_piv_animationType, IndicatorAnimationType.NONE.ordinal());
IndicatorAnimationType animationType = getAnimationType(animIndex);

int rtlIndex = typedArray.getInt(R.styleable.PageIndicatorView_piv_rtl_mode, RtlMode.Off.ordinal());
RtlMode rtlMode = getRtlMode(rtlIndex);
Expand Down Expand Up @@ -120,7 +119,7 @@ private void initSizeAttribute(@NonNull TypedArray typedArray) {
stroke = radius;
}

if (indicator.getAnimationType() != AnimationType.FILL) {
if (indicator.getAnimationType() != IndicatorAnimationType.FILL) {
stroke = 0;
}

Expand All @@ -131,31 +130,31 @@ private void initSizeAttribute(@NonNull TypedArray typedArray) {
indicator.setStroke(stroke);
}

private AnimationType getAnimationType(int index) {
private IndicatorAnimationType getAnimationType(int index) {
switch (index) {
case 0:
return AnimationType.NONE;
return IndicatorAnimationType.NONE;
case 1:
return AnimationType.COLOR;
return IndicatorAnimationType.COLOR;
case 2:
return AnimationType.SCALE;
return IndicatorAnimationType.SCALE;
case 3:
return AnimationType.WORM;
return IndicatorAnimationType.WORM;
case 4:
return AnimationType.SLIDE;
return IndicatorAnimationType.SLIDE;
case 5:
return AnimationType.FILL;
return IndicatorAnimationType.FILL;
case 6:
return AnimationType.THIN_WORM;
return IndicatorAnimationType.THIN_WORM;
case 7:
return AnimationType.DROP;
return IndicatorAnimationType.DROP;
case 8:
return AnimationType.SWAP;
return IndicatorAnimationType.SWAP;
case 9:
return AnimationType.SCALE_DOWN;
return IndicatorAnimationType.SCALE_DOWN;
}

return AnimationType.NONE;
return IndicatorAnimationType.NONE;
}

public static RtlMode getRtlMode(int index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import androidx.annotation.Nullable;
import android.view.MotionEvent;
import com.smarteist.autoimageslider.IndicatorView.animation.data.Value;
import com.smarteist.autoimageslider.IndicatorView.animation.type.AnimationType;
import com.smarteist.autoimageslider.IndicatorView.animation.type.IndicatorAnimationType;
import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
import com.smarteist.autoimageslider.IndicatorView.draw.drawer.Drawer;
import com.smarteist.autoimageslider.IndicatorView.utils.CoordinatesUtils;
Expand Down Expand Up @@ -91,7 +91,7 @@ private void drawIndicator(
}

private void drawWithAnimation(@NonNull Canvas canvas) {
AnimationType animationType = indicator.getAnimationType();
IndicatorAnimationType animationType = indicator.getAnimationType();
switch (animationType) {
case NONE:
drawer.drawBasic(canvas, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import androidx.annotation.NonNull;
import android.util.Pair;
import android.view.View;
import com.smarteist.autoimageslider.IndicatorView.animation.type.AnimationType;
import com.smarteist.autoimageslider.IndicatorView.animation.type.IndicatorAnimationType;
import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;
import com.smarteist.autoimageslider.IndicatorView.draw.data.Orientation;

Expand Down Expand Up @@ -52,7 +52,7 @@ public Pair<Integer, Integer> measureViewSize(@NonNull Indicator indicator, int
}
}

if (indicator.getAnimationType() == AnimationType.DROP) {
if (indicator.getAnimationType() == IndicatorAnimationType.DROP) {
if (orientation == Orientation.HORIZONTAL) {
desiredHeight *= 2;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import androidx.annotation.NonNull;
import android.view.View;
import com.smarteist.autoimageslider.IndicatorView.animation.type.AnimationType;
import com.smarteist.autoimageslider.IndicatorView.animation.type.IndicatorAnimationType;

public class Indicator {

Expand Down Expand Up @@ -43,7 +43,7 @@ public class Indicator {
private int viewPagerId = View.NO_ID;

private Orientation orientation;
private AnimationType animationType;
private IndicatorAnimationType animationType;
private RtlMode rtlMode;

public int getHeight() {
Expand Down Expand Up @@ -219,14 +219,14 @@ public void setOrientation(Orientation orientation) {
}

@NonNull
public AnimationType getAnimationType() {
public IndicatorAnimationType getAnimationType() {
if (animationType == null) {
animationType = AnimationType.NONE;
animationType = IndicatorAnimationType.NONE;
}
return animationType;
}

public void setAnimationType(AnimationType animationType) {
public void setAnimationType(IndicatorAnimationType animationType) {
this.animationType = animationType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import android.graphics.Canvas;
import android.graphics.Paint;
import androidx.annotation.NonNull;
import com.smarteist.autoimageslider.IndicatorView.animation.type.AnimationType;
import com.smarteist.autoimageslider.IndicatorView.animation.type.IndicatorAnimationType;
import com.smarteist.autoimageslider.IndicatorView.draw.data.Indicator;

public class BasicDrawer extends BaseDrawer {
Expand Down Expand Up @@ -33,12 +33,12 @@ public void draw(
int selectedColor = indicator.getSelectedColor();
int unselectedColor = indicator.getUnselectedColor();
int selectedPosition = indicator.getSelectedPosition();
AnimationType animationType = indicator.getAnimationType();
IndicatorAnimationType animationType = indicator.getAnimationType();

if (animationType == AnimationType.SCALE && !isSelectedItem) {
if (animationType == IndicatorAnimationType.SCALE && !isSelectedItem) {
radius *= scaleFactor;

} else if (animationType == AnimationType.SCALE_DOWN && isSelectedItem) {
} else if (animationType == IndicatorAnimationType.SCALE_DOWN && isSelectedItem) {
radius *= scaleFactor;
}

Expand All @@ -48,7 +48,7 @@ public void draw(
}

Paint paint;
if (animationType == AnimationType.FILL && position != selectedPosition) {
if (animationType == IndicatorAnimationType.FILL && position != selectedPosition) {
paint = strokePaint;
paint.setStrokeWidth(strokePx);
} else {
Expand Down
Loading

0 comments on commit ae6c20b

Please sign in to comment.