├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── inspectionProfiles │ ├── Project_Default.xml │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── img │ ├── QQ截图20191220111630.png │ └── img.gif ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── pj │ │ └── tv │ │ ├── MainActivity.java │ │ ├── NextActivity.java │ │ ├── base │ │ └── BaseApp.java │ │ └── view │ │ ├── BreatheShadowView.java │ │ ├── RoundImageView.java │ │ └── ShimmerShadowLayout.java │ └── res │ ├── layout │ ├── activity_main.xml │ └── activity_next.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ ├── ic_launcher_round.png │ └── test.jpg │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── attrs.xml │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ShimmerShadowLayout 2 | androidTv 焦点外发光控件、闪光、圆角、边框、呼吸灯效果 3 | ![Image text](https://github.com/pj567/ShimmerShadowLayout/blob/master/app/img/img.gif) 4 | 简单说明 5 | ![Image text](https://github.com/pj567/ShimmerShadowLayout/blob/master/app/img/QQ%E6%88%AA%E5%9B%BE20191220111630.png) 6 | 7 | 使用上有什么问题还需大家多多指点,希望大家给个Star,谢谢! 8 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.3" 6 | defaultConfig { 7 | applicationId "com.pj.tv" 8 | minSdkVersion 18 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile fileTree(dir: 'libs', include: ['*.jar']) 23 | compile 'com.android.support:appcompat-v7:25.3.1' 24 | compile 'me.jessyan:autosize:1.1.2' 25 | } 26 | -------------------------------------------------------------------------------- /app/img/QQ截图20191220111630.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pj567/ShimmerShadowLayout/e8384dd0dd1f8aa3123e096ef9b88f446bdb65be/app/img/QQ截图20191220111630.png -------------------------------------------------------------------------------- /app/img/img.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pj567/ShimmerShadowLayout/e8384dd0dd1f8aa3123e096ef9b88f446bdb65be/app/img/img.gif -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 29 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/pj/tv/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.pj.tv; 2 | 3 | import android.content.Intent; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.view.View; 7 | 8 | public class MainActivity extends AppCompatActivity { 9 | @Override 10 | protected void onCreate(Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | setContentView(R.layout.activity_main); 13 | } 14 | 15 | public void jump(View view) { 16 | startActivity(new Intent(this,NextActivity.class)); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/pj/tv/NextActivity.java: -------------------------------------------------------------------------------- 1 | package com.pj.tv; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.View; 6 | 7 | public class NextActivity extends AppCompatActivity { 8 | @Override 9 | protected void onCreate(Bundle savedInstanceState) { 10 | super.onCreate(savedInstanceState); 11 | setContentView(R.layout.activity_next); 12 | } 13 | 14 | public void jump(View view) { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/pj/tv/base/BaseApp.java: -------------------------------------------------------------------------------- 1 | package com.pj.tv.base; 2 | 3 | import android.app.Application; 4 | 5 | import me.jessyan.autosize.AutoSizeConfig; 6 | import me.jessyan.autosize.unit.Subunits; 7 | 8 | 9 | /** 10 | * @author acer 11 | * @date 2018/12/18 12 | */ 13 | 14 | public class BaseApp extends Application { 15 | 16 | @Override 17 | public void onCreate() { 18 | super.onCreate(); 19 | AutoSizeConfig.getInstance().getUnitsManager().setSupportDP(false).setSupportSubunits(Subunits.PT); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/pj/tv/view/BreatheShadowView.java: -------------------------------------------------------------------------------- 1 | package com.pj.tv.view; 2 | 3 | import android.animation.Animator; 4 | import android.animation.AnimatorListenerAdapter; 5 | import android.animation.AnimatorSet; 6 | import android.animation.ObjectAnimator; 7 | import android.content.Context; 8 | import android.graphics.BlurMaskFilter; 9 | import android.graphics.Canvas; 10 | import android.graphics.Color; 11 | import android.graphics.Paint; 12 | import android.graphics.Path; 13 | import android.graphics.RectF; 14 | import android.support.annotation.Nullable; 15 | import android.util.AttributeSet; 16 | import android.util.TypedValue; 17 | import android.view.View; 18 | import android.view.animation.AccelerateDecelerateInterpolator; 19 | 20 | import static android.animation.ValueAnimator.INFINITE; 21 | import static android.animation.ValueAnimator.REVERSE; 22 | 23 | /** 24 | * user by pj567 25 | * date on 2019/12/16. 26 | */ 27 | 28 | final class BreatheShadowView extends View { 29 | private Paint mShadowPaint; 30 | private Paint mBorderPaint; 31 | private RectF mShadowRectF; 32 | private Path mPath; 33 | private float mShadowWidth = pt2px(10); 34 | private float mBorderWidth = pt2px(2); 35 | private int mBorderColor = Color.WHITE; 36 | private int mShadowColor = Color.WHITE; 37 | private int mBreatheDuration = 4000; 38 | private long mStartDelay = 400; 39 | private AnimatorSet mAnimatorSet; 40 | private boolean isBreathe = true; 41 | private boolean isShadow = true; 42 | private boolean isBorder = true; 43 | private float mTopLeftRadius; 44 | private float mTopRightRadius; 45 | private float mBottomLeftRadius; 46 | private float mBottomRightRadius; 47 | 48 | public BreatheShadowView(Context context) { 49 | this(context, null); 50 | } 51 | 52 | public BreatheShadowView(Context context, @Nullable AttributeSet attrs) { 53 | this(context, attrs, 0); 54 | } 55 | 56 | public BreatheShadowView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { 57 | super(context, attrs, defStyleAttr); 58 | init(); 59 | } 60 | 61 | private void init() { 62 | // 需禁用硬件加速 63 | setLayerType(LAYER_TYPE_SOFTWARE, null); 64 | mShadowPaint = new Paint(); 65 | mPath = new Path(); 66 | mShadowPaint.setMaskFilter(new BlurMaskFilter(mShadowWidth, BlurMaskFilter.Blur.OUTER)); 67 | mShadowPaint.setStrokeWidth(pt2px(1)); 68 | mShadowPaint.setColor(mShadowColor); 69 | 70 | mBorderPaint = new Paint(); 71 | mBorderPaint.setColor(mBorderColor); 72 | mBorderPaint.setStrokeWidth(mBorderWidth); 73 | mBorderPaint.setStyle(Paint.Style.STROKE); 74 | mBorderPaint.setMaskFilter(new BlurMaskFilter(0.5f, BlurMaskFilter.Blur.NORMAL)); 75 | setVisibility(GONE); 76 | } 77 | 78 | @Override 79 | protected void onSizeChanged(int width, int height, int oldw, int oldh) { 80 | super.onSizeChanged(width, height, oldw, oldh); 81 | mShadowRectF = new RectF(mShadowWidth, mShadowWidth, width - mShadowWidth, height - mShadowWidth); 82 | final Path path = new Path(); 83 | final float[] shadowRadius = new float[]{ 84 | mTopLeftRadius, mTopLeftRadius, 85 | mTopRightRadius, mTopRightRadius, 86 | mBottomRightRadius, mBottomRightRadius, 87 | mBottomLeftRadius, mBottomLeftRadius}; 88 | if (mTopLeftRadius != 0 || mTopRightRadius != 0 || mBottomLeftRadius != 0 || mBottomRightRadius != 0) { 89 | path.addRoundRect(mShadowRectF, shadowRadius, Path.Direction.CW); 90 | } else { 91 | path.addRoundRect(mShadowRectF, 0, 0, Path.Direction.CW); 92 | } 93 | mPath = path; 94 | } 95 | 96 | @Override 97 | protected void onDraw(Canvas canvas) { 98 | super.onDraw(canvas); 99 | if (mShadowRectF == null) { 100 | return; 101 | } 102 | if (isShadow) { 103 | canvas.save(); 104 | canvas.drawPath(mPath, mShadowPaint); 105 | canvas.restore(); 106 | } 107 | if (isBorder) { 108 | canvas.save(); 109 | canvas.drawPath(mPath, mBorderPaint); 110 | canvas.restore(); 111 | } 112 | } 113 | 114 | private void createAnimatorSet() { 115 | mAnimatorSet = new AnimatorSet(); 116 | mAnimatorSet.playSequentially(getAlphaAnimator()); 117 | } 118 | 119 | private ObjectAnimator getAlphaAnimator() { 120 | ObjectAnimator alphaAnimator; 121 | alphaAnimator = ObjectAnimator.ofFloat(this, "alpha", 1f, 0.2f, 1f); 122 | alphaAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); 123 | alphaAnimator.setDuration(mBreatheDuration); 124 | alphaAnimator.setRepeatMode(REVERSE); 125 | alphaAnimator.setRepeatCount(INFINITE); 126 | alphaAnimator.setStartDelay(mStartDelay); 127 | alphaAnimator.addListener(new AnimatorListenerAdapter() { 128 | @Override 129 | public void onAnimationCancel(Animator animation) { 130 | super.onAnimationCancel(animation); 131 | setAlpha(1f); 132 | } 133 | }); 134 | return alphaAnimator; 135 | } 136 | 137 | public void start() { 138 | setVisibility(VISIBLE); 139 | if (isBreathe) { 140 | if (null != mAnimatorSet) { 141 | mAnimatorSet.cancel(); 142 | } 143 | createAnimatorSet(); 144 | mAnimatorSet.start(); 145 | } else { 146 | setAlpha(1f); 147 | } 148 | } 149 | 150 | public void stop() { 151 | setVisibility(GONE); 152 | if (isBreathe) { 153 | if (null != mAnimatorSet) { 154 | mAnimatorSet.cancel(); 155 | } 156 | } 157 | } 158 | 159 | public void setStartDelay(long mStartDelay) { 160 | this.mStartDelay = mStartDelay; 161 | } 162 | 163 | public void setShadowWidth(float mShadowWidth) { 164 | if (this.mShadowWidth != mShadowWidth) { 165 | this.mShadowWidth = mShadowWidth; 166 | if (mShadowPaint != null) { 167 | mShadowPaint.setMaskFilter(new BlurMaskFilter(mShadowWidth == 0 ? 0.1f : mShadowWidth, BlurMaskFilter.Blur.OUTER)); 168 | } 169 | } 170 | } 171 | 172 | public void setBorderWidth(float mBorderWidth) { 173 | this.mBorderWidth = mBorderWidth; 174 | if (mBorderPaint != null) { 175 | mBorderPaint.setStrokeWidth(mBorderWidth); 176 | } 177 | } 178 | 179 | public void setTopLeftRadius(float mTopLeftRadius) { 180 | this.mTopLeftRadius = mTopLeftRadius; 181 | } 182 | 183 | public void setTopRightRadius(float mTopRightRadius) { 184 | this.mTopRightRadius = mTopRightRadius; 185 | } 186 | 187 | public void setBottomLeftRadius(float mBottomLeftRadius) { 188 | this.mBottomLeftRadius = mBottomLeftRadius; 189 | } 190 | 191 | public void setBottomRightRadius(float mBottomRightRadius) { 192 | this.mBottomRightRadius = mBottomRightRadius; 193 | } 194 | 195 | 196 | public void setShadow(boolean shadow) { 197 | isShadow = shadow; 198 | } 199 | 200 | public void setBorder(boolean border) { 201 | isBorder = border; 202 | } 203 | 204 | public void setShadowColor(int mShadowColor) { 205 | this.mShadowColor = mShadowColor; 206 | if (mShadowPaint != null) { 207 | mShadowPaint.setColor(mShadowColor); 208 | } 209 | } 210 | 211 | public void setBorderColor(int mBorderColor) { 212 | this.mBorderColor = mBorderColor; 213 | if (mBorderPaint != null) { 214 | mBorderPaint.setColor(mBorderColor); 215 | } 216 | } 217 | 218 | public void setBreatheDuration(int mBreatheDuration) { 219 | this.mBreatheDuration = mBreatheDuration; 220 | } 221 | 222 | public void setBreathe(boolean breathe) { 223 | isBreathe = breathe; 224 | } 225 | 226 | private float pt2px(float value) { 227 | return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PT, value, getResources().getDisplayMetrics()) + 0.5f; 228 | } 229 | } 230 | -------------------------------------------------------------------------------- /app/src/main/java/com/pj/tv/view/RoundImageView.java: -------------------------------------------------------------------------------- 1 | package com.pj.tv.view; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.graphics.Path; 8 | import android.graphics.PorterDuff; 9 | import android.graphics.PorterDuffXfermode; 10 | import android.graphics.RectF; 11 | import android.os.Build; 12 | import android.util.AttributeSet; 13 | import android.widget.ImageView; 14 | 15 | import com.pj.tv.R; 16 | 17 | import static android.graphics.Canvas.ALL_SAVE_FLAG; 18 | 19 | /** 20 | * user by pj567 21 | * date on 2019/12/19. 22 | */ 23 | 24 | public class RoundImageView extends ImageView { 25 | private float mTopLeftRadius; 26 | private float mTopRightRadius; 27 | private float mBottomLeftRadius; 28 | private float mBottomRightRadius; 29 | 30 | private boolean mIsDrawRound; 31 | private Path mRoundPath; 32 | private Paint mRoundPaint; 33 | private RectF mRoundRectF; 34 | 35 | private boolean mIsDrawn; 36 | 37 | public RoundImageView(Context context) { 38 | this(context, null); 39 | } 40 | 41 | public RoundImageView(Context context, AttributeSet attrs) { 42 | this(context, attrs, 0); 43 | } 44 | 45 | public RoundImageView(Context context, AttributeSet attrs, int defStyle) { 46 | super(context, attrs, defStyle); 47 | if (attrs != null) { 48 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RoundImageView); 49 | float radius = a.getDimension(R.styleable.RoundImageView_radius, 0); 50 | mTopLeftRadius = a.getDimension(R.styleable.RoundImageView_topLeftRadius, radius); 51 | mTopRightRadius = a.getDimension(R.styleable.RoundImageView_topRightRadius, radius); 52 | mBottomLeftRadius = a.getDimension(R.styleable.RoundImageView_bottomLeftRadius, radius); 53 | mBottomRightRadius = a.getDimension(R.styleable.RoundImageView_bottomRightRadius, radius); 54 | a.recycle(); 55 | } 56 | mIsDrawRound = mTopLeftRadius != 0 || mTopRightRadius != 0 || mBottomLeftRadius != 0 || mBottomRightRadius != 0; 57 | 58 | mRoundPaint = new Paint(); 59 | mRoundPaint.setAntiAlias(true); 60 | // 取两层绘制交集。显示下层。 61 | mRoundPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN)); 62 | 63 | } 64 | 65 | @Override 66 | public boolean isInEditMode() { 67 | return true; 68 | } 69 | 70 | @Override 71 | protected void onSizeChanged(int width, int height, int oldw, int oldh) { 72 | super.onSizeChanged(width, height, oldw, oldh); 73 | if ((width != oldw || height != oldh) && mIsDrawRound) { 74 | final Path path = new Path(); 75 | mRoundRectF = new RectF(getPaddingLeft(), getPaddingTop(), width - getPaddingRight(), height - getPaddingBottom()); 76 | final float[] radius = new float[]{ 77 | mTopLeftRadius, mTopLeftRadius, 78 | mTopRightRadius, mTopRightRadius, 79 | mBottomRightRadius, mBottomRightRadius, 80 | mBottomLeftRadius, mBottomLeftRadius}; 81 | path.addRoundRect(mRoundRectF, radius, Path.Direction.CW); 82 | mRoundPath = path; 83 | } 84 | } 85 | 86 | @Override 87 | public void draw(Canvas canvas) { 88 | if (!mIsDrawRound) { 89 | super.draw(canvas); 90 | } else { 91 | mIsDrawn = true; 92 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 93 | canvas.saveLayer(mRoundRectF, null); 94 | } else { 95 | canvas.saveLayer(mRoundRectF, null, ALL_SAVE_FLAG); 96 | } 97 | super.draw(canvas); 98 | canvas.drawPath(mRoundPath, mRoundPaint); 99 | canvas.restore(); 100 | } 101 | } 102 | 103 | @Override 104 | protected void dispatchDraw(Canvas canvas) { 105 | if (mIsDrawn || !mIsDrawRound) { 106 | super.dispatchDraw(canvas); 107 | } else { 108 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 109 | canvas.saveLayer(mRoundRectF, null); 110 | } else { 111 | canvas.saveLayer(mRoundRectF, null, ALL_SAVE_FLAG); 112 | } 113 | super.dispatchDraw(canvas); 114 | canvas.drawPath(mRoundPath, mRoundPaint); 115 | canvas.restore(); 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /app/src/main/java/com/pj/tv/view/ShimmerShadowLayout.java: -------------------------------------------------------------------------------- 1 | package com.pj.tv.view; 2 | 3 | import android.animation.Animator; 4 | import android.animation.AnimatorListenerAdapter; 5 | import android.animation.AnimatorSet; 6 | import android.animation.ObjectAnimator; 7 | import android.content.Context; 8 | import android.content.res.TypedArray; 9 | import android.graphics.Canvas; 10 | import android.graphics.Color; 11 | import android.graphics.LinearGradient; 12 | import android.graphics.Matrix; 13 | import android.graphics.Paint; 14 | import android.graphics.Path; 15 | import android.graphics.RectF; 16 | import android.graphics.Shader; 17 | import android.os.Build; 18 | import android.support.v4.view.ViewCompat; 19 | import android.util.AttributeSet; 20 | import android.util.TypedValue; 21 | import android.view.View; 22 | import android.view.ViewTreeObserver; 23 | import android.view.animation.BounceInterpolator; 24 | import android.view.animation.DecelerateInterpolator; 25 | import android.widget.FrameLayout; 26 | 27 | import com.pj.tv.R; 28 | 29 | import java.util.ArrayList; 30 | import java.util.List; 31 | 32 | import static android.graphics.Canvas.ALL_SAVE_FLAG; 33 | 34 | /** 35 | * 结合compile 'me.jessyan:autosize:1.1.2'适配使用 36 | * 37 | * @author acer 38 | */ 39 | public class ShimmerShadowLayout extends FrameLayout implements View.OnFocusChangeListener { 40 | protected long mAnimDuration = 300; 41 | protected long mShimmerDelay = mAnimDuration + 100; 42 | private int mShimmerColor = 0x66FFFFFF; 43 | private boolean mIsShimmerAnim = true; 44 | private boolean mIsBounceInterpolator = true; 45 | private boolean mBringToFront = true; 46 | private boolean mIsParent = false; 47 | private float mScale = 1.05f; 48 | private LinearGradient mShimmerLinearGradient; 49 | private Matrix mShimmerGradientMatrix; 50 | private Paint mShimmerPaint; 51 | private Path mShimmerPath; 52 | protected RectF mFrameRectF; 53 | private float mShimmerTranslate = 0; 54 | private boolean mShimmerAnimating = false; 55 | private ViewTreeObserver.OnPreDrawListener startAnimationPreDrawListener; 56 | private AnimatorSet mAnimatorSet; 57 | private BreatheShadowView shadowView; 58 | private float mRadius = 0; 59 | private float mShadowWidth = pt2px(10); 60 | private float mBorderWidth = pt2px(10); 61 | private int mBorderColor = Color.WHITE; 62 | private int mShadowColor = Color.WHITE; 63 | private int mBreatheDuration = 4000; 64 | private boolean mIsBreathe = true; 65 | private boolean mIsShadow = true; 66 | private boolean mIsBorder = false; 67 | 68 | private float mTopLeftRadius; 69 | private float mTopRightRadius; 70 | private float mBottomLeftRadius; 71 | private float mBottomRightRadius; 72 | 73 | private boolean mIsDrawRound; 74 | private RectF mRefreshRectF; 75 | 76 | private boolean mIsDrawn; 77 | 78 | public ShimmerShadowLayout(Context context) { 79 | this(context, null); 80 | } 81 | 82 | public ShimmerShadowLayout(Context context, AttributeSet attrs) { 83 | this(context, attrs, 0); 84 | } 85 | 86 | public ShimmerShadowLayout(Context context, AttributeSet attrs, int defStyleAttr) { 87 | super(context, attrs, defStyleAttr); 88 | init(context, attrs); 89 | } 90 | 91 | private void init(Context context, AttributeSet attrs) { 92 | setWillNotDraw(false); 93 | TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ShimmerShadowLayout, 0, 0); 94 | try { 95 | mAnimDuration = a.getInteger(R.styleable.ShimmerShadowLayout_mAnimDuration, 300); 96 | mShimmerColor = a.getColor(R.styleable.ShimmerShadowLayout_mShimmerColor, 0x66FFFFFF); 97 | mIsShimmerAnim = a.getBoolean(R.styleable.ShimmerShadowLayout_mIsShimmerAnim, true); 98 | mBringToFront = a.getBoolean(R.styleable.ShimmerShadowLayout_mBringToFront, false); 99 | mIsBounceInterpolator = a.getBoolean(R.styleable.ShimmerShadowLayout_mIsBounceInterpolator, true); 100 | mIsParent = a.getBoolean(R.styleable.ShimmerShadowLayout_mIsParent, false); 101 | mScale = a.getFloat(R.styleable.ShimmerShadowLayout_mScale, 1.05f); 102 | mShimmerDelay = mAnimDuration + 100; 103 | 104 | mShadowWidth = a.getDimension(R.styleable.ShimmerShadowLayout_mShadowWidth, pt2px(10)); 105 | mBorderWidth = a.getDimension(R.styleable.ShimmerShadowLayout_mBorderWidth, pt2px(2)); 106 | mShadowColor = a.getColor(R.styleable.ShimmerShadowLayout_mShadowColor, Color.WHITE); 107 | mBorderColor = a.getColor(R.styleable.ShimmerShadowLayout_mBorderColor, Color.WHITE); 108 | mBreatheDuration = a.getInteger(R.styleable.ShimmerShadowLayout_mBreatheDuration, 4000); 109 | mIsBreathe = a.getBoolean(R.styleable.ShimmerShadowLayout_mIsBreathe, true); 110 | mIsShadow = a.getBoolean(R.styleable.ShimmerShadowLayout_mIsShadow, true); 111 | mIsBorder = a.getBoolean(R.styleable.ShimmerShadowLayout_mIsBorder, true); 112 | 113 | mRadius = a.getDimension(R.styleable.ShimmerShadowLayout_mRadius, 0); 114 | mTopLeftRadius = a.getDimension(R.styleable.ShimmerShadowLayout_mTopLeftRadius, mRadius); 115 | mTopRightRadius = a.getDimension(R.styleable.ShimmerShadowLayout_mTopRightRadius, mRadius); 116 | mBottomLeftRadius = a.getDimension(R.styleable.ShimmerShadowLayout_mBottomLeftRadius, mRadius); 117 | mBottomRightRadius = a.getDimension(R.styleable.ShimmerShadowLayout_mBottomRightRadius, mRadius); 118 | } finally { 119 | a.recycle(); 120 | } 121 | if (!mIsParent) { 122 | setOnFocusChangeListener(this); 123 | } 124 | //关闭硬件加速 125 | // setLayerType(View.LAYER_TYPE_SOFTWARE, null); 126 | mShimmerPaint = new Paint(); 127 | mShimmerPath = new Path(); 128 | mShimmerGradientMatrix = new Matrix(); 129 | mFrameRectF = new RectF(); 130 | mIsDrawRound = mTopLeftRadius != 0 || mTopRightRadius != 0 || mBottomLeftRadius != 0 || mBottomRightRadius != 0; 131 | 132 | } 133 | 134 | @Override 135 | public boolean isInEditMode() { 136 | return true; 137 | } 138 | 139 | @Override 140 | protected void onSizeChanged(int width, int height, int oldw, int oldh) { 141 | super.onSizeChanged(width, height, oldw, oldh); 142 | if (shadowView == null) { 143 | shadowView = new BreatheShadowView(getContext()); 144 | shadowView.setShadowWidth(mShadowWidth); 145 | shadowView.setBorderWidth(mBorderWidth); 146 | shadowView.setShadowColor(mShadowColor); 147 | shadowView.setBorderColor(mBorderColor); 148 | shadowView.setBreatheDuration(mBreatheDuration); 149 | shadowView.setBreathe(mIsBreathe); 150 | shadowView.setBorder(mIsBorder); 151 | shadowView.setShadow(mIsShadow); 152 | shadowView.setStartDelay(mShimmerDelay); 153 | shadowView.setTopLeftRadius(mTopLeftRadius); 154 | shadowView.setTopRightRadius(mTopRightRadius); 155 | shadowView.setBottomLeftRadius(mBottomLeftRadius); 156 | shadowView.setBottomRightRadius(mBottomRightRadius); 157 | LayoutParams layoutParams = new LayoutParams(width, height); 158 | addView(shadowView, layoutParams); 159 | } 160 | mFrameRectF.set(getPaddingLeft() + mShadowWidth + mBorderWidth / 2, getPaddingTop() + mShadowWidth + mBorderWidth / 2, 161 | width - getPaddingRight() - mShadowWidth - mBorderWidth / 2, height - getPaddingBottom() - mShadowWidth - mBorderWidth / 2); 162 | Path path = new Path(); 163 | final float[] shimmerRadius = new float[]{ 164 | mTopLeftRadius, mTopLeftRadius, 165 | mTopRightRadius, mTopRightRadius, 166 | mBottomRightRadius, mBottomRightRadius, 167 | mBottomLeftRadius, mBottomLeftRadius}; 168 | if (mTopLeftRadius != 0 || mTopRightRadius != 0 || mBottomLeftRadius != 0 || mBottomRightRadius != 0) { 169 | path.addRoundRect(mFrameRectF, shimmerRadius, Path.Direction.CW); 170 | } else { 171 | path.addRoundRect(mFrameRectF, 0, 0, Path.Direction.CW); 172 | } 173 | mShimmerPath = path; 174 | if ((height != oldw || height != oldh) && mIsDrawRound) { 175 | mRefreshRectF = new RectF(getPaddingLeft(), getPaddingTop(), width - getPaddingRight(), height - getPaddingBottom()); 176 | } 177 | } 178 | 179 | @Override 180 | protected void dispatchDraw(Canvas canvas) { 181 | if (mIsDrawn || !mIsDrawRound) { 182 | super.dispatchDraw(canvas); 183 | } else { 184 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 185 | canvas.saveLayer(mRefreshRectF, null); 186 | } else { 187 | canvas.saveLayer(mRefreshRectF, null, ALL_SAVE_FLAG); 188 | } 189 | super.dispatchDraw(canvas); 190 | canvas.restore(); 191 | } 192 | onDrawShimmer(canvas); 193 | } 194 | 195 | @Override 196 | public void draw(Canvas canvas) { 197 | if (!mIsDrawRound) { 198 | super.draw(canvas); 199 | } else { 200 | mIsDrawn = true; 201 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 202 | canvas.saveLayer(mRefreshRectF, null); 203 | } else { 204 | canvas.saveLayer(mRefreshRectF, null, ALL_SAVE_FLAG); 205 | } 206 | super.draw(canvas); 207 | canvas.restore(); 208 | } 209 | } 210 | 211 | @Override 212 | protected void onDetachedFromWindow() { 213 | stopAnimation(); 214 | super.onDetachedFromWindow(); 215 | } 216 | 217 | /** 218 | * 绘制闪光 219 | * 220 | * @param canvas 221 | */ 222 | protected void onDrawShimmer(Canvas canvas) { 223 | if (mShimmerAnimating) { 224 | canvas.save(); 225 | float shimmerTranslateX = mFrameRectF.width() * mShimmerTranslate; 226 | float shimmerTranslateY = mFrameRectF.height() * mShimmerTranslate; 227 | mShimmerGradientMatrix.setTranslate(shimmerTranslateX, shimmerTranslateY); 228 | mShimmerLinearGradient.setLocalMatrix(mShimmerGradientMatrix); 229 | canvas.drawPath(mShimmerPath, mShimmerPaint); 230 | canvas.restore(); 231 | } 232 | } 233 | 234 | private void setShimmerAnimating(boolean shimmerAnimating) { 235 | mShimmerAnimating = shimmerAnimating; 236 | if (mShimmerAnimating) { 237 | mShimmerLinearGradient = new LinearGradient( 238 | 0, 0, mFrameRectF.width(), mFrameRectF.height(), 239 | new int[]{0x00FFFFFF, reduceColorAlphaValueToZero(mShimmerColor), mShimmerColor, reduceColorAlphaValueToZero(mShimmerColor), 0x00FFFFFF}, 240 | new float[]{0f, 0.2f, 0.5f, 0.8f, 1f}, Shader.TileMode.CLAMP); 241 | mShimmerPaint.setShader(mShimmerLinearGradient); 242 | } 243 | } 244 | 245 | private int reduceColorAlphaValueToZero(int actualColor) { 246 | return Color.argb(0x1A, Color.red(actualColor), Color.green(actualColor), Color.blue(actualColor)); 247 | } 248 | 249 | public void startAnimation() { 250 | if (getWidth() == 0) { 251 | startAnimationPreDrawListener = new ViewTreeObserver.OnPreDrawListener() { 252 | @Override 253 | public boolean onPreDraw() { 254 | getViewTreeObserver().removeOnPreDrawListener(this); 255 | startAnimation(); 256 | return true; 257 | } 258 | }; 259 | getViewTreeObserver().addOnPreDrawListener(startAnimationPreDrawListener); 260 | return; 261 | } 262 | if (null != mAnimatorSet) { 263 | mAnimatorSet.cancel(); 264 | } 265 | if (shadowView != null) { 266 | shadowView.start(); 267 | } 268 | createAnimatorSet(true); 269 | mAnimatorSet.start(); 270 | setSelected(true); 271 | } 272 | 273 | public void stopAnimation() { 274 | if (startAnimationPreDrawListener != null) { 275 | getViewTreeObserver().removeOnPreDrawListener(startAnimationPreDrawListener); 276 | } 277 | if (null != mAnimatorSet) { 278 | mAnimatorSet.cancel(); 279 | } 280 | createAnimatorSet(false); 281 | if (shadowView != null) { 282 | shadowView.stop(); 283 | } 284 | mAnimatorSet.start(); 285 | setSelected(false); 286 | } 287 | 288 | private void createAnimatorSet(boolean isStart) { 289 | final List together = new ArrayList<>(); 290 | if (isStart) { 291 | together.add(getScaleXAnimator(mScale)); 292 | together.add(getScaleYAnimator(mScale)); 293 | } else { 294 | together.add(getScaleXAnimator(1.0f)); 295 | together.add(getScaleYAnimator(1.0f)); 296 | } 297 | final List sequentially = new ArrayList<>(); 298 | if (mIsShimmerAnim && isStart) { 299 | sequentially.add(getShimmerAnimator()); 300 | } 301 | mAnimatorSet = new AnimatorSet(); 302 | mAnimatorSet.playTogether(together); 303 | mAnimatorSet.playSequentially(sequentially); 304 | } 305 | 306 | private ObjectAnimator getScaleXAnimator(float scale) { 307 | ObjectAnimator scaleXObjectAnimator = ObjectAnimator.ofFloat(this, "scaleX", scale).setDuration(mAnimDuration); 308 | if (mIsBounceInterpolator) { 309 | scaleXObjectAnimator.setInterpolator(new BounceInterpolator()); 310 | } 311 | return scaleXObjectAnimator; 312 | } 313 | 314 | private ObjectAnimator getScaleYAnimator(float scale) { 315 | ObjectAnimator scaleYObjectAnimator = ObjectAnimator.ofFloat(this, "scaleY", scale).setDuration(mAnimDuration); 316 | if (mIsBounceInterpolator) { 317 | scaleYObjectAnimator.setInterpolator(new BounceInterpolator()); 318 | } 319 | return scaleYObjectAnimator; 320 | } 321 | 322 | private ObjectAnimator getShimmerAnimator() { 323 | ObjectAnimator mShimmerAnimator = ObjectAnimator.ofFloat(this, "shimmerTranslate", -1f, 1f); 324 | mShimmerAnimator.setInterpolator(new DecelerateInterpolator(1)); 325 | int screenWidth = getResources().getDisplayMetrics().widthPixels; 326 | int max = getWidth() >= getHeight() ? getWidth() : getHeight(); 327 | int duration = max > screenWidth / 3 ? screenWidth / 3 : max; 328 | mShimmerAnimator.setDuration(duration * 3); 329 | mShimmerAnimator.setStartDelay(mShimmerDelay); 330 | mShimmerAnimator.addListener(new AnimatorListenerAdapter() { 331 | @Override 332 | public void onAnimationStart(Animator animation) { 333 | setShimmerAnimating(true); 334 | } 335 | 336 | @Override 337 | public void onAnimationEnd(Animator animation) { 338 | setShimmerAnimating(false); 339 | } 340 | }); 341 | return mShimmerAnimator; 342 | } 343 | 344 | 345 | protected void setShimmerTranslate(float shimmerTranslate) { 346 | if (mIsShimmerAnim && mShimmerTranslate != shimmerTranslate) { 347 | mShimmerTranslate = shimmerTranslate; 348 | ViewCompat.postInvalidateOnAnimation(this); 349 | } 350 | } 351 | 352 | protected float getShimmerTranslate() { 353 | return mShimmerTranslate; 354 | } 355 | 356 | @Override 357 | public void onFocusChange(View v, boolean hasFocus) { 358 | if (hasFocus) { 359 | if (mBringToFront) { 360 | v.bringToFront(); 361 | } 362 | v.setSelected(true); 363 | startAnimation(); 364 | } else { 365 | v.setSelected(false); 366 | stopAnimation(); 367 | } 368 | } 369 | 370 | private float pt2px(float value) { 371 | return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PT, value, getResources().getDisplayMetrics()) + 0.5f; 372 | } 373 | } 374 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 16 | 17 | 26 | 27 | 33 | 34 | 35 | 44 | 45 | 51 | 52 | 53 | 64 | 65 | 71 | 72 | 73 | 82 | 83 | 89 | 90 | 91 | 100 | 101 | 107 | 108 | 109 | 119 | 120 | 130 | 131 | 140 | 141 | 151 | 152 | 161 | 162 | 172 | 173 | 182 | 183 | 193 | 194 | 195 | 204 | 205 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_next.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 16 | 17 | 27 | 28 | 35 | 36 | 37 | 48 | 49 | 57 | 58 | 59 | 70 | 71 | 77 | 78 | 79 | 93 | 102 | 103 | 104 | 118 | 119 | 129 | 130 | 131 | 141 | 142 | 152 | 153 | 162 | 163 | 173 | 174 | 183 | 184 | 194 | 195 | 204 | 205 | 215 | 216 | 217 | 226 | 227 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pj567/ShimmerShadowLayout/e8384dd0dd1f8aa3123e096ef9b88f446bdb65be/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pj567/ShimmerShadowLayout/e8384dd0dd1f8aa3123e096ef9b88f446bdb65be/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pj567/ShimmerShadowLayout/e8384dd0dd1f8aa3123e096ef9b88f446bdb65be/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pj567/ShimmerShadowLayout/e8384dd0dd1f8aa3123e096ef9b88f446bdb65be/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pj567/ShimmerShadowLayout/e8384dd0dd1f8aa3123e096ef9b88f446bdb65be/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pj567/ShimmerShadowLayout/e8384dd0dd1f8aa3123e096ef9b88f446bdb65be/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pj567/ShimmerShadowLayout/e8384dd0dd1f8aa3123e096ef9b88f446bdb65be/app/src/main/res/mipmap-xhdpi/test.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pj567/ShimmerShadowLayout/e8384dd0dd1f8aa3123e096ef9b88f446bdb65be/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pj567/ShimmerShadowLayout/e8384dd0dd1f8aa3123e096ef9b88f446bdb65be/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pj567/ShimmerShadowLayout/e8384dd0dd1f8aa3123e096ef9b88f446bdb65be/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pj567/ShimmerShadowLayout/e8384dd0dd1f8aa3123e096ef9b88f446bdb65be/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ShimmerShadowLayout 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 19 | 20 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.3.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | flatDir { 19 | dirs 'libs' 20 | } 21 | maven { url "https://jitpack.io" } 22 | maven { url "https://maven.google.com" }//需要添加的仓库地址 23 | maven { url "https://dl.google.com/dl/android/maven2/" }//需要添加的仓库地址 24 | } 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pj567/ShimmerShadowLayout/e8384dd0dd1f8aa3123e096ef9b88f446bdb65be/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Dec 18 15:26:03 CST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------