diff --git a/Demo.gif b/Demo.gif deleted file mode 100644 index 1fbe171..0000000 Binary files a/Demo.gif and /dev/null differ diff --git a/README.md b/README.md index c49596f..66885b0 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,21 @@ +# PLEASE NOTE, THIS PROJECT IS NO LONGER BEING MAINTAINED + +* * * + +[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-AVLoadingIndicatorView-green.svg?style=flat)](https://android-arsenal.com/details/1/2686) + AVLoadingIndicatorView =================== +> **Now AVLoadingIndicatorView was updated version to 2.X , If you have any question or suggestion with this library , welcome to tell me !** + ## Introduction AVLoadingIndicatorView is a collection of nice loading animations for Android. -You can also find IOS version of this [here](https://github.com/ninjaprox/NVActivityIndicatorView). +You can also find iOS version of this [here](https://github.com/ninjaprox/NVActivityIndicatorView). ## Demo -![](https://github.com/81813780/AVLoadingIndicatorView/blob/master/Demo.gif) - -[Download Apk](https://github.com/81813780/AVLoadingIndicatorView/releases/download/getSampleApk/app-debug.apk) +![avi](screenshots/avi.gif) ## Usage @@ -17,65 +23,147 @@ You can also find IOS version of this [here](https://github.com/ninjaprox/NVActi Add dependencies in build.gradle. ```groovy - dependencies { - compile 'com.wang.avi:library:1.0.0' - compile 'com.nineoldandroids:library:2.4.0' - } + dependencies { + compile 'com.wang.avi:library:2.1.3' + } ``` ### Step 2 Add the AVLoadingIndicatorView to your layout: + +Simple + ```java ``` +Advance + +```java + +``` + +### Step 3 + +It's very simple use just like . +```java + void startAnim(){ + avi.show(); + // or avi.smoothToShow(); + } + + void stopAnim(){ + avi.hide(); + // or avi.smoothToHide(); + } + +``` + +## Custom Indicator + +See [MyCustomIndicator](https://github.com/81813780/AVLoadingIndicatorView/blob/master/app/src/main/java/com/wang/avi/sample/MyCustomIndicator.java) in Sample . + +## Proguard + +When using proguard need add rules: + +``` +-keep class com.wang.avi.** { *; } +-keep class com.wang.avi.indicators.** { *; } +``` + +Indicators is load from class names, proguard may change it (rename). + ## Indicators -Here they are - - * `BallPulse` - * `BallGridPulse` - * `BallClipRotate` - * `BallClipRotatePulse` - * `SquareSpin` - * `BallClipRotateMultiple` - * `BallPulseRise` - * `BallRotate` - * `CubeTransition` - * `BallZigZag` - * `BallZigZagDeflect` - * `BallTrianglePath` - * `BallScale` - * `LineScale` - * `LineScaleParty` - * `BallScaleMultiple` - * `BallPulseSync` - * `BallBeat` - * `LineScalePulseOut` - * `LineScalePulseOutRapid` - * `BallScaleRipple` - * `BallScaleRippleMultiple` - * `BallSpinFadeLoader` - * `LineSpinFadeLoader` - * `TriangleSkewSpin` - * `Pacman` - * `BallGridBeat` - * `SemiCircleSpin` +As seen above in the **Demo**, the indicators are as follows: + +**Row 1** + * `BallPulseIndicator` + * `BallGridPulseIndicator` + * `BallClipRotateIndicator` + * `BallClipRotatePulseIndicator` + +**Row 2** + * `SquareSpinIndicator` + * `BallClipRotateMultipleIndicator` + * `BallPulseRiseIndicator` + * `BallRotateIndicator` + +**Row 3** + * `CubeTransitionIndicator` + * `BallZigZagIndicator` + * `BallZigZagDeflectIndicator` + * `BallTrianglePathIndicator` + +**Row 4** + * `BallScaleIndicator` + * `LineScaleIndicator` + * `LineScalePartyIndicator` + * `BallScaleMultipleIndicator` + +**Row 5** + * `BallPulseSyncIndicator` + * `BallBeatIndicator` + * `LineScalePulseOutIndicator` + * `LineScalePulseOutRapidIndicator` + +**Row 6** + * `BallScaleRippleIndicator` + * `BallScaleRippleMultipleIndicator` + * `BallSpinFadeLoaderIndicator` + * `LineSpinFadeLoaderIndicator` + +**Row 7** + * `TriangleSkewSpinIndicator` + * `PacmanIndicator` + * `BallGridBeatIndicator` + * `SemiCircleSpinIndicator` + +**Row 8** + * `com.wang.avi.sample.MyCustomIndicator` ## Thanks -- [nineoldandroids](https://github.com/JakeWharton/NineOldAndroids) - [NVActivityIndicatorView](https://github.com/ninjaprox/NVActivityIndicatorView) +- [Connor Atherton](https://github.com/ConnorAtherton) -##Contact me +## Contact me - if you have a better idea or way on this project, please let me know, thanks:) + If you have a better idea or way on this project, please let me know, thanks :) [Email](mailto:81813780@qq.com) [Weibo](http://weibo.com/601265161) + +[My Blog](http://hlong.xyz) + +### License +``` +Copyright 2015 jack wang + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +``` + diff --git a/apk/app-debug.apk b/apk/app-debug.apk new file mode 100644 index 0000000..3dfbfd5 Binary files /dev/null and b/apk/app-debug.apk differ diff --git a/app-debug.apk b/app-debug.apk deleted file mode 100644 index 04031bd..0000000 Binary files a/app-debug.apk and /dev/null differ diff --git a/app/build.gradle b/app/build.gradle index ce04e33..8807715 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,15 +1,15 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 22 - buildToolsVersion "22.0.1" + compileSdkVersion 23 + buildToolsVersion "23.0.2" defaultConfig { applicationId "com.wang.avi.sample" - minSdkVersion 9 - targetSdkVersion 22 - versionCode 1 - versionName "1.0" + minSdkVersion 14 + targetSdkVersion 23 + versionCode 33 + versionName "2.1.3" } buildTypes { release { @@ -21,6 +21,7 @@ android { dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') - compile 'com.android.support:appcompat-v7:22.2.0' + compile 'com.android.support:appcompat-v7:23.2.0' + compile 'com.android.support:recyclerview-v7:23.2.0' compile project(':library') } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ab87e26..342ead3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,7 +8,7 @@ android:label="@string/app_name" android:theme="@style/AppTheme" > @@ -16,6 +16,7 @@ + diff --git a/app/src/main/java/com/wang/avi/sample/IndicatorActivity.java b/app/src/main/java/com/wang/avi/sample/IndicatorActivity.java new file mode 100644 index 0000000..94073c6 --- /dev/null +++ b/app/src/main/java/com/wang/avi/sample/IndicatorActivity.java @@ -0,0 +1,37 @@ +package com.wang.avi.sample; + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v7.app.AppCompatActivity; +import android.view.View; + +import com.wang.avi.AVLoadingIndicatorView; + +/** + * Created by Jack Wang on 2016/8/5. + */ + +public class IndicatorActivity extends AppCompatActivity{ + + private AVLoadingIndicatorView avi; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_indicator); + + String indicator=getIntent().getStringExtra("indicator"); + avi= (AVLoadingIndicatorView) findViewById(R.id.avi); + avi.setIndicator(indicator); + } + + public void hideClick(View view) { + avi.hide(); + // or avi.smoothToHide(); + } + + public void showClick(View view) { + avi.show(); + // or avi.smoothToShow(); + } +} diff --git a/app/src/main/java/com/wang/avi/sample/MainActivity.java b/app/src/main/java/com/wang/avi/sample/MainActivity.java deleted file mode 100644 index 48c2b1a..0000000 --- a/app/src/main/java/com/wang/avi/sample/MainActivity.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.wang.avi.sample; - -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; - - -public class MainActivity extends AppCompatActivity { - - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_loading); - } - - -} diff --git a/app/src/main/java/com/wang/avi/sample/MyCustomIndicator.java b/app/src/main/java/com/wang/avi/sample/MyCustomIndicator.java new file mode 100644 index 0000000..56fe1a0 --- /dev/null +++ b/app/src/main/java/com/wang/avi/sample/MyCustomIndicator.java @@ -0,0 +1,72 @@ +package com.wang.avi.sample; + +import android.graphics.Canvas; +import android.graphics.Paint; + +import android.animation.ValueAnimator; +import com.wang.avi.Indicator; + +import java.util.ArrayList; + +/** + * Created by Jack Wang on 2016/8/5. + */ + +public class MyCustomIndicator extends Indicator{ + + + public static final float SCALE=1.0f; + + //scale x ,y + private float[] scaleFloats=new float[]{SCALE, + SCALE, + SCALE, + SCALE, + SCALE}; + + + + @Override + public void draw(Canvas canvas, Paint paint) { + float circleSpacing=4; + float radius=(Math.min(getWidth(),getHeight())-circleSpacing*2)/12; + float x = getWidth()/ 2-(radius*2+circleSpacing); + float y=getHeight() / 2; + for (int i = 0; i < 4; i++) { + canvas.save(); + float translateX=x+(radius*2)*i+circleSpacing*i; + canvas.translate(translateX, y); + canvas.scale(scaleFloats[i], scaleFloats[i]); + canvas.drawCircle(0, 0, radius, paint); + canvas.restore(); + } + } + + @Override + public ArrayList onCreateAnimators() { + ArrayList animators=new ArrayList<>(); + int[] delays=new int[]{120,240,360,480}; + for (int i = 0; i < 4; i++) { + final int index=i; + + ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.3f,1); + + scaleAnim.setDuration(750); + scaleAnim.setRepeatCount(-1); + scaleAnim.setStartDelay(delays[i]); + + addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + scaleFloats[index] = (float) animation.getAnimatedValue(); + postInvalidate(); + + } + }); + animators.add(scaleAnim); + } + return animators; + } + + +} diff --git a/app/src/main/java/com/wang/avi/sample/SampleActivity.java b/app/src/main/java/com/wang/avi/sample/SampleActivity.java new file mode 100644 index 0000000..f6f2d8d --- /dev/null +++ b/app/src/main/java/com/wang/avi/sample/SampleActivity.java @@ -0,0 +1,104 @@ +package com.wang.avi.sample; + +import android.content.Intent; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.GridLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.View; +import android.view.ViewGroup; + +import com.wang.avi.AVLoadingIndicatorView; + +/** + * Created by Jack Wang on 2016/8/5. + */ + +public class SampleActivity extends AppCompatActivity{ + + private RecyclerView mRecycler; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_sample); + + mRecycler= (RecyclerView) findViewById(R.id.recycler); + + GridLayoutManager layoutManager=new GridLayoutManager(this,4); + mRecycler.setLayoutManager(layoutManager); + mRecycler.setAdapter(new RecyclerView.Adapter() { + @Override + public IndicatorHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View itemView=getLayoutInflater().inflate(R.layout.item_indicator,parent,false); + return new IndicatorHolder(itemView); + } + + @Override + public void onBindViewHolder(IndicatorHolder holder, final int position) { + holder.indicatorView.setIndicator(INDICATORS[position]); + holder.itemLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent=new Intent(SampleActivity.this,IndicatorActivity.class); + intent.putExtra("indicator",INDICATORS[position]); + startActivity(intent); + } + }); + } + + @Override + public int getItemCount() { + return INDICATORS.length; + } + }); + } + + final static class IndicatorHolder extends RecyclerView.ViewHolder{ + + public AVLoadingIndicatorView indicatorView; + public View itemLayout; + + public IndicatorHolder(View itemView) { + super(itemView); + itemLayout= itemView.findViewById(R.id.itemLayout); + indicatorView= (AVLoadingIndicatorView) itemView.findViewById(R.id.indicator); + } + } + + + + private static final String[] INDICATORS=new String[]{ + "BallPulseIndicator", + "BallGridPulseIndicator", + "BallClipRotateIndicator", + "BallClipRotatePulseIndicator", + "SquareSpinIndicator", + "BallClipRotateMultipleIndicator", + "BallPulseRiseIndicator", + "BallRotateIndicator", + "CubeTransitionIndicator", + "BallZigZagIndicator", + "BallZigZagDeflectIndicator", + "BallTrianglePathIndicator", + "BallScaleIndicator", + "LineScaleIndicator", + "LineScalePartyIndicator", + "BallScaleMultipleIndicator", + "BallPulseSyncIndicator", + "BallBeatIndicator", + "LineScalePulseOutIndicator", + "LineScalePulseOutRapidIndicator", + "BallScaleRippleIndicator", + "BallScaleRippleMultipleIndicator", + "BallSpinFadeLoaderIndicator", + "LineSpinFadeLoaderIndicator", + "TriangleSkewSpinIndicator", + "PacmanIndicator", + "BallGridBeatIndicator", + "SemiCircleSpinIndicator", + "com.wang.avi.sample.MyCustomIndicator" + }; + +} diff --git a/app/src/main/res/layout/activity_indicator.xml b/app/src/main/res/layout/activity_indicator.xml new file mode 100644 index 0000000..7c87600 --- /dev/null +++ b/app/src/main/res/layout/activity_indicator.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + +