All Projects → ezralazuardy → orb

ezralazuardy / orb

Licence: MIT license
Android network monitoring made easy 🎉️

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to orb

imgalign
Webapplication for image stitching and aligning
Stars: ✭ 162 (+800%)
Mutual labels:  orb
Motion-Estimation-using-Speeded-Up-Robust-Features-SURF-and-Oriented-Fast-Rotated-Brief-ORB-
No description or website provided.
Stars: ✭ 25 (+38.89%)
Mutual labels:  orb
cypress-example-circleci-orb
Demo of using the Cypress CircleCI Orb
Stars: ✭ 26 (+44.44%)
Mutual labels:  orb
Semigroups
The GAP package Semigroups
Stars: ✭ 21 (+16.67%)
Mutual labels:  orb
Feature-Detection-and-Matching
Feature Detection and Matching with SIFT, SURF, KAZE, BRIEF, ORB, BRISK, AKAZE and FREAK through the Brute Force and FLANN algorithms using Python and OpenCV
Stars: ✭ 95 (+427.78%)
Mutual labels:  orb
Orb-Project-Template
A starter template for orb projects. Build, test, and publish orbs automatically on CircleCI. Use the Orb Development Kit to get started.
Stars: ✭ 24 (+33.33%)
Mutual labels:  orb
Feature-Detection-and-Description
Feature Detection and Description with SIFT, SURF, KAZE, BRIEF, ORB, BRISK, AKAZE and FREAK using Python and OpenCV
Stars: ✭ 31 (+72.22%)
Mutual labels:  orb

Orb

code quality maintainability build status security release minimum API issues license


Orb is a lifecycle-aware asynchronous network monitoring library to simplify the needs of network state monitoring in Android. This library can help you monitor (observe) the current network state of Android device. It can give you the current connection status, and connection type in realtime change events without blocking the main thread. Orb really works well with the MVVM architecture pattern in Android.

How it works

Orb is an implementation of Android Live Data that use an observable pattern to get the network state data in realtime. This is what makes Orb lifecycle-aware. Since the lifecycle of Live Data object is already handled automatically by Android lifecycle, you don't need to handle the Orb lifecycle manually. It's guarantee you to be flexible and no memory leak. You can just start Orb and forget about it, it'll handle the lifecycle based on your Activity lifecycle automatically.

How Orb determine the current network state and type is by using ConnectivityManager. And due to some Android ConnectivityManager API deprecation, applying network managing algorithm can be a little bit hard and tricky. Here's come Orb to the rescue. Orb is simple, powerful, sweet, and the most important, idiomatic!. It's written in pure Kotlin.

Latest version

See the latest released Orb version here.


✍️ Installation

Gradle setup

// project level gradle
allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}
// module level gradle
dependencies {
    implementation 'com.github.ezralazuardy:orb:$version' //replace '$version' with the latest version of orb
}

Maven setup

<!-- <repositories> section of pom.xml -->
<repository>
    <id>jitpack.io</id>
   <url>https://jitpack.io</url>
</repository>
<!-- <dependencies> section of pom.xml -->
<dependency>
    <groupId>com.github.ezralazuardy</groupId>
    <artifactId>orb</artifactId>
    <version>version</version> <!-- replace 'version' with the latest version of orb -->
</dependency>

🚀️ Getting Started

Manifest permission settings

Since Orb API need to access and change the current network status of the device, you need to add the following permissions in you App manifest.

<manifest>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    ...
</manifest>

Using Orb

Orb usage is pretty simple, you just need to initialize it in your current context (view), and the rest will be handled by Orb.

Orb.with(this).observe { response ->
    Log.d(this::javaClass.simpleName, response.toString())
    // do something awesome..
}

All the action defined inside observe function will be converted into an observer. Make sure you've initialize the Orb only in the onCreate() function of your activity. Why?, because Orb only can observe a single observer and that need to be happened in the creation process of your activity.

What if you want to change the observer?, like changing the observer action after you observing the Orb? or changing the observer action when each time Orb detecting network changes? to do that, please read more about Orb advanced usage in the documentation.

If you don't want to use a direct written observer, you can use the Orb observer function builder, and pass the observer to observe function parameter.

// use the Orb observer function builder
val observer = orbObserver { response ->
  Log.d(this::javaClass.simpleName, response.toString())
  // do something awesome..
}

Orb.with(this).observe(observer)

Orb observer will be called each time Orb is detecting network changes in the device. The observe function also gives you an OrbResponse that hold the network state information, so that you can interact with it.

Please note that Orb will observing the network asynchronously. It's mean that Orb will not blocking your main thread, resulting in hang and stuttering effect on Android screen. And Orb is also lifecycle-aware. You don't need to worry about memory leak, all already handled by Orb. You just need to focus on functionality of your app, and let Orb do all the network monitoring stuff.

The OrbResponse

The observe method will return an OrbResponse object (accessible by keyword it by default) when each time Orb detecting a change in device network state. This object hold some properties as follows:

Property Value Type Default Value Information
state OrbState OrbState.UNKNOWN Current network state of the device
type OrbType OrbType.UNKNOWN Current network type of the device
errorMessage String null The message when error happened in Orb process

📖️ Documentation

Read the Orb documentation here.


🤔️ Sample Implementation

You can try the sample implementation of Orb by cloning this repository to your local, and run the sample module.


👷️ Contributing

All contributions are welcomed. Please make a pull request so that I can review your changes.

Before start making contributions to Orb, please read the contribution guidelines and code of conduct.


🛡️ Security Policy

Read the current Orb's security policy here.


🗒️ Side Note

Orb is at it's early stage. If you experiencing an error or bug, please report it by creating a new issues.


📜 License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].