Repository: liangchengcheng/android-loading-dialog
Branch: master
Commit: 0c49f8294ba6
Files: 40
Total size: 70.3 KB
Directory structure:
gitextract__b8dyl2m/
├── .gitignore
├── LICENSE
├── README.md
├── build.gradle
├── demo/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ ├── androidTest/
│ │ └── java/
│ │ └── com/
│ │ └── kaopiz/
│ │ └── progresshud/
│ │ └── demo/
│ │ └── ApplicationTest.java
│ ├── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── kaopiz/
│ │ │ └── progresshud/
│ │ │ └── demo/
│ │ │ └── MainActivity.java
│ │ └── res/
│ │ ├── layout/
│ │ │ └── activity_main.xml
│ │ ├── values/
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── values-w820dp/
│ │ └── dimens.xml
│ └── test/
│ └── java/
│ └── com/
│ └── kaopiz/
│ └── progresshud/
│ └── ExampleUnitTest.java
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── kprogresshud/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ ├── androidTest/
│ │ └── java/
│ │ └── com/
│ │ └── kaopiz/
│ │ └── kprogresshud/
│ │ └── ApplicationTest.java
│ ├── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── kaopiz/
│ │ │ └── kprogresshud/
│ │ │ ├── AnnularView.java
│ │ │ ├── BackgroundLayout.java
│ │ │ ├── BarView.java
│ │ │ ├── Determinate.java
│ │ │ ├── Helper.java
│ │ │ ├── Indeterminate.java
│ │ │ ├── KProgressHUD.java
│ │ │ ├── PieView.java
│ │ │ └── SpinView.java
│ │ └── res/
│ │ ├── layout/
│ │ │ └── kprogresshud_hud.xml
│ │ └── values/
│ │ └── colors.xml
│ └── test/
│ └── java/
│ └── com/
│ └── kaopiz/
│ └── kprogresshud/
│ └── ExampleUnitTest.java
└── settings.gradle
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
*.iml
.gradle
/local.properties
/.idea
.DS_Store
/build
/captures
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2015 Kaopiz Software Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================
# KProgressHUD
[](http://opensource.org/licenses/Apache-2.0)
[  ](https://bintray.com/kaopiz/KProgressHUD/KProgressHUD/_latestVersion)
[](https://android-arsenal.com/details/1/2975)
An implement of ProgressHUD for Android, similar to MBProgressHUD, SVProgressHUD.
Inspired by [MBProgressHUD](https://github.com/jdg/MBProgressHUD) for iOS.

<!---
[](https://github.com/Kaopiz/KProgressHUD/blob/master/demo/screenshoots/image01.png?raw=true)
[](https://github.com/Kaopiz/KProgressHUD/blob/master/demo/screenshoots/image02.png?raw=true)
[](https://github.com/Kaopiz/KProgressHUD/blob/master/demo/screenshoots/image03.png?raw=true)
[](https://github.com/Kaopiz/KProgressHUD/blob/master/demo/screenshoots/image04.png?raw=true)
[](https://github.com/Kaopiz/KProgressHUD/blob/master/demo/screenshoots/image05.png?raw=true)
[](https://github.com/Kaopiz/KProgressHUD/blob/master/demo/screenshoots/image06.png?raw=true)
[](https://github.com/Kaopiz/KProgressHUD/blob/master/demo/screenshoots/image07.png?raw=true)
[](https://github.com/Kaopiz/KProgressHUD/blob/master/demo/screenshoots/image08.png?raw=true)
-->
## Compatibility
Android 2.3 and later
## Adding KProgressHUD to your project
### Gradle
Include this in your module `build.gradle`
```
dependencies {
// Other dependencies
compile 'com.kaopiz:kprogresshud:1.0.2'
}
```
### Source code
You can download and import the `kprogresshud` folder as module to your project.
## Usage
The usage of KProgressHUD is pretty straight forward. You create the HUD, customize its style and show it on the UI thread. Then fire a background thread to work on long-running tasks. When done, call `dismiss()` to close it (if you use a determinate style, the HUD will automatically dismiss if progress reach its max).
Indeterminate HUD
```java
KProgressHUD.create(MainActivity.this)
.setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
.setLabel("Please wait")
.setDetailsLabel("Downloading data");
.setCancellable(true)
.setAnimationSpeed(2)
.setDimAmount(0.5f)
.show();
```
Determinate HUD
```java
KProgressHUD hud = KProgressHUD.create(MainActivity.this)
.setStyle(KProgressHUD.Style.ANNULAR_DETERMINATE)
.setLabel("Please wait")
.setMaxProgress(100)
.show();
hud.setProgress(90);
```
Alternatively, you can create a custom view and pass to the HUD to display it.
```java
ImageView imageView = new ImageView(this);
imageView.setImageResource(R.mipmap.ic_launcher);
KProgressHUD.create(MainActivity.this)
.setCustomView(imageView)
.setLabel("This is a custom view")
.show();
```
The custom view can implement `Determinate` or `Indeterminate`, which make the HUD treats this view like the default determinate or indeterminate implementations, not required.
See [**Javadocs**](http://kaopiz.github.io/KProgressHUD/) or [**sample app**](https://github.com/Kaopiz/KProgressHUD/tree/master/demo/src/main) for more information.
## Contributing
1. Fork it ( https://github.com/Kaopiz/KProgressHUD/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
## Contributor
* [tuanna-hsp](https://github.com/tuanna-hsp)
* [nafuto](https://github.com/nafuto)
## License
```
Copyright 2015 Kaopiz Software Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
================================================
FILE: build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: demo/.gitignore
================================================
/build
================================================
FILE: demo/build.gradle
================================================
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.kaopiz.progresshud"
minSdkVersion 8
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile project(':kprogresshud')
}
================================================
FILE: demo/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in E:\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
================================================
FILE: demo/src/androidTest/java/com/kaopiz/progresshud/demo/ApplicationTest.java
================================================
package com.kaopiz.progresshud.demo;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
================================================
FILE: demo/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.kaopiz.progresshud"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".demo.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
================================================
FILE: demo/src/main/java/com/kaopiz/progresshud/demo/MainActivity.java
================================================
/*
* Copyright (c) 2015 Kaopiz Software Co., Ltd
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.kaopiz.progresshud.demo;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import com.kaopiz.kprogresshud.KProgressHUD;
import com.kaopiz.progresshud.R;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button indeterminate = (Button) findViewById(R.id.indeterminate);
indeterminate.setOnClickListener(this);
Button labelIndeterminate = (Button) findViewById(R.id.label_indeterminate);
labelIndeterminate.setOnClickListener(this);
Button detailIndeterminate = (Button) findViewById(R.id.detail_indeterminate);
detailIndeterminate.setOnClickListener(this);
Button determinate = (Button) findViewById(R.id.determinate);
determinate.setOnClickListener(this);
Button annularDeterminate = (Button) findViewById(R.id.annular_determinate);
annularDeterminate.setOnClickListener(this);
Button barDeterminate = (Button) findViewById(R.id.bar_determinate);
barDeterminate.setOnClickListener(this);
Button customView = (Button) findViewById(R.id.custom_view);
customView.setOnClickListener(this);
Button dimBackground = (Button) findViewById(R.id.dim_background);
dimBackground.setOnClickListener(this);
Button customColor = (Button) findViewById(R.id.custom_color_animate);
customColor.setOnClickListener(this);
}
private KProgressHUD hud;
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.indeterminate:
hud = KProgressHUD.create(this)
.setStyle(KProgressHUD.Style.SPIN_INDETERMINATE);
scheduleDismiss();
break;
case R.id.label_indeterminate:
hud = KProgressHUD.create(this)
.setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
.setLabel("Please wait")
.setCancellable(true);
scheduleDismiss();
break;
case R.id.detail_indeterminate:
hud = KProgressHUD.create(this)
.setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
.setLabel("Please wait")
.setDetailsLabel("Downloading data");
scheduleDismiss();
break;
case R.id.determinate:
hud = KProgressHUD.create(MainActivity.this)
.setStyle(KProgressHUD.Style.PIE_DETERMINATE)
.setLabel("Please wait");
simulateProgressUpdate();
break;
case R.id.annular_determinate:
hud = KProgressHUD.create(MainActivity.this)
.setStyle(KProgressHUD.Style.ANNULAR_DETERMINATE)
.setLabel("Please wait");
simulateProgressUpdate();
break;
case R.id.bar_determinate:
hud = KProgressHUD.create(MainActivity.this)
.setStyle(KProgressHUD.Style.BAR_DETERMINATE)
.setLabel("Please wait");
simulateProgressUpdate();
break;
case R.id.custom_view:
ImageView imageView = new ImageView(this);
imageView.setImageResource(R.mipmap.ic_launcher);
hud = KProgressHUD.create(this)
.setCustomView(imageView)
.setLabel("This is a custom view");
scheduleDismiss();
break;
case R.id.dim_background:
hud = KProgressHUD.create(this)
.setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
.setDimAmount(0.5f);
scheduleDismiss();
break;
case R.id.custom_color_animate:
//noinspection deprecation
hud = KProgressHUD.create(this)
.setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
.setWindowColor(getResources().getColor(R.color.colorPrimary))
.setAnimationSpeed(2);
scheduleDismiss();
break;
}
hud.show();
}
private void simulateProgressUpdate() {
hud.setMaxProgress(100);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
int currentProgress;
@Override
public void run() {
currentProgress += 1;
hud.setProgress(currentProgress);
if (currentProgress < 100) {
handler.postDelayed(this, 50);
}
}
}, 100);
}
private void scheduleDismiss() {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
hud.dismiss();
}
}, 2000);
}
}
================================================
FILE: demo/src/main/res/layout/activity_main.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.kaopiz.progresshud.demo.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<Button
android:id="@+id/indeterminate"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="Indeterminate"/>
<Button
android:id="@+id/label_indeterminate"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="With label and cancellable"/>
<Button
android:id="@+id/detail_indeterminate"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="With details"/>
<Button
android:id="@+id/determinate"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="Determinate"/>
<Button
android:id="@+id/annular_determinate"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="Annular determinate"/>
<Button
android:id="@+id/bar_determinate"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="Bar determinate"/>
<Button
android:id="@+id/custom_view"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="Custom view"/>
<Button
android:id="@+id/dim_background"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="Dim background"/>
<Button
android:id="@+id/custom_color_animate"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="Custom color and speed"/>
</LinearLayout>
</ScrollView>
================================================
FILE: demo/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
================================================
FILE: demo/src/main/res/values/dimens.xml
================================================
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
================================================
FILE: demo/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">KProgressHUD</string>
</resources>
================================================
FILE: demo/src/main/res/values/styles.xml
================================================
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
================================================
FILE: demo/src/main/res/values-w820dp/dimens.xml
================================================
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
================================================
FILE: demo/src/test/java/com/kaopiz/progresshud/ExampleUnitTest.java
================================================
package com.kaopiz.progresshud;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#Wed Oct 21 11:34:03 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
================================================
FILE: gradle.properties
================================================
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
================================================
FILE: gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: kprogresshud/.gitignore
================================================
/build
================================================
FILE: kprogresshud/build.gradle
================================================
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
}
}
apply plugin: 'com.android.library'
project.archivesBaseName = 'kprogresshud'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 8
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
ext {
bintrayRepo = 'KProgressHUD'
bintrayName = 'KProgressHUD'
publishedGroupId = 'com.kaopiz'
libraryName = 'kprogresshud'
artifact = 'kprogresshud'
libraryDescription = 'A customizable ProgressHUD for Android'
siteUrl = 'http://kaopiz.github.io/KProgressHUD/'
gitUrl = 'https://github.com/Kaopiz/KProgressHUD'
libraryVersion = '1.0.2'
developerId = 'kaopiz'
developerName = 'Kaopiz Software Co., Ltd.'
developerEmail = 'contact@kaopiz.com'
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
group = publishedGroupId
version = libraryVersion
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
// Bintray
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = bintrayRepo
name = bintrayName
userOrg = 'kaopiz'
desc = libraryDescription
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = allLicenses
publish = true
publicDownloadNumbers = true
version {
desc = libraryDescription
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = properties.getProperty("bintray.gpg.password")
//Optional. The passphrase for GPG signing'
}
}
}
}
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
groupId 'com.kaopiz'
artifactId 'kprogresshud'
// Add your description here
name libraryName
description libraryDescription
url siteUrl
// Set your license
licenses {
license {
name licenseName
url licenseUrl
}
}
developers {
developer {
id developerId
name developerName
email developerEmail
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
================================================
FILE: kprogresshud/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in E:\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
================================================
FILE: kprogresshud/src/androidTest/java/com/kaopiz/kprogresshud/ApplicationTest.java
================================================
package com.kaopiz.kprogresshud;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
================================================
FILE: kprogresshud/src/main/AndroidManifest.xml
================================================
<manifest package="com.kaopiz.kprogresshud"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:supportsRtl="true" />
</manifest>
================================================
FILE: kprogresshud/src/main/java/com/kaopiz/kprogresshud/AnnularView.java
================================================
/*
* Copyright 2015 Kaopiz Software Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kaopiz.kprogresshud;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;
class AnnularView extends View implements Determinate {
private Paint mWhitePaint;
private Paint mGreyPaint;
private RectF mBound;
private int mMax = 100;
private int mProgress = 0;
public AnnularView(Context context) {
super(context);
init(context);
}
public AnnularView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public AnnularView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
private void init(Context context){
mWhitePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mWhitePaint.setStyle(Paint.Style.STROKE);
mWhitePaint.setStrokeWidth(Helper.dpToPixel(3, getContext()));
mWhitePaint.setColor(Color.WHITE);
mGreyPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mGreyPaint.setStyle(Paint.Style.STROKE);
mGreyPaint.setStrokeWidth(Helper.dpToPixel(3, getContext()));
mGreyPaint.setColor(context.getResources().getColor(R.color.kprogresshud_grey_color));
mBound = new RectF();
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
int padding = Helper.dpToPixel(4, getContext());
mBound.set(padding, padding, w - padding, h - padding);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
float mAngle = mProgress * 360f / mMax;
canvas.drawArc(mBound, 270, mAngle, false, mWhitePaint);
canvas.drawArc(mBound, 270 + mAngle, 360 - mAngle, false, mGreyPaint);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int dimension = Helper.dpToPixel(40, getContext());
setMeasuredDimension(dimension, dimension);
}
@Override
public void setMax(int max) {
this.mMax = max;
}
@Override
public void setProgress(int progress) {
mProgress = progress;
invalidate();
}
}
================================================
FILE: kprogresshud/src/main/java/com/kaopiz/kprogresshud/BackgroundLayout.java
================================================
/*
* Copyright 2015 Kaopiz Software Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kaopiz.kprogresshud;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.widget.FrameLayout;
class BackgroundLayout extends FrameLayout {
private float mCornerRadius;
private Paint mPaint;
private RectF mRect;
public BackgroundLayout(Context context) {
super(context);
init();
}
public BackgroundLayout(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public BackgroundLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
@SuppressWarnings("deprecation")
private void init() {
setBaseColor(getContext().getResources().getColor(R.color.kprogresshud_default_color));
// Remove background, we will drawing background using base color
setBackgroundColor(getContext().getResources().getColor(android.R.color.transparent));
}
public void setCornerRadius(float radius) {
mCornerRadius = Helper.dpToPixel(radius, getContext());
}
public void setBaseColor(int color) {
mPaint = new Paint();
//noinspection deprecation
mPaint.setColor(color);
mPaint.setStyle(Paint.Style.FILL);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mRect = new RectF(0, 0, w, h);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawRoundRect(mRect, mCornerRadius, mCornerRadius, mPaint);
}
}
================================================
FILE: kprogresshud/src/main/java/com/kaopiz/kprogresshud/BarView.java
================================================
/*
* Copyright 2015 Kaopiz Software Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kaopiz.kprogresshud;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;
class BarView extends View implements Determinate {
private Paint mOuterPaint;
private Paint mInnerPaint;
private RectF mBound;
private RectF mInBound;
private int mMax = 100;
private int mProgress = 0;
private float mRadius;
private float mBoundGap;
public BarView(Context context) {
super(context);
init();
}
public BarView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public BarView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init() {
mOuterPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mOuterPaint.setStyle(Paint.Style.STROKE);
mOuterPaint.setStrokeWidth(Helper.dpToPixel(2, getContext()));
mOuterPaint.setColor(Color.WHITE);
mInnerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mInnerPaint.setStyle(Paint.Style.FILL);
mInnerPaint.setColor(Color.WHITE);
mBoundGap = Helper.dpToPixel(5, getContext());
mInBound = new RectF(mBoundGap, mBoundGap,
(getWidth() - mBoundGap) * mProgress / mMax, getHeight() - mBoundGap);
mRadius = Helper.dpToPixel(10, getContext());
mBound = new RectF();
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
int padding = Helper.dpToPixel(2, getContext());
mBound.set(padding, padding, w - padding, h - padding);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawRoundRect(mBound, mRadius, mRadius, mOuterPaint);
canvas.drawRoundRect(mInBound, mRadius, mRadius, mInnerPaint);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int widthDimension = Helper.dpToPixel(100, getContext());
int heightDimension = Helper.dpToPixel(20, getContext());
setMeasuredDimension(widthDimension, heightDimension);
}
@Override
public void setMax(int max) {
this.mMax = max;
}
@Override
public void setProgress(int progress) {
this.mProgress = progress;
mInBound.set(mBoundGap, mBoundGap,
(getWidth() - mBoundGap) * mProgress / mMax, getHeight() - mBoundGap);
invalidate();
}
}
================================================
FILE: kprogresshud/src/main/java/com/kaopiz/kprogresshud/Determinate.java
================================================
/*
* Copyright 2015 Kaopiz Software Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kaopiz.kprogresshud;
/**
* If a view implements this interface passed to the HUD as a custom view, its progress
* can be updated by calling setMax() and setProgress() on the HUD.
* This interface only provides convenience, how progress work depends on the view implementation.
*/
public interface Determinate {
void setMax(int max);
void setProgress(int progress);
}
================================================
FILE: kprogresshud/src/main/java/com/kaopiz/kprogresshud/Helper.java
================================================
/*
* Copyright 2015 Kaopiz Software Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kaopiz.kprogresshud;
import android.content.Context;
class Helper {
private static float scale;
public static int dpToPixel(float dp, Context context) {
if (scale == 0) {
scale = context.getResources().getDisplayMetrics().density;
}
return (int) (dp * scale);
}
}
================================================
FILE: kprogresshud/src/main/java/com/kaopiz/kprogresshud/Indeterminate.java
================================================
/*
* Copyright 2015 Kaopiz Software Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kaopiz.kprogresshud;
/**
* If a view implements this interface passed to the HUD as a custom view, its animation
* speed can be change by calling setAnimationSpeed() on the HUD.
* This interface only provides convenience, how animation speed work depends on the view implementation.
*/
public interface Indeterminate {
void setAnimationSpeed(float scale);
}
================================================
FILE: kprogresshud/src/main/java/com/kaopiz/kprogresshud/KProgressHUD.java
================================================
/*
* Copyright 2015 Kaopiz Software Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kaopiz.kprogresshud;
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.TextView;
public class KProgressHUD {
public enum Style {
SPIN_INDETERMINATE, PIE_DETERMINATE, ANNULAR_DETERMINATE, BAR_DETERMINATE
}
// To avoid redundant APIs, all HUD functions will be forward to
// a custom dialog
private ProgressDialog mProgressDialog;
private float mDimAmount;
private int mWindowColor;
private float mCornerRadius;
private boolean mCancellable;
private Context mContext;
private int mAnimateSpeed;
private String mLabel;
private String mDetailsLabel;
private int mMaxProgress;
private boolean mIsAutoDismiss;
public KProgressHUD(Context context) {
mContext = context;
mProgressDialog = new ProgressDialog(context);
mDimAmount = 0;
//noinspection deprecation
mWindowColor = context.getResources().getColor(R.color.kprogresshud_default_color);
mAnimateSpeed = 1;
mCornerRadius = 10;
mIsAutoDismiss = true;
setStyle(Style.SPIN_INDETERMINATE);
}
/**
* Create a new HUD. Have the same effect as the constructor.
* For convenient only.
* @param context Activity context that the HUD bound to
* @return An unique HUD instance
*/
public static KProgressHUD create(Context context) {
return new KProgressHUD(context);
}
/**
* Specify the HUD style (not needed if you use a custom view)
* @param style One of the KProgressHUD.Style values
* @return Current HUD
*/
public KProgressHUD setStyle(Style style) {
View view = null;
switch (style) {
case SPIN_INDETERMINATE:
view = new SpinView(mContext);
break;
case PIE_DETERMINATE:
view = new PieView(mContext);
break;
case ANNULAR_DETERMINATE:
view = new AnnularView(mContext);
break;
case BAR_DETERMINATE:
view = new BarView(mContext);
break;
// No custom view style here, because view will be added later
}
mProgressDialog.setView(view);
return this;
}
/**
* Specify the dim area around the HUD, like in Dialog
* @param dimAmount May take value from 0 to 1.
* 0 means no dimming, 1 mean darkness
* @return Current HUD
*/
public KProgressHUD setDimAmount(float dimAmount) {
if (dimAmount >= 0 && dimAmount <= 1) {
mDimAmount = dimAmount;
}
return this;
}
/**
* Specify the HUD background color
* @param color ARGB color
* @return Current HUD
*/
public KProgressHUD setWindowColor(int color) {
mWindowColor = color;
return this;
}
/**
* Specify corner radius of the HUD (default is 10)
* @param radius Corner radius in dp
* @return Current HUD
*/
public KProgressHUD setCornerRadius(float radius) {
mCornerRadius = radius;
return this;
}
/**
* Change animate speed relative to default. Only have effect when use with indeterminate style
* @param scale 1 is default, 2 means double speed, 0.5 means half speed..etc.
* @return Current HUD
*/
public KProgressHUD setAnimationSpeed(int scale) {
mAnimateSpeed = scale;
return this;
}
/**
* Optional label to be displayed on the HUD
* @return Current HUD
*/
public KProgressHUD setLabel(String label) {
mLabel = label;
return this;
}
/**
* Optional detail description to be displayed on the HUD
* @return Current HUD
*/
public KProgressHUD setDetailsLabel(String detailsLabel) {
mDetailsLabel = detailsLabel;
return this;
}
/**
* Max value for use in one of the determinate styles
* @return Current HUD
*/
public KProgressHUD setMaxProgress(int maxProgress) {
mMaxProgress = maxProgress;
return this;
}
/**
* Set current progress. Only have effect when use with a determinate style, or a custom
* view which implements Determinate interface.
*/
public void setProgress(int progress) {
mProgressDialog.setProgress(progress);
}
/**
* Provide a custom view to be displayed.
* @param view Must not be null
* @return Current HUD
*/
public KProgressHUD setCustomView(View view) {
if (view != null) {
mProgressDialog.setView(view);
} else {
throw new RuntimeException("Custom view must not be null!");
}
return this;
}
/**
* Specify whether this HUD can be cancelled by using back button (default is false)
* @return Current HUD
*/
public KProgressHUD setCancellable(boolean isCancellable) {
mCancellable = isCancellable;
return this;
}
/**
* Specify whether this HUD closes itself if progress reaches max. Default is true.
* @return Current HUD
*/
public KProgressHUD setAutoDismiss(boolean isAutoDismiss) {
mIsAutoDismiss = isAutoDismiss;
return this;
}
public KProgressHUD show() {
if (!isShowing()) {
mProgressDialog.show();
}
return this;
}
public boolean isShowing() {
return mProgressDialog != null && mProgressDialog.isShowing();
}
public void dismiss() {
if (mProgressDialog != null && mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
}
private class ProgressDialog extends Dialog {
private Determinate mDeterminateView;
private Indeterminate mIndeterminateView;
private View mView;
public ProgressDialog(Context context) {
super(context);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.kprogresshud_hud);
Window window = getWindow();
window.setBackgroundDrawable(new ColorDrawable(0));
window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
WindowManager.LayoutParams layoutParams = window.getAttributes();
layoutParams.dimAmount = mDimAmount;
window.setAttributes(layoutParams);
setCanceledOnTouchOutside(false);
setCancelable(mCancellable);
initViews();
}
private void initViews() {
BackgroundLayout background = (BackgroundLayout) findViewById(R.id.background);
background.setBaseColor(mWindowColor);
background.setCornerRadius(mCornerRadius);
FrameLayout containerFrame = (FrameLayout) findViewById(R.id.container);
int wrapParam = ViewGroup.LayoutParams.WRAP_CONTENT;
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(wrapParam, wrapParam);
containerFrame.addView(mView, params);
if (mDeterminateView != null) {
mDeterminateView.setMax(mMaxProgress);
}
if (mIndeterminateView != null) {
mIndeterminateView.setAnimationSpeed(mAnimateSpeed);
}
if (mLabel != null) {
TextView labelText = (TextView) findViewById(R.id.label);
labelText.setText(mLabel);
labelText.setVisibility(View.VISIBLE);
}
if (mDetailsLabel != null) {
TextView detailsText = (TextView) findViewById(R.id.details_label);
detailsText.setText(mDetailsLabel);
detailsText.setVisibility(View.VISIBLE);
}
}
public void setProgress(int progress) {
if (mDeterminateView != null) {
mDeterminateView.setProgress(progress);
if (mIsAutoDismiss && progress >= mMaxProgress) {
dismiss();
}
}
}
public void setView(View view) {
if (view != null) {
if (view instanceof Determinate) {
mDeterminateView = (Determinate) view;
}
if (view instanceof Indeterminate) {
mIndeterminateView = (Indeterminate) view;
}
mView = view;
}
}
}
}
================================================
FILE: kprogresshud/src/main/java/com/kaopiz/kprogresshud/PieView.java
================================================
/*
* Copyright 2015 Kaopiz Software Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kaopiz.kprogresshud;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;
class PieView extends View implements Determinate {
private Paint mWhitePaint;
private Paint mGreyPaint;
private RectF mBound;
private int mMax = 100;
private int mProgress = 0;
public PieView(Context context) {
super(context);
init();
}
public PieView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public PieView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init(){
mWhitePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mWhitePaint.setStyle(Paint.Style.FILL_AND_STROKE);
mWhitePaint.setStrokeWidth(Helper.dpToPixel(0.1f, getContext()));
mWhitePaint.setColor(Color.WHITE);
mGreyPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mGreyPaint.setStyle(Paint.Style.STROKE);
mGreyPaint.setStrokeWidth(Helper.dpToPixel(2, getContext()));
mGreyPaint.setColor(Color.WHITE);
mBound = new RectF();
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
int padding = Helper.dpToPixel(4, getContext());
mBound.set(padding, padding, w - padding, h - padding);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
float mAngle = mProgress * 360f / mMax;
canvas.drawArc(mBound, 270, mAngle, true, mWhitePaint);
int padding = Helper.dpToPixel(4, getContext());
canvas.drawCircle(getWidth()/2, getHeight()/2, getWidth()/2-padding, mGreyPaint);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int dimension = Helper.dpToPixel(40, getContext());
setMeasuredDimension(dimension, dimension);
}
@Override
public void setMax(int max) {
this.mMax = max;
}
@Override
public void setProgress(int progress) {
this.mProgress = progress;
invalidate();
}
}
================================================
FILE: kprogresshud/src/main/java/com/kaopiz/kprogresshud/SpinView.java
================================================
/*
* Copyright 2015 Kaopiz Software Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kaopiz.kprogresshud;
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.ImageView;
class SpinView extends ImageView implements Indeterminate {
private float mRotateDegrees;
private int mFrameTime;
private boolean mNeedToUpdateView;
private Runnable mUpdateViewRunnable;
public SpinView(Context context) {
super(context);
init();
}
public SpinView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
private void init() {
setImageResource(R.drawable.kprogresshud_spinner);
mFrameTime = 1000 / 12;
mUpdateViewRunnable = new Runnable() {
@Override
public void run() {
mRotateDegrees += 30;
mRotateDegrees = mRotateDegrees < 360 ? mRotateDegrees : mRotateDegrees - 360;
invalidate();
if (mNeedToUpdateView) {
postDelayed(this, mFrameTime);
}
}
};
}
@Override
public void setAnimationSpeed(float scale) {
mFrameTime = (int) (1000 / 12 / scale);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.rotate(mRotateDegrees, getWidth() / 2, getHeight() / 2);
super.onDraw(canvas);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
mNeedToUpdateView = true;
post(mUpdateViewRunnable);
}
@Override
protected void onDetachedFromWindow() {
mNeedToUpdateView = false;
super.onDetachedFromWindow();
}
}
================================================
FILE: kprogresshud/src/main/res/layout/kprogresshud_hud.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<com.kaopiz.kprogresshud.BackgroundLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:background="@android:color/transparent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<FrameLayout
android:id="@+id/container"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/label"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="16sp"
android:layout_marginTop="8dp"
android:layout_marginBottom="4dp"/>
<TextView
android:id="@+id/details_label"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="13sp"/>
</LinearLayout>
</com.kaopiz.kprogresshud.BackgroundLayout>
================================================
FILE: kprogresshud/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="kprogresshud_default_color">#b1000000</color>
<color name="kprogresshud_grey_color">#449E9E9E</color>
</resources>
================================================
FILE: kprogresshud/src/test/java/com/kaopiz/kprogresshud/ExampleUnitTest.java
================================================
package com.kaopiz.kprogresshud;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
================================================
FILE: settings.gradle
================================================
include ':demo', ':kprogresshud'
gitextract__b8dyl2m/ ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── demo/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── kaopiz/ │ │ └── progresshud/ │ │ └── demo/ │ │ └── ApplicationTest.java │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── kaopiz/ │ │ │ └── progresshud/ │ │ │ └── demo/ │ │ │ └── MainActivity.java │ │ └── res/ │ │ ├── layout/ │ │ │ └── activity_main.xml │ │ ├── values/ │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── values-w820dp/ │ │ └── dimens.xml │ └── test/ │ └── java/ │ └── com/ │ └── kaopiz/ │ └── progresshud/ │ └── ExampleUnitTest.java ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── kprogresshud/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── kaopiz/ │ │ └── kprogresshud/ │ │ └── ApplicationTest.java │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── kaopiz/ │ │ │ └── kprogresshud/ │ │ │ ├── AnnularView.java │ │ │ ├── BackgroundLayout.java │ │ │ ├── BarView.java │ │ │ ├── Determinate.java │ │ │ ├── Helper.java │ │ │ ├── Indeterminate.java │ │ │ ├── KProgressHUD.java │ │ │ ├── PieView.java │ │ │ └── SpinView.java │ │ └── res/ │ │ ├── layout/ │ │ │ └── kprogresshud_hud.xml │ │ └── values/ │ │ └── colors.xml │ └── test/ │ └── java/ │ └── com/ │ └── kaopiz/ │ └── kprogresshud/ │ └── ExampleUnitTest.java └── settings.gradle
SYMBOL INDEX (92 symbols across 14 files)
FILE: demo/src/androidTest/java/com/kaopiz/progresshud/demo/ApplicationTest.java
class ApplicationTest (line 9) | public class ApplicationTest extends ApplicationTestCase<Application> {
method ApplicationTest (line 10) | public ApplicationTest() {
FILE: demo/src/main/java/com/kaopiz/progresshud/demo/MainActivity.java
class MainActivity (line 35) | public class MainActivity extends AppCompatActivity implements View.OnCl...
method onCreate (line 37) | @Override
method onClick (line 72) | @Override
method simulateProgressUpdate (line 139) | private void simulateProgressUpdate() {
method scheduleDismiss (line 155) | private void scheduleDismiss() {
FILE: demo/src/test/java/com/kaopiz/progresshud/ExampleUnitTest.java
class ExampleUnitTest (line 10) | public class ExampleUnitTest {
method addition_isCorrect (line 11) | @Test
FILE: kprogresshud/src/androidTest/java/com/kaopiz/kprogresshud/ApplicationTest.java
class ApplicationTest (line 9) | public class ApplicationTest extends ApplicationTestCase<Application> {
method ApplicationTest (line 10) | public ApplicationTest() {
FILE: kprogresshud/src/main/java/com/kaopiz/kprogresshud/AnnularView.java
class AnnularView (line 27) | class AnnularView extends View implements Determinate {
method AnnularView (line 35) | public AnnularView(Context context) {
method AnnularView (line 40) | public AnnularView(Context context, AttributeSet attrs) {
method AnnularView (line 45) | public AnnularView(Context context, AttributeSet attrs, int defStyleAt...
method init (line 50) | private void init(Context context){
method onSizeChanged (line 64) | @Override
method onDraw (line 71) | @Override
method onMeasure (line 79) | @Override
method setMax (line 86) | @Override
method setProgress (line 91) | @Override
FILE: kprogresshud/src/main/java/com/kaopiz/kprogresshud/BackgroundLayout.java
class BackgroundLayout (line 26) | class BackgroundLayout extends FrameLayout {
method BackgroundLayout (line 32) | public BackgroundLayout(Context context) {
method BackgroundLayout (line 37) | public BackgroundLayout(Context context, AttributeSet attrs) {
method BackgroundLayout (line 42) | public BackgroundLayout(Context context, AttributeSet attrs, int defSt...
method init (line 47) | @SuppressWarnings("deprecation")
method setCornerRadius (line 54) | public void setCornerRadius(float radius) {
method setBaseColor (line 58) | public void setBaseColor(int color) {
method onSizeChanged (line 65) | @Override
method onDraw (line 71) | @Override
FILE: kprogresshud/src/main/java/com/kaopiz/kprogresshud/BarView.java
class BarView (line 27) | class BarView extends View implements Determinate {
method BarView (line 38) | public BarView(Context context) {
method BarView (line 43) | public BarView(Context context, AttributeSet attrs) {
method BarView (line 48) | public BarView(Context context, AttributeSet attrs, int defStyleAttr) {
method init (line 53) | private void init() {
method onSizeChanged (line 71) | @Override
method onDraw (line 78) | @Override
method onMeasure (line 85) | @Override
method setMax (line 93) | @Override
method setProgress (line 98) | @Override
FILE: kprogresshud/src/main/java/com/kaopiz/kprogresshud/Determinate.java
type Determinate (line 24) | public interface Determinate {
method setMax (line 25) | void setMax(int max);
method setProgress (line 26) | void setProgress(int progress);
FILE: kprogresshud/src/main/java/com/kaopiz/kprogresshud/Helper.java
class Helper (line 21) | class Helper {
method dpToPixel (line 25) | public static int dpToPixel(float dp, Context context) {
FILE: kprogresshud/src/main/java/com/kaopiz/kprogresshud/Indeterminate.java
type Indeterminate (line 24) | public interface Indeterminate {
method setAnimationSpeed (line 25) | void setAnimationSpeed(float scale);
FILE: kprogresshud/src/main/java/com/kaopiz/kprogresshud/KProgressHUD.java
class KProgressHUD (line 30) | public class KProgressHUD {
type Style (line 32) | public enum Style {
method KProgressHUD (line 52) | public KProgressHUD(Context context) {
method create (line 71) | public static KProgressHUD create(Context context) {
method setStyle (line 80) | public KProgressHUD setStyle(Style style) {
method setDimAmount (line 107) | public KProgressHUD setDimAmount(float dimAmount) {
method setWindowColor (line 119) | public KProgressHUD setWindowColor(int color) {
method setCornerRadius (line 129) | public KProgressHUD setCornerRadius(float radius) {
method setAnimationSpeed (line 139) | public KProgressHUD setAnimationSpeed(int scale) {
method setLabel (line 148) | public KProgressHUD setLabel(String label) {
method setDetailsLabel (line 157) | public KProgressHUD setDetailsLabel(String detailsLabel) {
method setMaxProgress (line 166) | public KProgressHUD setMaxProgress(int maxProgress) {
method setProgress (line 175) | public void setProgress(int progress) {
method setCustomView (line 184) | public KProgressHUD setCustomView(View view) {
method setCancellable (line 197) | public KProgressHUD setCancellable(boolean isCancellable) {
method setAutoDismiss (line 206) | public KProgressHUD setAutoDismiss(boolean isAutoDismiss) {
method show (line 211) | public KProgressHUD show() {
method isShowing (line 218) | public boolean isShowing() {
method dismiss (line 222) | public void dismiss() {
class ProgressDialog (line 228) | private class ProgressDialog extends Dialog {
method ProgressDialog (line 234) | public ProgressDialog(Context context) {
method onCreate (line 238) | @Override
method initViews (line 257) | private void initViews() {
method setProgress (line 286) | public void setProgress(int progress) {
method setView (line 295) | public void setView(View view) {
FILE: kprogresshud/src/main/java/com/kaopiz/kprogresshud/PieView.java
class PieView (line 27) | class PieView extends View implements Determinate {
method PieView (line 35) | public PieView(Context context) {
method PieView (line 40) | public PieView(Context context, AttributeSet attrs) {
method PieView (line 45) | public PieView(Context context, AttributeSet attrs, int defStyleAttr) {
method init (line 50) | private void init(){
method onSizeChanged (line 64) | @Override
method onDraw (line 71) | @Override
method onMeasure (line 80) | @Override
method setMax (line 87) | @Override
method setProgress (line 92) | @Override
FILE: kprogresshud/src/main/java/com/kaopiz/kprogresshud/SpinView.java
class SpinView (line 24) | class SpinView extends ImageView implements Indeterminate {
method SpinView (line 31) | public SpinView(Context context) {
method SpinView (line 36) | public SpinView(Context context, AttributeSet attrs) {
method init (line 41) | private void init() {
method setAnimationSpeed (line 57) | @Override
method onDraw (line 62) | @Override
method onAttachedToWindow (line 68) | @Override
method onDetachedFromWindow (line 75) | @Override
FILE: kprogresshud/src/test/java/com/kaopiz/kprogresshud/ExampleUnitTest.java
class ExampleUnitTest (line 10) | public class ExampleUnitTest {
method addition_isCorrect (line 11) | @Test
Condensed preview — 40 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (77K chars).
[
{
"path": ".gitignore",
"chars": 66,
"preview": "*.iml\n.gradle\n/local.properties\n/.idea\n.DS_Store\n/build\n/captures\n"
},
{
"path": "LICENSE",
"chars": 11323,
"preview": "Apache License\n Version 2.0, January 2004\n http://www.apache.org/licens"
},
{
"path": "README.md",
"chars": 5034,
"preview": "# KProgressHUD\n[](http://opensource.org/licenses/"
},
{
"path": "build.gradle",
"chars": 498,
"preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n r"
},
{
"path": "demo/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "demo/build.gradle",
"chars": 659,
"preview": "apply plugin: 'com.android.application'\n\nandroid {\n compileSdkVersion 23\n buildToolsVersion \"23.0.2\"\n\n defaultC"
},
{
"path": "demo/proguard-rules.pro",
"chars": 645,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in E:"
},
{
"path": "demo/src/androidTest/java/com/kaopiz/progresshud/demo/ApplicationTest.java",
"chars": 358,
"preview": "package com.kaopiz.progresshud.demo;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\n/**\n * <"
},
{
"path": "demo/src/main/AndroidManifest.xml",
"chars": 671,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest package=\"com.kaopiz.progresshud\"\n xmlns:android=\"http://schema"
},
{
"path": "demo/src/main/java/com/kaopiz/progresshud/demo/MainActivity.java",
"chars": 6504,
"preview": "/*\n * Copyright (c) 2015 Kaopiz Software Co., Ltd\n *\n * Permission is hereby granted, free of charge, to any person obta"
},
{
"path": "demo/src/main/res/layout/activity_main.xml",
"chars": 2533,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<ScrollView\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xm"
},
{
"path": "demo/src/main/res/values/colors.xml",
"chars": 208,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"colorPrimary\">#3F51B5</color>\n <color name=\"color"
},
{
"path": "demo/src/main/res/values/dimens.xml",
"chars": 211,
"preview": "<resources>\n <!-- Default screen margins, per the Android Design guidelines. -->\n <dimen name=\"activity_horizontal"
},
{
"path": "demo/src/main/res/values/strings.xml",
"chars": 75,
"preview": "<resources>\n <string name=\"app_name\">KProgressHUD</string>\n</resources>\n"
},
{
"path": "demo/src/main/res/values/styles.xml",
"chars": 383,
"preview": "<resources>\n\n <!-- Base application theme. -->\n <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar"
},
{
"path": "demo/src/main/res/values-w820dp/dimens.xml",
"chars": 358,
"preview": "<resources>\n <!-- Example customization of dimensions originally defined in res/values/dimens.xml\n (such as s"
},
{
"path": "demo/src/test/java/com/kaopiz/progresshud/ExampleUnitTest.java",
"chars": 315,
"preview": "package com.kaopiz.progresshud;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * To work on unit tests"
},
{
"path": "gradle/wrapper/gradle-wrapper.properties",
"chars": 230,
"preview": "#Wed Oct 21 11:34:03 PDT 2015\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
},
{
"path": "gradle.properties",
"chars": 855,
"preview": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will o"
},
{
"path": "gradlew",
"chars": 4971,
"preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n## Gradle start "
},
{
"path": "gradlew.bat",
"chars": 2314,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem "
},
{
"path": "kprogresshud/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "kprogresshud/build.gradle",
"chars": 3954,
"preview": "buildscript {\n repositories {\n jcenter()\n }\n dependencies {\n classpath 'com.jfrog.bintray.gradle:"
},
{
"path": "kprogresshud/proguard-rules.pro",
"chars": 645,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in E:"
},
{
"path": "kprogresshud/src/androidTest/java/com/kaopiz/kprogresshud/ApplicationTest.java",
"chars": 354,
"preview": "package com.kaopiz.kprogresshud;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\n/**\n * <a hr"
},
{
"path": "kprogresshud/src/main/AndroidManifest.xml",
"chars": 217,
"preview": "<manifest package=\"com.kaopiz.kprogresshud\"\n xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n <"
},
{
"path": "kprogresshud/src/main/java/com/kaopiz/kprogresshud/AnnularView.java",
"chars": 3051,
"preview": "/*\n * Copyright 2015 Kaopiz Software Co., Ltd.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\""
},
{
"path": "kprogresshud/src/main/java/com/kaopiz/kprogresshud/BackgroundLayout.java",
"chars": 2358,
"preview": "/*\n * Copyright 2015 Kaopiz Software Co., Ltd.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\""
},
{
"path": "kprogresshud/src/main/java/com/kaopiz/kprogresshud/BarView.java",
"chars": 3377,
"preview": "/*\n * Copyright 2015 Kaopiz Software Co., Ltd.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\""
},
{
"path": "kprogresshud/src/main/java/com/kaopiz/kprogresshud/Determinate.java",
"chars": 1032,
"preview": "/*\n * Copyright 2015 Kaopiz Software Co., Ltd.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\""
},
{
"path": "kprogresshud/src/main/java/com/kaopiz/kprogresshud/Helper.java",
"chars": 968,
"preview": "/*\n * Copyright 2015 Kaopiz Software Co., Ltd.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\""
},
{
"path": "kprogresshud/src/main/java/com/kaopiz/kprogresshud/Indeterminate.java",
"chars": 1019,
"preview": "/*\n * Copyright 2015 Kaopiz Software Co., Ltd.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\""
},
{
"path": "kprogresshud/src/main/java/com/kaopiz/kprogresshud/KProgressHUD.java",
"chars": 9505,
"preview": "/*\n * Copyright 2015 Kaopiz Software Co., Ltd.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\""
},
{
"path": "kprogresshud/src/main/java/com/kaopiz/kprogresshud/PieView.java",
"chars": 3030,
"preview": "/*\n * Copyright 2015 Kaopiz Software Co., Ltd.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\""
},
{
"path": "kprogresshud/src/main/java/com/kaopiz/kprogresshud/SpinView.java",
"chars": 2324,
"preview": "/*\n * Copyright 2015 Kaopiz Software Co., Ltd.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\""
},
{
"path": "kprogresshud/src/main/res/layout/kprogresshud_hud.xml",
"chars": 1414,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<com.kaopiz.kprogresshud.BackgroundLayout\n xmlns:android=\"http://schemas.andro"
},
{
"path": "kprogresshud/src/main/res/values/colors.xml",
"chars": 186,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"kprogresshud_default_color\">#b1000000</color>\n <c"
},
{
"path": "kprogresshud/src/test/java/com/kaopiz/kprogresshud/ExampleUnitTest.java",
"chars": 316,
"preview": "package com.kaopiz.kprogresshud;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * To work on unit test"
},
{
"path": "settings.gradle",
"chars": 33,
"preview": "include ':demo', ':kprogresshud'\n"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the liangchengcheng/android-loading-dialog GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 40 files (70.3 KB), approximately 18.0k tokens, and a symbol index with 92 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.