Skip to content

Instantly share code, notes, and snippets.

View tbruyelle's full-sized avatar

Thomas Bruyelle tbruyelle

View GitHub Profile
@tbruyelle
tbruyelle / file.MD
Last active August 29, 2015 13:56
AAR in the local repository
apply plugin: 'maven'
uploadArchives {
  repositories {
    mavenDeployer {
      repository url: 'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath
    }
  }
}
task install(dependsOn: uploadArchives)
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<solid android:color="#1A000000"/>
</shape>
</item>
<item android:state_focused="true">
@tbruyelle
tbruyelle / gist:c2f852aafbaceda82bdf
Created July 28, 2014 09:01
Android get ColorBackground
TypedValue tv = new TypedValue();
context.getTheme().resolveAttribute(android.R.attr.colorBackground, tv, true);
if (tv.type >= TypedValue.TYPE_FIRST_COLOR_INT && tv.type <= TypedValue.TYPE_LAST_COLOR_INT) {
// windowBackground is a color
setBackgroundColor(tv.data);
} else {
// windowBackground is not a color, probably a drawable
setBackgroundDrawable(getResources().getDrawable(tv.resourceId));
}
package com.comalia.gesicamobile.manager.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import com.comalia.gesicamobile.manager.R;
@tbruyelle
tbruyelle / SingleClickListener.java
Created July 31, 2014 09:56
SingleClickListener
package com.tweetping.util;
import android.os.SystemClock;
import android.view.View;
import android.widget.AdapterView;
public abstract class SingleClickListener
implements AdapterView.OnItemClickListener, View.OnClickListener {
private static final long MIN_CLICK_INTERVAL = 600;
@tbruyelle
tbruyelle / RadarView.java
Created September 9, 2014 12:55
RadarView
/*
* Copyright (C) 2008 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
public class Fetcher {
public Observable<String> fetch() {
return Observable.just("1","2","3").compose(composer());
// Compiler error: Incompatible type: required Observable<String>, found Observable<Object>
}
private <T> Observable.Transformer<T,T> composer() {
return new Observable.Transformer<T, T>() {
@Override
@tbruyelle
tbruyelle / gist:535816a7da15eab56c89
Last active August 29, 2015 14:24
list_section.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center_vertical"
android:paddingLeft="72dp"
android:paddingRight="16dp"
android:textColor="?android:attr/textColorSecondary"
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_gravity="bottom"
android:layout_marginLeft="72dp"
android:background="#9e9e9e"
android:src="@android:drawable/divider_horizontal_dim_dark"
/>
/*
* Copyright (C) 2014 The Android Open Source Project
*
* 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