Skip to content

Instantly share code, notes, and snippets.

View rafali's full-sized avatar

Maxime Rafalimanana rafali

View GitHub Profile
@rafali
rafali / BackgroundTransitionView.java
Last active September 16, 2017 09:51
Background transition on Android
TransitionDrawable transition = (TransitionDrawable) view.getBackground();
if (toggle) {
view.startTransition(1200);
} else {
view.reverseTransition(1200);
}
@rafali
rafali / ResizeAnimation.java
Last active February 26, 2021 13:05
Resize animation on Android
public class ResizeAnimation extends Animation {
final int startWidth;
final int targetWidth;
View view;
public ResizeAnimation(View view, int targetWidth) {
this.view = view;
this.targetWidth = targetWidth;
startWidth = view.getWidth();
}
@rafali
rafali / BytesToHexString.java
Last active May 25, 2016 03:44
Convert byte array to Hex string
javax.xml.bind.DatatypeConverter.printHexBinary(bytes);
@rafali
rafali / EqualsAndHashCode.java
Last active December 14, 2015 22:49
Correct equals and hashCode
//from http://developer.android.com/reference/java/lang/Object.html
// Use @Override to avoid accidental overloading.
@Override public boolean equals(Object o) {
// Return true if the objects are identical.
// (This is just an optimization, not required for correctness.)
if (this == o) {
return true;
}
@rafali
rafali / text_view_shadow.xml
Created March 19, 2013 00:40
Text shadow on Android
<TextView
android:shadowColor="@color/black"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="1.5"
android:textColor="@color/white" />
@rafali
rafali / LoadProperties.java
Created March 24, 2013 19:35
Load .properties file
ResourceBundle config = ResourceBundle.getBundle("config");
System.out.println(config.getString("api_key"));