Skip to content

Instantly share code, notes, and snippets.

View ndorigatti's full-sized avatar

Nicola Dorigatti ndorigatti

View GitHub Profile
@meeDamian
meeDamian / MyTextView.java
Last active December 25, 2015 16:39
Just a handy trick to handle lack of `android:textAllCaps="true"` on devices prior to ICS
public class MyTextView extends TextView {
private boolean allCaps = false;
public MyTextView(Context context, AttributeSet attrs) {
super(context, attrs);
if( isLegacy() ) {
allCaps = attrs.getAttributeBooleanValue("http://schemas.android.com/apk/res/android", "textAllCaps", false);
if(allCaps) setText(getText()); // this line is really stupid, but initial setText() is called in TextView constructor, once allCaps isn't yet properly set...
}
@lucasr
lucasr / sample.java
Last active March 5, 2016 03:41
Using ItemClickSupport from TwoWayView
ItemClickSupport itemClick = ItemClickSupport.addTo(recyclerView);
itemclick.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(RecyclerView p, View c, int pos, long id) {
...
}
});
itemClick.setOnItemLongClickListener(new OnItemLongClickListener() {
@ndorigatti
ndorigatti / misc.xml
Created February 12, 2018 13:16
Roboto Font Variant in XML
android:fontFamily="sans-serif" // roboto regular
android:fontFamily="sans-serif-light" // roboto light
android:fontFamily="sans-serif-condensed" // roboto condensed
android:fontFamily="sans-serif-black" // roboto black
android:fontFamily="sans-serif-thin" // roboto thin (android 4.2)
android:fontFamily="sans-serif-medium" // roboto medium (android 5.0)
in combination with
android:textStyle="normal|bold|italic"
STORE_FILE=/path/to/your.keystore
STORE_PASSWORD=yourkeystorepass
KEY_ALIAS=projectkeyalias
KEY_PASSWORD=keyaliaspassword
@swankjesse
swankjesse / RetrofitCachingExample.java
Created June 29, 2013 03:03
Demonstrate HTTP caching with OkHttp and Retrofit.
/*
* Copyright (C) 2013 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@homj
homj / CardViewUtils.java
Last active January 26, 2020 21:21
A utility-class providing methods to easily align a CardView in a layout by using margins; modifications pulled from https://gist.github.com/flore2003/943ef5e9fe316f903262
package de.twoid.widget.util;
/*
* Copyright 2015 Johannes Homeier, Florian Reifschneider
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@gabrielemariotti
gabrielemariotti / README.md
Last active February 24, 2021 10:52
How to manage the support libraries in a multi-module projects. Thanks to Fernando Cejas (http://fernandocejas.com/)

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:

root
  --gradleScript
 ----dependencies.gradle
@romannurik
romannurik / SwipeDismissListViewTouchListener.java
Last active May 1, 2021 10:16
**BETA** Android 4.0-style "Swipe to Dismiss" sample code
Moved to
https://github.com/romannurik/android-swipetodismiss
@tito
tito / main.py
Last active July 21, 2021 14:31
iBeacon iOS 8 Scanner (python / pyobjus / kivy), using ranging API
# coding=utf-8
"""
iBeacon Scanner
===============
This scanner works exclusively on iOS real devices, simulator don't support
iBeacon ranging API at all.
The usage is quite simple:
@romannurik
romannurik / CharsPerLineActivity.java
Last active December 17, 2021 03:15
Demonstrates how to identify and avoid line-length issues with TextView. The measure, or characters per line, of a block of text plays a key role in how comfortable it is to read (sometimes referred to as readability). A widely accepted optimal range for a text block's measure is between 45 and 75 characters. This code demonstrates two phases of…
/*
* Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software