Skip to content

Instantly share code, notes, and snippets.

Avatar

Maxime Rafalimanana rafali

View GitHub Profile
@rafali
rafali / LoadProperties.java
Created Mar 24, 2013
Load .properties file
View LoadProperties.java
ResourceBundle config = ResourceBundle.getBundle("config");
System.out.println(config.getString("api_key"));
@rafali
rafali / text_view_shadow.xml
Created Mar 19, 2013
Text shadow on Android
View text_view_shadow.xml
<TextView
android:shadowColor="@color/black"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="1.5"
android:textColor="@color/white" />
@rafali
rafali / EqualsAndHashCode.java
Last active Dec 14, 2015
Correct equals and hashCode
View EqualsAndHashCode.java
//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 / BytesToHexString.java
Last active May 25, 2016
Convert byte array to Hex string
View BytesToHexString.java
javax.xml.bind.DatatypeConverter.printHexBinary(bytes);
@rafali
rafali / ResizeAnimation.java
Last active Feb 26, 2021
Resize animation on Android
View ResizeAnimation.java
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 / BackgroundTransitionView.java
Last active Sep 16, 2017
Background transition on Android
View BackgroundTransitionView.java
TransitionDrawable transition = (TransitionDrawable) view.getBackground();
if (toggle) {
view.startTransition(1200);
} else {
view.reverseTransition(1200);
}