├── .gitignore ├── .travis.yml ├── LICENSE ├── Loaders.iml ├── README.md ├── Screenshots ├── cocentric_circle2.gif ├── cocentric_circles.gif ├── crossword_grid.gif ├── device-2016-02-10-103401.png ├── heart_beat.gif └── heart_shape.gif ├── app ├── .gitignore ├── app.iml ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── devkhan │ │ └── loaders │ │ └── app │ │ ├── ConcentricCirclesDialog.java │ │ ├── CrosswordGridDialog.java │ │ ├── HeartBeatDIalog.java │ │ ├── HeartDrawDialog.java │ │ └── MainActivity.java │ └── res │ ├── layout │ ├── activity_main.xml │ ├── concentric_circles.xml │ ├── cross.xml │ ├── dynasore_animation.xml │ ├── fill_able.xml │ ├── football_animaation.xml │ ├── github_animation.xml │ ├── heart_beat.xml │ ├── heart_draw.xml │ ├── rounded_animation.xml │ ├── text_animation.xml │ └── wavw_animation.xml │ ├── menu │ └── menu_main.xml │ ├── mipmap-hdpi │ ├── ic_all_inclusive_black_24dp.png │ └── ic_launcher.png │ ├── mipmap-mdpi │ ├── ic_all_inclusive_black_24dp.png │ └── ic_launcher.png │ ├── mipmap-xhdpi │ ├── ic_all_inclusive_black_24dp.png │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ ├── ic_all_inclusive_black_24dp.png │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── color.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── heartbeat.mp4 ├── lib ├── .gitignore ├── build.gradle ├── lib.iml ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── devkhan │ │ └── loaders │ │ └── lib │ │ ├── ConcentricCircleView.java │ │ ├── CrosswordGrid.java │ │ ├── CustomProgressDialog.java │ │ ├── HeartBeatView.java │ │ ├── HeartDrawView.java │ │ └── utils │ │ ├── MeasureUtils.java │ │ └── Utils.java │ └── res │ ├── drawable │ └── black_square.jpg │ ├── layout │ └── custom_progress_dialog.xml │ └── values │ ├── attrs.xml │ ├── color.xml │ ├── dimen.xml │ ├── integers.xml │ └── strings.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | /captures 8 | ======= 9 | # Built application files 10 | *.apk 11 | *.ap_ 12 | 13 | # Files for the Dalvik VM 14 | *.dex 15 | 16 | # Java class files 17 | *.class 18 | 19 | # Generated files 20 | bin/ 21 | gen/ 22 | 23 | # Gradle files 24 | .gradle/ 25 | build/ 26 | /*/build/ 27 | 28 | # Local configuration file (sdk path, etc) 29 | local.properties 30 | 31 | # Proguard folder generated by Eclipse 32 | proguard/ 33 | 34 | # Log Files 35 | *.log 36 | 37 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio 38 | 39 | *.iml 40 | 41 | ## Directory-based project format: 42 | .idea/ 43 | *.idea/* 44 | # if you remove the above rule, at least ignore the following: 45 | 46 | # User-specific stuff: 47 | # .idea/workspace.xml 48 | # .idea/tasks.xml 49 | # .idea/dictionaries 50 | 51 | # Sensitive or high-churn files: 52 | # .idea/dataSources.ids 53 | # .idea/dataSources.xml 54 | # .idea/sqlDataSources.xml 55 | # .idea/dynamic.xml 56 | # .idea/uiDesigner.xml 57 | 58 | # Gradle: 59 | # .idea/gradle.xml 60 | # .idea/libraries 61 | 62 | # Mongo Explorer plugin: 63 | # .idea/mongoSettings.xml 64 | 65 | ## File-based project format: 66 | *.ipr 67 | *.iws 68 | 69 | ## Plugin-specific files: 70 | 71 | # IntelliJ 72 | /out/ 73 | 74 | # mpeltonen/sbt-idea plugin 75 | .idea_modules/ 76 | 77 | # JIRA plugin 78 | atlassian-ide-plugin.xml 79 | 80 | # Crashlytics plugin (for Android Studio and IntelliJ) 81 | com_crashlytics_export_strings.xml 82 | crashlytics.properties 83 | crashlytics-build.properties -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | jdk: oraclejdk8 3 | android: 4 | components: 5 | - tools 6 | - extra-android-support 7 | - extra-google-google_play_services 8 | - extra-android-m2repository 9 | - extra-google-m2repository 10 | - build-tools-26.0.2 11 | - android-26 12 | 13 | script: "./gradlew build --stacktrace" 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE (Modified) 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 5 | 6 | Devesh Khandelwal 7 | Rajan Maurya 8 | Pawan Kumar Pal 9 | 10 | Everyone is permitted to copy and distribute verbatim or modified 11 | copies of this license document, and changing it is allowed as long 12 | as the name is changed. 13 | 14 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 15 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 16 | 17 | 0. You just DO WHAT THE FUCK YOU WANT TO. 18 | 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 23 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 24 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 25 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 26 | OTHER DEALINGS IN THE SOFTWARE. 27 | -------------------------------------------------------------------------------- /Loaders.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Loaders 2 | 3 | [![Build Status](https://travis-ci.org/devkhan/Loaders.svg?branch=main)](https://travis-ci.org/devkhan/Loaders) 4 | 5 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Loaders-blue.svg?style=flat)](http://android-arsenal.com/details/1/3130) 6 | 7 | An animation library consisting of different types of loading animations, progress dialogs, etc. 8 | 9 | 10 | # Usage 11 | 12 | Add dependency 13 | ```gradle 14 | dependencies { 15 | compile 'teamdapsr.loaders:lib:1.0' 16 | } 17 | ``` 18 | 19 | XML Code: 20 | 21 | ```xml 22 | 31 | ``` 32 | 33 | ### Contribute 34 | 35 | If you want to contribute, please add new class in Loaders/lib/java/. 36 | 37 | ### License 38 | 39 | ![WTFPL Badge](http://www.wtfpl.net/wp-content/uploads/2012/12/wtfpl-badge-4.png) 40 | 41 | _Namaste_ 42 | -------------------------------------------------------------------------------- /Screenshots/cocentric_circle2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkhan/Loaders/b4ceef1e8daefa2379d5e0eb976a0c34788c48fb/Screenshots/cocentric_circle2.gif -------------------------------------------------------------------------------- /Screenshots/cocentric_circles.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkhan/Loaders/b4ceef1e8daefa2379d5e0eb976a0c34788c48fb/Screenshots/cocentric_circles.gif -------------------------------------------------------------------------------- /Screenshots/crossword_grid.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkhan/Loaders/b4ceef1e8daefa2379d5e0eb976a0c34788c48fb/Screenshots/crossword_grid.gif -------------------------------------------------------------------------------- /Screenshots/device-2016-02-10-103401.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkhan/Loaders/b4ceef1e8daefa2379d5e0eb976a0c34788c48fb/Screenshots/device-2016-02-10-103401.png -------------------------------------------------------------------------------- /Screenshots/heart_beat.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkhan/Loaders/b4ceef1e8daefa2379d5e0eb976a0c34788c48fb/Screenshots/heart_beat.gif -------------------------------------------------------------------------------- /Screenshots/heart_shape.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkhan/Loaders/b4ceef1e8daefa2379d5e0eb976a0c34788c48fb/Screenshots/heart_shape.gif -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 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 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion "26.0.2" 6 | 7 | defaultConfig { 8 | applicationId "devkhan.loaders.app" 9 | minSdkVersion 15 10 | targetSdkVersion 26 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | lintOptions { 21 | abortOnError false 22 | } 23 | } 24 | 25 | dependencies { 26 | compile fileTree(dir: 'libs', include: ['*.jar']) 27 | compile 'com.android.support:appcompat-v7:26.1.0' 28 | compile 'com.jakewharton:butterknife:8.8.1' 29 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' 30 | compile project(':lib') 31 | compile 'com.android.support:design:26.1.0' 32 | 33 | } 34 | -------------------------------------------------------------------------------- /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 E:\Utils\And\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 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/java/devkhan/loaders/app/ConcentricCirclesDialog.java: -------------------------------------------------------------------------------- 1 | package devkhan.loaders.app; 2 | 3 | import android.app.Dialog; 4 | import android.content.DialogInterface; 5 | import android.os.Bundle; 6 | import android.support.v4.app.DialogFragment; 7 | import android.support.v7.app.AlertDialog; 8 | import android.view.LayoutInflater; 9 | 10 | /** 11 | * Created by pa1pal on 9/6/15. 12 | */ 13 | public class ConcentricCirclesDialog extends DialogFragment { 14 | @Override 15 | public Dialog onCreateDialog(Bundle savedInstanceState) { 16 | // Use the Builder class for convenient dialog construction 17 | AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 18 | LayoutInflater inflater = getActivity().getLayoutInflater(); 19 | 20 | // Inflate and set the layout for the dialog 21 | // Pass null as the parent view because its going in the dialog layout 22 | builder.setView(inflater.inflate(R.layout.concentric_circles, null)) 23 | // Add action buttons 24 | .setPositiveButton("positive", new DialogInterface.OnClickListener() { 25 | @Override 26 | public void onClick(DialogInterface dialog, int id) { 27 | // sign in the user ... 28 | } 29 | }) 30 | ; 31 | return builder.create(); 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/java/devkhan/loaders/app/CrosswordGridDialog.java: -------------------------------------------------------------------------------- 1 | package devkhan.loaders.app; 2 | 3 | import android.app.Dialog; 4 | import android.content.DialogInterface; 5 | import android.os.Bundle; 6 | import android.support.v4.app.DialogFragment; 7 | import android.support.v7.app.AlertDialog; 8 | import android.view.LayoutInflater; 9 | 10 | /** 11 | * Created by pa1pal on 9/6/15. 12 | */ 13 | public class CrosswordGridDialog extends DialogFragment { 14 | @Override 15 | public Dialog onCreateDialog(Bundle savedInstanceState) { 16 | // Use the Builder class for convenient dialog construction 17 | AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 18 | LayoutInflater inflater = getActivity().getLayoutInflater(); 19 | 20 | // Inflate and set the layout for the dialog 21 | // Pass null as the parent view because its going in the dialog layout 22 | builder.setView(inflater.inflate(R.layout.cross, null)) 23 | // Add action buttons 24 | .setPositiveButton("positive", new DialogInterface.OnClickListener() { 25 | @Override 26 | public void onClick(DialogInterface dialog, int id) { 27 | // sign in the user ... 28 | } 29 | }) 30 | ; 31 | return builder.create(); 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/java/devkhan/loaders/app/HeartBeatDIalog.java: -------------------------------------------------------------------------------- 1 | package devkhan.loaders.app; 2 | 3 | import android.app.Dialog; 4 | import android.content.DialogInterface; 5 | import android.os.Bundle; 6 | import android.support.v4.app.DialogFragment; 7 | import android.support.v7.app.AlertDialog; 8 | import android.view.LayoutInflater; 9 | 10 | /** 11 | * Created by Devesh on 23-Jul-15. 12 | */ 13 | public class HeartBeatDIalog extends DialogFragment { 14 | @Override 15 | public Dialog onCreateDialog(Bundle savedInstanceState) { 16 | // Use the Builder class for convenient dialog construction 17 | AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 18 | LayoutInflater inflater = getActivity().getLayoutInflater(); 19 | 20 | // Inflate and set the layout for the dialog 21 | // Pass null as the parent view because its going in the dialog layout 22 | builder.setView(inflater.inflate(R.layout.heart_beat, null)) 23 | // Add action buttons 24 | .setPositiveButton("positive", new DialogInterface.OnClickListener() { 25 | @Override 26 | public void onClick(DialogInterface dialog, int id) { 27 | // sign in the user ... 28 | } 29 | }) 30 | ; 31 | return builder.create(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/devkhan/loaders/app/HeartDrawDialog.java: -------------------------------------------------------------------------------- 1 | package devkhan.loaders.app; 2 | 3 | import android.app.Dialog; 4 | import android.content.DialogInterface; 5 | import android.os.Bundle; 6 | import android.support.v4.app.DialogFragment; 7 | import android.support.v7.app.AlertDialog; 8 | import android.view.LayoutInflater; 9 | 10 | /** 11 | * Created by Devesh on 28-Jul-15. 12 | */ 13 | public class HeartDrawDialog extends DialogFragment { 14 | @Override 15 | public Dialog onCreateDialog(Bundle savedInstanceState) { 16 | // Use the Builder class for convenient dialog construction 17 | AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 18 | LayoutInflater inflater = getActivity().getLayoutInflater(); 19 | 20 | // Inflate and set the layout for the dialog 21 | // Pass null as the parent view because its going in the dialog layout 22 | builder.setView(inflater.inflate(R.layout.heart_draw, null)) 23 | // Add action buttons 24 | .setPositiveButton("positive", new DialogInterface.OnClickListener() { 25 | @Override 26 | public void onClick(DialogInterface dialog, int id) { 27 | // sign in the user ... 28 | } 29 | }) 30 | ; 31 | return builder.create(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/devkhan/loaders/app/MainActivity.java: -------------------------------------------------------------------------------- 1 | package devkhan.loaders.app; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.DialogFragment; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.Menu; 7 | import android.view.MenuItem; 8 | import android.view.View; 9 | import android.widget.AdapterView; 10 | import android.widget.ArrayAdapter; 11 | import android.widget.ListView; 12 | import android.widget.Toast; 13 | 14 | 15 | public class MainActivity extends AppCompatActivity { 16 | 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | 22 | getSupportActionBar().setTitle(getString(R.string.app_name)); 23 | setContentView(R.layout.activity_main); 24 | 25 | ListView list = (ListView) findViewById(R.id.loaders_list); 26 | 27 | String[] loader = 28 | new String[]{"Crossword Grid", "Concentric Cirlces", "HeartBeat", "Heart Shape"}; 29 | 30 | ArrayAdapter adapter = new ArrayAdapter(this, 31 | android.R.layout.simple_list_item_1, android.R.id.text1, loader); 32 | list.setAdapter(adapter); 33 | 34 | list.setOnItemClickListener(new AdapterView.OnItemClickListener() { 35 | @Override 36 | public void onItemClick(AdapterView parent, View view, int position, long id) { 37 | switch (position) { 38 | case 0: 39 | DialogFragment dialog = new CrosswordGridDialog(); 40 | dialog.show(getSupportFragmentManager(), "CrosswordGridDialog"); 41 | break; 42 | 43 | case 1: 44 | DialogFragment concentricCirclesDialog = new ConcentricCirclesDialog(); 45 | concentricCirclesDialog.show(getSupportFragmentManager(), 46 | "ConcentricCirclesDialog"); 47 | break; 48 | 49 | case 2: 50 | DialogFragment heartBeatDIalog = new HeartBeatDIalog(); 51 | heartBeatDIalog.show(getSupportFragmentManager(), "HeartBeatDialog"); 52 | break; 53 | 54 | case 3: 55 | DialogFragment heartDrawDialog = new HeartDrawDialog(); 56 | heartDrawDialog.show(getSupportFragmentManager(), "HeartDrawDialog"); 57 | break; 58 | 59 | default: 60 | Toast.makeText(getApplicationContext(), "wrong choice", 61 | Toast.LENGTH_LONG).show(); 62 | break; 63 | 64 | } 65 | } 66 | }); 67 | } 68 | 69 | @Override 70 | public boolean onCreateOptionsMenu(Menu menu) { 71 | // Inflate the menu; this adds items to the action bar if it is present. 72 | getMenuInflater().inflate(R.menu.menu_main, menu); 73 | return true; 74 | } 75 | 76 | @Override 77 | public boolean onOptionsItemSelected(MenuItem item) { 78 | // Handle action bar item clicks here. The action bar will 79 | // automatically handle clicks on the Home/Up button, so long 80 | // as you specify a parent activity in AndroidManifest.xml. 81 | int id = item.getItemId(); 82 | 83 | //noinspection SimplifiableIfStatement 84 | if (id == R.id.action_settings) { 85 | return true; 86 | } 87 | 88 | return super.onOptionsItemSelected(item); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 | 21 | 22 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/layout/concentric_circles.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/cross.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/layout/dynasore_animation.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fill_able.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 13 | 14 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/layout/football_animaation.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/layout/github_animation.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/heart_beat.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/heart_draw.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/rounded_animation.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/text_animation.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/wavw_animation.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_all_inclusive_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkhan/Loaders/b4ceef1e8daefa2379d5e0eb976a0c34788c48fb/app/src/main/res/mipmap-hdpi/ic_all_inclusive_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkhan/Loaders/b4ceef1e8daefa2379d5e0eb976a0c34788c48fb/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_all_inclusive_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkhan/Loaders/b4ceef1e8daefa2379d5e0eb976a0c34788c48fb/app/src/main/res/mipmap-mdpi/ic_all_inclusive_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkhan/Loaders/b4ceef1e8daefa2379d5e0eb976a0c34788c48fb/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_all_inclusive_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkhan/Loaders/b4ceef1e8daefa2379d5e0eb976a0c34788c48fb/app/src/main/res/mipmap-xhdpi/ic_all_inclusive_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkhan/Loaders/b4ceef1e8daefa2379d5e0eb976a0c34788c48fb/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_all_inclusive_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkhan/Loaders/b4ceef1e8daefa2379d5e0eb976a0c34788c48fb/app/src/main/res/mipmap-xxhdpi/ic_all_inclusive_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkhan/Loaders/b4ceef1e8daefa2379d5e0eb976a0c34788c48fb/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FF5722 4 | #E64A19 5 | #FF7043 6 | #EA9B08 7 | #e7e7e7 8 | #fafafa 9 | #009688 10 | #FFFFFF 11 | #000000 12 | #00B551 13 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Loaders Demo 3 | 4 | Hello world! 5 | Settings 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /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 | maven { 7 | url 'https://maven.google.com/' 8 | name 'Google' 9 | } 10 | } 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:3.0.1' 13 | 14 | // NOTE: Do not place your application dependencies here; they belong 15 | // in the individual module build.gradle files 16 | } 17 | } 18 | 19 | allprojects { 20 | repositories { 21 | jcenter() 22 | maven { 23 | url 'https://maven.google.com/' 24 | name 'Google' 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkhan/Loaders/b4ceef1e8daefa2379d5e0eb976a0c34788c48fb/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Mar 08 20:44:05 IST 2018 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-4.1-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 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /heartbeat.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkhan/Loaders/b4ceef1e8daefa2379d5e0eb976a0c34788c48fb/heartbeat.mp4 -------------------------------------------------------------------------------- /lib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /lib/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | ext { 4 | PUBLISH_GROUP_ID = 'devkhan.loaders' 5 | PUBLISH_ARTIFACT_ID = 'lib' 6 | PUBLISH_VERSION = '1.0' 7 | } 8 | 9 | android { 10 | compileSdkVersion 26 11 | buildToolsVersion "26.0.2" 12 | 13 | defaultConfig { 14 | minSdkVersion 15 15 | targetSdkVersion 26 16 | versionCode 1 17 | versionName "1.0" 18 | } 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | 26 | lintOptions { 27 | checkReleaseBuilds false 28 | abortOnError false 29 | } 30 | } 31 | 32 | dependencies { 33 | compile fileTree(dir: 'libs', include: ['*.jar']) 34 | compile 'com.android.support:appcompat-v7:26.1.0' 35 | } 36 | 37 | apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle' -------------------------------------------------------------------------------- /lib/lib.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 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 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /lib/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 E:\Utils\And\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 | -------------------------------------------------------------------------------- /lib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /lib/src/main/java/devkhan/loaders/lib/ConcentricCircleView.java: -------------------------------------------------------------------------------- 1 | package devkhan.loaders.lib; 2 | 3 | import android.animation.ValueAnimator; 4 | import android.content.Context; 5 | import android.content.res.TypedArray; 6 | import android.graphics.Canvas; 7 | import android.graphics.Color; 8 | import android.graphics.Paint; 9 | import android.util.AttributeSet; 10 | import android.util.Log; 11 | import android.view.View; 12 | 13 | import devkhan.loaders.lib.utils.MeasureUtils; 14 | import devkhan.loaders.lib.utils.Utils; 15 | 16 | /** 17 | * Animating concentric circles. Extends {@link View}. A Custom View. 18 | *

19 | * Created on 08-July-2015. 20 | * Modified on 13-July-2015. 21 | * 22 | * @author Devesh Khandelwal 23 | */ 24 | public class ConcentricCircleView extends View { 25 | 26 | /** 27 | * Minimum radius of the circles. 28 | */ 29 | protected int mMinRadius; 30 | /** 31 | * Maximum radius of the circles. 32 | */ 33 | protected int mMaxRadius; 34 | /** 35 | * Number of circles. 36 | */ 37 | protected int mCirclesCount; 38 | /** 39 | * Animate color or not. 40 | */ 41 | protected boolean mAnimateColor; 42 | /** 43 | * Starting color, if animating. 44 | */ 45 | protected int mStartColor; 46 | /** 47 | * Ending color, if animating. 48 | */ 49 | protected int mEndColor; 50 | /** 51 | * Animation duration. 52 | */ 53 | protected int mDuration; 54 | /** 55 | * Array of {@link ValueAnimator} objects. One for each circle. 56 | */ 57 | protected ValueAnimator mAnim[]; 58 | /** 59 | * Array of {@link Paint} objects. One for each circle, if not animating color. 60 | */ 61 | protected Paint mPaint[]; 62 | /** 63 | * Paint object used for drawing, if animating color. 64 | */ 65 | protected Paint mAnimatePaint; 66 | /** 67 | * Aniamtor for color, if animating. 68 | */ 69 | protected ValueAnimator mColorAnim; 70 | /** 71 | * Class name for logging. 72 | */ 73 | private String LOG_TAG = getClass().getSimpleName(); 74 | 75 | 76 | /** 77 | * Instantiates an object with just a {@link Context} and the default attributes. Used when 78 | * creating a view programmatically. 79 | * 80 | * @param context variable required for instantiating a view. 81 | */ 82 | public ConcentricCircleView(Context context) { 83 | super(context); 84 | 85 | /** 86 | * Setting default values. 87 | */ 88 | mMaxRadius = 0; 89 | mMaxRadius = 100; 90 | mCirclesCount = 3; 91 | mAnimateColor = false; 92 | mDuration = 3000; 93 | 94 | init(); 95 | } 96 | 97 | /** 98 | * Instantiates an object with just a {@link Context} and attributes provided in the 99 | * attribute set by the XML resource file. Called when defining view via XML resource. 100 | * 101 | * @param context variable required for instantiating a view. 102 | * @param attrs Attribute Set containing attributes defined in the layout resource file. 103 | */ 104 | public ConcentricCircleView(Context context, AttributeSet attrs) { 105 | super(context, attrs); 106 | 107 | // TODO: Get parent view's measurements so that max radius can be defaulted to max 108 | // height/width. 109 | 110 | /** 111 | * Gets the defined attributes in the layout resource file as a {@link TypedArray}. 112 | */ 113 | TypedArray styledAttributes = context.getTheme().obtainStyledAttributes( 114 | attrs, 115 | R.styleable.ConcentricCircleView, 116 | 0, 0 117 | ); 118 | 119 | /** 120 | * Trying to extract defined attributes in the layout resource file. 121 | */ 122 | try { 123 | mMinRadius = styledAttributes.getInt(R.styleable.ConcentricCircleView_min_radius, 0); 124 | mMaxRadius = styledAttributes.getInt(R.styleable.ConcentricCircleView_max_radius, 100); 125 | mCirclesCount = styledAttributes.getInt(R.styleable.ConcentricCircleView_circles_count, 126 | 3); 127 | mAnimateColor = styledAttributes.getBoolean( 128 | R.styleable.ConcentricCircleView_animate_color, true); 129 | if (mAnimateColor) { 130 | mStartColor = styledAttributes.getColor( 131 | R.styleable.ConcentricCircleView_start_color, Color 132 | .parseColor("#00000000")); 133 | mEndColor = styledAttributes.getColor(R.styleable.ConcentricCircleView_end_color, 134 | Color.parseColor 135 | ("#ffffffff")); 136 | } 137 | mDuration = styledAttributes.getInt(R.styleable.ConcentricCircleView_duration, 1500); 138 | 139 | } catch (Exception e) { 140 | e.printStackTrace(); 141 | } finally { 142 | styledAttributes.recycle(); 143 | } 144 | init(); 145 | } 146 | 147 | /** 148 | * Initializing {@link Paint} objects to draw later on. 149 | */ 150 | protected void init() { 151 | /** 152 | * Setting up paints for drawing circles. 153 | */ 154 | if (mAnimateColor) { 155 | mAnimatePaint = new Paint(Paint.ANTI_ALIAS_FLAG); 156 | mAnimatePaint.setStyle(Paint.Style.FILL); 157 | mAnimatePaint.setColor(mStartColor); 158 | } else { 159 | mPaint = new Paint[mCirclesCount]; 160 | 161 | for (int i = 0; i < mPaint.length; i++) { 162 | mPaint[i] = new Paint(Paint.ANTI_ALIAS_FLAG); 163 | mPaint[i].setStyle(Paint.Style.FILL); 164 | mPaint[i].setColor(Utils.randomColor()); 165 | } 166 | } 167 | 168 | } 169 | 170 | /** 171 | * Setting up {@link ValueAnimator} objects and starting them. 172 | */ 173 | protected void setupAnimations() { 174 | /** 175 | * Setting up animations for animating circles and colors. 176 | */ 177 | if (mAnimateColor) { 178 | if (mStartColor <= mEndColor) { 179 | mColorAnim = ValueAnimator.ofInt(mStartColor, mEndColor); 180 | } else { 181 | mColorAnim = ValueAnimator.ofInt(mEndColor, mStartColor); 182 | } 183 | 184 | mColorAnim.setDuration(mDuration * 10); 185 | mColorAnim.setRepeatMode(ValueAnimator.REVERSE); 186 | mColorAnim.setRepeatCount(ValueAnimator.INFINITE); 187 | mColorAnim.start(); 188 | } 189 | 190 | mAnim = new ValueAnimator[mCirclesCount]; 191 | 192 | for (int i = 0; i < mAnim.length; i++) { 193 | mAnim[i] = ValueAnimator.ofInt(mMinRadius, mMaxRadius); 194 | mAnim[i].setDuration(mDuration); 195 | mAnim[i].setRepeatMode(ValueAnimator.REVERSE); 196 | mAnim[i].setRepeatCount(ValueAnimator.INFINITE); 197 | mAnim[i].setInterpolator(Utils.randomInterpolator()); 198 | mAnim[i].start(); 199 | } 200 | } 201 | 202 | @Override 203 | public void onDraw(Canvas canvas) { 204 | 205 | super.onDraw(canvas); 206 | 207 | if (!mAnimateColor) { 208 | for (int i = 0; i < mCirclesCount; i++) { 209 | Log.i(LOG_TAG, "Radius " + i + " : " + (int) (mAnim[i] 210 | .getAnimatedValue())); 211 | canvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, (int) (mAnim[i] 212 | .getAnimatedValue()), mPaint[i]); 213 | } 214 | } else { 215 | mAnimatePaint.setColor((int) (mColorAnim.getAnimatedValue())); 216 | for (int i = 0; i < mCirclesCount; i++) { 217 | Log.i(LOG_TAG, "Radius " + i + " : " + (int) (mAnim[i] 218 | .getAnimatedValue())); 219 | canvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, (int) (mAnim[i] 220 | .getAnimatedValue()), mAnimatePaint); 221 | } 222 | } 223 | 224 | /** 225 | * Waiting for sometime, mainly for animation purposes and litte bit performance issues. 226 | */ 227 | try { 228 | Thread.sleep(50); 229 | } catch (InterruptedException e) { 230 | e.printStackTrace(); 231 | } 232 | invalidate(); 233 | 234 | } 235 | 236 | @Override 237 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 238 | super.onSizeChanged(w, h, oldw, oldh); 239 | } 240 | 241 | @Override 242 | public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 243 | // Get the width measurement 244 | int widthSize = MeasureUtils.getMeasurement(widthMeasureSpec, getDesiredWidth()); 245 | 246 | // Get the height measurement 247 | int heightSize = MeasureUtils.getMeasurement(heightMeasureSpec, getDesiredHeight()); 248 | 249 | 250 | //MUST call this to store the measurements 251 | setMeasuredDimension(widthSize + 10, heightSize + 10); 252 | 253 | setupAnimations(); 254 | } 255 | 256 | /** 257 | * Calculates width from child components. 258 | * 259 | * @return Desired width in view. 260 | */ 261 | private int getDesiredWidth() { 262 | // TO-DO Calculate width from child components. 263 | 264 | return 2 * mMaxRadius + 100; 265 | } 266 | 267 | /** 268 | * Calculate height from child components. 269 | * 270 | * @return Desired height of view. 271 | */ 272 | private int getDesiredHeight() { 273 | // TO-DO Calculate height from child components. 274 | return 2 * mMaxRadius + 100; 275 | } 276 | 277 | 278 | /** 279 | * Getter for attribute 'min_radius'. 280 | * 281 | * @return Value for attribute 'min_radius'. 282 | */ 283 | public int getMinRadius() { 284 | return mMinRadius; 285 | } 286 | 287 | /** 288 | * Setter for attribute 'min_radius'. 289 | * 290 | * @param mMinRadius Value to set for attribute 'min_radius'. 291 | */ 292 | public void setMinRadius(int mMinRadius) { 293 | this.mMinRadius = mMinRadius; 294 | setupAnimations(); 295 | invalidate(); 296 | } 297 | 298 | /** 299 | * Getter for attribute 'max_radius'. 300 | * 301 | * @return Value for attribute 'max_radius'. 302 | */ 303 | public int getMaxRadius() { 304 | return mMaxRadius; 305 | } 306 | 307 | /** 308 | * Setter for attribute 'max_radius'. 309 | * 310 | * @param mMaxRadius Value to set for attribute 'max_radius'. 311 | */ 312 | public void setMaxRadius(int mMaxRadius) { 313 | this.mMaxRadius = mMaxRadius; 314 | setupAnimations(); 315 | invalidate(); 316 | } 317 | 318 | /** 319 | * Getter for attribute 'circles_count'. 320 | * 321 | * @return Value for attribute 'circles_count'. 322 | */ 323 | public int getCirclesCount() { 324 | return mCirclesCount; 325 | } 326 | 327 | /** 328 | * Setter for attribute 'circles_count'. 329 | * 330 | * @param mCirclesCount Value to set for attribute 'circles_count'. 331 | */ 332 | public void setCirclesCount(int mCirclesCount) { 333 | this.mCirclesCount = mCirclesCount; 334 | init(); 335 | setupAnimations(); 336 | invalidate(); 337 | } 338 | 339 | /** 340 | * Getter for property 'duration'. 341 | * 342 | * @return Value for property 'duration'. 343 | */ 344 | public int getDuration() { 345 | return mDuration; 346 | } 347 | 348 | /** 349 | * Setter for property 'duration'. 350 | * 351 | * @param mDuration Value to set for property 'duration'. 352 | */ 353 | public void setDuration(int mDuration) { 354 | this.mDuration = mDuration; 355 | setupAnimations(); 356 | invalidate(); 357 | } 358 | 359 | } 360 | -------------------------------------------------------------------------------- /lib/src/main/java/devkhan/loaders/lib/CrosswordGrid.java: -------------------------------------------------------------------------------- 1 | package devkhan.loaders.lib; 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.Rect; 8 | import android.util.AttributeSet; 9 | import android.view.View; 10 | 11 | import java.util.Random; 12 | 13 | import devkhan.loaders.lib.utils.MeasureUtils; 14 | 15 | /** 16 | * Created by Devesh on 08-Jun-15. 17 | */ 18 | public class CrosswordGrid extends View { 19 | private int squareSide; 20 | private Paint mSquarePaint; 21 | private Paint mSquarePaintFill; 22 | 23 | private int GRID_ROWS; 24 | private int GRID_COLUMNS; 25 | private boolean coordinates[][]; 26 | 27 | public CrosswordGrid(Context context, AttributeSet attrs) { 28 | super(context, attrs); 29 | TypedArray a = context.getTheme().obtainStyledAttributes( 30 | attrs, 31 | R.styleable.CrosswordGrid, 32 | 0, 0 33 | ); 34 | 35 | try { 36 | squareSide = a.getInt(R.styleable.CrosswordGrid_squareSide, 10); 37 | } catch (Exception e) { 38 | e.printStackTrace(); 39 | } finally { 40 | a.recycle(); 41 | } 42 | 43 | GRID_ROWS = GRID_COLUMNS = 10; 44 | coordinates = new boolean[GRID_ROWS][GRID_COLUMNS]; 45 | for (int i = 0; i < GRID_ROWS; i++) { 46 | for (int j = 0; j < GRID_COLUMNS; j++) { 47 | coordinates[i][j] = false; 48 | } 49 | } 50 | 51 | init(); 52 | } 53 | 54 | 55 | public CrosswordGrid(Context context, int squareSide) { 56 | super(context); 57 | this.squareSide = squareSide; 58 | 59 | } 60 | 61 | /** 62 | * Returns a pseudo-random number between min and max, inclusive. 63 | * The difference between min and max can be at most 64 | * Integer.MAX_VALUE - 1. 65 | * 66 | * @param min Minimum value 67 | * @param max Maximum value. Must be greater than min. 68 | * @return Integer between min and max, inclusive. 69 | * @see java.util.Random#nextInt(int) 70 | */ 71 | public static int randInt(int min, int max) { 72 | 73 | // NOTE: Usually this should be a field rather than a method 74 | // variable so that it is not re-seeded every call. 75 | Random rand = new Random(); 76 | 77 | // nextInt is normally exclusive of the top value, 78 | // so add 1 to make it inclusive 79 | int randomNum = rand.nextInt((max - min) + 1) + min; 80 | 81 | return randomNum; 82 | } 83 | 84 | @Override 85 | public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 86 | // Get the width measurement 87 | int widthSize = MeasureUtils.getMeasurement(widthMeasureSpec, getDesiredWidth()); 88 | 89 | // Get the height measurement 90 | int heightSize = MeasureUtils.getMeasurement(heightMeasureSpec, getDesiredHeight()); 91 | 92 | //MUST call this to store the measurements 93 | setMeasuredDimension(widthSize + 10, heightSize + 10); 94 | } 95 | 96 | private int getDesiredWidth() { 97 | // TO-DO Calculate width from child components. 98 | 99 | return 2 * squareSide + 200; 100 | } 101 | 102 | private int getDesiredHeight() { 103 | // TO-DO Calculate height from chile components. 104 | return 2 * squareSide + 200; 105 | } 106 | 107 | public int getSquareSide() { 108 | return squareSide; 109 | } 110 | 111 | public void setSquareSide(int side) { 112 | this.squareSide = side; 113 | invalidate(); 114 | requestLayout(); 115 | } 116 | 117 | private void init() { 118 | mSquarePaint = new Paint(Paint.ANTI_ALIAS_FLAG); 119 | mSquarePaint.setColor(0xff101010); 120 | mSquarePaint.setStyle(Paint.Style.FILL); 121 | mSquarePaintFill = new Paint(Paint.ANTI_ALIAS_FLAG); 122 | mSquarePaintFill.setColor(0xffffffff); 123 | mSquarePaintFill.setStyle(Paint.Style.FILL); 124 | } 125 | 126 | @Override 127 | public void onDraw(Canvas canvas) { 128 | super.onDraw(canvas); 129 | 130 | for (int i = 0; i < GRID_ROWS; i++) { 131 | for (int j = 0; j < GRID_COLUMNS; j++) { 132 | int left = i * (10); 133 | int top = j * (10); 134 | int right = left + 10; 135 | int bottom = top + 10; 136 | if (coordinates[i][j]) { 137 | canvas.drawRect(new Rect(left, top, right, bottom), 138 | mSquarePaint); 139 | } else { 140 | canvas.drawRect(new Rect(left, top, right, bottom), 141 | mSquarePaintFill); 142 | } 143 | } 144 | } 145 | try { 146 | Thread.sleep(150); 147 | } catch (InterruptedException e) { 148 | e.printStackTrace(); 149 | } 150 | generateRandomCoordinates(); 151 | } 152 | 153 | @Override 154 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 155 | super.onSizeChanged(w, h, oldw, oldh); 156 | } 157 | 158 | private void generateRandomCoordinates() { 159 | 160 | for (int i = 0; i < GRID_ROWS; i++) { 161 | for (int j = 0; j < GRID_COLUMNS; j++) { 162 | coordinates[i][j] = false; 163 | } 164 | } 165 | 166 | for (int i = 0; i < 40; i++) { 167 | coordinates[randInt(0, GRID_ROWS - 1)][randInt(0, GRID_COLUMNS - 1) 168 | ] = true; 169 | } 170 | invalidate(); 171 | requestLayout(); 172 | } 173 | 174 | } 175 | -------------------------------------------------------------------------------- /lib/src/main/java/devkhan/loaders/lib/CustomProgressDialog.java: -------------------------------------------------------------------------------- 1 | package devkhan.loaders.lib; 2 | 3 | import android.app.Dialog; 4 | import android.content.Context; 5 | import android.os.Bundle; 6 | import android.util.Log; 7 | import android.view.animation.AccelerateDecelerateInterpolator; 8 | import android.view.animation.Animation; 9 | import android.view.animation.TranslateAnimation; 10 | import android.widget.ImageView; 11 | import android.widget.RelativeLayout; 12 | 13 | /** 14 | * Created by Devesh on 08-Jun-15. 15 | */ 16 | public class CustomProgressDialog extends Dialog { 17 | private final String LOG_TAG = "CustomProgressDialog"; 18 | private ImageView one, two, three, four; 19 | private float beginValue, endValue, height, width; 20 | private RelativeLayout.LayoutParams layoutParams; 21 | private int duration = 3000; 22 | private float interpolationTime = 0.9f; 23 | 24 | /** 25 | * @param context Activity context to create views. 26 | */ 27 | public CustomProgressDialog(Context context) { 28 | super(context); 29 | } 30 | 31 | /** 32 | * @param savedInstance Saved instance for resuming from onPause. 33 | */ 34 | @Override 35 | protected void onCreate(Bundle savedInstance) { 36 | super.onCreate(savedInstance); 37 | setContentView(R.layout.custom_progress_dialog); 38 | 39 | one = (ImageView) findViewById(R.id.one); 40 | two = (ImageView) findViewById(R.id.two); 41 | three = (ImageView) findViewById(R.id.three); 42 | four = (ImageView) findViewById(R.id.four); 43 | 44 | height = this.getWindow().getDecorView().getHeight(); 45 | width = this.getWindow().getDecorView().getWidth(); 46 | 47 | Log.i(LOG_TAG, "Height: " + height + " Width: " + width); 48 | 49 | } 50 | 51 | private void animate() { 52 | 53 | height = width = 200; 54 | final TranslateAnimation left2right = new TranslateAnimation(0, 55 | width, 0, 0); 56 | final TranslateAnimation top2bottom = new TranslateAnimation(0, 0, 0, 57 | height); 58 | final TranslateAnimation right2left = new TranslateAnimation(0, 59 | -width, 0, 0); 60 | final TranslateAnimation bottom2top = new TranslateAnimation(0, 0, 0, 61 | -height); 62 | 63 | left2right.setDuration(duration); 64 | top2bottom.setDuration(duration); 65 | right2left.setDuration(duration); 66 | bottom2top.setDuration(duration); 67 | 68 | left2right.setInterpolator(new AccelerateDecelerateInterpolator() { 69 | @Override 70 | public float getInterpolation(float v) { 71 | return v; 72 | } 73 | }); 74 | top2bottom.setInterpolator(new AccelerateDecelerateInterpolator() { 75 | @Override 76 | public float getInterpolation(float v) { 77 | return v; 78 | } 79 | }); 80 | right2left.setInterpolator(new AccelerateDecelerateInterpolator() { 81 | @Override 82 | public float getInterpolation(float v) { 83 | return v; 84 | } 85 | }); 86 | bottom2top.setInterpolator(new AccelerateDecelerateInterpolator() { 87 | @Override 88 | public float getInterpolation(float v) { 89 | return v; 90 | } 91 | }); 92 | 93 | left2right.setFillAfter(true); 94 | top2bottom.setFillAfter(true); 95 | right2left.setFillAfter(true); 96 | bottom2top.setFillAfter(true); 97 | 98 | left2right.setAnimationListener(new Animation.AnimationListener() { 99 | @Override 100 | public void onAnimationStart(Animation animation) { 101 | 102 | } 103 | 104 | @Override 105 | public void onAnimationEnd(Animation animation) { 106 | one.startAnimation(top2bottom); 107 | } 108 | 109 | @Override 110 | public void onAnimationRepeat(Animation animation) { 111 | 112 | } 113 | }); 114 | top2bottom.setAnimationListener(new Animation.AnimationListener() { 115 | @Override 116 | public void onAnimationStart(Animation animation) { 117 | 118 | } 119 | 120 | @Override 121 | public void onAnimationEnd(Animation animation) { 122 | one.startAnimation(right2left); 123 | } 124 | 125 | @Override 126 | public void onAnimationRepeat(Animation animation) { 127 | 128 | } 129 | }); 130 | right2left.setAnimationListener(new Animation.AnimationListener() { 131 | @Override 132 | public void onAnimationStart(Animation animation) { 133 | 134 | } 135 | 136 | @Override 137 | public void onAnimationEnd(Animation animation) { 138 | one.startAnimation(bottom2top); 139 | } 140 | 141 | @Override 142 | public void onAnimationRepeat(Animation animation) { 143 | 144 | } 145 | }); 146 | bottom2top.setAnimationListener(new Animation.AnimationListener() { 147 | @Override 148 | public void onAnimationStart(Animation animation) { 149 | 150 | } 151 | 152 | @Override 153 | public void onAnimationEnd(Animation animation) { 154 | one.startAnimation(left2right); 155 | } 156 | 157 | @Override 158 | public void onAnimationRepeat(Animation animation) { 159 | 160 | } 161 | }); 162 | 163 | one.startAnimation(left2right); 164 | } 165 | 166 | @Override 167 | public void show() { 168 | super.show(); 169 | animate(); 170 | } 171 | 172 | @Override 173 | public void dismiss() { 174 | super.dismiss(); 175 | 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /lib/src/main/java/devkhan/loaders/lib/HeartBeatView.java: -------------------------------------------------------------------------------- 1 | package devkhan.loaders.lib; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Color; 6 | import android.graphics.Paint; 7 | import android.graphics.Path; 8 | import android.util.AttributeSet; 9 | import android.view.View; 10 | 11 | /** 12 | * Created by Devesh on 23-Jul-15. 13 | * http://stackoverflow.com/a/12037831/3286583 14 | */ 15 | public class HeartBeatView extends View { 16 | 17 | private static Paint paint; 18 | private int screenW, screenH; 19 | private float X, Y; 20 | private Path path; 21 | private float initialScreenW; 22 | private float initialX, plusX; 23 | private float TX; 24 | private boolean translate; 25 | private int flash; 26 | private Context context; 27 | 28 | 29 | public HeartBeatView(Context context, AttributeSet attrs) { 30 | super(context); 31 | 32 | this.context = context; 33 | 34 | paint = new Paint(); 35 | paint.setColor(Color.argb(0x11, 0x11, 0xdd, 0x22)); 36 | paint.setStrokeWidth(10); 37 | paint.setAntiAlias(true); 38 | paint.setStrokeCap(Paint.Cap.ROUND); 39 | paint.setStrokeJoin(Paint.Join.ROUND); 40 | paint.setStyle(Paint.Style.STROKE); 41 | paint.setShadowLayer(7, 0, 0, Color.RED); 42 | 43 | 44 | path = new Path(); 45 | TX = 0; 46 | translate = false; 47 | 48 | flash = 0; 49 | 50 | } 51 | 52 | @Override 53 | public void onSizeChanged(int w, int h, int oldw, int oldh) { 54 | super.onSizeChanged(w, h, oldw, oldh); 55 | 56 | screenW = w; 57 | screenH = h; 58 | X = 0; 59 | Y = (screenH / 2) + (screenH / 4) + (screenH / 10); 60 | 61 | initialScreenW = screenW; 62 | initialX = ((screenW / 2) + (screenW / 4)); 63 | plusX = (screenW / 24); 64 | 65 | path.moveTo(X, Y); 66 | 67 | } 68 | 69 | 70 | @Override 71 | public void onDraw(Canvas canvas) { 72 | super.onDraw(canvas); 73 | 74 | //canvas.save(); 75 | 76 | 77 | flash += 1; 78 | if (flash < 10 || (flash > 20 && flash < 30)) { 79 | paint.setStrokeWidth(16); 80 | paint.setColor(Color.RED); 81 | paint.setShadowLayer(12, 0, 0, Color.RED); 82 | } else { 83 | paint.setStrokeWidth(10); 84 | paint.setColor(Color.argb(0xff, 0x99, 0x00, 0x00)); 85 | paint.setShadowLayer(7, 0, 0, Color.RED); 86 | } 87 | 88 | if (flash == 100) { 89 | flash = 0; 90 | } 91 | 92 | path.lineTo(X, Y); 93 | canvas.translate(-TX, 0); 94 | if (translate == true) { 95 | TX += 4; 96 | } 97 | 98 | if (X < initialX) { 99 | X += 8; 100 | } else { 101 | if (X < initialX + plusX) { 102 | X += 2; 103 | Y -= 8; 104 | } else { 105 | if (X < initialX + (plusX * 2)) { 106 | X += 2; 107 | Y += 14; 108 | } else { 109 | if (X < initialX + (plusX * 3)) { 110 | X += 2; 111 | Y -= 12; 112 | } else { 113 | if (X < initialX + (plusX * 4)) { 114 | X += 2; 115 | Y += 6; 116 | } else { 117 | if (X < initialScreenW) { 118 | X += 8; 119 | } else { 120 | translate = true; 121 | initialX = initialX + initialScreenW; 122 | } 123 | } 124 | } 125 | } 126 | } 127 | 128 | } 129 | 130 | canvas.drawPath(path, paint); 131 | 132 | 133 | //canvas.restore(); 134 | 135 | invalidate(); 136 | } 137 | } -------------------------------------------------------------------------------- /lib/src/main/java/devkhan/loaders/lib/HeartDrawView.java: -------------------------------------------------------------------------------- 1 | package devkhan.loaders.lib; 2 | 3 | import static java.lang.Math.cos; 4 | import static java.lang.Math.pow; 5 | import static java.lang.Math.sin; 6 | import static java.lang.Math.toRadians; 7 | 8 | import android.animation.ValueAnimator; 9 | import android.content.Context; 10 | import android.content.res.TypedArray; 11 | import android.graphics.Canvas; 12 | import android.graphics.Paint; 13 | import android.graphics.Path; 14 | import android.util.AttributeSet; 15 | import android.util.Log; 16 | import android.view.MotionEvent; 17 | import android.view.View; 18 | import android.view.animation.AnticipateOvershootInterpolator; 19 | 20 | import devkhan.loaders.lib.utils.MeasureUtils; 21 | 22 | /** 23 | * Beating Heart. Extends {@link View}. A Custom View. 24 | *

25 | * Created on 27-July-2015. 26 | * Modified on 28-July-2015. 27 | * 28 | * @author Devesh Khandelwal 29 | */ 30 | public class HeartDrawView extends View { 31 | protected int mTValue; 32 | protected Paint mHeartPaint; 33 | protected int mAngle = 0; 34 | protected Path mHeartOutline; 35 | protected int mX, mY, centerX, centerY; 36 | protected ValueAnimator mSizeAnimator; 37 | protected Path mEmptyPath = new Path(); 38 | private String LOG_TAG = getClass().getSimpleName(); 39 | 40 | /** 41 | * Simple constructor to use when creating a view from code. 42 | * 43 | * @param context The Context the view is running in, through which it can 44 | * access the current theme, resources, etc. 45 | */ 46 | public HeartDrawView(Context context) { 47 | super(context); 48 | } 49 | 50 | /** 51 | * Constructor that is called when inflating a view from XML. This is called 52 | * when a view is being constructed from an XML file, supplying attributes 53 | * that were specified in the XML file. This version uses a default style of 54 | * 0, so the only attribute values applied are those in the Context's Theme 55 | * and the given AttributeSet. 56 | *

57 | *

58 | * The method onFinishInflate() will be called after all children have been 59 | * added. 60 | * 61 | * @param context The Context the view is running in, through which it can 62 | * access the current theme, resources, etc. 63 | * @param attrs The attributes of the XML tag that is inflating the view. 64 | */ 65 | public HeartDrawView(Context context, AttributeSet attrs) { 66 | super(context, attrs); 67 | 68 | /** 69 | * Gets the defined attributes in the layout resource file as a {@link TypedArray}. 70 | */ 71 | TypedArray styledAttributes = context.getTheme().obtainStyledAttributes( 72 | attrs, 73 | R.styleable.HeartDrawView, 74 | 0, 0 75 | ); 76 | 77 | /** 78 | * Trying to extract defined attributes in the layout resource file. 79 | */ 80 | try { 81 | mTValue = styledAttributes.getInt(R.styleable.HeartDrawView_tValue, 10); 82 | 83 | } catch (Exception e) { 84 | e.printStackTrace(); 85 | } finally { 86 | styledAttributes.recycle(); 87 | } 88 | init(); 89 | } 90 | 91 | protected void init() { 92 | mHeartPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 93 | mHeartPaint.setStyle(Paint.Style.STROKE); 94 | mHeartPaint.setColor(0xffff0000); 95 | 96 | mHeartOutline = new Path(); 97 | 98 | /** 99 | * Animating size of the shape/path to be drawn. 100 | */ 101 | mSizeAnimator = ValueAnimator.ofFloat((float) (0.5 * mTValue), (float) mTValue); 102 | mSizeAnimator.setDuration(3000); 103 | mSizeAnimator.setInterpolator(new AnticipateOvershootInterpolator()); 104 | mSizeAnimator.setRepeatMode(ValueAnimator.REVERSE); 105 | mSizeAnimator.setRepeatCount(ValueAnimator.INFINITE); 106 | mSizeAnimator.start(); 107 | 108 | } 109 | 110 | @Override 111 | protected void onDraw(Canvas canvas) { 112 | super.onDraw(canvas); 113 | 114 | // Reallocating path to remove previous draws. 115 | mHeartOutline.reset(); 116 | 117 | // Resetting angle. 118 | mAngle = 360; 119 | Log.i(LOG_TAG, "Angle reset."); 120 | 121 | // Get the size of the shape to be drawn from the animator. 122 | float size = ((float) (mSizeAnimator.getAnimatedValue())); 123 | Log.i(LOG_TAG, "TValue animated value: " + mTValue); 124 | 125 | // Creating path for angle 360->0 degrees. 126 | while (mAngle != 0) { 127 | mHeartOutline.moveTo(mX, mY); 128 | mX = centerX + (int) (size * 16 * pow(sin(toRadians(mAngle)), 3)); 129 | mY = centerY + (int) (size * ((13 * cos(toRadians(mAngle))) - 5 * cos 130 | (2 * toRadians(mAngle)) - 2 * cos(3 * toRadians(mAngle)) - cos( 131 | 4 * toRadians(mAngle)))); 132 | mY *= -1; 133 | mY += getMeasuredHeight(); 134 | mHeartOutline.lineTo(mX, mY); 135 | mAngle -= 2; 136 | } 137 | 138 | // Draw the path. 139 | canvas.drawPath(mHeartOutline, mHeartPaint); 140 | Log.i(LOG_TAG, "Shape drawn."); 141 | /** 142 | * Waiting for sometime, mainly for animation purposes and litte bit performance issues. 143 | */ 144 | try { 145 | Thread.sleep(50); 146 | } catch (InterruptedException e) { 147 | e.printStackTrace(); 148 | } 149 | invalidate(); 150 | } 151 | 152 | @Override 153 | public boolean onTouchEvent(MotionEvent event) { 154 | centerX = (int) event.getX(); 155 | centerY = (int) event.getY(); 156 | 157 | postInvalidate(); 158 | return true; 159 | } 160 | 161 | @Override 162 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 163 | super.onSizeChanged(w, h, oldw, oldh); 164 | } 165 | 166 | @Override 167 | public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 168 | // Get the width measurement 169 | int widthSize = MeasureUtils.getMeasurement(widthMeasureSpec, getDesiredWidth()); 170 | 171 | // Get the height measurement 172 | int heightSize = MeasureUtils.getMeasurement(heightMeasureSpec, getDesiredHeight()); 173 | 174 | //MUST call this to store the measurements 175 | setMeasuredDimension(widthSize + 10, heightSize + 10); 176 | 177 | centerX = getMeasuredWidth() / 2; 178 | centerY = getMeasuredHeight() / 2; 179 | } 180 | 181 | /** 182 | * Calculates width from child components. 183 | * 184 | * @return Desired width in view. 185 | */ 186 | private int getDesiredWidth() { 187 | // TO-DO Calculate width from child components. 188 | 189 | return 2 * mTValue + 300; 190 | } 191 | 192 | /** 193 | * Calculate height from child components. 194 | * 195 | * @return Desired height of view. 196 | */ 197 | private int getDesiredHeight() { 198 | // TO-DO Calculate height from child components. 199 | return 2 * mTValue + 300; 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /lib/src/main/java/devkhan/loaders/lib/utils/MeasureUtils.java: -------------------------------------------------------------------------------- 1 | package devkhan.loaders.lib.utils; 2 | 3 | import android.view.View; 4 | 5 | /** 6 | * Created by Devesh on 08-Jun-15. 7 | */ 8 | public class MeasureUtils { 9 | /** 10 | * Utility to return a view's standard measurement. Uses the 11 | * supplied size when constraints are given. Attempts to 12 | * hold to the desired size unless it conflicts with provided 13 | * constraints. 14 | * 15 | * @param measureSpec Constraints imposed by the parent 16 | * @param contentSize Desired size for the view 17 | * @return The size the view should be. 18 | */ 19 | public static int getMeasurement(int measureSpec, int contentSize) { 20 | int specMode = View.MeasureSpec.getMode(measureSpec); 21 | int specSize = View.MeasureSpec.getSize(measureSpec); 22 | int resultSize = 0; 23 | switch (specMode) { 24 | case View.MeasureSpec.UNSPECIFIED: 25 | //Big as we want to be 26 | resultSize = contentSize; 27 | break; 28 | case View.MeasureSpec.AT_MOST: 29 | //Big as we want to be, up to the spec 30 | resultSize = Math.min(contentSize, specSize); 31 | break; 32 | case View.MeasureSpec.EXACTLY: 33 | //Must be the spec size 34 | resultSize = specSize; 35 | break; 36 | } 37 | 38 | return resultSize; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lib/src/main/java/devkhan/loaders/lib/utils/Utils.java: -------------------------------------------------------------------------------- 1 | package devkhan.loaders.lib.utils; 2 | 3 | import android.graphics.Color; 4 | import android.support.v4.view.animation.FastOutLinearInInterpolator; 5 | import android.support.v4.view.animation.FastOutSlowInInterpolator; 6 | import android.support.v4.view.animation.LinearOutSlowInInterpolator; 7 | import android.view.animation.AccelerateDecelerateInterpolator; 8 | import android.view.animation.AccelerateInterpolator; 9 | import android.view.animation.AnticipateInterpolator; 10 | import android.view.animation.AnticipateOvershootInterpolator; 11 | import android.view.animation.BounceInterpolator; 12 | import android.view.animation.DecelerateInterpolator; 13 | import android.view.animation.Interpolator; 14 | import android.view.animation.LinearInterpolator; 15 | import android.view.animation.OvershootInterpolator; 16 | 17 | import java.util.ArrayList; 18 | import java.util.Random; 19 | 20 | /** 21 | * Methods useful in many other reduntant tasks. 22 | *

23 | * Created on 12-July-15. 24 | * Modified on 12-July-2015. 25 | * 26 | * @author Devesh Khandelwal 27 | */ 28 | public class Utils { 29 | 30 | /** 31 | * Selects and returns a random {@link Interpolator} from a predefined set of interpolator. 32 | * 33 | * @return A random interpolator object. 34 | */ 35 | public static Interpolator randomInterpolator() { 36 | Random rnd = new Random(); 37 | 38 | ArrayList interpolatorList = new ArrayList<>(); 39 | interpolatorList.add(new AccelerateDecelerateInterpolator()); 40 | interpolatorList.add(new AccelerateInterpolator()); 41 | interpolatorList.add(new AnticipateInterpolator()); 42 | interpolatorList.add(new AnticipateOvershootInterpolator()); 43 | interpolatorList.add(new BounceInterpolator()); 44 | interpolatorList.add(new DecelerateInterpolator()); 45 | interpolatorList.add(new FastOutLinearInInterpolator()); 46 | interpolatorList.add(new FastOutSlowInInterpolator()); 47 | interpolatorList.add(new LinearInterpolator()); 48 | interpolatorList.add(new LinearOutSlowInInterpolator()); 49 | interpolatorList.add(new OvershootInterpolator()); 50 | 51 | return interpolatorList.get(rnd.nextInt(11)); 52 | } 53 | 54 | /** 55 | * Generates a random ARGB {@link Color}. 56 | * 57 | * @return Random {@link Color} as an integer. 58 | */ 59 | public static int randomColor() { 60 | Random rnd = new Random(); 61 | 62 | return Color.argb(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)); 63 | } 64 | 65 | public static float constrain(float min, float max, float v) { 66 | return Math.max(min, Math.min(max, v)); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/src/main/res/drawable/black_square.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkhan/Loaders/b4ceef1e8daefa2379d5e0eb976a0c34788c48fb/lib/src/main/res/drawable/black_square.jpg -------------------------------------------------------------------------------- /lib/src/main/res/layout/custom_progress_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 16 | 23 | 30 | 39 | -------------------------------------------------------------------------------- /lib/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 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 48 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /lib/src/main/res/values/color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ffffff 4 | #2196F3 5 | -------------------------------------------------------------------------------- /lib/src/main/res/values/dimen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1dp 4 | 185dp 5 | 2dp 6 | -------------------------------------------------------------------------------- /lib/src/main/res/values/integers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 2000 4 | 1000 5 | -------------------------------------------------------------------------------- /lib/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Loaders 3 | 4 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':lib' 2 | --------------------------------------------------------------------------------