android-awesome-libraries
Index
- Support
- Network
- Rest Client
- Object Serialization
- Database
- Network Image Handling
- Event Pub/Sub
- Gesture
- Utility
- Cloud Handling
- Social Network Handling
- DI
- View Model Binding
- UI
- Album Handling
- Rx
- Promise
- Security
- Debug Utilitiy
- Gradle Plugin
- Testing
Support
-
[TransitionsBackport](guerwan/TransitionsBackport : https://github.com/guerwan/TransitionsBackport)
-
Android Device Compatibility - Compatibility package project for android device difference.
-
Android Support Annotations
private void displayName(@NonNull String name) {
// name can not be null
}
private void receiveDrawableRes(@DrawableRes int resId) {
// resId must be Drawable Resource ID
}
- gradle-retrolabmda - lambda suppor for android!
mButton.setOnClickListener((View v) -> {
// do something here
});
- icepick - Android Instance State made easy
@Icicle String username; // This will be automatically saved and restored
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Icepick.restoreInstanceState(this, savedInstanceState);
}
@Override public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Icepick.saveInstanceState(this, outState);
}
- Michelangelo - Layout inflation library for Android based on annotations
@InflateLayout(R.layout.custom_view)
public class MyCustomView extends FrameLayout {
public MyCustomView(Context context) {
super(context);
}
@AfterInflate
public void updateTextView() {
((TextView) findViewById(R.id.my_text_view)).setText("hey!");
}
}
@Background
void someBackgroundWork(String aParam, long anotherParam) {
[...]
}
@UiThread
void doInUiThread(String aParam, long anotherParam) {
[...]
}
- HeaderGridView - Header view support for GridView!
gridView.addHeaderView(View v);
- HeaderFooterGridView - HeaderFooterGridView supports adding header rows and footer rows to GridView
final HeaderFooterGridView headerFooterGridView = (HeaderFooterGridView) findViewById(R.id.HeaderFooterGridView);
HeaderView headerView = new HeaderView(context);
headerFooterGridView.addHeaderView(headerView);
FooterView footerView = new FooterView(context);
headerFooterGridView.addFooterView(footerView);
mAdapter = new HeaderFooterGridViewAdapter(this);
headerFooterGridView.setAdapter(mAdapter);
Network
RequestQueue queue = Volley.newRequestQueue(this);
String url = "SOMEURL";
JsonObjectRequest jsObjRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
// TODO
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO
}
});
queue.add(jsObjRequest);
Ion.with(context)
.load("http://example.com/thing.json")
.asJsonObject()
.setCallback(new FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonObject result) {
// do stuff with the result or error
}
});
- okhttp - An HTTP+SPDY client for Android and Java applications
OkHttpClient client = new OkHttpClient();
String run(String url) throws IOException {
Request request = new Request.Builder()
.url(url)
.build();
Response response = client.newCall(request).execute();
return response.body().string();
}
REST Client
public interface GitHubService {
@GET("/users/{user}/repos")
List<Repo> listRepos(@Path("user") String user);
}
Object Serialization
BagOfPrimitives obj = new BagOfPrimitives();
Gson gson = new Gson();
String json = gson.toJson(obj);
Database
Category restaurants = new Category();
restaurants.name = "Restaurants";
restaurants.save();
List joes = userDao.queryBuilder()
.where(Properties.FirstName.eq("Joe"))
.orderAsc(Properties.LastName)
.list();
Network Image Handling
Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);
// Load image, decode it to Bitmap and display Bitmap in ImageView (or any other view
// which implements ImageAware interface)
imageLoader.displayImage(imageUri, imageView);
really configurable!
// DON'T COPY THIS CODE TO YOUR PROJECT! This is just example of ALL options using.
// See the sample project how to use ImageLoader correctly.
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.ic_stub) // resource or drawable
.showImageForEmptyUri(R.drawable.ic_empty) // resource or drawable
.showImageOnFail(R.drawable.ic_error) // resource or drawable
.resetViewBeforeLoading(false) // default
.delayBeforeLoading(1000)
.cacheInMemory(false) // default
.cacheOnDisk(false) // default
.preProcessor(...)
.postProcessor(...)
.extraForDownloader(...)
.considerExifParams(false) // default
.imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) // default
.bitmapConfig(Bitmap.Config.ARGB_8888) // default
.decodingOptions(...)
.displayer(new SimpleBitmapDisplayer()) // default
.handler(new Handler()) // default
.build();
Glide - An image loading and caching library for Android focused on smooth scrolling
Glide.with(this).load("http://goo.gl/h8qOq7").into(imageView);
Event Pub/Sub
eventBus.post(event);
eventBus.register(this);
public void onEvent(AnyEventType event) {
// TODO: React to the event!
}
bus.post(new AnswerAvailableEvent(42));
@Subscribe public void answerAvailable(AnswerAvailableEvent event) {
// TODO: React to the event somehow!
}
Gesture
Utility
- Bolts - a collection of low-level libraries designed to make developing mobile apps easier
final ParseQuery<ParseObject> query = ParseQuery.getQuery("Student");
query.orderByDescending("gpa");
findAsync(query).onSuccessTask(new Continuation<List<ParseObject>, Task<ParseObject>>() {
public Task<ParseObject> then(Task<List<ParseObject>> task) throws Exception {
List<ParseObject> students = task.getResult();
students.get(0).put("valedictorian", true);
return saveAsync(students.get(0));
}
}).onSuccessTask(new Continuation<ParseObject, Task<List<ParseObject>>>() {
public Task<List<ParseObject>> then(Task<ParseObject> task) throws Exception{
ParseObject valedictorian = task.getResult();
return findAsync(query);
}
}).onSuccessTask(new Continuation<List<ParseObject>, Task<ParseObject>>() {
public Task<ParseObject> then(Task<List<ParseObject>> task) throws Exception {
List<ParseObject> students = task.getResult();
students.get(1).put("salutatorian", true);
return saveAsync(students.get(1));
}
}).onSuccess(new Continuation<ParseObject, Void>() {
public Void then(Task<ParseObject> task) throws Exception {
// Everything is done!
return null;
}
});
- routable-android - routes.rb for Android
Router.sharedRouter().map("users/:id", UserActivity.class);
Router.sharedRouter().map("users/new/:name/:zip", NewUserActivity.class);
Router.sharedRouter().open("users/16");
Router.sharedRouter().open("users/new/Clay/94303");
- android-intents - A collection of well-known Android intents for most common actions
Intent intent = IntentUtils.sendEmail(to, subject, body);
startActivity(Intent.createChooser(intent, "TEST"));
- GAlette - Tracking events with Google Analytics by annotations
@SendEvent(category = "HelloWorld", action = "sayHello", label="%1$s")
String sayHello (String name) {
return format("Hello, %s.", name);
}
- Paraphrase - compile-safe format string builders.
<string name="greeting">Hello, {other_name}! My name is {my_name}.</string>
CharSequence greeting = Phrase.greeting()
.other_name("GitHub user")
.my_name("Jake Wharton")
.build(this);
- esperandro - Easy SharedPreference Engine foR ANDROid
String superFancyPreference = preferences.superFancyPreferenceKey()
preferences.superFancyPreferenceKey(superFancyPreference)
public void onSendClick() {
final String status = editText.getText().toString();
if(status.trim().length() > 0) {
jobManager.addJobInBackground(new PostTweetJob(status));
editText.setText("");
}
}
- Android Saripaar - UI Validation Library
@Required(order = 1)
@Email(order = 2)
private EditText emailEditText;
@Password(order = 3)
@TextRule(order = 4, minLength = 6, message = "Enter at least 6 characters.")
private EditText passwordEditText;
@ConfirmPassword(order = 5)
private EditText confirmPasswordEditText;
@Checked(order = 6, message = "You must agree to the terms.")
private CheckBox iAgreeCheckBox;
MyObject myObject = new MyObject("foo");
cacheManager.put("myKey", myObject);
mGPUImage = new GPUImage(this);
mGPUImage.setGLSurfaceView((GLSurfaceView) findViewById(R.id.surfaceView));
mGPUImage.setImage(imageUri); // this loads image on the current thread, should be run in a thread
mGPUImage.setFilter(new GPUImageSepiaFilter());
- Amalgam - Common codes for Android
ToastUtils.showOnUiThread(activity, "SOMESTRING", Toast.LENGTH_SHORT);
isMainThread() // Check if current thread is the main thread.
- Android Checkout - Android In-App Billing made easy.
checkout.start();
// you only need this if this activity starts purchase process
checkout.createPurchaseFlow(new PurchaseListener());
// you only need this if this activity needs information about purchases/SKUs
inventory = checkout.loadInventory();
inventory.whenLoaded(new InventoryLoadedListener())
new AsyncJob.AsyncJobBuilder<Boolean>()
.doInBackground(new AsyncJob.AsyncAction<Boolean>() {
@Override
public Boolean doAsync() {
// Do some background work
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return true;
}
})
.doWhenFinished(new AsyncJob.AsyncResultAction<Boolean>() {
@Override
public void onResult(Boolean result) {
Toast.makeText(context, "Result was: " + result, Toast.LENGTH_SHORT).show();
}
}).create().start();
Cloud Handling
- Driven - A unified API calls for different cloud storage providers
StorageProvider provider = new Dropbox();
provider.authenticate(credentials);
// list all files in the root
provider.listAsync(new Task<List<DrivenFile>>(){
public void onComplete(List<DrivenFile> files){
...
}
});
Social Network Handling
- AndroidSocialNetworks - easy work with Facebook, Twitter, LinkedIn and Google
mSocialNetworkManager = (SocialNetworkManager) getFragmentManager().findFragmentByTag(SOCIAL_NETWORK_TAG);
if (mSocialNetworkManager == null) {
mSocialNetworkManager = SocialNetworkManager.Builder.from(getActivity())
.twitter(<< TWITTER API TOKEN >>, << TWITTER API SECRET >>)
.linkedIn(<< LINKED_IN API TOKEN >>, << LINKED_IN API TOKEN >>, "r_basicprofile+rw_nus+r_network+w_messages")
.facebook()
.googlePlus()
.build();
getFragmentManager().beginTransaction().add(mSocialNetworkManager, SOCIAL_NETWORK_TAG).commit();
}
DI
@InjectView(R.id.user) EditText username;
@InjectView(R.id.pass) EditText password;
@OnClick(R.id.submit) void submit() {
// TODO call server...
}
@Inject
Thermosiphon(Heater heater) {
this.heater = heater;
}
View Model Binding
- android-binding - MVVM for Android
public StringObservable message = new StringObservable();
...
message.set("Hello MVVM!"); // will change the model and view
UI
- PhotoView - ImageView for Android that supports zooming, by various touch gestures.
-
CWAC TouchListView - A Drag-and-Drop Capable ListView
AdapterViewAnimator animator = new AdapterViewAnimator(adapterView);
data.add(item);
adapter.notifyDataSetChanged();
animator.animate();
- ListViewAnimations - allows developers to easily add animations to ListView items
Album handling
- DeviceAlbums (Compatibility library for dealing with various device photo albums.)
- Laevatein
- RoboGuice
Rx
Subscription sub = Observable.from(1, 2, 3, 4, 5)
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(observer);
Promise
Deferred deferred = new DeferredObject();
Promise promise = deferred.promise();
promise.done(new DoneCallback() {
public void onDone(Object result) {
...
}
}).fail(new FailCallback() {
public void onFail(Object rejection) {
...
}
}).progress(new ProgressCallback() {
public void onProgress(Object progress) {
...
}
}).always(new AlwaysCallback() {
public void onAlways(State state, Object result, Object rejection) {
...
}
});
Security
- Conceal - Fast cryptographic operations for Android by Facebook
Debug Utility
@DebugLog
public String getName(String first, String last) {
SystemClock.sleep(15); // Don't ever really do this!
return first + " " + last;
}
- dspec - An easy way to draw UI specs on top of your Android UI
Gradle Plugin
Testing
Unit
- JUnit
- Robospock
def "should display hello text"() {
given:
def textView = new TextView(Robolectric.application)
and:
def hello = "Hello"
when:
textView.setText(hello)
then:
textView.getText() == hello
}
Assert
assertThat(frodo.getName()).isEqualTo("Frodo");
assertThat(frodo).isNotEqualTo(sauron)
.isIn(fellowshipOfTheRing);
assertThat(sauron).isNotIn(fellowshipOfTheRing);
Fixture
Factory.define(
// This will guess the User class
new Definition(User.class) {
@Override
public Bundle set(Bundle attrs) {
attrs.putString("name", "John");
attrs.putBoolean("admin", false);
return attrs;
}
// This will use the User class (Adming would have been guessed)
}, new Definition(User.class, "admin") {
@Override
public Bundle set(Bundle attrs) {
attrs.putString("name", "Admin");
attrs.putBoolean("admin", true);
return attrs;
}
});
Mock
LinkedList mockedList = mock(LinkedList.class);
when(mockedList.get(0)).thenReturn("first");
when(mockedList.get(1)).thenThrow(new RuntimeException());
UI Test
public void testSayHello() {
onView(withId(R.id.name_field))
.perform(typeText("Steve"));
onView(withId(R.id.greet_button))
.perform(click());
onView(withText("Hello Steve!"))
.check(matches(isDisplayed()));
}
Others
buck - A high-performance Android & Java build tool
Documentation
Contribution
Just fork & edit & send pull-request on GitHub!
####Policy
- Official Website over GitHub Repository for links.
- Should put codes which reflects the library.
- For UI libraries, put demonstorations (AniGIF, PNG, Movies).
And I am considering to ...
- Put reference links for each libraries.
- Separate pages for each categories.
- Separate UI categories.
####Maintainer
kaiinui (https://github.com/kaiinui)
####and...
I am building a website to browse awesome libraries! https://github.com/kaiinui/droidgems