├── app
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── values
│ │ │ ├── strings.xml
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ └── styles.xml
│ │ ├── drawable
│ │ │ └── girl.jpg
│ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ └── layout
│ │ │ └── activity_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── lj_3d
│ │ └── gearloadingproject
│ │ └── MainActivity.java
├── build.gradle
└── proguard-rules.pro
├── .idea
├── .name
├── dictionaries
│ └── LJ.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── compiler.xml
├── gradle.xml
└── misc.xml
├── gearloadinglayout
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── values
│ │ │ ├── strings.xml
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ ├── styles.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── attrs.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ ├── colors.xml
│ │ │ ├── styles.xml
│ │ │ ├── attrs.xml
│ │ │ └── dimens.xml
│ │ ├── drawable
│ │ │ ├── cloud.png
│ │ │ ├── girl.jpg
│ │ │ └── shadow.xml
│ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ └── layout
│ │ │ ├── test.xml
│ │ │ ├── layout_one_gear.xml
│ │ │ ├── layout_two_gears.xml
│ │ │ └── layout_three_gears.xml
│ │ ├── java
│ │ └── lj_3d
│ │ │ └── gearloadinglayout
│ │ │ ├── enums
│ │ │ ├── Style.java
│ │ │ ├── Type.java
│ │ │ └── ShowMode.java
│ │ │ ├── interfaces
│ │ │ └── OnBlurCompleteInterface.java
│ │ │ ├── utils
│ │ │ ├── DeviceScreenHelper.java
│ │ │ ├── GearDialogBuilder.java
│ │ │ └── FastBlur.java
│ │ │ └── gearViews
│ │ │ ├── CutOutLayout.java
│ │ │ ├── OneGearLayout.java
│ │ │ ├── TwoGearsLayout.java
│ │ │ ├── ThreeGearsLayout.java
│ │ │ ├── GearView.java
│ │ │ └── GearLoadingLayout.java
│ │ └── AndroidManifest.xml
├── build.gradle
└── proguard-rules.pro
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── gradlew
├── README.md
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | GearLoadingProject
--------------------------------------------------------------------------------
/gearloadinglayout/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':gearloadinglayout'
2 |
--------------------------------------------------------------------------------
/.idea/dictionaries/LJ.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | GearLoadingProject
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/girl.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Devlight/GearLoadingProject/HEAD/app/src/main/res/drawable/girl.jpg
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Devlight/GearLoadingProject/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | GearLoadingLayout
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Devlight/GearLoadingProject/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Devlight/GearLoadingProject/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Devlight/GearLoadingProject/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Devlight/GearLoadingProject/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Devlight/GearLoadingProject/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/drawable/cloud.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Devlight/GearLoadingProject/HEAD/gearloadinglayout/src/main/res/drawable/cloud.png
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/drawable/girl.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Devlight/GearLoadingProject/HEAD/gearloadinglayout/src/main/res/drawable/girl.jpg
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Devlight/GearLoadingProject/HEAD/gearloadinglayout/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Devlight/GearLoadingProject/HEAD/gearloadinglayout/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Devlight/GearLoadingProject/HEAD/gearloadinglayout/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Devlight/GearLoadingProject/HEAD/gearloadinglayout/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Devlight/GearLoadingProject/HEAD/gearloadinglayout/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/values/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 | #D6D5D6
3 | #D5DEE4
4 |
5 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/java/lj_3d/gearloadinglayout/enums/Style.java:
--------------------------------------------------------------------------------
1 | package lj_3d.gearloadinglayout.enums;
2 |
3 | /**
4 | * Created by LJ on 18.04.2016.
5 | */
6 | public enum Style {
7 | SNACK_BAR, DIALOG
8 | }
9 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/java/lj_3d/gearloadinglayout/enums/Type.java:
--------------------------------------------------------------------------------
1 | package lj_3d.gearloadinglayout.enums;
2 |
3 | /**
4 | * Created by LJ on 23.03.2016.
5 | */
6 | public enum Type {
7 | ONE_GEAR, TWO_GEARS, THREE_GEARS
8 | }
9 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/java/lj_3d/gearloadinglayout/enums/ShowMode.java:
--------------------------------------------------------------------------------
1 | package lj_3d.gearloadinglayout.enums;
2 |
3 | /**
4 | * Created by LJ on 23.03.2016.
5 | */
6 | public enum ShowMode {
7 | TOP, BOTTOM, LEFT, RIGHT, CENTER
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/values/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | GearLoadingLayout
3 |
4 | Hello world!
5 | Settings
6 |
7 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/values/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/drawable/shadow.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
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-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/java/lj_3d/gearloadinglayout/interfaces/OnBlurCompleteInterface.java:
--------------------------------------------------------------------------------
1 | package lj_3d.gearloadinglayout.interfaces;
2 |
3 | /**
4 | * Created by LJ on 22.03.2016.
5 | */
6 | public interface OnBlurCompleteInterface {
7 |
8 | public void onBlurComplete();
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/values/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 240dp
6 | 2dp
7 | 10dp
8 |
9 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/values/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #D6D5D6
7 | #D5DEE4
8 |
9 | #868686
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | applicationId "lj_3d.gearloadingproject"
9 | minSdkVersion 14
10 | targetSdkVersion 23
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 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile 'com.android.support:appcompat-v7:23.1.1'
25 | compile project(':gearloadinglayout')
26 | }
27 |
--------------------------------------------------------------------------------
/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 C:\Program Files\Android\Android Studio\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 |
--------------------------------------------------------------------------------
/gearloadinglayout/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | // applicationId "lj_3d.gearloadinglayout"
9 | minSdkVersion 14
10 | targetSdkVersion 23
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 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.1.1'
26 | }
27 |
--------------------------------------------------------------------------------
/gearloadinglayout/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 C:\Program Files\Android\Android Studio\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 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/java/lj_3d/gearloadinglayout/utils/DeviceScreenHelper.java:
--------------------------------------------------------------------------------
1 | package lj_3d.gearloadinglayout.utils;
2 |
3 | import android.app.Activity;
4 | import android.util.DisplayMetrics;
5 |
6 | /**
7 | * Created by LJ on 18.04.2016.
8 | */
9 | public class DeviceScreenHelper {
10 |
11 | public static int mDeviceWidth;
12 | public static int mDeviceHeight;
13 | public static boolean isDialogMode;
14 |
15 | public static void init(final Activity activity) {
16 | if (activity == null) return;
17 | DisplayMetrics displaymetrics = new DisplayMetrics();
18 | activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
19 | mDeviceHeight = displaymetrics.heightPixels;
20 | mDeviceWidth = displaymetrics.widthPixels;
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/values/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/layout/test.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
42 |
43 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/java/lj_3d/gearloadinglayout/utils/GearDialogBuilder.java:
--------------------------------------------------------------------------------
1 | package lj_3d.gearloadinglayout.utils;
2 |
3 | import android.app.Activity;
4 | import android.view.ViewGroup;
5 |
6 | import lj_3d.gearloadinglayout.gearViews.GearLoadingLayout;
7 | import lj_3d.gearloadinglayout.gearViews.OneGearLayout;
8 | import lj_3d.gearloadinglayout.gearViews.ThreeGearsLayout;
9 | import lj_3d.gearloadinglayout.gearViews.TwoGearsLayout;
10 |
11 | /**
12 | * Created by LJ on 21.03.2016.
13 | */
14 | public class GearDialogBuilder {
15 |
16 | private static GearDialogBuilder mGearLoadingBuilder;
17 |
18 | private Activity mActivity;
19 | private ViewGroup mRootViewGroup;
20 | private GearLoadingLayout mGearLoadingLayout;
21 |
22 | public static GearDialogBuilder getInstance(final Activity activity) {
23 | if (mGearLoadingBuilder == null)
24 | mGearLoadingBuilder = new GearDialogBuilder();
25 |
26 | mGearLoadingBuilder.mActivity = activity;
27 | mGearLoadingBuilder.mRootViewGroup = ((ViewGroup) activity.findViewById(android.R.id.content));
28 |
29 | DeviceScreenHelper.init(activity);
30 | return mGearLoadingBuilder;
31 | }
32 |
33 | /**
34 | * Method that define type of GearLoadingLayout
35 | *
36 | * @param type is a type of child class that extend GearLoadingLayout
37 | * @return GearLoadingLayout that casted to child layout, in accordance with type of class
38 | */
39 |
40 | public T setType(Class type) {
41 | DeviceScreenHelper.isDialogMode = true;
42 | switch (type.getSimpleName()) {
43 | case OneGearLayout.IDENTIFIER:
44 | mGearLoadingLayout = new OneGearLayout(mActivity);
45 | break;
46 | case TwoGearsLayout.IDENTIFIER:
47 | mGearLoadingLayout = new TwoGearsLayout(mActivity);
48 | break;
49 | case ThreeGearsLayout.IDENTIFIER:
50 | mGearLoadingLayout = new ThreeGearsLayout(mActivity);
51 | break;
52 | default:
53 | mGearLoadingLayout = new ThreeGearsLayout(mActivity);
54 | break;
55 | }
56 | mGearLoadingLayout.setActivityContentView(mRootViewGroup);
57 | return type.cast(mGearLoadingLayout);
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/layout/layout_one_gear.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
16 |
20 |
21 |
22 |
26 |
27 |
33 |
34 |
43 |
44 |
45 |
46 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 1dp
3 | 5dp
4 | 10dp
5 |
6 | 120dp
7 | 100dp
8 | 90dp
9 |
10 | 40dp
11 |
12 | 9dp
13 | 60dp
14 | 45dp
15 | 7dp
16 | 35dp
17 | -15dp
18 | 6dp
19 | 55dp
20 | 45dp
21 | 6dp
22 | -24dp
23 | -60dp
24 | 14dp
25 | 60dp
26 | 50dp
27 | 8dp
28 |
29 | 10dp
30 | 70dp
31 | 55dp
32 | 9dp
33 | 63dp
34 | 31dp
35 | 6dp
36 | 55dp
37 | 44dp
38 | 7dp
39 | 10dp
40 | 70dp
41 | 55dp
42 | 10dp
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/layout/layout_two_gears.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
16 |
20 |
21 |
22 |
26 |
27 |
33 |
34 |
43 |
44 |
55 |
56 |
57 |
58 |
59 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | 1.7
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/java/lj_3d/gearloadinglayout/gearViews/CutOutLayout.java:
--------------------------------------------------------------------------------
1 | package lj_3d.gearloadinglayout.gearViews;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Paint;
8 | import android.graphics.PorterDuff;
9 | import android.graphics.PorterDuffXfermode;
10 | import android.util.AttributeSet;
11 | import android.view.View;
12 |
13 | import lj_3d.gearloadinglayout.R;
14 |
15 |
16 | /**
17 | * Created by LJ on 28.09.2015.
18 | */
19 | public class CutOutLayout extends View {
20 |
21 | private int color;
22 | private int cutRadius;
23 | private int height = 218;
24 | private int width = 620;
25 | private Paint paint;
26 | private Paint shadow;
27 | private final PorterDuffXfermode mPorterDuffXfermode = new PorterDuffXfermode(PorterDuff.Mode.CLEAR);
28 |
29 | public void setColor(int backgroundColor) {
30 | this.color = backgroundColor;
31 | }
32 |
33 | public void setWidth(int width) {
34 | this.width = width;
35 | requestLayout();
36 | }
37 |
38 | public void setHeight(int height) {
39 | this.height = height;
40 | requestLayout();
41 | }
42 |
43 | public void setCutRadius(int cutRadius) {
44 | if (cutRadius == 0)
45 | return;
46 | this.cutRadius = cutRadius;
47 | requestLayout();
48 | }
49 |
50 |
51 | public CutOutLayout(Context context) {
52 | super(context);
53 | }
54 |
55 | public CutOutLayout(Context context, AttributeSet attrs) {
56 | super(context, attrs);
57 | parseAttributes(attrs);
58 | initTools();
59 | }
60 |
61 | public CutOutLayout(Context context, AttributeSet attrs, int defStyleAttr) {
62 | super(context, attrs, defStyleAttr);
63 | parseAttributes(attrs);
64 | initTools();
65 | }
66 |
67 |
68 | @Override
69 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
70 | width = w;
71 | height = h;
72 | super.onSizeChanged(w, h, oldw, oldh);
73 | }
74 |
75 | private void initTools() {
76 | paint = new Paint();
77 | shadow = new Paint();
78 | shadow.setShadowLayer(15, 0.0f, 0.0f, getResources().getColor(R.color.shadow_grey));
79 | shadow.setAntiAlias(true);
80 | shadow.setDither(true);
81 | shadow.setColor(getResources().getColor(R.color.shadow_grey));
82 | shadow.setStyle(Paint.Style.STROKE);
83 | shadow.setAlpha(70);
84 | shadow.setStrokeWidth(7);
85 | paint.setStyle(Paint.Style.FILL_AND_STROKE);
86 | paint.setXfermode(mPorterDuffXfermode);
87 | }
88 |
89 | private void parseAttributes(AttributeSet attrs) {
90 | TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CutOutLayout);
91 |
92 | color = a.getColor(R.styleable.CutOutLayout_cutLayoutColor, Color.WHITE);
93 | setColor(color);
94 |
95 | cutRadius = (int) a.getDimension(R.styleable.CutOutLayout_cutRadius, 50);
96 | setCutRadius(cutRadius);
97 |
98 | a.recycle();
99 | requestLayout();
100 | }
101 |
102 | @Override
103 | protected void onDraw(Canvas canvas) {
104 | super.onDraw(canvas);
105 | canvas.drawColor(color);
106 | canvas.drawCircle(width / 2, height / 2, cutRadius, paint);
107 | canvas.drawCircle(width / 2, height / 2, cutRadius, shadow);
108 | }
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
14 |
15 |
20 |
21 |
27 |
28 |
33 |
34 |
39 |
40 |
41 |
42 |
51 |
52 |
62 |
63 |
70 |
71 |
78 |
79 |
87 |
88 |
96 |
97 |
98 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/res/layout/layout_three_gears.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
16 |
20 |
21 |
22 |
26 |
27 |
33 |
34 |
46 |
47 |
61 |
62 |
77 |
78 |
79 |
80 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/java/lj_3d/gearloadinglayout/gearViews/OneGearLayout.java:
--------------------------------------------------------------------------------
1 | package lj_3d.gearloadinglayout.gearViews;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Color;
6 | import android.util.AttributeSet;
7 | import android.view.View;
8 |
9 | import lj_3d.gearloadinglayout.R;
10 | import lj_3d.gearloadinglayout.enums.ShowMode;
11 | import lj_3d.gearloadinglayout.enums.Style;
12 | import lj_3d.gearloadinglayout.utils.DeviceScreenHelper;
13 |
14 | /**
15 | * Created by LJ on 23.03.2016.
16 | */
17 | public class OneGearLayout extends GearLoadingLayout {
18 |
19 | public static final String IDENTIFIER = "OneGearLayout";
20 |
21 | private GearView mFirstGearView;
22 |
23 | public OneGearLayout(Context context) {
24 | super(context);
25 | addChildView();
26 | }
27 |
28 | public OneGearLayout(Context context, AttributeSet attrs) {
29 | super(context, attrs);
30 | addChildView();
31 | parseAttributes(attrs);
32 | }
33 |
34 | public OneGearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
35 | super(context, attrs, defStyleAttr);
36 | addChildView();
37 | parseAttributes(attrs);
38 | }
39 |
40 | private void addChildView() {
41 | final View childView = inflate(getContext(), R.layout.layout_one_gear, null);
42 | initUI(childView);
43 | addView(childView);
44 | }
45 |
46 | protected void initUI(View rootView) {
47 | super.initUI(rootView);
48 | initDimensions();
49 | mFirstGearView = (GearView) rootView.findViewById(R.id.gear_view);
50 | }
51 |
52 | private void initDimensions() {
53 | mDialogWidth = DeviceScreenHelper.mDeviceWidth;
54 | if (DeviceScreenHelper.isDialogMode)
55 | mDialogHeight = mResources.getDimensionPixelSize(R.dimen.three_gear_layout_wrapper_height);
56 | }
57 |
58 | public void start() {
59 | mFirstGearView.startSpinning(false);
60 | }
61 |
62 |
63 |
64 | public OneGearLayout setDuration(final int duration) {
65 | mFirstGearView.setDuration(duration);
66 | return this;
67 | }
68 |
69 | public OneGearLayout setFirstGearColor(int color) {
70 | mFirstGearView.setColor(color);
71 | return this;
72 | }
73 |
74 | public OneGearLayout setFirstGearInnerColor(int color) {
75 | setFirstGearInnerColor(color, false);
76 | return this;
77 | }
78 |
79 | private OneGearLayout setFirstGearInnerColor(int color, boolean enableCuttedCenter) {
80 | mFirstGearView.setInnerColor(color);
81 | mFirstGearView.enableCuttedCenter(enableCuttedCenter);
82 | return this;
83 | }
84 |
85 | public OneGearLayout setStyle(final Style style) {
86 | super.setStyle(style);
87 | return this;
88 | }
89 |
90 | public OneGearLayout setDialogBackgroundColor(int color) {
91 | super.setDialogBackgroundColor(color);
92 | return this;
93 | }
94 |
95 | public OneGearLayout setDialogBackgroundAlpha(float alpha) {
96 | super.setDialogBackgroundAlpha(alpha);
97 | return this;
98 | }
99 |
100 | public OneGearLayout setMainBackgroundColor(int color) {
101 | super.setMainBackgroundColor(color);
102 | return this;
103 | }
104 |
105 | public OneGearLayout setMainBackgroundAlpha(float alpha) {
106 | super.setMainBackgroundAlpha(alpha);
107 | return this;
108 | }
109 |
110 | public OneGearLayout enableCutLayout(boolean enable) {
111 | super.enableCutLayout(enable);
112 | return this;
113 | }
114 |
115 | public OneGearLayout setCutRadius(int radius) {
116 | super.setCutRadius(radius);
117 | return this;
118 | }
119 |
120 | public OneGearLayout setCutLayoutColor(int color) {
121 | super.setCutLayoutColor(color);
122 | return this;
123 | }
124 |
125 | public OneGearLayout setCutLayoutAlpha(float alpha) {
126 | super.setCutLayoutAlpha(alpha);
127 | return this;
128 | }
129 |
130 | public OneGearLayout setShowMode(ShowMode showMode) {
131 | super.setShowMode(showMode);
132 | return this;
133 | }
134 |
135 | public OneGearLayout setShowDialogDuration(int showDialogDuration) {
136 | super.setShowDialogDuration(showDialogDuration);
137 | return this;
138 | }
139 |
140 | public OneGearLayout blurBackground(boolean enable) {
141 | super.blurBackground(enable);
142 | return this;
143 | }
144 |
145 | public OneGearLayout setCancelable(boolean cancelable) {
146 | super.setCancelable(cancelable);
147 | return this;
148 | }
149 |
150 | protected void parseAttributes(AttributeSet attrs) {
151 | super.parseAttributes(attrs);
152 | TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.GearLoadingLayout);
153 | setFirstGearColor(a.getColor(R.styleable.GearLoadingLayout_firstGearColor, Color.GRAY));
154 | setFirstGearInnerColor(a.getColor(R.styleable.GearLoadingLayout_firstInnerGearColor, Color.WHITE), a.getBoolean(R.styleable.GearLoadingLayout_firstGearCuttedCenter, true));
155 | a.recycle();
156 | requestLayout();
157 | }
158 |
159 | }
160 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/java/lj_3d/gearloadinglayout/gearViews/TwoGearsLayout.java:
--------------------------------------------------------------------------------
1 | package lj_3d.gearloadinglayout.gearViews;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Color;
6 | import android.util.AttributeSet;
7 | import android.view.View;
8 |
9 | import lj_3d.gearloadinglayout.R;
10 | import lj_3d.gearloadinglayout.enums.ShowMode;
11 | import lj_3d.gearloadinglayout.enums.Style;
12 | import lj_3d.gearloadinglayout.utils.DeviceScreenHelper;
13 |
14 | /**
15 | * Created by LJ on 23.03.2016.
16 | */
17 | public class TwoGearsLayout extends GearLoadingLayout {
18 |
19 | public static final String IDENTIFIER = "TwoGearsLayout";
20 |
21 | private GearView mFirstGearView;
22 | private GearView mSecondGearView;
23 |
24 | public TwoGearsLayout(Context context) {
25 | super(context);
26 | addChildView();
27 | }
28 |
29 | public TwoGearsLayout(Context context, AttributeSet attrs) {
30 | super(context, attrs);
31 | addChildView();
32 | parseAttributes(attrs);
33 | }
34 |
35 | public TwoGearsLayout(Context context, AttributeSet attrs, int defStyleAttr) {
36 | super(context, attrs, defStyleAttr);
37 | addChildView();
38 | parseAttributes(attrs);
39 | }
40 |
41 | private void addChildView() {
42 | final View childView = inflate(getContext(), R.layout.layout_two_gears, null);
43 | initUI(childView);
44 | addView(childView);
45 | }
46 |
47 | protected void initUI(View rootView) {
48 | super.initUI(rootView);
49 | initDimensions();
50 | mFirstGearView = (GearView) rootView.findViewById(R.id.gear_view);
51 | mSecondGearView = (GearView) rootView.findViewById(R.id.gear_view_second);
52 | }
53 |
54 | private void initDimensions() {
55 | mDialogWidth = DeviceScreenHelper.mDeviceWidth;
56 | if (DeviceScreenHelper.isDialogMode)
57 | mDialogHeight = mResources.getDimensionPixelSize(R.dimen.three_gear_layout_wrapper_height);
58 | }
59 |
60 | public void start() {
61 | mFirstGearView.startSpinning(false);
62 | mSecondGearView.startSpinning(true);
63 | }
64 |
65 | public TwoGearsLayout setDuration(final int duration) {
66 | mFirstGearView.setDuration(duration);
67 | mSecondGearView.setDuration(duration);
68 | return this;
69 | }
70 |
71 | public TwoGearsLayout setFirstGearColor(int color) {
72 | mFirstGearView.setColor(color);
73 | return this;
74 | }
75 |
76 | public TwoGearsLayout setSecondGearColor(int color) {
77 | mSecondGearView.setColor(color);
78 | return this;
79 | }
80 |
81 |
82 | public TwoGearsLayout setFirstGearInnerColor(int color) {
83 | setFirstGearInnerColor(color, false);
84 | return this;
85 | }
86 |
87 | public TwoGearsLayout setSecondGearInnerColor(int color) {
88 | setSecondGearInnerColor(color, false);
89 | return this;
90 | }
91 |
92 |
93 | private TwoGearsLayout setFirstGearInnerColor(int color, boolean enableCuttedCenter) {
94 | mFirstGearView.setInnerColor(color);
95 | mFirstGearView.enableCuttedCenter(enableCuttedCenter);
96 | return this;
97 | }
98 |
99 | private TwoGearsLayout setSecondGearInnerColor(int color, boolean enableCuttedCenter) {
100 | mSecondGearView.setInnerColor(color);
101 | mSecondGearView.enableCuttedCenter(enableCuttedCenter);
102 | return this;
103 | }
104 |
105 | public TwoGearsLayout setStyle(final Style style) {
106 | super.setStyle(style);
107 | return this;
108 | }
109 |
110 | public TwoGearsLayout setDialogBackgroundColor(int color) {
111 | super.setDialogBackgroundColor(color);
112 | return this;
113 | }
114 |
115 | public TwoGearsLayout setDialogBackgroundAlpha(float alpha) {
116 | super.setDialogBackgroundAlpha(alpha);
117 | return this;
118 | }
119 |
120 | public TwoGearsLayout setMainBackgroundColor(int color) {
121 | super.setMainBackgroundColor(color);
122 | return this;
123 | }
124 |
125 | public TwoGearsLayout setMainBackgroundAlpha(float alpha) {
126 | super.setMainBackgroundAlpha(alpha);
127 | return this;
128 | }
129 |
130 | public TwoGearsLayout enableCutLayout(boolean enable) {
131 | super.enableCutLayout(enable);
132 | return this;
133 | }
134 |
135 | public TwoGearsLayout setCutRadius(int radius) {
136 | super.setCutRadius(radius);
137 | return this;
138 | }
139 |
140 | public TwoGearsLayout setCutLayoutColor(int color) {
141 | super.setCutLayoutColor(color);
142 | return this;
143 | }
144 |
145 | public TwoGearsLayout setCutLayoutAlpha(float alpha) {
146 | super.setCutLayoutAlpha(alpha);
147 | return this;
148 | }
149 |
150 | public TwoGearsLayout setShowMode(ShowMode showMode) {
151 | super.setShowMode(showMode);
152 | return this;
153 | }
154 |
155 | public TwoGearsLayout setShowDialogDuration(int showDialogDuration) {
156 | super.setShowDialogDuration(showDialogDuration);
157 | return this;
158 | }
159 |
160 | public TwoGearsLayout blurBackground(boolean enable) {
161 | super.blurBackground(enable);
162 | return this;
163 | }
164 |
165 | public TwoGearsLayout setCancelable(boolean cancelable) {
166 | super.setCancelable(cancelable);
167 | return this;
168 | }
169 |
170 |
171 | protected void parseAttributes(AttributeSet attrs) {
172 | super.parseAttributes(attrs);
173 |
174 | TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.GearLoadingLayout);
175 |
176 | setFirstGearColor(a.getColor(R.styleable.GearLoadingLayout_firstGearColor, Color.GRAY));
177 | setSecondGearColor(a.getColor(R.styleable.GearLoadingLayout_secondGearColor, Color.GRAY));
178 |
179 | setFirstGearInnerColor(a.getColor(R.styleable.GearLoadingLayout_firstInnerGearColor, Color.WHITE), a.getBoolean(R.styleable.GearLoadingLayout_firstGearCuttedCenter, true));
180 | setSecondGearInnerColor(a.getColor(R.styleable.GearLoadingLayout_secondInnerGearColor, Color.WHITE), a.getBoolean(R.styleable.GearLoadingLayout_secondGearCuttedCenter, true));
181 |
182 | a.recycle();
183 | requestLayout();
184 | }
185 | }
186 |
--------------------------------------------------------------------------------
/app/src/main/java/lj_3d/gearloadingproject/MainActivity.java:
--------------------------------------------------------------------------------
1 | package lj_3d.gearloadingproject;
2 |
3 | import android.content.res.Resources;
4 | import android.graphics.Color;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.CheckBox;
10 | import android.widget.CompoundButton;
11 | import android.widget.RadioGroup;
12 |
13 | import lj_3d.gearloadinglayout.enums.ShowMode;
14 | import lj_3d.gearloadinglayout.enums.Style;
15 | import lj_3d.gearloadinglayout.enums.Type;
16 | import lj_3d.gearloadinglayout.gearViews.GearView;
17 | import lj_3d.gearloadinglayout.utils.GearDialogBuilder;
18 | import lj_3d.gearloadinglayout.gearViews.OneGearLayout;
19 | import lj_3d.gearloadinglayout.gearViews.ThreeGearsLayout;
20 | import lj_3d.gearloadinglayout.gearViews.TwoGearsLayout;
21 |
22 | public class MainActivity extends AppCompatActivity implements View.OnClickListener {
23 |
24 | private Type mSelectedType = Type.ONE_GEAR;
25 | private Resources mResources;
26 | private boolean blur;
27 | private Style mStyle = Style.SNACK_BAR;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 |
33 | ViewGroup rootView = (ViewGroup) View.inflate(this, R.layout.activity_main, null);
34 | setContentView(rootView);
35 |
36 | mResources = getResources();
37 |
38 | final View topButton = findViewById(R.id.btn_top);
39 | final View centerButton = findViewById(R.id.btn_center);
40 | final View bottomButton = findViewById(R.id.btn_bottom);
41 | final View leftButton = findViewById(R.id.btn_left);
42 | final View rightButton = findViewById(R.id.btn_rigth);
43 |
44 | final CheckBox enableBlur = (CheckBox) findViewById(R.id.cb_blur);
45 | final CheckBox style = (CheckBox)findViewById(R.id.cb_mode);
46 |
47 | final RadioGroup radioGroup = (RadioGroup) findViewById(R.id.rg_types);
48 | radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
49 | @Override
50 | public void onCheckedChanged(RadioGroup group, int checkedId) {
51 | switch (checkedId) {
52 | case R.id.cb_one_gear:
53 | mSelectedType = Type.ONE_GEAR;
54 | break;
55 | case R.id.cb_two_gears:
56 | mSelectedType = Type.TWO_GEARS;
57 | break;
58 | case R.id.cb_three_gears:
59 | mSelectedType = Type.THREE_GEARS;
60 | break;
61 | }
62 | }
63 | });
64 |
65 | enableBlur.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
66 | @Override
67 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
68 | blur = isChecked;
69 | }
70 | });
71 |
72 | style.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
73 | @Override
74 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
75 | mStyle = isChecked ? Style.SNACK_BAR : Style.DIALOG;
76 | }
77 | });
78 |
79 | enableBlur.setChecked(true);
80 | style.setChecked(true);
81 | //
82 | topButton.setTag(ShowMode.TOP);
83 | centerButton.setTag(ShowMode.CENTER);
84 | bottomButton.setTag(ShowMode.BOTTOM);
85 | leftButton.setTag(ShowMode.LEFT);
86 | rightButton.setTag(ShowMode.RIGHT);
87 |
88 | topButton.setOnClickListener(this);
89 | centerButton.setOnClickListener(this);
90 | bottomButton.setOnClickListener(this);
91 | leftButton.setOnClickListener(this);
92 | rightButton.setOnClickListener(this);
93 | }
94 |
95 | @Override
96 | public void onClick(View v) {
97 | final ShowMode showMode = (ShowMode) v.getTag();
98 | switch (mSelectedType) {
99 | case ONE_GEAR:
100 | GearDialogBuilder.getInstance(MainActivity.this)
101 | .setType(OneGearLayout.class)
102 | .setShowDialogDuration(200)
103 | .setShowMode(showMode)
104 | .setDuration(3000)
105 | .blurBackground(blur)
106 | .enableCutLayout(false)
107 | .setDialogBackgroundAlpha(0.5f)
108 | .setStyle(mStyle)
109 | .setDialogBackgroundColor(mResources.getColor(R.color.colorAccent))
110 | .setFirstGearColor(mResources.getColor(R.color.colorPrimaryDark))
111 | .show();
112 | break;
113 | case TWO_GEARS:
114 | GearDialogBuilder.getInstance(MainActivity.this)
115 | .setType(TwoGearsLayout.class)
116 | .setShowDialogDuration(200)
117 | .setShowMode(showMode)
118 | .setDuration(3000)
119 | .blurBackground(blur)
120 | .enableCutLayout(false)
121 | .setDialogBackgroundAlpha(0.5f)
122 | .setStyle(mStyle)
123 | .setDialogBackgroundColor(mResources.getColor(R.color.colorAccent))
124 | .setFirstGearColor(mResources.getColor(R.color.colorPrimaryDark))
125 | .setSecondGearColor(mResources.getColor(R.color.dialog_stroke_color))
126 | .show();
127 | break;
128 | case THREE_GEARS:
129 | GearDialogBuilder.getInstance(MainActivity.this)
130 | .setType(ThreeGearsLayout.class)
131 | .setShowDialogDuration(200)
132 | .setShowMode(showMode)
133 | .setDuration(3000)
134 | .blurBackground(blur)
135 | .enableCutLayout(false)
136 | .setDialogBackgroundAlpha(0.5f)
137 | .setStyle(mStyle)
138 | .setDialogBackgroundColor(mResources.getColor(R.color.colorAccent))
139 | .setFirstGearColor(mResources.getColor(R.color.colorPrimaryDark))
140 | .setSecondGearColor(mResources.getColor(R.color.dialog_stroke_color))
141 | .setThirdGearColor(mResources.getColor(R.color.colorPrimary))
142 | .show();
143 | break;
144 | }
145 |
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/java/lj_3d/gearloadinglayout/gearViews/ThreeGearsLayout.java:
--------------------------------------------------------------------------------
1 | package lj_3d.gearloadinglayout.gearViews;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.content.res.TypedArray;
6 | import android.graphics.Color;
7 | import android.util.AttributeSet;
8 | import android.view.View;
9 |
10 | import lj_3d.gearloadinglayout.R;
11 | import lj_3d.gearloadinglayout.enums.ShowMode;
12 | import lj_3d.gearloadinglayout.enums.Style;
13 | import lj_3d.gearloadinglayout.utils.DeviceScreenHelper;
14 |
15 | /**
16 | * Created by LJ on 23.03.2016.
17 | */
18 | public class ThreeGearsLayout extends GearLoadingLayout {
19 |
20 | public static final String IDENTIFIER = "ThreeGearsLayout";
21 |
22 | private GearView mFirstGearView;
23 | private GearView mSecondGearView;
24 | private GearView mThirdGearView;
25 |
26 | public ThreeGearsLayout(Context context) {
27 | super(context);
28 | addChildView();
29 | }
30 |
31 | public ThreeGearsLayout(Context context, AttributeSet attrs) {
32 | super(context, attrs);
33 | addChildView();
34 | parseAttributes(attrs);
35 | }
36 |
37 | public ThreeGearsLayout(Context context, AttributeSet attrs, int defStyleAttr) {
38 | super(context, attrs, defStyleAttr);
39 | addChildView();
40 | parseAttributes(attrs);
41 | }
42 |
43 | private void addChildView() {
44 | final View childView = inflate(getContext(), R.layout.layout_three_gears, null);
45 | initUI(childView);
46 | addView(childView);
47 | }
48 |
49 | protected void initUI(View rootView) {
50 | super.initUI(rootView);
51 | initDimensions();
52 | mFirstGearView = (GearView) rootView.findViewById(R.id.gear_view);
53 | mSecondGearView = (GearView) rootView.findViewById(R.id.gear_view_second);
54 | mThirdGearView = (GearView) rootView.findViewById(R.id.gear_view_third);
55 | }
56 |
57 | private void initDimensions() {
58 | mDialogWidth = DeviceScreenHelper.mDeviceWidth;
59 | if (DeviceScreenHelper.isDialogMode)
60 | mDialogHeight = mResources.getDimensionPixelSize(R.dimen.three_gear_layout_wrapper_height);
61 | }
62 |
63 | public void start() {
64 | mFirstGearView.startSpinning(false);
65 | mSecondGearView.startSpinning(true);
66 | mThirdGearView.startSpinning(false);
67 | }
68 |
69 | public ThreeGearsLayout setDuration(final int duration) {
70 | mFirstGearView.setDuration(duration);
71 | mSecondGearView.setDuration(duration);
72 | mThirdGearView.setDuration(duration);
73 | return this;
74 | }
75 |
76 | public ThreeGearsLayout setFirstGearColor(int color) {
77 | mFirstGearView.setColor(color);
78 | return this;
79 | }
80 |
81 | public ThreeGearsLayout setSecondGearColor(int color) {
82 | mSecondGearView.setColor(color);
83 | return this;
84 | }
85 |
86 |
87 | public ThreeGearsLayout setThirdGearColor(int color) {
88 | mThirdGearView.setColor(color);
89 | return this;
90 | }
91 |
92 | public ThreeGearsLayout setFirstGearInnerColor(int color) {
93 | setFirstGearInnerColor(color, false);
94 | return this;
95 | }
96 |
97 | public ThreeGearsLayout setSecondGearInnerColor(int color) {
98 | setSecondGearInnerColor(color, false);
99 | return this;
100 | }
101 |
102 | public ThreeGearsLayout setThirdGearInnerColor(int color) {
103 | setThirdGearInnerColor(color, false);
104 | return this;
105 | }
106 |
107 | private ThreeGearsLayout setFirstGearInnerColor(int color, boolean enableCuttedCenter) {
108 | mFirstGearView.setInnerColor(color);
109 | mFirstGearView.enableCuttedCenter(enableCuttedCenter);
110 | return this;
111 | }
112 |
113 | private ThreeGearsLayout setSecondGearInnerColor(int color, boolean enableCuttedCenter) {
114 | mSecondGearView.setInnerColor(color);
115 | mSecondGearView.enableCuttedCenter(enableCuttedCenter);
116 | return this;
117 | }
118 |
119 | private ThreeGearsLayout setThirdGearInnerColor(int color, boolean enableCuttedCenter) {
120 | mThirdGearView.setInnerColor(color);
121 | mThirdGearView.enableCuttedCenter(enableCuttedCenter);
122 | return this;
123 | }
124 |
125 | public ThreeGearsLayout setStyle(final Style style) {
126 | super.setStyle(style);
127 | return this;
128 | }
129 |
130 | public ThreeGearsLayout setDialogBackgroundColor(int color) {
131 | super.setDialogBackgroundColor(color);
132 | return this;
133 | }
134 |
135 | public ThreeGearsLayout setDialogBackgroundAlpha(float alpha) {
136 | super.setDialogBackgroundAlpha(alpha);
137 | return this;
138 | }
139 |
140 | public ThreeGearsLayout setMainBackgroundColor(int color) {
141 | super.setMainBackgroundColor(color);
142 | return this;
143 | }
144 |
145 | public ThreeGearsLayout setMainBackgroundAlpha(float alpha) {
146 | super.setMainBackgroundAlpha(alpha);
147 | return this;
148 | }
149 |
150 | public ThreeGearsLayout enableCutLayout(boolean enable) {
151 | super.enableCutLayout(enable);
152 | return this;
153 | }
154 |
155 | public ThreeGearsLayout setCutRadius(int radius) {
156 | super.setCutRadius(radius);
157 | return this;
158 | }
159 |
160 | public ThreeGearsLayout setCutLayoutColor(int color) {
161 | super.setCutLayoutColor(color);
162 | return this;
163 | }
164 |
165 | public ThreeGearsLayout setCutLayoutAlpha(float alpha) {
166 | super.setCutLayoutAlpha(alpha);
167 | return this;
168 | }
169 |
170 | public ThreeGearsLayout setShowMode(ShowMode showMode) {
171 | super.setShowMode(showMode);
172 | return this;
173 | }
174 |
175 | public ThreeGearsLayout setShowDialogDuration(int showDialogDuration) {
176 | super.setShowDialogDuration(showDialogDuration);
177 | return this;
178 | }
179 |
180 | public ThreeGearsLayout blurBackground(boolean enable) {
181 | super.blurBackground(enable);
182 | return this;
183 | }
184 |
185 | public ThreeGearsLayout setCancelable(boolean cancelable) {
186 | super.setCancelable(cancelable);
187 | return this;
188 | }
189 |
190 | protected void parseAttributes(AttributeSet attrs) {
191 | super.parseAttributes(attrs);
192 |
193 | TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.GearLoadingLayout);
194 | setFirstGearColor(a.getColor(R.styleable.GearLoadingLayout_firstGearColor, Color.GRAY));
195 | setSecondGearColor(a.getColor(R.styleable.GearLoadingLayout_secondGearColor, Color.GRAY));
196 | setThirdGearColor(a.getColor(R.styleable.GearLoadingLayout_thirdGearColor, Color.GRAY));
197 |
198 | setFirstGearInnerColor(a.getColor(R.styleable.GearLoadingLayout_firstInnerGearColor, Color.WHITE), a.getBoolean(R.styleable.GearLoadingLayout_firstGearCuttedCenter, true));
199 | setSecondGearInnerColor(a.getColor(R.styleable.GearLoadingLayout_secondInnerGearColor, Color.WHITE), a.getBoolean(R.styleable.GearLoadingLayout_secondGearCuttedCenter, true));
200 | setThirdGearInnerColor(a.getColor(R.styleable.GearLoadingLayout_thirdInnerGearColor, Color.WHITE), a.getBoolean(R.styleable.GearLoadingLayout_thirdGearCuttedCenter, true));
201 |
202 | a.recycle();
203 | requestLayout();
204 | }
205 |
206 |
207 | }
208 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/java/lj_3d/gearloadinglayout/gearViews/GearView.java:
--------------------------------------------------------------------------------
1 | package lj_3d.gearloadinglayout.gearViews;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Bitmap;
6 | import android.graphics.Canvas;
7 | import android.graphics.Color;
8 | import android.graphics.CornerPathEffect;
9 | import android.graphics.Matrix;
10 | import android.graphics.Paint;
11 | import android.graphics.Path;
12 | import android.graphics.PorterDuff;
13 | import android.graphics.PorterDuffXfermode;
14 | import android.util.AttributeSet;
15 | import android.view.View;
16 | import android.view.animation.Animation;
17 | import android.view.animation.LinearInterpolator;
18 | import android.view.animation.RotateAnimation;
19 |
20 | import lj_3d.gearloadinglayout.R;
21 |
22 | /**
23 | * Created by LJ on 28.03.2016.
24 | */
25 | public class GearView extends View {
26 |
27 | private Paint mainTeethPaint;
28 | private Paint mainCirclePaint;
29 | private Paint innerCirclePaint;
30 | private Paint cutCenterPaint;
31 |
32 | private Path path;
33 | private RotateAnimation rotateAnimation;
34 | private RotateAnimation rotateAnimationReverse;
35 | private final PorterDuffXfermode mPorterDuffXfermode = new PorterDuffXfermode(PorterDuff.Mode.CLEAR);
36 |
37 | private int cutOffset;
38 | private float rotateOffset;
39 | private int teethWidth = 40;
40 | private int mainDiameter = 400;
41 | private int secondDiameter = 150;
42 | private int duration = 5000;
43 | private int innerDiameter = mainDiameter / 6;
44 |
45 | private int mainColor = Color.RED;
46 | private int innerColor = Color.WHITE;
47 |
48 | private boolean enableCutCenter = true;
49 |
50 | private Bitmap mainBitmap;
51 | private Bitmap teeth;
52 | private Matrix matrix;
53 |
54 | public GearView(Context context) {
55 | super(context);
56 | initAndConfigTools();
57 | }
58 |
59 | public GearView(Context context, AttributeSet attrs) {
60 | super(context, attrs);
61 | parseAttributes(attrs);
62 | initAndConfigTools();
63 | }
64 |
65 | public GearView(Context context, AttributeSet attrs, int defStyleAttr) {
66 | super(context, attrs, defStyleAttr);
67 | parseAttributes(attrs);
68 | initAndConfigTools();
69 | }
70 |
71 | @Override
72 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
73 | final int desiredWSpec = MeasureSpec.makeMeasureSpec(mainDiameter, MeasureSpec.EXACTLY);
74 | final int desiredHSpec = MeasureSpec.makeMeasureSpec(mainDiameter, MeasureSpec.EXACTLY);
75 | super.onMeasure(desiredWSpec, desiredHSpec);
76 | }
77 |
78 | @Override
79 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
80 | super.onSizeChanged(mainDiameter, mainDiameter, w, h);
81 | mainBitmap = Bitmap.createBitmap(mainDiameter, mainDiameter, Bitmap.Config.ARGB_8888);
82 | drawGear();
83 | }
84 |
85 | @Override
86 | protected void onDraw(Canvas canvas) {
87 | super.onDraw(canvas);
88 | canvas.drawBitmap(mainBitmap, 0, 0, null);
89 | }
90 |
91 | public void setTeethWidth(int width) {
92 | this.teethWidth = width;
93 | }
94 |
95 | public void setColor(int color) {
96 | this.mainColor = color;
97 | }
98 |
99 | public void setInnerColor(int innerColor) {
100 | this.innerColor = innerColor;
101 | }
102 |
103 | public void enableCuttedCenter(boolean enableCutCenter) {
104 | this.enableCutCenter = enableCutCenter;
105 | }
106 |
107 | public void setMainDiameter(int mainDiameter) {
108 | this.mainDiameter = mainDiameter;
109 | }
110 |
111 | public void setSecondDiameter(int secondDiameter) {
112 | this.secondDiameter = secondDiameter;
113 | }
114 |
115 | public void setInnerDiameter(int innerDiameter) {
116 | this.innerDiameter = innerDiameter;
117 | }
118 |
119 | private void initAndConfigTools() {
120 | mainTeethPaint = new Paint();
121 | mainCirclePaint = new Paint();
122 | innerCirclePaint = new Paint();
123 | cutCenterPaint = new Paint();
124 |
125 | path = new Path();
126 | mainTeethPaint.setAntiAlias(true);
127 | mainTeethPaint.setDither(true);
128 | mainTeethPaint.setStyle(Paint.Style.FILL_AND_STROKE);
129 | mainTeethPaint.setColor(mainColor);
130 | mainTeethPaint.setStrokeJoin(Paint.Join.ROUND);
131 | mainTeethPaint.setStrokeCap(Paint.Cap.ROUND);
132 | mainTeethPaint.setPathEffect(new CornerPathEffect(2));
133 |
134 | mainCirclePaint.setAntiAlias(true);
135 | mainCirclePaint.setDither(true);
136 | mainCirclePaint.setStyle(Paint.Style.FILL_AND_STROKE);
137 | mainCirclePaint.setColor(mainColor);
138 |
139 | innerCirclePaint.setAntiAlias(true);
140 | innerCirclePaint.setDither(true);
141 | innerCirclePaint.setStyle(Paint.Style.FILL_AND_STROKE);
142 | innerCirclePaint.setColor(innerColor);
143 |
144 | cutCenterPaint.setAntiAlias(true);
145 | cutCenterPaint.setDither(true);
146 | cutCenterPaint.setStyle(Paint.Style.FILL_AND_STROKE);
147 | cutCenterPaint.setXfermode(mPorterDuffXfermode);
148 | matrix = new Matrix();
149 |
150 | setRotateAnimations();
151 | }
152 |
153 | public void startSpinning(boolean reverse) {
154 | setRotateAnimations();
155 | if (reverse) {
156 | startAnimation(rotateAnimationReverse);
157 | } else
158 | startAnimation(rotateAnimation);
159 | }
160 |
161 | public void setDuration(int duration) {
162 | this.duration = duration;
163 | rotateAnimation.setDuration(duration);
164 | rotateAnimationReverse.setDuration(duration);
165 | }
166 |
167 | public void setRotateAnimations() {
168 | rotateAnimation = new RotateAnimation(0, 360, mainDiameter / 2, mainDiameter / 2);
169 | rotateAnimationReverse = new RotateAnimation(360, 0, mainDiameter / 2, mainDiameter / 2);
170 | rotateAnimation.setDuration(duration);
171 | rotateAnimation.setRepeatCount(Animation.INFINITE);
172 | rotateAnimation.setInterpolator(new LinearInterpolator());
173 | rotateAnimationReverse.setDuration(duration);
174 | rotateAnimationReverse.setRepeatCount(Animation.INFINITE);
175 | rotateAnimationReverse.setInterpolator(new LinearInterpolator());
176 | }
177 |
178 | public void setRotateOffset(float rotateOffset) {
179 | this.rotateOffset = rotateOffset;
180 | }
181 |
182 |
183 | private void drawTeeth() {
184 | initAndConfigTools();
185 | teeth = Bitmap.createBitmap(mainDiameter, mainDiameter, Bitmap.Config.ARGB_8888);
186 | Canvas canvas = new Canvas(teeth);
187 |
188 | int xZero = (mainDiameter / 2) - (teethWidth / 2);
189 | int xMax = (mainDiameter / 2) + (teethWidth / 2);
190 | int yZero = 0;
191 | cutOffset = teethWidth / 6;
192 | path.moveTo(xZero + cutOffset, yZero);
193 | path.lineTo(xMax - cutOffset, yZero);
194 | path.lineTo(xMax, teethWidth);
195 | path.lineTo(xMax, mainDiameter - teethWidth);
196 | path.lineTo(xMax - cutOffset, mainDiameter);
197 | path.lineTo(xZero + cutOffset, mainDiameter);
198 | path.lineTo(xZero, mainDiameter - teethWidth);
199 | path.lineTo(xZero, teethWidth);
200 | path.close();
201 | canvas.drawPath(path, mainTeethPaint);
202 | }
203 |
204 | private void drawGear() {
205 | final Canvas mainCanvas = new Canvas(mainBitmap);
206 | drawTeeth();
207 | for (float angle = (0 + rotateOffset); angle <= (150 + rotateOffset); angle = (angle + 30)) {
208 | matrix.setRotate(angle, mainDiameter / 2, mainDiameter / 2);
209 | mainCanvas.drawBitmap(teeth, matrix, null);
210 | }
211 | mainCanvas.drawCircle(mainDiameter / 2, mainDiameter / 2, secondDiameter / 2, mainCirclePaint);
212 | mainCanvas.drawCircle(mainDiameter / 2, mainDiameter / 2, innerDiameter, enableCutCenter ? cutCenterPaint : innerCirclePaint);
213 | }
214 |
215 | private void parseAttributes(AttributeSet attrs) {
216 | TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.GearView);
217 | setColor(a.getColor(R.styleable.GearView_mainColor, Color.RED));
218 | setInnerColor(a.getColor(R.styleable.GearView_innerColor, Color.WHITE));
219 | setMainDiameter((int) a.getDimension(R.styleable.GearView_mainDiameter, 400));
220 | setSecondDiameter((int) a.getDimension(R.styleable.GearView_secondDiameter, 150));
221 | setInnerDiameter((int) a.getDimension(R.styleable.GearView_innerDiameter, 50));
222 | setTeethWidth((int) a.getDimension(R.styleable.GearView_teethWidth, 40));
223 | setRotateOffset(a.getFloat(R.styleable.GearView_rotateAngle, 0));
224 | enableCuttedCenter(a.getBoolean(R.styleable.GearView_enableCutCenter, false));
225 | requestLayout();
226 | a.recycle();
227 | }
228 | }
229 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GearLoadingLayout
2 |
3 | ### Description
4 |
5 | **GearLoadingLayout** widget for android that can be used as a progress bar, snack bar or yourself to create your own arrangements for their needs.
6 |
7 | ### Short Description
8 |
9 | - [**Use GearView as standalone widget**](#gear_view)
10 |
11 | - [**Use one of the three prepared layouts (One Gear, Two Gears, Three Gears)**](#prepared_layout)
12 |
13 | - [**Use GearDialogBuilder to create you loading dialog, with lot functionality**](#gear_dialog_builder)
14 |
15 |
16 |
17 | ### GearView
18 | ____
19 |
20 | #### Samples
21 |
22 | #### In Xml
23 |
24 |
35 |
36 | #### In Code
37 |
38 | GearView gearView = new GearView(mContext);
39 | gearView.setMainDiameter(300);
40 | gearView.setSecondDiameter(240);
41 | gearView.setInnerDiameter(80);
42 | gearView.setTeethWidth(40);
43 | gearView.setRotateOffset(20);
44 | gearView.setColor(Color.BLUE);
45 | gearView.setInnerColor(Color.RED);
46 | gearView.enableCuttedCenter(true); // boolean param == true (center of GearView will be cutted)
47 | gearView.startSpinning(false); // start spinning animation, boolean param == true (rotate to the left side) | param == false (rotate to the right side)
48 |
49 | (and don`t forget add to your root view)
50 |
51 | #### On Android Device
52 | ____
53 |
54 |
55 | Cutted Center | Filled Center
56 | :-------------------------:|:-------------------------:
57 | |
58 |
59 |
60 |
61 | ### GearLayout
62 |
63 | #### Features
64 |
65 | - Already preset layout
66 | - Small feature as CutOut Layout
67 | - Flexible functionality
68 |
69 | #### Samples
70 |
71 | #### In Xml
72 |
73 | - Three Gears
74 |
75 |
92 |
93 | - Two Gears
94 |
95 |
109 |
110 | - One Gear
111 |
112 |
123 |
124 | #### In Code
125 |
126 | - One Gear
127 |
128 | OneGearLayout threeGearsLayout = new OneGearLayout(this);
129 | threeGearsLayout.setFirstGearColor(Color.WHITE);
130 | threeGearsLayout.setDialogBackgroundColor(Color.GREEN);
131 | threeGearsLayout.setDialogBackgroundAlpha(0.3f);
132 | threeGearsLayout.blurBackground(true);
133 | threeGearsLayout.enableCutLayout(false);
134 | threeGearsLayout.setCutRadius(80);
135 | threeGearsLayout.start();
136 |
137 | - Two Gears
138 |
139 | TwoGearsLayout threeGearsLayout = new TwoGearsLayout(this);
140 | threeGearsLayout.setFirstGearColor(Color.WHITE);
141 | threeGearsLayout.setSecondGearColor(Color.RED);
142 | threeGearsLayout.setDialogBackgroundColor(Color.GREEN);
143 | threeGearsLayout.setDialogBackgroundAlpha(0.3f);
144 | threeGearsLayout.blurBackground(true);
145 | threeGearsLayout.enableCutLayout(false);
146 | threeGearsLayout.setCutRadius(80);
147 | threeGearsLayout.start();
148 |
149 | - Three Gears
150 |
151 | ThreeGearsLayout threeGearsLayout = new ThreeGearsLayout(this);
152 | threeGearsLayout.setFirstGearColor(Color.WHITE);
153 | threeGearsLayout.setSecondGearColor(Color.RED);
154 | threeGearsLayout.setThirdGearColor(Color.CYAN);
155 | threeGearsLayout.setDialogBackgroundColor(Color.GREEN);
156 | threeGearsLayout.setDialogBackgroundAlpha(0.3f);
157 | threeGearsLayout.blurBackground(true);
158 | threeGearsLayout.enableCutLayout(false);
159 | threeGearsLayout.setCutRadius(80);
160 | threeGearsLayout.start();
161 |
162 |
163 | #### On Android Device
164 |
165 | |With CutLayout | One Gear | Two Gears | Three Gears |
166 | :-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
167 | |||
168 |
169 |
170 |
171 |
172 |
173 | ### GearDialogBuilder
174 |
175 | #### Features
176 |
177 | - Fast create loading dialog
178 | - Enable Blur Effect (Thanks [This Stack Overflow Resource](http://stackoverflow.com/questions/2067955/fast-bitmap-blur-for-android-sdk))
179 | - Support modes : Dialog, Snackbar
180 |
181 | #### Sample
182 |
183 | GearDialogBuilder.getInstance(MainActivity.this)
184 | .setType(ThreeGearsLayout.class)
185 | .setShowDialogDuration(200)
186 | .setShowMode(showMode)
187 | .setDuration(3000)
188 | .blurBackground(blur)
189 | .enableCutLayout(false)
190 | .setDialogBackgroundAlpha(0.5f)
191 | .setDialogBackgroundColor(mResources.getColor(R.color.colorAccent))
192 | .setFirstGearColor(mResources.getColor(R.color.colorPrimaryDark))
193 | .setSecondGearColor(mResources.getColor(R.color.dialog_stroke_color))
194 | .setThirdGearColor(mResources.getColor(R.color.colorPrimary))
195 | .show();
196 |
197 | #### On Android Device
198 |
199 | 
200 |
201 |
202 | Android SDK Version
203 | =========
204 | Min SDK Version == 11.
205 |
206 | License
207 | ======
208 |
209 | Apache 2.0. See LICENSE file for details.
210 |
211 | Author
212 | =======
213 |
214 | Liubomyr Miller (lj-3d)
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/java/lj_3d/gearloadinglayout/utils/FastBlur.java:
--------------------------------------------------------------------------------
1 | package lj_3d.gearloadinglayout.utils;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.graphics.drawable.BitmapDrawable;
8 | import android.os.Build;
9 | import android.view.View;
10 | import android.view.ViewTreeObserver;
11 |
12 | import lj_3d.gearloadinglayout.interfaces.OnBlurCompleteInterface;
13 |
14 | public class FastBlur {
15 |
16 | private float scaleFactor = 8;
17 | private int radius = 5;
18 |
19 | public static Bitmap doBlur(Bitmap sentBitmap, int radius, boolean canReuseInBitmap) {
20 |
21 | // Stack Blur v1.0 from
22 | // http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html
23 | //
24 | // Java Author: Mario Klingemann
25 | // http://incubator.quasimondo.com
26 | // created Feburary 29, 2004
27 | // Android port : Yahel Bouaziz
28 | // http://www.kayenko.com
29 | // ported april 5th, 2012
30 |
31 | // This is a compromise between Gaussian Blur and Box blur
32 | // It creates much better looking blurs than Box Blur, but is
33 | // 7x faster than my Gaussian Blur implementation.
34 | //
35 | // I called it Stack Blur because this describes best how this
36 | // filter works internally: it creates a kind of moving stack
37 | // of colors whilst scanning through the image. Thereby it
38 | // just has to add one new block of color to the right side
39 | // of the stack and remove the leftmost color. The remaining
40 | // colors on the topmost layer of the stack are either added on
41 | // or reduced by one, depending on if they are on the right or
42 | // on the left side of the stack.
43 | //
44 | // If you are using this algorithm in your code please add
45 | // the following line:
46 | //
47 | // Stack Blur Algorithm by Mario Klingemann
48 |
49 | Bitmap bitmap;
50 | if (canReuseInBitmap) {
51 | bitmap = sentBitmap;
52 | } else {
53 | bitmap = sentBitmap.copy(sentBitmap.getConfig(), true);
54 | }
55 |
56 | if (radius < 1) {
57 | return (null);
58 | }
59 |
60 | int w = bitmap.getWidth();
61 | int h = bitmap.getHeight();
62 |
63 | int[] pix = new int[w * h];
64 | bitmap.getPixels(pix, 0, w, 0, 0, w, h);
65 |
66 | int wm = w - 1;
67 | int hm = h - 1;
68 | int wh = w * h;
69 | int div = radius + radius + 1;
70 |
71 | int r[] = new int[wh];
72 | int g[] = new int[wh];
73 | int b[] = new int[wh];
74 | int rsum, gsum, bsum, x, y, i, p, yp, yi, yw;
75 | int vmin[] = new int[Math.max(w, h)];
76 |
77 | int divsum = (div + 1) >> 1;
78 | divsum *= divsum;
79 | int dv[] = new int[256 * divsum];
80 | for (i = 0; i < 256 * divsum; i++) {
81 | dv[i] = (i / divsum);
82 | }
83 |
84 | yw = yi = 0;
85 |
86 | int[][] stack = new int[div][3];
87 | int stackpointer;
88 | int stackstart;
89 | int[] sir;
90 | int rbs;
91 | int r1 = radius + 1;
92 | int routsum, goutsum, boutsum;
93 | int rinsum, ginsum, binsum;
94 |
95 | for (y = 0; y < h; y++) {
96 | rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
97 | for (i = -radius; i <= radius; i++) {
98 | p = pix[yi + Math.min(wm, Math.max(i, 0))];
99 | sir = stack[i + radius];
100 | sir[0] = (p & 0xff0000) >> 16;
101 | sir[1] = (p & 0x00ff00) >> 8;
102 | sir[2] = (p & 0x0000ff);
103 | rbs = r1 - Math.abs(i);
104 | rsum += sir[0] * rbs;
105 | gsum += sir[1] * rbs;
106 | bsum += sir[2] * rbs;
107 | if (i > 0) {
108 | rinsum += sir[0];
109 | ginsum += sir[1];
110 | binsum += sir[2];
111 | } else {
112 | routsum += sir[0];
113 | goutsum += sir[1];
114 | boutsum += sir[2];
115 | }
116 | }
117 | stackpointer = radius;
118 |
119 | for (x = 0; x < w; x++) {
120 |
121 | r[yi] = dv[rsum];
122 | g[yi] = dv[gsum];
123 | b[yi] = dv[bsum];
124 |
125 | rsum -= routsum;
126 | gsum -= goutsum;
127 | bsum -= boutsum;
128 |
129 | stackstart = stackpointer - radius + div;
130 | sir = stack[stackstart % div];
131 |
132 | routsum -= sir[0];
133 | goutsum -= sir[1];
134 | boutsum -= sir[2];
135 |
136 | if (y == 0) {
137 | vmin[x] = Math.min(x + radius + 1, wm);
138 | }
139 | p = pix[yw + vmin[x]];
140 |
141 | sir[0] = (p & 0xff0000) >> 16;
142 | sir[1] = (p & 0x00ff00) >> 8;
143 | sir[2] = (p & 0x0000ff);
144 |
145 | rinsum += sir[0];
146 | ginsum += sir[1];
147 | binsum += sir[2];
148 |
149 | rsum += rinsum;
150 | gsum += ginsum;
151 | bsum += binsum;
152 |
153 | stackpointer = (stackpointer + 1) % div;
154 | sir = stack[(stackpointer) % div];
155 |
156 | routsum += sir[0];
157 | goutsum += sir[1];
158 | boutsum += sir[2];
159 |
160 | rinsum -= sir[0];
161 | ginsum -= sir[1];
162 | binsum -= sir[2];
163 |
164 | yi++;
165 | }
166 | yw += w;
167 | }
168 | for (x = 0; x < w; x++) {
169 | rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
170 | yp = -radius * w;
171 | for (i = -radius; i <= radius; i++) {
172 | yi = Math.max(0, yp) + x;
173 |
174 | sir = stack[i + radius];
175 |
176 | sir[0] = r[yi];
177 | sir[1] = g[yi];
178 | sir[2] = b[yi];
179 |
180 | rbs = r1 - Math.abs(i);
181 |
182 | rsum += r[yi] * rbs;
183 | gsum += g[yi] * rbs;
184 | bsum += b[yi] * rbs;
185 |
186 | if (i > 0) {
187 | rinsum += sir[0];
188 | ginsum += sir[1];
189 | binsum += sir[2];
190 | } else {
191 | routsum += sir[0];
192 | goutsum += sir[1];
193 | boutsum += sir[2];
194 | }
195 |
196 | if (i < hm) {
197 | yp += w;
198 | }
199 | }
200 | yi = x;
201 | stackpointer = radius;
202 | for (y = 0; y < h; y++) {
203 | // Preserve alpha channel: ( 0xff000000 & pix[yi] )
204 | pix[yi] = (0xff000000 & pix[yi]) | (dv[rsum] << 16) | (dv[gsum] << 8) | dv[bsum];
205 |
206 | rsum -= routsum;
207 | gsum -= goutsum;
208 | bsum -= boutsum;
209 |
210 | stackstart = stackpointer - radius + div;
211 | sir = stack[stackstart % div];
212 |
213 | routsum -= sir[0];
214 | goutsum -= sir[1];
215 | boutsum -= sir[2];
216 |
217 | if (x == 0) {
218 | vmin[y] = Math.min(y + r1, hm) * w;
219 | }
220 | p = x + vmin[y];
221 |
222 | sir[0] = r[p];
223 | sir[1] = g[p];
224 | sir[2] = b[p];
225 |
226 | rinsum += sir[0];
227 | ginsum += sir[1];
228 | binsum += sir[2];
229 |
230 | rsum += rinsum;
231 | gsum += ginsum;
232 | bsum += binsum;
233 |
234 | stackpointer = (stackpointer + 1) % div;
235 | sir = stack[stackpointer];
236 |
237 | routsum += sir[0];
238 | goutsum += sir[1];
239 | boutsum += sir[2];
240 |
241 | rinsum -= sir[0];
242 | ginsum -= sir[1];
243 | binsum -= sir[2];
244 |
245 | yi += w;
246 | }
247 | }
248 |
249 | bitmap.setPixels(pix, 0, w, 0, 0, w, h);
250 |
251 | return (bitmap);
252 | }
253 |
254 |
255 | public void callBlur(final View targetView, final View pasteView, final OnBlurCompleteInterface onBlurCompleteInterface) {
256 | targetView.requestLayout();
257 | targetView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
258 | @Override
259 | public void onGlobalLayout() {
260 | if (Integer.valueOf(Build.VERSION.SDK_INT) >= 16) {
261 | targetView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
262 | pasteView.setBackground(new BitmapDrawable(pasteView.getResources(), prepareAndSetBitmap(targetView)));
263 | } else {
264 | targetView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
265 | pasteView.setBackgroundDrawable(new BitmapDrawable(pasteView.getResources(), prepareAndSetBitmap(targetView)));
266 | }
267 |
268 | onBlurCompleteInterface.onBlurComplete();
269 | }
270 | });
271 | }
272 |
273 | private Bitmap prepareAndSetBitmap(final View targetView) {
274 | targetView.setDrawingCacheEnabled(true);
275 | targetView.destroyDrawingCache();
276 | targetView.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_AUTO);
277 | targetView.buildDrawingCache(true);
278 | Bitmap sourceBitmap = Bitmap.createBitmap(targetView.getDrawingCache());
279 | targetView.setDrawingCacheEnabled(false);
280 | targetView.destroyDrawingCache();
281 |
282 | Bitmap overlay = Bitmap.createBitmap((int) (targetView.getMeasuredWidth() / scaleFactor),
283 | (int) (targetView.getMeasuredHeight() / scaleFactor), Bitmap.Config.ARGB_8888);
284 | Canvas canvas = new Canvas(overlay);
285 | // canvas.translate(-targetView.getLeft() / scaleFactor, -targetView.getTop() / scaleFactor);
286 | canvas.scale(1 / scaleFactor, 1 / scaleFactor);
287 | Paint paint = new Paint();
288 | paint.setColor(Color.RED);
289 | paint.setFlags(Paint.FILTER_BITMAP_FLAG);
290 | canvas.drawBitmap(sourceBitmap, 0, 0, paint);
291 | // canvas.drawColor(Color.RED);
292 | sourceBitmap.recycle();
293 | return FastBlur.doBlur(overlay, radius, false);
294 | }
295 |
296 |
297 | }
298 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/gearloadinglayout/src/main/java/lj_3d/gearloadinglayout/gearViews/GearLoadingLayout.java:
--------------------------------------------------------------------------------
1 | package lj_3d.gearloadinglayout.gearViews;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.content.res.TypedArray;
6 | import android.graphics.Color;
7 | import android.support.v4.view.ViewCompat;
8 | import android.util.AttributeSet;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.FrameLayout;
12 | import android.widget.RelativeLayout;
13 |
14 | import lj_3d.gearloadinglayout.R;
15 | import lj_3d.gearloadinglayout.enums.ShowMode;
16 | import lj_3d.gearloadinglayout.enums.Style;
17 | import lj_3d.gearloadinglayout.interfaces.OnBlurCompleteInterface;
18 | import lj_3d.gearloadinglayout.utils.DeviceScreenHelper;
19 | import lj_3d.gearloadinglayout.utils.FastBlur;
20 |
21 | /**
22 | * Created by LJ on 23.03.2016.
23 | */
24 | public class GearLoadingLayout extends FrameLayout implements OnBlurCompleteInterface, View.OnClickListener {
25 |
26 | protected Resources mResources;
27 | protected Style mCurrentStyle = Style.SNACK_BAR;
28 |
29 | protected ViewGroup mActivityContentView;
30 | protected View mGearLayoutInnerWrapper;
31 | protected View mGearWrapper;
32 | protected RelativeLayout mMainWrapper;
33 | protected FrameLayout mGearLayoutWrapper;
34 | protected CutOutLayout mCutOutLayout;
35 | protected FrameLayout mMainBackground;
36 | protected ShowMode mShowMode = ShowMode.CENTER;
37 | protected FastBlur mFastBlur = new FastBlur();
38 |
39 | protected int showDialogDuration = 333;
40 | protected int mDialogWidth;
41 | protected int mDialogHeight;
42 |
43 |
44 | protected int mMainBackgroundColor = Color.TRANSPARENT;
45 | protected int mInnerWrapperColor = Color.TRANSPARENT;
46 | protected float mMainBackgroundAlpha;
47 |
48 | protected boolean isDialogShown;
49 | protected boolean cancelable = true;
50 | protected boolean showDialog;
51 | protected boolean isAnimating;
52 | protected boolean isEnableBlur = true;
53 |
54 | public GearLoadingLayout(Context context) {
55 | super(context);
56 | mResources = getResources();
57 | }
58 |
59 | public GearLoadingLayout(Context context, AttributeSet attrs) {
60 | super(context, attrs);
61 | mResources = getResources();
62 | }
63 |
64 | public GearLoadingLayout(Context context, AttributeSet attrs, int defStyleAttr) {
65 | super(context, attrs, defStyleAttr);
66 | mResources = getResources();
67 | }
68 |
69 | @Override
70 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
71 | super.onSizeChanged(w, h, oldw, oldh);
72 | if (!DeviceScreenHelper.isDialogMode)
73 | mDialogHeight = h;
74 | }
75 |
76 | protected void initUI(View rootView) {
77 | mMainWrapper = (RelativeLayout) rootView.findViewById(R.id.main_wrapper);
78 | mGearLayoutWrapper = (FrameLayout) rootView.findViewById(R.id.gear_layout_wrapper);
79 | mGearLayoutInnerWrapper = rootView.findViewById(R.id.gear_layout_inner_wrapper);
80 | mGearWrapper = rootView.findViewById(R.id.gears_wrapper);
81 | mMainBackground = (FrameLayout) rootView.findViewById(R.id.main_background);
82 | mCutOutLayout = (CutOutLayout) rootView.findViewById(R.id.cut_out_layout);
83 | mMainWrapper.setOnClickListener(this);
84 | }
85 |
86 | @Override
87 | public void onBlurComplete() {
88 | selectShowAnimation(true);
89 | }
90 |
91 |
92 | public void show() {
93 | if (mActivityContentView == null) return;
94 | mGearLayoutWrapper.getLayoutParams().height = mDialogHeight;
95 | mGearLayoutWrapper.requestLayout();
96 | if (isEnableBlur) {
97 | mFastBlur.callBlur(mActivityContentView, mMainBackground, this);
98 | } else {
99 | mMainBackground.setBackgroundColor(mMainBackgroundColor);
100 | mMainBackground.setAlpha(mMainBackgroundAlpha);
101 | selectShowAnimation(true);
102 | }
103 |
104 | }
105 |
106 | public void hide() {
107 | selectShowAnimation(false);
108 | }
109 |
110 |
111 | public void setActivityContentView(ViewGroup activityContentView) {
112 | mActivityContentView = activityContentView;
113 | }
114 |
115 | public GearLoadingLayout setStyle(Style style) {
116 | this.mCurrentStyle = style;
117 | return this;
118 | }
119 |
120 | public GearLoadingLayout setDialogBackgroundColor(int color) {
121 | this.mInnerWrapperColor = color;
122 | mGearLayoutInnerWrapper.setBackgroundColor(color);
123 | return this;
124 | }
125 |
126 | public GearLoadingLayout setDialogBackgroundAlpha(float alpha) {
127 | mGearLayoutInnerWrapper.setAlpha(alpha);
128 | return this;
129 | }
130 |
131 | public GearLoadingLayout setMainBackgroundColor(int color) {
132 | this.mMainBackgroundColor = color;
133 | return this;
134 | }
135 |
136 | public GearLoadingLayout setMainBackgroundAlpha(float alpha) {
137 | this.mMainBackgroundAlpha = alpha;
138 | return this;
139 | }
140 |
141 | public GearLoadingLayout enableCutLayout(boolean enable) {
142 | mCutOutLayout.setVisibility(enable ? VISIBLE : GONE);
143 | return this;
144 | }
145 |
146 | public GearLoadingLayout setCutRadius(int radius) {
147 | mCutOutLayout.setCutRadius(radius);
148 | return this;
149 | }
150 |
151 | public GearLoadingLayout setCutLayoutColor(int color) {
152 | mCutOutLayout.setColor(color);
153 | return this;
154 | }
155 |
156 | public GearLoadingLayout setCutLayoutAlpha(float alpha) {
157 | mCutOutLayout.setAlpha(alpha);
158 | return this;
159 | }
160 |
161 | public GearLoadingLayout setShowMode(ShowMode showMode) {
162 | mShowMode = showMode;
163 | return this;
164 | }
165 |
166 | public GearLoadingLayout setDuration(final int duration) {
167 | return this;
168 | }
169 |
170 | public GearLoadingLayout setShowDialogDuration(int showDialogDuration) {
171 | this.showDialogDuration = showDialogDuration;
172 | return this;
173 | }
174 |
175 | public GearLoadingLayout blurBackground(boolean enable) {
176 | isEnableBlur = enable;
177 | return this;
178 | }
179 |
180 | public GearLoadingLayout setCancelable(boolean cancelable) {
181 | this.cancelable = cancelable;
182 | return this;
183 | }
184 |
185 |
186 | public void start() {
187 | }
188 |
189 | public boolean isDialogShown() {
190 | return isDialogShown;
191 | }
192 |
193 | private final Runnable startAction = new Runnable() {
194 | @Override
195 | public void run() {
196 | isAnimating = true;
197 | if (showDialog)
198 | isDialogShown = true;
199 | }
200 | };
201 |
202 | private final Runnable endAction = new Runnable() {
203 | @Override
204 | public void run() {
205 | isAnimating = false;
206 | if (!showDialog) {
207 | mActivityContentView.removeView(GearLoadingLayout.this);
208 | isDialogShown = false;
209 | }
210 | }
211 | };
212 |
213 | private void setGearLayoutWrapperGravity() {
214 | final RelativeLayout.LayoutParams mLayoutParams = (RelativeLayout.LayoutParams) mGearLayoutWrapper.getLayoutParams();
215 | switch (mShowMode) {
216 | case CENTER:
217 | case LEFT:
218 | case RIGHT:
219 | mLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
220 | break;
221 | case TOP:
222 | mLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
223 | break;
224 | case BOTTOM:
225 | mLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
226 | break;
227 | }
228 | mGearLayoutWrapper.setLayoutParams(mLayoutParams);
229 | }
230 |
231 | private void applyStyle() {
232 | if (mCurrentStyle == Style.DIALOG) {
233 | mGearLayoutWrapper.setBackgroundColor(Color.TRANSPARENT);
234 | mGearLayoutInnerWrapper.setBackgroundColor(Color.TRANSPARENT);
235 | mCutOutLayout.setVisibility(GONE);
236 | }
237 | }
238 |
239 | private void selectShowAnimation(boolean showDialog) {
240 | if (mActivityContentView == null || isAnimating)
241 | return;
242 |
243 | if (showDialog) {
244 | mActivityContentView.addView(GearLoadingLayout.this);
245 | }
246 |
247 | this.showDialog = showDialog;
248 | float from = 0f;
249 | float to = 0f;
250 | boolean xAxis = false;
251 | boolean scaleDialog = false;
252 |
253 |
254 | switch (mShowMode) {
255 | case TOP:
256 | from = -mDialogHeight;
257 | to = 0;
258 | break;
259 | case BOTTOM:
260 | from = mDialogHeight;
261 | to = 0;
262 | break;
263 | case LEFT:
264 | from = -mDialogWidth;
265 | to = 0;
266 | xAxis = true;
267 | break;
268 | case RIGHT:
269 | from = mDialogWidth;
270 | to = 0;
271 | xAxis = true;
272 | break;
273 | case CENTER:
274 | scaleDialog = true;
275 | break;
276 | default:
277 | break;
278 | }
279 |
280 | setGearLayoutWrapperGravity();
281 | applyStyle();
282 | start();
283 | if (scaleDialog) {
284 | ViewCompat.setScaleX(mGearLayoutWrapper, showDialog ? 0 : 1);
285 | ViewCompat.setScaleY(mGearLayoutWrapper, showDialog ? 0 : 1);
286 | ViewCompat.animate(mGearLayoutWrapper).scaleX(showDialog ? 1 : 0).scaleY(showDialog ? 1 : 0).setDuration(showDialogDuration).withStartAction(startAction).withEndAction(endAction).start();
287 | } else {
288 | if (!xAxis) {
289 | ViewCompat.setTranslationY(mGearLayoutWrapper, showDialog ? from : to);
290 | ViewCompat.animate(mGearLayoutWrapper).translationY(showDialog ? to : from).setDuration(showDialogDuration).withStartAction(startAction).withEndAction(endAction).start();
291 | } else {
292 | ViewCompat.setTranslationX(mGearLayoutWrapper, showDialog ? from : to);
293 | ViewCompat.animate(mGearLayoutWrapper).translationX(showDialog ? to : from).setDuration(showDialogDuration).withStartAction(startAction).withEndAction(endAction).start();
294 | }
295 | }
296 |
297 | ViewCompat.setAlpha(mMainBackground, showDialog ? 0 : isEnableBlur ? 1 : mMainBackgroundAlpha);
298 | ViewCompat.animate(mMainBackground).alpha(showDialog ? isEnableBlur ? 1 : mMainBackgroundAlpha : 0).setDuration(showDialogDuration).start();
299 | }
300 |
301 |
302 | @Override
303 | public void onClick(View v) {
304 | if (cancelable)
305 | hide();
306 | }
307 |
308 | protected void parseAttributes(AttributeSet attrs) {
309 | TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.GearLoadingLayout);
310 |
311 | setCutRadius((int) a.getDimension(R.styleable.GearLoadingLayout_gearLayoutCutRadius, 120));
312 | setCutLayoutColor(a.getColor(R.styleable.GearLoadingLayout_gearLayoutCutColor, Color.WHITE));
313 | enableCutLayout(a.getBoolean(R.styleable.GearLoadingLayout_cutLayoutVisibility, true));
314 | setCutLayoutAlpha(a.getFloat(R.styleable.GearLoadingLayout_gearLayoutCutAlpha, 0.5f));
315 | setDialogBackgroundColor(a.getColor(R.styleable.GearLoadingLayout_layoutBackground, Color.WHITE));
316 | setDialogBackgroundAlpha(a.getFloat(R.styleable.GearLoadingLayout_layoutAlpha, 1f));
317 |
318 |
319 | a.recycle();
320 | requestLayout();
321 | }
322 |
323 | }
324 |
--------------------------------------------------------------------------------