Skip to content

Instantly share code, notes, and snippets.

View vbarthel-fr's full-sized avatar
🎶

Vincent Barthélémy vbarthel-fr

🎶
View GitHub Profile
@vbarthel-fr
vbarthel-fr / outputs.md
Created May 4, 2019 08:00
Tenuun: random images

Sortie possible 1

L'image orange sera en position 5
Voici la liste des images. Rappel: la premiere case d'une liste a l'index 0.
L'index 5 correspond donc a la case 6
['red_image', 'red_image', 'red_image', 'red_image', 'red_image', 'orange_image', 'red_image', 'red_image', 'red_image']

Sortie possible 2

@vbarthel-fr
vbarthel-fr / dipToPx
Created January 28, 2015 13:30
View utils
/**
* Convert a value from dip to pixel.
*
* @param displayMetrics the {@link android.util.DisplayMetrics} used to convert.
* @param dip the value in dip to convert.
* @return a value in pixel.
*/
public static int dipToPx(DisplayMetrics displayMetrics, float dip) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, displayMetrics);
}
public class MyActivity extends Activity {
private Toast mTextToast;
...
private void makeToast(String message) {
if (mTextToast != null) {
mTextToast.cancel();
}