Skip to content

Commit 9e341ef

Browse files
author
Chris Banes
committed
Fix Some Lint warnings
1 parent 23713eb commit 9e341ef

File tree

5 files changed

+67
-27
lines changed

5 files changed

+67
-27
lines changed

library/src/com/handmark/pulltorefresh/library/PullToRefreshAdapterViewBase.java

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ public PullToRefreshAdapterViewBase(Context context, Mode mode, AnimationStyle a
7575
* Gets whether an indicator graphic should be displayed when the View is in
7676
* a state where a Pull-to-Refresh can happen. An example of this state is
7777
* when the Adapter View is scrolled to the top and the mode is set to
78-
* {@link Mode#PULL_FROM_START}. The default value is <var>true</var>
79-
* if {@link PullToRefreshBase#isPullToRefreshOverScrollEnabled()
78+
* {@link Mode#PULL_FROM_START}. The default value is <var>true</var> if
79+
* {@link PullToRefreshBase#isPullToRefreshOverScrollEnabled()
8080
* isPullToRefreshOverScrollEnabled()} returns false.
81-
*
81+
*
8282
* @return true if the indicators will be shown
8383
*/
8484
public boolean getShowIndicator() {
@@ -89,9 +89,8 @@ public final void onScroll(final AbsListView view, final int firstVisibleItem, f
8989
final int totalItemCount) {
9090

9191
if (DEBUG) {
92-
Log.d(LOG_TAG,
93-
"First Visible: " + firstVisibleItem + ". Visible Count: " + visibleItemCount + ". Total Items:" +
94-
totalItemCount);
92+
Log.d(LOG_TAG, "First Visible: " + firstVisibleItem + ". Visible Count: " + visibleItemCount
93+
+ ". Total Items:" + totalItemCount);
9594
}
9695

9796
// If we have a OnItemVisibleListener, do check...
@@ -132,9 +131,10 @@ public final void onScrollStateChanged(final AbsListView view, final int scrollS
132131

133132
/**
134133
* Pass-through method for {@link PullToRefreshBase#getRefreshableView()
135-
* getRefreshableView()}.{@link AdapterView#setAdapter(android.widget.Adapter)}
134+
* getRefreshableView()}.
135+
* {@link AdapterView#setAdapter(android.widget.Adapter)}
136136
* setAdapter(adapter)}. This is just for convenience!
137-
*
137+
*
138138
* @param adapter - Adapter to set
139139
*/
140140
public void setAdapter(ListAdapter adapter) {
@@ -151,7 +151,7 @@ public void setAdapter(ListAdapter adapter) {
151151
* yourself. Calling setEmptyView on the AdapterView will automatically call
152152
* this method and set everything up. This includes when the Android
153153
* Framework automatically sets the Empty View based on it's ID.
154-
*
154+
*
155155
* @param newEmptyView - Empty View to be used
156156
*/
157157
public final void setEmptyView(View newEmptyView) {
@@ -189,7 +189,7 @@ public final void setEmptyView(View newEmptyView) {
189189
* getRefreshableView()}.
190190
* {@link AdapterView#setOnItemClickListener(OnItemClickListener)
191191
* setOnItemClickListener(listener)}. This is just for convenience!
192-
*
192+
*
193193
* @param listener - OnItemClickListener to use
194194
*/
195195
public void setOnItemClickListener(OnItemClickListener listener) {
@@ -213,7 +213,7 @@ public final void setScrollEmptyView(boolean doScroll) {
213213
* a state where a Pull-to-Refresh can happen. An example of this state is
214214
* when the Adapter View is scrolled to the top and the mode is set to
215215
* {@link Mode#PULL_FROM_START}
216-
*
216+
*
217217
* @param showIndicator - true if the indicators should be shown.
218218
*/
219219
public void setShowIndicator(boolean showIndicator) {
@@ -242,6 +242,9 @@ void onPullToRefresh() {
242242
case PULL_FROM_START:
243243
mIndicatorIvTop.pullToRefresh();
244244
break;
245+
default:
246+
// NO-OP
247+
break;
245248
}
246249
}
247250
}
@@ -266,6 +269,9 @@ void onReleaseToRefresh() {
266269
case PULL_FROM_START:
267270
mIndicatorIvTop.releaseToRefresh();
268271
break;
272+
default:
273+
// NO-OP
274+
break;
269275
}
270276
}
271277
}
@@ -394,8 +400,8 @@ private boolean isLastItemVisible() {
394400
final int lastVisiblePosition = mRefreshableView.getLastVisiblePosition();
395401

396402
if (DEBUG) {
397-
Log.d(LOG_TAG, "isLastItemVisible. Last Item Position: " + lastItemPosition + " Last Visible Pos: " +
398-
lastVisiblePosition);
403+
Log.d(LOG_TAG, "isLastItemVisible. Last Item Position: " + lastItemPosition + " Last Visible Pos: "
404+
+ lastVisiblePosition);
399405
}
400406

401407
/**

library/src/com/handmark/pulltorefresh/library/PullToRefreshBase.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
import com.handmark.pulltorefresh.library.internal.FlipLoadingLayout;
3838
import com.handmark.pulltorefresh.library.internal.LoadingLayout;
3939
import com.handmark.pulltorefresh.library.internal.RotateLoadingLayout;
40-
import com.handmark.pulltorefresh.library.internal.SDK16;
4140
import com.handmark.pulltorefresh.library.internal.Utils;
41+
import com.handmark.pulltorefresh.library.internal.ViewCompat;
4242

4343
public abstract class PullToRefreshBase<T extends View> extends LinearLayout implements IPullToRefresh<T> {
4444

@@ -544,6 +544,9 @@ void onPullToRefresh() {
544544
case PULL_FROM_START:
545545
mHeaderLayout.pullToRefresh();
546546
break;
547+
default:
548+
// NO-OP
549+
break;
547550
}
548551
}
549552

@@ -594,6 +597,9 @@ void onReleaseToRefresh() {
594597
case PULL_FROM_START:
595598
mHeaderLayout.releaseToRefresh();
596599
break;
600+
default:
601+
// NO-OP
602+
break;
597603
}
598604
}
599605

@@ -1021,8 +1027,9 @@ private boolean isReadyForPull() {
10211027
return isReadyForPullEnd();
10221028
case BOTH:
10231029
return isReadyForPullEnd() || isReadyForPullStart();
1030+
default:
1031+
return false;
10241032
}
1025-
return false;
10261033
}
10271034

10281035
private void measureView(View child) {
@@ -1086,6 +1093,7 @@ private void pullEvent() {
10861093
mFooterLayout.onPull(scale);
10871094
break;
10881095
case PULL_FROM_START:
1096+
default:
10891097
mHeaderLayout.onPull(scale);
10901098
break;
10911099
}
@@ -1510,9 +1518,6 @@ int getIntValue() {
15101518
}
15111519

15121520
final class SmoothScrollRunnable implements Runnable {
1513-
1514-
static final int ANIMATION_DELAY = 10;
1515-
15161521
private final Interpolator mInterpolator;
15171522
private final int mScrollToY;
15181523
private final int mScrollFromY;
@@ -1558,11 +1563,7 @@ public void run() {
15581563

15591564
// If we're not at the target Y, keep going...
15601565
if (mContinueRunning && mScrollToY != mCurrentY) {
1561-
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
1562-
SDK16.postOnAnimation(PullToRefreshBase.this, this);
1563-
} else {
1564-
postDelayed(this, ANIMATION_DELAY);
1565-
}
1566+
ViewCompat.postOnAnimation(PullToRefreshBase.this, this);
15661567
} else {
15671568
if (null != mListener) {
15681569
mListener.onSmoothScrollFinished();

library/src/com/handmark/pulltorefresh/library/internal/FlipLoadingLayout.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*******************************************************************************/
1616
package com.handmark.pulltorefresh.library.internal;
1717

18+
import android.annotation.SuppressLint;
1819
import android.content.Context;
1920
import android.content.res.TypedArray;
2021
import android.graphics.Matrix;
@@ -29,6 +30,7 @@
2930
import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;
3031
import com.handmark.pulltorefresh.library.R;
3132

33+
@SuppressLint("ViewConstructor")
3234
public class FlipLoadingLayout extends LoadingLayout {
3335

3436
static final int FLIP_ANIMATION_DURATION = 150;
@@ -133,6 +135,9 @@ private float getDrawableRotationAngle() {
133135
angle = 270f;
134136
}
135137
break;
138+
139+
default:
140+
break;
136141
}
137142

138143
return angle;

library/src/com/handmark/pulltorefresh/library/internal/LoadingLayout.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public LoadingLayout(Context context, final Mode mode, final int scrollDirection
111111
if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderBackground)) {
112112
Drawable background = attrs.getDrawable(R.styleable.PullToRefresh_ptrHeaderBackground);
113113
if (null != background) {
114-
setBackgroundDrawable(background);
114+
ViewCompat.setBackground(this, background);
115115
}
116116
}
117117

library/src/com/handmark/pulltorefresh/library/internal/SDK16.java renamed to library/src/com/handmark/pulltorefresh/library/internal/ViewCompat.java

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,41 @@
1616
package com.handmark.pulltorefresh.library.internal;
1717

1818
import android.annotation.TargetApi;
19+
import android.graphics.drawable.Drawable;
20+
import android.os.Build.VERSION;
21+
import android.os.Build.VERSION_CODES;
1922
import android.view.View;
2023

21-
@TargetApi(16)
22-
public class SDK16 {
24+
@SuppressWarnings("deprecation")
25+
public class ViewCompat {
2326

2427
public static void postOnAnimation(View view, Runnable runnable) {
25-
view.postOnAnimation(runnable);
28+
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
29+
SDK16.postOnAnimation(view, runnable);
30+
} else {
31+
view.postDelayed(runnable, 16);
32+
}
33+
}
34+
35+
public static void setBackground(View view, Drawable background) {
36+
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
37+
SDK16.setBackground(view, background);
38+
} else {
39+
view.setBackgroundDrawable(background);
40+
}
41+
}
42+
43+
@TargetApi(16)
44+
static class SDK16 {
45+
46+
public static void postOnAnimation(View view, Runnable runnable) {
47+
view.postOnAnimation(runnable);
48+
}
49+
50+
public static void setBackground(View view, Drawable background) {
51+
view.setBackground(background);
52+
}
53+
2654
}
2755

2856
}

0 commit comments

Comments
 (0)