44import android .annotation .SuppressLint ;
55import android .annotation .TargetApi ;
66import android .content .Context ;
7- import android .content .res .ColorStateList ;
87import android .content .res .TypedArray ;
98import android .graphics .*;
109import android .os .Build ;
11- import android .os .Handler ;
1210import android .os .Parcel ;
1311import android .os .Parcelable ;
1412import android .support .annotation .ArrayRes ;
1816import android .support .v4 .content .ContextCompat ;
1917import android .support .v4 .view .PagerAdapter ;
2018import android .support .v4 .view .ViewPager ;
21- import android .support . v7 . widget . ViewUtils ;
19+ import android .util . Log ;
2220import android .view .animation .AlphaAnimation ;
23- import android .view .animation .Animation ;
2421import android .view .animation .LinearInterpolator ;
25- import android .view .animation .RotateAnimation ;
26- import android .widget .LinearLayout ;
2722import android .util .AttributeSet ;
2823import android .util .DisplayMetrics ;
2924import android .view .MotionEvent ;
3025import android .view .View ;
31- import android .widget .TextView ;
32- import com .devmike .pagestepindicator .R ;
3326
34- import java . util . ArrayList ;
27+ import com . devmike . pagestepindicator . R ;
3528
3629
3730public class PageStepIndicator extends View {
@@ -48,6 +41,7 @@ public class PageStepIndicator extends View {
4841 public static final float DEFAULT_LINE_HEIGHT =6.0f ;
4942 public static final int DEFAULT_STROKE_ALPHA = 100 ;
5043 private static final int DEFAULT_TITLE_SIZE =14 ;
44+ private static final boolean DEFAULT_STEP_CLICK =true ;
5145
5246 private String [] titles ;
5347
@@ -88,6 +82,8 @@ public class PageStepIndicator extends View {
8882 private float [] hsvBG = new float [3 ];
8983 private float [] hsvProgress = new float [3 ];
9084
85+ private boolean pgEnableStepClick = true ;
86+
9187 private boolean clickable = true ;
9288 private boolean withViewpager ;
9389 private ViewPagerOnChangeListener viewPagerChangeListener ;
@@ -120,7 +116,7 @@ public interface OnClickListener {
120116 void onClick (int position );
121117 }
122118
123- public void setOnClickListener (OnClickListener onClickListener ) {
119+ private void setOnClickListener (OnClickListener onClickListener ) {
124120 this .onClickListener = onClickListener ;
125121 }
126122
@@ -192,6 +188,7 @@ private void initAttributes(Context context, AttributeSet attributeSet) {
192188 pageActiveTitleColor = attr .getColor (R .styleable .PageStepIndicator_pgActiveTitleColor , ContextCompat .getColor (context , DEFAULT_TEXT_COLOR ));
193189 pageTitleId = attr .getResourceId (R .styleable .PageStepIndicator_pgTitles , View .NO_ID );
194190 pageStrokeAlpha = attr .getInt (R .styleable .PageStepIndicator_pgStrokeAlpha , DEFAULT_STROKE_ALPHA );
191+ pgEnableStepClick = attr .getBoolean (R .styleable .PageStepIndicator_pgEnableStepClick , DEFAULT_STEP_CLICK );
195192
196193 } finally {
197194 attr .recycle ();
@@ -246,6 +243,10 @@ public void setRadius(int radius) {
246243 this .radius = radius ;
247244 }
248245
246+ public void setEnableStepClick (boolean enableStep ){
247+ this .pgEnableStepClick = enableStep ;
248+ }
249+
249250 public void setupWithViewPager (@ NonNull ViewPager viewPager ) {
250251 final PagerAdapter adapter = viewPager .getAdapter ();
251252 if (adapter == null ) {
@@ -500,7 +501,7 @@ public boolean onTouchEvent(MotionEvent event) {
500501 setCurrentStepPosition (i );
501502 }
502503
503- if (onClickListener != null ) {
504+ if (onClickListener != null && pgEnableStepClick ) {
504505 onClickListener .onClick (i );
505506 }
506507 }
@@ -570,6 +571,7 @@ public void onClick(int position) {
570571 disablePageChange = true ;
571572 setCurrentStepPosition (position );
572573 mViewPager .setCurrentItem (position );
574+ Log .d ("PageStepIndicator" , "___" +position );
573575 }
574576 }
575577
0 commit comments