Skip to content

Instantly share code, notes, and snippets.


Sira siralam

  • Hong Kong
View GitHub Profile
Abdelhady / DeviceOrientation
Last active Feb 8, 2021
A utility class to help get current device orientation, you will need it if you decided to fix the activity's orientation in the manifest :)
View DeviceOrientation
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
* Created by abdelhady on 9/23/14.
* to use this class do the following 3 steps in your activity:
gabrielemariotti /
Last active Feb 24, 2021
How to manage the support libraries in a multi-module projects. Thanks to Fernando Cejas (

Centralize the support libraries dependencies in gradle

Working with multi-modules project, it is very useful to centralize the dependencies, especially the support libraries.

A very good way is to separate gradle build files, defining something like:

arriolac /
Last active Sep 27, 2021
Custom Android ImageView for top-crop scaling of the contained drawable.
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.ImageView;
* Created by chris on 7/27/16.