Fixed warnings.

Fixed warnings, by calling the right versions of the API. Added
SuppressLint, if the warning had no easy fix.
This commit is contained in:
Bennet Brunsen committed 2015-03-09 12:21:54 +01:00
1 parent 8892b1bdf5
commit 98235dcf37
5 files changed
+71 -8

No files matched your search

@@ -19,6 +19,8 @@ package com.viewpagerindicator;
import static android.graphics.Paint.ANTI_ALIAS_FLAG;
import static android.widget.LinearLayout.HORIZONTAL;
import static android.widget.LinearLayout.VERTICAL;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -26,6 +28,7 @@ import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.v4.view.MotionEventCompat;
@@ -73,6 +76,10 @@ public class CirclePageIndicator extends View implements PageIndicator {
this(context, attrs, R.attr.vpiCirclePageIndicatorStyle);
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
// Allows code which, is not part of the minSDK.
@SuppressWarnings("deprecation")
// Deprecated method will only be called if API level is below 16.
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (isInEditMode()) return;
@@ -105,7 +112,13 @@ public class CirclePageIndicator extends View implements PageIndicator {
Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
if (background != null) {
setBackgroundDrawable(background);
if (background != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
setBackground(background);
} else {
setBackgroundDrawable(background);
}
}
}
a.recycle();
@@ -279,6 +292,9 @@ public class CirclePageIndicator extends View implements PageIndicator {
canvas.drawCircle(dX, dY, mRadius, mPaintFill);
}
@SuppressLint("ClickableViewAccessibility")
// OnClick method is not overridden. This has no impact on the app.
@Override
public boolean onTouchEvent(android.view.MotionEvent ev) {
if (super.onTouchEvent(ev)) {
return true;
@@ -16,7 +16,7 @@
*/
package com.viewpagerindicator;
import static android.view.ViewGroup.LayoutParams.FILL_PARENT;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
@@ -51,7 +51,7 @@ public class IconPageIndicator extends HorizontalScrollView implements PageIndic
setHorizontalScrollBarEnabled(false);
mIconsLayout = new IcsLinearLayout(context, R.attr.vpiIconPageIndicatorStyle);
addView(mIconsLayout, new LayoutParams(WRAP_CONTENT, FILL_PARENT, Gravity.CENTER));
addView(mIconsLayout, new LayoutParams(WRAP_CONTENT, MATCH_PARENT, Gravity.CENTER));
}
private void animateToIcon(final int position) {
@@ -15,12 +15,15 @@
*/
package com.viewpagerindicator;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.v4.view.MotionEventCompat;
@@ -63,6 +66,10 @@ public class LinePageIndicator extends View implements PageIndicator {
this(context, attrs, R.attr.vpiLinePageIndicatorStyle);
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
// Allows code which, is not part of the minSDK.
@SuppressWarnings("deprecation")
// Deprecated method will only be called if API level is below 16.
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (isInEditMode()) return;
@@ -89,7 +96,13 @@ public class LinePageIndicator extends View implements PageIndicator {
Drawable background = a.getDrawable(R.styleable.LinePageIndicator_android_background);
if (background != null) {
setBackgroundDrawable(background);
if (background != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
setBackground(background);
} else {
setBackgroundDrawable(background);
}
}
}
a.recycle();
@@ -191,7 +204,9 @@ public class LinePageIndicator extends View implements PageIndicator {
}
}
public boolean onTouchEvent(android.view.MotionEvent ev) {
@SuppressLint("ClickableViewAccessibility")
// OnClick method is not overridden. This has no impact on the app.
public boolean onTouchEvent(android.view.MotionEvent ev) {
if (super.onTouchEvent(ev)) {
return true;
}
@@ -19,6 +19,8 @@ package com.viewpagerindicator;
import java.util.ArrayList;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -28,6 +30,7 @@ import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.v4.view.MotionEventCompat;
@@ -37,6 +40,7 @@ import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import com.sap.sailing.android.tracking.app.R;
@@ -158,7 +162,11 @@ public class TitlePageIndicator extends View implements PageIndicator {
this(context, attrs, R.attr.vpiTitlePageIndicatorStyle);
}
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
// Allows code which, is not part of the minSDK.
@SuppressWarnings("deprecation")
// Deprecated method will only be called if API level is below 16.
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (isInEditMode()) return;
@@ -208,7 +216,11 @@ public class TitlePageIndicator extends View implements PageIndicator {
Drawable background = a.getDrawable(R.styleable.TitlePageIndicator_android_background);
if (background != null) {
setBackgroundDrawable(background);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
setBackground(background);
} else {
setBackgroundDrawable(background);
}
}
a.recycle();
@@ -540,9 +552,14 @@ public class TitlePageIndicator extends View implements PageIndicator {
canvas.drawPath(mPath, mPaintFooterIndicator);
mPaintFooterIndicator.setAlpha(0xFF);
break;
default:
break;
}
}
@SuppressLint("ClickableViewAccessibility")
// OnClick method is not overridden. This has no impact on the app.
@Override
public boolean onTouchEvent(android.view.MotionEvent ev) {
if (super.onTouchEvent(ev)) {
return true;
@@ -15,12 +15,15 @@
*/
package com.viewpagerindicator;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.v4.view.MotionEventCompat;
@@ -80,6 +83,10 @@ public class UnderlinePageIndicator extends View implements PageIndicator {
this(context, attrs, R.attr.vpiUnderlinePageIndicatorStyle);
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
// Allows code which, is not part of the minSDK.
@SuppressWarnings("deprecation")
// Deprecated method will only be called if API level is below 16.
public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (isInEditMode()) return;
@@ -102,7 +109,13 @@ public class UnderlinePageIndicator extends View implements PageIndicator {
Drawable background = a.getDrawable(R.styleable.UnderlinePageIndicator_android_background);
if (background != null) {
setBackgroundDrawable(background);
if (background != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
setBackground(background);
} else {
setBackgroundDrawable(background);
}
}
}
a.recycle();
@@ -180,6 +193,8 @@ public class UnderlinePageIndicator extends View implements PageIndicator {
canvas.drawRect(left, top, right, bottom, mPaint);
}
@SuppressLint("ClickableViewAccessibility")
// OnClick method is not overridden. This has no impact on the app.
public boolean onTouchEvent(MotionEvent ev) {
if (super.onTouchEvent(ev)) {
return true;