Github open Source: github.com/AlanCheen/P…

In ancient Greek mythology, Pandora is the first woman in the world, an all-gifted woman, and Pandora’s box contains hope.

With the all-gifted implication, I created an open source library Pandora, a collection of very commonly used utility classes.

Although it is a collection of Utils, it is different from other libraries. The number of classes and methods here is very small. I only select a very small number of classes that I think are really useful and have a high probability of reuse.

Therefore, it can also be regarded as an “Utils heart choice”.

So let’s talk about Pandora’s capabilities.

ApplicationUtils

Context is very common in Android, but most of the time we don’t need to pass an Activity Context. Using ApplicationUtils relieves the dilemma of passing the Context around. (The Application is fetched from ActivityThread by default)


MainThread

A main thread utility class that makes it easy to post Runnable to the main thread for execution.


ToastUtils

A global singleton Toast to solve the problem of repeatedly playing the Toast caused by multiple instances of Toast.


LifecycleHandler

When using Handler, we are always worried that it will cause memory leaks, so we remove Handler messages in onDestroy every time and write boilerplate code. LifecycleHandler is designed to solve this dilemma. You don’t need to pay attention to onDestroy anymore!

UiUtils

Android development inevitably deals with pixel DP, etc. UiUtils includes some operations for converting data units.

Predictions

A utility class that does “assertions” to verify that arguments are valid. Even though we have annotations such as NonNull, we can’t avoid sending false arguments from the outside. In this case we can’t avoid writing boilerboard code to check whether the arguments are false and throw exceptions if they are.


You can have all the above abilities in one sentence:

implementation 'me. Yifeiyuan. Pandora: Pandora - basic: 1.0.3'
Copy the code

Github address: github.com/AlanCheen/P…

Feel the power of the Pandora box?

Welcome Star! ~