wind : mWinds.entrySet()) {
// We want that interval will be greater than fifth part of draggable distance
- if (Math.abs(wind.getKey() - tmp) > mHeaderHeight / RANDOM_Y_COEFFICIENT) {
+ if (Math.abs(wind.getKey() - tmp) > 1f * mHeaderHeight / RANDOM_Y_COEFFICIENT) {
y = tmp;
} else {
y = 0;
diff --git a/refresh-header/src/main/java/com/scwang/smart/refresh/header/WaterDropHeader.java b/refresh-header/src/main/java/com/scwang/smart/refresh/header/WaterDropHeader.java
index 024ea56ed..5c13017ee 100644
--- a/refresh-header/src/main/java/com/scwang/smart/refresh/header/WaterDropHeader.java
+++ b/refresh-header/src/main/java/com/scwang/smart/refresh/header/WaterDropHeader.java
@@ -5,13 +5,14 @@
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
-import android.support.annotation.ColorInt;
-import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
+import androidx.annotation.ColorInt;
+import androidx.annotation.NonNull;
+
import com.scwang.smart.drawable.ProgressDrawable;
import com.scwang.smart.refresh.header.material.MaterialProgressDrawable;
import com.scwang.smart.refresh.header.waterdrop.WaterDropView;
@@ -31,7 +32,7 @@
/**
* WaterDropHeader
* Created by scwang on 2017/5/31.
- * from https://github.com/THEONE10211024/WaterDropListView
+ * from ...
*/
public class WaterDropHeader extends SimpleComponent implements RefreshHeader {
@@ -124,7 +125,7 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
//
@Override
- protected void dispatchDraw(Canvas canvas) {
+ protected void dispatchDraw(@NonNull Canvas canvas) {
super.dispatchDraw(canvas);
final View thisView = this;
final View dropView = mWaterDropView;
diff --git a/refresh-header/src/main/java/com/scwang/smart/refresh/header/WaveSwipeHeader.java b/refresh-header/src/main/java/com/scwang/smart/refresh/header/WaveSwipeHeader.java
index 5b3694903..0d21049c3 100644
--- a/refresh-header/src/main/java/com/scwang/smart/refresh/header/WaveSwipeHeader.java
+++ b/refresh-header/src/main/java/com/scwang/smart/refresh/header/WaveSwipeHeader.java
@@ -5,10 +5,6 @@
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
-import android.support.annotation.ColorInt;
-import android.support.annotation.IdRes;
-import android.support.annotation.NonNull;
-import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.View;
@@ -16,17 +12,22 @@
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.Transformation;
-import android.widget.ImageView;
+
+import androidx.annotation.ColorInt;
+import androidx.annotation.IdRes;
+import androidx.annotation.NonNull;
+import androidx.appcompat.widget.AppCompatImageView;
+import androidx.core.content.ContextCompat;
import com.scwang.smart.refresh.header.material.MaterialProgressDrawable;
import com.scwang.smart.refresh.header.waveswipe.WaveView;
import com.scwang.smart.refresh.layout.api.RefreshHeader;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.constant.RefreshState;
-import com.scwang.smart.refresh.layout.simple.SimpleComponent;
import com.scwang.smart.refresh.layout.constant.SpinnerStyle;
+import com.scwang.smart.refresh.layout.simple.SimpleComponent;
import com.scwang.smart.refresh.layout.util.SmartUtil;
-import com.scwang.smartrefresh.header.R;
+import com.scwang.smart.refresh.header.R;
import static android.view.View.MeasureSpec.EXACTLY;
import static android.view.View.MeasureSpec.getSize;
@@ -35,7 +36,7 @@
/**
* 全屏水滴下拉头
* Created by scwang on 2017/6/4.
- * from https://github.com/recruit-lifestyle/WaveSwipeRefreshLayout
+ * from ...
*/
@SuppressWarnings("unused")
public class WaveSwipeHeader extends SimpleComponent implements RefreshHeader {
@@ -271,13 +272,10 @@ public void onReleased(@NonNull RefreshLayout layout, int height, int maxDragHei
ValueAnimator animator = ValueAnimator.ofFloat(0, 0);
animator.setDuration(500);
animator.setInterpolator(new AccelerateDecelerateInterpolator());
- animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator valueAnimator) {
- final View circleView = mCircleView;
- circleView.setTranslationY(
- mWaveView.getCurrentCircleCenterY() + circleView.getHeight() / 2.f);
- }
+ animator.addUpdateListener(valueAnimator -> {
+ final View circleView = mCircleView;
+ circleView.setTranslationY(
+ mWaveView.getCurrentCircleCenterY() + circleView.getHeight() / 2.f);
});
animator.start();
}
@@ -347,12 +345,6 @@ public void setPrimaryColors(@ColorInt int ... colors) {
}
}
}
-//
-// @NonNull
-// @Override
-// public SpinnerStyle getSpinnerStyle() {
-// return SpinnerStyle.MatchLayout;
-// }
//
//
@@ -372,7 +364,7 @@ public static boolean isOver600dp() {
*
* @author jmatsu
*/
- protected class ProgressAnimationImageView extends ImageView {
+ protected class ProgressAnimationImageView extends AppCompatImageView {
/**
* AnimationのStartとEnd時にListenerにアレする
diff --git a/refresh-header/src/main/java/com/scwang/smart/refresh/header/flyrefresh/MountainSceneView.java b/refresh-header/src/main/java/com/scwang/smart/refresh/header/flyrefresh/MountainSceneView.java
index 7c880f636..fa31fe4fa 100644
--- a/refresh-header/src/main/java/com/scwang/smart/refresh/header/flyrefresh/MountainSceneView.java
+++ b/refresh-header/src/main/java/com/scwang/smart/refresh/header/flyrefresh/MountainSceneView.java
@@ -7,19 +7,21 @@
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
-import android.support.annotation.ColorInt;
-import android.support.v4.graphics.ColorUtils;
-import android.support.v4.view.animation.PathInterpolatorCompat;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.Interpolator;
-import com.scwang.smartrefresh.header.R;
+import androidx.annotation.ColorInt;
+import androidx.annotation.NonNull;
+import androidx.core.graphics.ColorUtils;
+import androidx.core.view.animation.PathInterpolatorCompat;
+
+import com.scwang.smart.refresh.header.R;
/**
* 山丘树木场景视图
* Created by scwang on 2018/5/28.
- * from https://github.com/race604/FlyRefresh
+ * from ...
*/
@SuppressWarnings("UnnecessaryLocalVariable")
public class MountainSceneView extends View {
@@ -232,7 +234,7 @@ protected void drawTree(Canvas canvas, float scale, float baseX, float baseY,
}
@Override
- protected void onDraw(Canvas canvas) {
+ protected void onDraw(@NonNull Canvas canvas) {
super.onDraw(canvas);
final View thisView = this;
canvas.drawColor(COLOR_BACKGROUND);
diff --git a/refresh-header/src/main/java/com/scwang/smart/refresh/header/fungame/FunGameBase.java b/refresh-header/src/main/java/com/scwang/smart/refresh/header/fungame/FunGameBase.java
index 742e5003c..9c5515948 100644
--- a/refresh-header/src/main/java/com/scwang/smart/refresh/header/fungame/FunGameBase.java
+++ b/refresh-header/src/main/java/com/scwang/smart/refresh/header/fungame/FunGameBase.java
@@ -2,19 +2,20 @@
import android.annotation.SuppressLint;
import android.content.Context;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
import com.scwang.smart.refresh.layout.api.RefreshContent;
import com.scwang.smart.refresh.layout.api.RefreshHeader;
import com.scwang.smart.refresh.layout.api.RefreshKernel;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.constant.RefreshState;
-import com.scwang.smart.refresh.layout.simple.SimpleComponent;
import com.scwang.smart.refresh.layout.constant.SpinnerStyle;
+import com.scwang.smart.refresh.layout.simple.SimpleComponent;
import com.scwang.smart.refresh.layout.util.SmartUtil;
import static android.view.MotionEvent.ACTION_MASK;
@@ -206,11 +207,5 @@ public int onFinish(@NonNull RefreshLayout layout, boolean success) {
}
return 0;
}
-//
-// @NonNull
-// @Override
-// public SpinnerStyle getSpinnerStyle() {
-// return SpinnerStyle.MatchLayout;
-// }
//
}
diff --git a/refresh-header/src/main/java/com/scwang/smart/refresh/header/fungame/FunGameView.java b/refresh-header/src/main/java/com/scwang/smart/refresh/header/fungame/FunGameView.java
index 15b4cb5cc..cf8d8d1b2 100644
--- a/refresh-header/src/main/java/com/scwang/smart/refresh/header/fungame/FunGameView.java
+++ b/refresh-header/src/main/java/com/scwang/smart/refresh/header/fungame/FunGameView.java
@@ -9,9 +9,6 @@
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
-import android.support.annotation.ColorInt;
-import android.support.annotation.NonNull;
-import android.support.v4.graphics.ColorUtils;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
@@ -22,18 +19,22 @@
import android.widget.RelativeLayout;
import android.widget.TextView;
+import androidx.annotation.ColorInt;
+import androidx.annotation.NonNull;
+import androidx.core.graphics.ColorUtils;
+
import com.scwang.smart.refresh.layout.api.RefreshKernel;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.constant.RefreshState;
import com.scwang.smart.refresh.layout.util.SmartUtil;
-import com.scwang.smartrefresh.header.R;
+import com.scwang.smart.refresh.header.R;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
/**
* Created by scwang on 2018/2/29.
- * https://github.com/Hitomis/FunGameRefresh
+ * from ...
*/
@SuppressWarnings("unused")
public abstract class FunGameView extends FunGameBase {
@@ -235,7 +236,7 @@ protected TextView createMaskView(Context context, String text, int textSize, in
protected abstract void drawGame(Canvas canvas, int width, int height);
@Override
- protected void dispatchDraw(Canvas canvas) {
+ protected void dispatchDraw(@NonNull Canvas canvas) {
final View thisView = this;
final int width = thisView.getWidth();
final int height = mHeaderHeight;
@@ -392,7 +393,7 @@ public void onStateChanged(@NonNull RefreshLayout refreshLayout, @NonNull Refres
mMaskViewTop.setText(mMaskTextTopRelease);
break;
// case ReleaseToTwoLevel:
-// mMaskViewTop.setText(com.scwang.smartrefresh.layout.R.string.srl_header_secondary);
+// mMaskViewTop.setText(com.scwang.smart.refresh.layout.R.string.srl_header_secondary);
// break;
}
}
diff --git a/refresh-header/src/main/java/com/scwang/smart/refresh/header/waterdrop/WaterDropView.java b/refresh-header/src/main/java/com/scwang/smart/refresh/header/waterdrop/WaterDropView.java
index b2a89e779..6bb415eb5 100644
--- a/refresh-header/src/main/java/com/scwang/smart/refresh/header/waterdrop/WaterDropView.java
+++ b/refresh-header/src/main/java/com/scwang/smart/refresh/header/waterdrop/WaterDropView.java
@@ -6,17 +6,18 @@
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
-import android.support.annotation.ColorInt;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
-import com.scwang.smartrefresh.layout.util.SmartUtil;
+import androidx.annotation.ColorInt;
+import androidx.annotation.NonNull;
+import com.scwang.smart.refresh.layout.util.SmartUtil;
/**
* 下拉头中间的 “水滴”
* Created by scwang on 2018/6/23.
- * from https://github.com/THEONE10211024/WaterDropListView
+ * from ...
*/
@SuppressWarnings("unused")
public class WaterDropView extends View {
@@ -85,7 +86,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
}
@Override
- protected void onDraw(Canvas canvas) {
+ protected void onDraw(@NonNull Canvas canvas) {
super.onDraw(canvas);
final View thisView = this;
@@ -119,13 +120,13 @@ protected void makeBezierPath() {
float top_y1 = (float) (topCircle.y + topCircle.radius * Math.sin(angle));
float top_x2 = (float) (topCircle.x + topCircle.radius * Math.cos(angle));
- float top_y2 = top_y1;
+ float top_y2 = top_y1 * 1;
float bottom_x1 = (float) (bottomCircle.x - bottomCircle.radius * Math.cos(angle));
float bottom_y1 = (float) (bottomCircle.y + bottomCircle.radius * Math.sin(angle));
float bottom_x2 = (float) (bottomCircle.x + bottomCircle.radius * Math.cos(angle));
- float bottom_y2 = bottom_y1;
+ float bottom_y2 = bottom_y1 * 1;
mPath.moveTo(topCircle.x, topCircle.y);
@@ -165,13 +166,10 @@ protected double getAngle() {
public ValueAnimator createAnimator() {
ValueAnimator valueAnimator = ValueAnimator.ofFloat(1, 0.001f).setDuration(BACK_ANIM_DURATION);
valueAnimator.setInterpolator(new DecelerateInterpolator());
- valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator valueAnimator1) {
- WaterDropView.this.updateCompleteState((float) valueAnimator1.getAnimatedValue());
- final View thisView = WaterDropView.this;
- thisView.postInvalidate();
- }
+ valueAnimator.addUpdateListener(animator -> {
+ WaterDropView.this.updateCompleteState((float) animator.getAnimatedValue());
+ final View thisView = WaterDropView.this;
+ thisView.postInvalidate();
});
return valueAnimator;
}
diff --git a/refresh-header/src/main/java/com/scwang/smart/refresh/header/waveswipe/WaveView.java b/refresh-header/src/main/java/com/scwang/smart/refresh/header/waveswipe/WaveView.java
index 00d7163d1..c161b4bae 100644
--- a/refresh-header/src/main/java/com/scwang/smart/refresh/header/waveswipe/WaveView.java
+++ b/refresh-header/src/main/java/com/scwang/smart/refresh/header/waveswipe/WaveView.java
@@ -23,13 +23,14 @@
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
-import android.os.Build;
-import android.support.annotation.ColorInt;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.BounceInterpolator;
+import androidx.annotation.ColorInt;
+import androidx.annotation.NonNull;
+
/**
* @author amyu
*
@@ -213,14 +214,10 @@ public class WaveView extends View implements ViewTreeObserver.OnPreDrawListener
/**
* 各AnimatorのAnimatorUpdateListener
*/
- protected ValueAnimator.AnimatorUpdateListener mAnimatorUpdateListener =
- new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator valueAnimator) {
- final View thisView = WaveView.this;
- thisView.postInvalidate();
- }
- };
+ protected ValueAnimator.AnimatorUpdateListener mAnimatorUpdateListener = valueAnimator -> {
+ final View thisView = WaveView.this;
+ thisView.postInvalidate();
+ };
/**
* Constructor
@@ -278,7 +275,7 @@ public boolean onPreDraw() {
}
@Override
- protected void onDraw(Canvas canvas) {
+ protected void onDraw(@NonNull Canvas canvas) {
super.onDraw(canvas);
//引っ張ってる最中の波と終わったあとの波
// canvas.drawPath(mWavePath, mShadowPaint);
@@ -439,11 +436,7 @@ public void beginPhase(float move1) {
BEGIN_PHASE_POINTS[0][1], mWidth, 0);
final View thisView = this;
- if (Build.VERSION.SDK_INT >= 16) {
- thisView.postInvalidateOnAnimation();
- } else {
- thisView.invalidate();
- }
+ thisView.postInvalidateOnAnimation();
}
@@ -480,11 +473,7 @@ public void appearPhase(float move1, float move2) {
+ mDropCircleRadius;
final View thisView = this;
- if (Build.VERSION.SDK_INT >= 16) {
- thisView.postInvalidateOnAnimation();
- } else {
- thisView.invalidate();
- }
+ thisView.postInvalidateOnAnimation();
}
public void expandPhase(float move1, float move2, float move3) {
@@ -538,11 +527,7 @@ public void expandPhase(float move1, float move2, float move3) {
EXPAND_PHASE_POINTS[3][1]) + mDropCircleRadius;
final View thisView = this;
- if (Build.VERSION.SDK_INT >= 16) {
- thisView.postInvalidateOnAnimation();
- } else {
- thisView.invalidate();
- }
+ thisView.postInvalidateOnAnimation();
}
/**
@@ -569,17 +554,10 @@ public void startDropAnimation() {
mDropCircleAnimator = ValueAnimator.ofFloat(500 * (mWidth / 1440.f), mMaxDropHeight);
mDropCircleAnimator.setDuration(DROP_CIRCLE_ANIMATOR_DURATION);
- mDropCircleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- mCurrentCircleCenterY = (float) animation.getAnimatedValue();
- final View thisView = WaveView.this;
- if (Build.VERSION.SDK_INT >= 16) {
- thisView.postInvalidateOnAnimation();
- } else {
- thisView.invalidate();
- }
- }
+ mDropCircleAnimator.addUpdateListener(animation -> {
+ mCurrentCircleCenterY = (float) animation.getAnimatedValue();
+ final View thisView = WaveView.this;
+ thisView.postInvalidateOnAnimation();
});
mDropCircleAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
mDropCircleAnimator.start();
@@ -627,17 +605,14 @@ public void startWaveAnimation(float h) {
h = Math.min(h, MAX_WAVE_HEIGHT) * mWidth;
mWaveReverseAnimator = ValueAnimator.ofFloat(h, 0.f);
mWaveReverseAnimator.setDuration(WAVE_ANIMATOR_DURATION);
- mWaveReverseAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator valueAnimator) {
- float h = (Float) valueAnimator.getAnimatedValue();
- mWavePath.moveTo(0, 0);
- mWavePath.quadTo(0.25f * mWidth, 0, 0.333f * mWidth, h * 0.5f);
- mWavePath.quadTo(mWidth * 0.5f, h * 1.4f, 0.666f * mWidth, h * 0.5f);
- mWavePath.quadTo(0.75f * mWidth, 0, mWidth, 0);
- final View thisView = WaveView.this;
- thisView.postInvalidate();
- }
+ mWaveReverseAnimator.addUpdateListener(valueAnimator -> {
+ float h1 = (Float) valueAnimator.getAnimatedValue();
+ mWavePath.moveTo(0, 0);
+ mWavePath.quadTo(0.25f * mWidth, 0, 0.333f * mWidth, h1 * 0.5f);
+ mWavePath.quadTo(mWidth * 0.5f, h1 * 1.4f, 0.666f * mWidth, h1 * 0.5f);
+ mWavePath.quadTo(0.75f * mWidth, 0, mWidth, 0);
+ final View thisView = WaveView.this;
+ thisView.postInvalidate();
});
mWaveReverseAnimator.setInterpolator(new BounceInterpolator());
mWaveReverseAnimator.start();
diff --git a/refresh-header/src/main/java/com/scwang/smartrefresh/header/BezierCircleHeader.java b/refresh-header/src/main/java/com/scwang/smartrefresh/header/BezierCircleHeader.java
deleted file mode 100644
index dbcaefd67..000000000
--- a/refresh-header/src/main/java/com/scwang/smartrefresh/header/BezierCircleHeader.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.scwang.smartrefresh.header;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import com.scwang.smartrefresh.layout.api.RefreshHeader;
-
-/**
- * CircleRefresh
- * Created by scwang on 2018/7/18.
- * from https://github.com/tuesda/CircleRefreshLayout
- */
-public class BezierCircleHeader extends com.scwang.smart.refresh.header.BezierCircleHeader implements RefreshHeader {
-
- //
- public BezierCircleHeader(Context context) {
- this(context, null);
- }
-
- public BezierCircleHeader(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
- //
-}
\ No newline at end of file
diff --git a/refresh-header/src/main/java/com/scwang/smartrefresh/header/DeliveryHeader.java b/refresh-header/src/main/java/com/scwang/smartrefresh/header/DeliveryHeader.java
deleted file mode 100644
index a5b176421..000000000
--- a/refresh-header/src/main/java/com/scwang/smartrefresh/header/DeliveryHeader.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.scwang.smartrefresh.header;
-
-import android.content.Context;
-import android.support.annotation.Nullable;
-import android.util.AttributeSet;
-
-import com.scwang.smartrefresh.layout.api.RefreshHeader;
-
-/**
- * Refresh your delivery!
- * Created by scwang on 2017/6/25.
- * design https://dribbble.com/shots/2753803-Refresh-your-delivery
- */
-public class DeliveryHeader extends com.scwang.smart.refresh.header.DeliveryHeader implements RefreshHeader {
-
- //
- public DeliveryHeader(Context context) {
- this(context, null);
- }
-
- public DeliveryHeader(Context context, @Nullable AttributeSet attrs) {
- super(context, attrs);
- }
- //
-}
diff --git a/refresh-header/src/main/java/com/scwang/smartrefresh/header/DropBoxHeader.java b/refresh-header/src/main/java/com/scwang/smartrefresh/header/DropBoxHeader.java
deleted file mode 100644
index b705ce6c1..000000000
--- a/refresh-header/src/main/java/com/scwang/smartrefresh/header/DropBoxHeader.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.scwang.smartrefresh.header;
-
-import android.content.Context;
-import android.support.annotation.Nullable;
-import android.util.AttributeSet;
-
-import com.scwang.smartrefresh.layout.api.RefreshHeader;
-
-/**
- * DropBoxRefresh
- * Created by scwang on 2017/6/24.
- * design https://dribbble.com/shots/3470499-DropBox-Refresh
- */
-public class DropBoxHeader extends com.scwang.smart.refresh.header.DropBoxHeader implements RefreshHeader {
-
- //
- public DropBoxHeader(Context context) {
- this(context, null);
- }
-
- public DropBoxHeader(Context context, @Nullable AttributeSet attrs) {
- super(context, attrs);
- }
- //
-}
diff --git a/refresh-header/src/main/java/com/scwang/smartrefresh/header/FlyRefreshHeader.java b/refresh-header/src/main/java/com/scwang/smartrefresh/header/FlyRefreshHeader.java
deleted file mode 100644
index 713d46380..000000000
--- a/refresh-header/src/main/java/com/scwang/smartrefresh/header/FlyRefreshHeader.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.scwang.smartrefresh.header;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import com.scwang.smartrefresh.layout.api.RefreshHeader;
-
-/**
- * 纸飞机和山丘
- * Created by scwang on 2017/6/6.
- * from https://github.com/race604/FlyRefresh
- */
-public class FlyRefreshHeader extends com.scwang.smart.refresh.header.FlyRefreshHeader implements RefreshHeader {
-
- //
- public FlyRefreshHeader(Context context) {
- super(context);
- }
-
- public FlyRefreshHeader(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
- //
-}
diff --git a/refresh-header/src/main/java/com/scwang/smartrefresh/header/FunGameBattleCityHeader.java b/refresh-header/src/main/java/com/scwang/smartrefresh/header/FunGameBattleCityHeader.java
deleted file mode 100644
index 15c321e1a..000000000
--- a/refresh-header/src/main/java/com/scwang/smartrefresh/header/FunGameBattleCityHeader.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.scwang.smartrefresh.header;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import com.scwang.smartrefresh.layout.api.RefreshHeader;
-
-import java.util.Random;
-
-/**
- * Created by scwang on 2018/3/09.
- * from https://github.com/Hitomis/FunGameRefresh
- */
-public class FunGameBattleCityHeader extends com.scwang.smart.refresh.header.FunGameBattleCityHeader implements RefreshHeader {
-
- //
- public FunGameBattleCityHeader(Context context) {
- this(context, null);
- }
-
- public FunGameBattleCityHeader(Context context, AttributeSet attrs) {
- super(context, attrs);
- random = new Random();
- }
- //
-
-}
diff --git a/refresh-header/src/main/java/com/scwang/smartrefresh/header/FunGameHitBlockHeader.java b/refresh-header/src/main/java/com/scwang/smartrefresh/header/FunGameHitBlockHeader.java
deleted file mode 100644
index 60585dec7..000000000
--- a/refresh-header/src/main/java/com/scwang/smartrefresh/header/FunGameHitBlockHeader.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.scwang.smartrefresh.header;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import com.scwang.smartrefresh.layout.api.RefreshHeader;
-
-/**
- * Created by scwang on 2018/2/29.
- * from https://github.com/Hitomis/FunGameRefresh
- */
-public class FunGameHitBlockHeader extends com.scwang.smart.refresh.header.FunGameHitBlockHeader implements RefreshHeader {
-
- //
- public FunGameHitBlockHeader(Context context) {
- this(context, null);
- }
-
- public FunGameHitBlockHeader(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
- //
-
-}
diff --git a/refresh-header/src/main/java/com/scwang/smartrefresh/header/MaterialHeader.java b/refresh-header/src/main/java/com/scwang/smartrefresh/header/MaterialHeader.java
deleted file mode 100644
index 63b93fa46..000000000
--- a/refresh-header/src/main/java/com/scwang/smartrefresh/header/MaterialHeader.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.scwang.smartrefresh.header;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import com.scwang.smartrefresh.layout.api.RefreshHeader;
-
-/**
- * Material 主题下拉头
- * Created by scwang on 2017/6/2.
- */
-public class MaterialHeader extends com.scwang.smart.refresh.header.MaterialHeader implements RefreshHeader {
-
- //
- public MaterialHeader(Context context) {
- this(context, null);
- }
-
- public MaterialHeader(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
- //
-}
diff --git a/refresh-header/src/main/java/com/scwang/smartrefresh/header/PhoenixHeader.java b/refresh-header/src/main/java/com/scwang/smartrefresh/header/PhoenixHeader.java
deleted file mode 100644
index 3e03e743f..000000000
--- a/refresh-header/src/main/java/com/scwang/smartrefresh/header/PhoenixHeader.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.scwang.smartrefresh.header;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import com.scwang.smartrefresh.layout.api.RefreshHeader;
-
-/**
- * Phoenix
- * Created by scwang on 2017/5/31.
- * from https://github.com/Yalantis/Phoenix
- */
-public class PhoenixHeader extends com.scwang.smart.refresh.header.PhoenixHeader implements RefreshHeader {
-
- //
- public PhoenixHeader(Context context) {
- this(context, null);
- }
-
- public PhoenixHeader(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
- //
-
-}
-
-
diff --git a/refresh-header/src/main/java/com/scwang/smartrefresh/header/StoreHouseHeader.java b/refresh-header/src/main/java/com/scwang/smartrefresh/header/StoreHouseHeader.java
deleted file mode 100644
index 3824a9fc1..000000000
--- a/refresh-header/src/main/java/com/scwang/smartrefresh/header/StoreHouseHeader.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.scwang.smartrefresh.header;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import com.scwang.smartrefresh.layout.api.RefreshHeader;
-
-/**
- * StoreHouseHeader
- * Created by scwang on 2017/5/31.
- * from https://github.com/liaohuqiu/android-Ultra-Pull-To-Refresh
- */
-public class StoreHouseHeader extends com.scwang.smart.refresh.header.StoreHouseHeader implements RefreshHeader {
-
- //
- public StoreHouseHeader(Context context) {
- this(context, null);
- }
-
- public StoreHouseHeader(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
- //
-}
\ No newline at end of file
diff --git a/refresh-header/src/main/java/com/scwang/smartrefresh/header/TaurusHeader.java b/refresh-header/src/main/java/com/scwang/smartrefresh/header/TaurusHeader.java
deleted file mode 100644
index dd4c37d03..000000000
--- a/refresh-header/src/main/java/com/scwang/smartrefresh/header/TaurusHeader.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.scwang.smartrefresh.header;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import com.scwang.smartrefresh.layout.api.RefreshHeader;
-
-/**
- * Taurus
- * Created by scwang on 2017/5/31.
- * from https://github.com/Yalantis/Taurus
- */
-public class TaurusHeader extends com.scwang.smart.refresh.header.TaurusHeader implements RefreshHeader {
-
- //
- public TaurusHeader(Context context) {
- this(context, null);
- }
-
- public TaurusHeader(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
- //
-}
diff --git a/refresh-header/src/main/java/com/scwang/smartrefresh/header/WaterDropHeader.java b/refresh-header/src/main/java/com/scwang/smartrefresh/header/WaterDropHeader.java
deleted file mode 100644
index a3f28a6d7..000000000
--- a/refresh-header/src/main/java/com/scwang/smartrefresh/header/WaterDropHeader.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.scwang.smartrefresh.header;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import com.scwang.smartrefresh.layout.api.RefreshHeader;
-
-/**
- * WaterDropHeader
- * Created by scwang on 2017/5/31.
- * from https://github.com/THEONE10211024/WaterDropListView
- */
-public class WaterDropHeader extends com.scwang.smart.refresh.header.WaterDropHeader implements RefreshHeader {
-
- //
- public WaterDropHeader(Context context) {
- this(context, null);
- }
-
- public WaterDropHeader(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
- //
-}
\ No newline at end of file
diff --git a/refresh-header/src/main/java/com/scwang/smartrefresh/header/WaveSwipeHeader.java b/refresh-header/src/main/java/com/scwang/smartrefresh/header/WaveSwipeHeader.java
deleted file mode 100644
index 14db546ba..000000000
--- a/refresh-header/src/main/java/com/scwang/smartrefresh/header/WaveSwipeHeader.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.scwang.smartrefresh.header;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import com.scwang.smartrefresh.layout.api.RefreshHeader;
-
-/**
- * 全屏水滴下拉头
- * Created by scwang on 2017/6/4.
- * from https://github.com/recruit-lifestyle/WaveSwipeRefreshLayout
- */
-public class WaveSwipeHeader extends com.scwang.smart.refresh.header.WaveSwipeHeader implements RefreshHeader {
-
- //
- public WaveSwipeHeader(Context context) {
- this(context, null);
- }
-
- public WaveSwipeHeader(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
- //
-}
diff --git a/refresh-header/src/test/java/com/scwang/smartrefresh/header/ExampleUnitTest.java b/refresh-header/src/test/java/com/scwang/smartrefresh/header/ExampleUnitTest.java
index ccffdf534..14e752a12 100644
--- a/refresh-header/src/test/java/com/scwang/smartrefresh/header/ExampleUnitTest.java
+++ b/refresh-header/src/test/java/com/scwang/smartrefresh/header/ExampleUnitTest.java
@@ -1,4 +1,4 @@
-package com.scwang.smartrefresh.header;
+package com.scwang.smart.refresh.header;
import org.junit.Test;
@@ -6,7 +6,7 @@
import java.util.Date;
import java.util.Locale;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
/**
* Example local unit test, which will execute on the development machine (host).
@@ -15,7 +15,7 @@
*/
public class ExampleUnitTest {
@Test
- public void addition_isCorrect() throws Exception {
+ public void addition_isCorrect() {
System.out.println(new SimpleDateFormat("'Last update' M-d HH:mm", Locale.CHINA).format(new Date()));
assertEquals(4, 2 + 2);
}
diff --git a/refresh-layout-kernel/build.gradle b/refresh-layout-kernel/build.gradle
index 8ac0c4115..73ed667a1 100644
--- a/refresh-layout-kernel/build.gradle
+++ b/refresh-layout-kernel/build.gradle
@@ -4,16 +4,15 @@ description = 'the kernel of SmartRefreshLayout'
android {
- compileSdkVersion 28
+ compileSdkVersion 34
defaultConfig {
- minSdkVersion 16
- targetSdkVersion 28
+ minSdkVersion 21
+ targetSdkVersion 34
versionCode 1
- versionName "1.0"
+ versionName SMART_VERSION
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
-
}
buildTypes {
release {
@@ -28,82 +27,10 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
- androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
- exclude group: 'com.android.support', module: 'support-annotations'
- })
- testImplementation 'junit:junit:4.12'
- compileOnly 'com.android.support:design:28.0.0'
-}
+ compileOnly 'com.google.android.material:material:1.12.0'
-//apply plugin: 'maven-publish'
-//apply plugin: 'signing'
-//
-//task androidSourcesJar(type: Jar) {
-// archiveClassifier.set("sources")
-// from android.sourceSets.main.java.source
-// exclude "**/R.class"
-// exclude "**/BuildConfig.class"
-//}
-//
-//def projectName = name
-//def projectDescription = description
-//publishing {
-// publications {
-// mavenJava(MavenPublication) {
-// // group id,发布后引用的依赖的 group id
-// groupId SMART_GROUP_MVN
-// // 发布后引用的依赖的 artifact id
-// artifactId projectName
-// // 发布的版本
-// version SMART_VERSION
-// // 发布的 arr 的文件和源码文件
-// artifact("$buildDir/outputs/aar/${projectName}-release.aar")
-// artifact androidSourcesJar
-// pom {
-// // 构件名称,可以自定义
-// name = projectName
-// // 构件描述
-// description = projectDescription
-// // 构件主页
-// url = "https://github.com/scwang90/${rootProject.name}"
-// // 许可证名称和地址
-// licenses {
-// license {
-// name = 'The Apache License, Version 2.0'
-// url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
-// }
-// }
-// // 开发者信息
-// developers {
-// developer {
-// name = SMART_USER
-// email = SMART_EMAIL
-// }
-// }
-// // 版本控制仓库地址
-// scm {
-// url = "https://github.com/scwang90/${rootProject.name}"
-// connection = "scm:git:github.com/scwang90/${rootProject.name}.git"
-// developerConnection = "scm:git:ssh://git@github.com/scwang90/${rootProject.name}.git"
-// }
-// }
-// }
-// }
-// repositories {
-// maven {
-// // 发布的位置,这里根据发布的版本区分了 SNAPSHOT 和最终版本两种情况
-// def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
-// def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
-// url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
-// credentials {
-// // 这里就是之前在 issues.sonatype.org 注册的账号
-// username "${properties["sonatype.username"]}"
-// password new String(Base64.mimeDecoder.decode("${properties["sonatype.password"]}"), "UTF-8")
-// }
-// }
-// }
-//}
-//signing {
-// sign publishing.publications
-//}
\ No newline at end of file
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.2.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
+}
diff --git a/refresh-layout-kernel/src/androidTest/java/com/scwang/smart/refresh/layout/ExampleInstrumentedTest.java b/refresh-layout-kernel/src/androidTest/java/com/scwang/smart/refresh/layout/ExampleInstrumentedTest.java
index 18d5469a4..d13614571 100644
--- a/refresh-layout-kernel/src/androidTest/java/com/scwang/smart/refresh/layout/ExampleInstrumentedTest.java
+++ b/refresh-layout-kernel/src/androidTest/java/com/scwang/smart/refresh/layout/ExampleInstrumentedTest.java
@@ -1,13 +1,14 @@
package com.scwang.smart.refresh.layout;
import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.platform.app.InstrumentationRegistry;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
/**
* Instrumentation test, which will execute on an Android device.
@@ -17,10 +18,10 @@
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
- public void useAppContext() throws Exception {
+ public void useAppContext() {
// Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
- assertEquals("com.scwang.smartrefresh.layout.test", appContext.getPackageName());
+ assertEquals("com.scwang.smart.refresh.layout.test", appContext.getPackageName());
}
}
diff --git a/refresh-layout-kernel/src/main/java/com/scwang/smart/refresh/layout/SmartRefreshLayout.java b/refresh-layout-kernel/src/main/java/com/scwang/smart/refresh/layout/SmartRefreshLayout.java
index 12be6f520..35963cbac 100644
--- a/refresh-layout-kernel/src/main/java/com/scwang/smart/refresh/layout/SmartRefreshLayout.java
+++ b/refresh-layout-kernel/src/main/java/com/scwang/smart/refresh/layout/SmartRefreshLayout.java
@@ -11,16 +11,8 @@
import android.graphics.Paint;
import android.os.Handler;
import android.os.Looper;
-import android.support.annotation.ColorInt;
-import android.support.annotation.ColorRes;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v4.content.ContextCompat;
-import android.support.v4.view.NestedScrollingChildHelper;
-import android.support.v4.view.NestedScrollingParent;
-import android.support.v4.view.NestedScrollingParentHelper;
-import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.VelocityTracker;
@@ -30,7 +22,6 @@
import android.view.ViewParent;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
-import android.widget.AbsListView;
import android.widget.Scroller;
import android.widget.TextView;
import android.widget.Toast;
@@ -69,16 +60,25 @@
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static com.scwang.smart.refresh.layout.util.SmartUtil.dp2px;
import static com.scwang.smart.refresh.layout.util.SmartUtil.fling;
-import static com.scwang.smart.refresh.layout.util.SmartUtil.isContentView;
import static java.lang.System.currentTimeMillis;
+import androidx.annotation.ColorInt;
+import androidx.annotation.ColorRes;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.core.view.NestedScrollingChildHelper;
+import androidx.core.view.NestedScrollingParent;
+import androidx.core.view.NestedScrollingParentHelper;
+import androidx.core.view.ViewCompat;
+
/**
* 智能刷新布局
* Intelligent RefreshLayout
* Created by scwang on 2017/5/26.
*/
-@SuppressLint("RestrictedApi")
@SuppressWarnings({"unused"})
+@SuppressLint("RestrictedApi")
public class SmartRefreshLayout extends ViewGroup implements RefreshLayout, NestedScrollingParent/*, NestedScrollingChild*/ {
//
@@ -175,7 +175,12 @@ public class SmartRefreshLayout extends ViewGroup implements RefreshLayout, Nest
protected RefreshComponent mRefreshHeader; //下拉头部视图
protected RefreshComponent mRefreshFooter; //上拉底部视图
- protected RefreshContent mRefreshContent; //显示内容视图
+ /**
+ * 显示内容视图
+ * 根据开发设计,本变量最终不可能为空,因为在 onAttachedToWindow 中判断如果未设置内容视图
+ * 会自动创建一个 TextView 提示必须创建,并且 TextView 会变为 内容视图
+ */
+ protected RefreshContent mRefreshContent;
//
protected Paint mPaint;
@@ -209,6 +214,14 @@ public class SmartRefreshLayout extends ViewGroup implements RefreshLayout, Nest
protected boolean mFooterLocked = false;//Footer 正在loading 的时候是否锁住 列表不能向上滚动
+ /*
+ * https://github.com/scwang90/SmartRefreshLayout/issues/1540
+ * 问题修复辅助变量,记录关闭动画执行时手势事件 ACTION_DOWN 的触发时间 和 按下的坐标
+ */
+ protected long mLastTimeOnActionDown = 0;
+ protected float mLastTouchXOnActionDown = 0;
+ protected float mLastTouchYOnActionDown = 0;
+
//全局默认 Footer 构造器
protected static DefaultRefreshFooterCreator sFooterCreator = null;
//全局默认 Header 构造器
@@ -243,6 +256,11 @@ public SmartRefreshLayout(Context context, AttributeSet attrs) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SmartRefreshLayout);
+ /*
+ * SmartRefreshLayout 继承 ViewGroup 后即使不设置 android:clipToPadding,也等效于 android:clipToPadding=true
+ * 特意添加 android:clipToPadding 来在 Java 代码中 判断是否设置过,没有设置强制 setClipToPadding(false)
+ * android:clipChildren 也是同样
+ */
if (!ta.hasValue(R.styleable.SmartRefreshLayout_android_clipToPadding)) {
super.setClipToPadding(false);
}
@@ -329,16 +347,18 @@ protected void onFinishInflate() {
throw new RuntimeException("最多只支持3个子View,Most only support three sub view");
}
- int contentLevel = 0;
- int indexContent = -1;
+ int contentLevel = 0; // 当前找到内容布局的级别(0还没找到 1普通内容 2可滚动内容)
+ int indexContent = -1; // 内容布局所在的序号
for (int i = 0; i < count; i++) {
View view = super.getChildAt(i);
- if (isContentView(view) && (contentLevel < 2 || i == 1)) {
+ if (SmartUtil.isContentView(view) && (contentLevel < 2 || i == 1)) {
+ // 可滚动内容
indexContent = i;
- contentLevel = 2;
+ contentLevel = 2; // 标记为可滚动内容,不会再被替换
} else if (!(view instanceof RefreshComponent) && contentLevel < 1) {
+ // 普通内容
indexContent = i;
- contentLevel = i > 0 ? 1 : 0;
+ contentLevel = i > 0 ? 1 : 0; // 如果是第一个标记为:未找到(第一个有可能是自定义Header),否则标记为:普通内容
}
}
@@ -369,7 +389,7 @@ protected void onFinishInflate() {
}
/**
- * 重写 onAttachedToWindow 来完成 smart 的特定功能
+ * 重写 onAttachedToWindow 来完成 smart 的特定功能 (在 onFinishInflate 之后执行)
* 1.添加默认或者全局设置的 Header 和 Footer (缺省情况下才会)
* 2.做 Content 为空时的 TextView 提示
* 3.智能开启 嵌套滚动 NestedScrollingEnabled
@@ -381,6 +401,7 @@ protected void onAttachedToWindow() {
mAttachedToWindow = true;
final View thisView = this;
+ // 在非编辑模式下,如果 onFinishInflate 初始化组件未成功,onAttachedToWindow 可以进行补充处理
if (!thisView.isInEditMode()) {
if (mRefreshHeader == null) {
@@ -765,7 +786,7 @@ protected void onDetachedFromWindow() {
* @param drawingTime 绘制耗时
*/
@Override
- protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
+ protected boolean drawChild(@NonNull Canvas canvas, View child, long drawingTime) {
final View thisView = this;
final View contentView = mRefreshContent != null ? mRefreshContent.getView() : null;
if (mRefreshHeader != null && mRefreshHeader.getView() == child) {
@@ -903,6 +924,17 @@ public boolean dispatchTouchEvent(MotionEvent e) {
//---------------------------------------------------------------------------
//