KProgressHUD
An implement of ProgressHUD for Android, similar to MBProgressHUD, SVProgressHUD for iOS.
Top Related Projects
Android loading animations
DEPRECATED
A material style progress wheel compatible with 2.3
A progress wheel for android, intended for use instead of the standard progress bar.
Quick Overview
KProgressHUD is a progress HUD written in Swift, inspired by the popular MBProgressHUD library for Objective-C. It provides a simple and customizable way to display progress indicators and notifications within your iOS applications.
Pros
- Customizable Appearance: KProgressHUD allows you to easily customize the appearance of the progress indicator, including the style, color, and size.
- Flexible Usage: The library supports a variety of use cases, including showing progress indicators, success/error messages, and custom views.
- Smooth Animations: KProgressHUD provides smooth animations for showing and hiding the progress HUD, creating a polished user experience.
- Lightweight and Efficient: The library is lightweight and efficient, with a small footprint and minimal impact on your application's performance.
Cons
- Limited Platform Support: KProgressHUD is designed specifically for iOS and does not provide support for other platforms, such as Android or web.
- Dependency on Swift: As the library is written in Swift, it may not be as easily integrated into Objective-C-based projects.
- Lack of Extensive Documentation: The project's documentation could be more comprehensive, which may make it more challenging for new users to get started.
- Potential Compatibility Issues: With the rapid evolution of iOS and Swift, there is a possibility of compatibility issues with newer versions of the operating system or the programming language.
Code Examples
Displaying a Progress Indicator
// Show a progress indicator
KProgressHUD.show()
// Hide the progress indicator
KProgressHUD.dismiss()
Displaying a Success or Error Message
// Show a success message
KProgressHUD.showSuccess("Operation completed successfully!")
// Show an error message
KProgressHUD.showError("An error occurred. Please try again.")
Customizing the Progress Indicator
// Set the progress HUD style
KProgressHUD.set(style: .custom)
// Set the progress HUD color
KProgressHUD.set(foregroundColor: .blue)
KProgressHUD.set(backgroundColor: .white)
Displaying a Custom View
// Create a custom view
let customView = UIImageView(image: UIImage(named: "custom_icon"))
// Show the custom view
KProgressHUD.show(customView: customView)
Getting Started
To get started with KProgressHUD, follow these steps:
-
Add the KProgressHUD library to your project. You can do this using a package manager like CocoaPods or Carthage, or by manually adding the source files to your project.
-
Import the KProgressHUD library in your Swift file:
import KProgressHUD
-
Use the provided methods to display and customize the progress HUD:
// Show a progress indicator KProgressHUD.show() // Hide the progress indicator KProgressHUD.dismiss() // Show a success message KProgressHUD.showSuccess("Operation completed successfully!") // Show an error message KProgressHUD.showError("An error occurred. Please try again.") // Customize the progress HUD KProgressHUD.set(style: .custom) KProgressHUD.set(foregroundColor: .blue) KProgressHUD.set(backgroundColor: .white)
-
Explore the available customization options and additional features provided by the KProgressHUD library to fit your specific needs.
Competitor Comparisons
Android loading animations
Pros of Android-SpinKit
- Provides a wide variety of pre-built loading spinner animations, allowing for easy customization and integration into your app.
- Supports both XML and programmatic configuration, making it flexible for different use cases.
- Includes a comprehensive set of documentation and examples, making it easy to get started.
Cons of Android-SpinKit
- May have a larger footprint in your app compared to a more lightweight custom loading indicator.
- Customization options are limited to the pre-built animations, so creating a completely custom loading indicator may require more effort.
- Dependency on an external library, which could increase the overall complexity of your project.
Code Comparison
KProgressHUD (Kaopiz/KProgressHUD):
KProgressHUD hud = KProgressHUD.create(this)
.setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
.setLabel("Please wait")
.setCancellable(true)
.setAnimationSpeed(2)
.setDimAmount(0.5f)
.show();
Android-SpinKit (ybq/Android-SpinKit):
<com.github.ybq.android.spinkit.SpinKitView
android:id="@+id/spin_kit"
style="@style/SpinKitView.Large.CubeGrid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
DEPRECATED
Pros of AVLoadingIndicatorView
- Provides a wide variety of loading indicator styles, allowing for more visual customization.
- Supports both iOS and Android platforms, making it a cross-platform solution.
- Includes a simple and straightforward API for easy integration into projects.
Cons of AVLoadingIndicatorView
- May have a larger footprint in terms of file size and dependencies compared to KProgressHUD.
- Requires more configuration and setup to achieve the desired look and feel.
- May not offer as many advanced features and customization options as KProgressHUD.
Code Comparison
KProgressHUD:
let hud = KProgressHUD.showOn(self)
hud.setTitle("Loading...")
hud.setDetailsLabel("Please wait")
hud.show()
AVLoadingIndicatorView:
let loadingIndicator = AVLoadingIndicatorView(frame: view.bounds)
loadingIndicator.type = .ballPulse
loadingIndicator.color = .gray
view.addSubview(loadingIndicator)
loadingIndicator.startAnimating()
A material style progress wheel compatible with 2.3
Pros of materialish-progress
- Material Design Inspired: materialish-progress follows the Material Design guidelines, providing a visually appealing and modern progress indicator.
- Customizable: The library offers a range of customization options, allowing you to adjust the color, size, and animation of the progress indicator to match your app's design.
- Cross-platform: The library is designed to work across multiple platforms, including iOS and Android, making it a versatile choice for your project.
Cons of materialish-progress
- Limited Functionality: Compared to KProgressHUD, materialish-progress has a more limited set of features, focusing primarily on the progress indicator itself.
- Smaller Community: KProgressHUD has a larger and more active community, with more contributors and a wider range of resources available.
Code Comparison
KProgressHUD:
let progressHUD = KProgressHUD.showOn(self.view)
progressHUD.setLabel("Loading...")
progressHUD.show()
materialish-progress:
let progressView = MaterialishProgress(frame: view.bounds)
progressView.color = UIColor.blue
progressView.startAnimating()
view.addSubview(progressView)
A progress wheel for android, intended for use instead of the standard progress bar.
Pros of ProgressWheel
- Customizable Appearance: ProgressWheel offers a wide range of customization options, allowing you to adjust the size, color, and animation of the progress indicator to match your app's design.
- Smooth Animation: The progress wheel in ProgressWheel has a smooth, fluid animation that provides a polished and responsive user experience.
- Lightweight and Efficient: ProgressWheel is a lightweight library, adding minimal overhead to your app's performance.
Cons of ProgressWheel
- Limited Functionality: Compared to KProgressHUD, ProgressWheel has a more limited set of features, such as the lack of support for text or image overlays.
- Older Codebase: ProgressWheel has not been actively maintained for several years, which may raise concerns about compatibility with newer iOS versions or potential issues.
Code Comparison
KProgressHUD:
let hud = KProgressHUD.show()
hud.setTitle("Loading...")
hud.setDetailsLabel("Please wait")
hud.dismiss(afterDelay: 2.0)
ProgressWheel:
let progressWheel = ProgressWheel(frame: view.bounds)
progressWheel.progressColor = .blue
progressWheel.startAnimation()
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
KProgressHUD
A progress HUD implementation for Android. Inspired by MBProgressHUD for iOS.
Compatibility
Android 2.3 and later
Adding KProgressHUD to your project
Gradle
Include this in your app build.gradle
dependencies {
// Other dependencies
implementation 'com.kaopiz:kprogresshud:1.2.0'
}
Source code
If you want more control over the implementation, download and import the kprogresshud
folder as a module to your project and modify according to your need.
Usage
The usage of KProgressHUD is pretty straight forward.
- Create the HUD, customize its style and show on the UI thread.
- Fire a background worker to handle long-running tasks.
- When done, call
dismiss()
to close (or if you use a determinate style, the HUD will automatically dismiss when progress reaches its max).
Indeterminate HUD
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
KProgressHUD hud = KProgressHUD.create(MainActivity.this)
.setStyle(KProgressHUD.Style.ANNULAR_DETERMINATE)
.setLabel("Please wait")
.setMaxProgress(100)
.show();
hud.setProgress(90);
You can also create a custom view to be displayed.
ImageView imageView = new ImageView(this);
imageView.setBackgroundResource(R.drawable.spin_animation);
AnimationDrawable drawable = (AnimationDrawable) imageView.getBackground();
drawable.start();
KProgressHUD.create(MainActivity.this)
.setCustomView(imageView)
.setLabel("This is a custom view")
.show();
Optionally, the custom view can implement Determinate
or Indeterminate
interface, which make the HUD treats this view like the default determinate or indeterminate one.
See Javadocs or sample for more information.
Contributing
- Fork it ( https://github.com/Kaopiz/KProgressHUD/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
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.
Top Related Projects
Android loading animations
DEPRECATED
A material style progress wheel compatible with 2.3
A progress wheel for android, intended for use instead of the standard progress bar.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot