Skip to content

Instantly share code, notes, and snippets.

View realdadfish's full-sized avatar

Thomas Keller realdadfish

View GitHub Profile
public class ViewUtils
{
/**
* Starts animations inside a LayerDrawable
*
* @param drawable
*/
public static void startLayerAnimation(LayerDrawable drawable)
{
for (int i = 0; i < drawable.getNumberOfLayers(); ++i)
public class ChromeTint implements Parcelable
{
private int mToolbarColor;
private int mToolbarTitleColor;
private int mStatusbarColor;
public static ChromeTint createFromBitmap(Bitmap bm, int defaultToolbarColor, int defaultTitleColor, int defaultStatusbarColor)
{
Palette pal = Palette.generate(bm);
Palette.Swatch vibrant = pal.getVibrantSwatch();
apply plugin: "sonar-runner"
sonarRunner {
sonarProperties {
// connectivity
property "sonar.host.url", "http://your.server/sonar"
property "sonar.jdbc.url", "jdbc:mysql://..."
property "sonar.jdbc.driverClassName", "com.mysql.jdbc.Driver"
property "sonar.jdbc.username", "..."
// project configuration
@realdadfish
realdadfish / OkHttpDownloader.java
Last active August 29, 2015 14:06
How to use OkHttp 2.0 API to download stuff on behalf of Picasso.
public class OkHttpDownloader implements Downloader
{
@Override
public Response load(Uri uri, boolean b) throws IOException
{
HttpClientProxy clientProxy = // create a HttpClient proxy that
// forwards stuff to a real OkHttpClient
// or some mocked class
Request request = new Request.Builder()
.url(uri.toString())
#!/usr/bin/perl
#
# ATTENTION: In addition to Net::Jabber you also need to apply
# this patch http://toroid.org/ams/etc/net-xmpp-virtualhost-support
# to let this script connect to a jabber server independent from
# the domain you gave it.
#
# Then, symlink this script in each git repository you want to
# receive notifications for (i.e. ln -s path/to/post-receive.pl repo.git/hooks/post-receive)
# and configure the branches (".*" as catch-all works) and chat ID
@realdadfish
realdadfish / Spinner
Created December 11, 2013 13:44
Idiom to preselect an item in an Android `Spinner` widget without firing its `OnItemSelectedListener` right away. Unfortunately the notification of item selection changes happens asynchronously and also the check whether a listener exists _at all_ is only executed the next time the main loop has time to process the `View`'s request to process th…
final Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.setSelection(2);
spinner.post(new Runnable() {
@Override
public void run() {
spinner.setOnItemSelectedListener(new OnItemSelectedListener() { ... });
}
});