Skip to content

Instantly share code, notes, and snippets.

View tbruyelle's full-sized avatar

Thomas Bruyelle tbruyelle

View GitHub Profile
@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));
}
<?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 / 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)
@tbruyelle
tbruyelle / ProgressBarWrapper.java
Created January 15, 2014 15:05
smooth progress bar in action bar
package util;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.view.Gravity;
import android.view.LayoutInflater;
@tbruyelle
tbruyelle / ActionButtonRotate.java
Created January 15, 2014 14:38
action button rotate
package com.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.animation.Animation;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EViewGroup;
package com.comalia.gesicamobile.util;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Looper;
import android.util.DisplayMetrics;
import android.util.TypedValue;
@tbruyelle
tbruyelle / gist:8183003
Created December 30, 2013 14:55
update action bar title
int titleId = getResources().getIdentifier("action_bar_title", "id",
"android");
TextView yourTextView = (TextView) findViewById(titleId);
yourTextView.setTypeface(TypefaceUtil.getTypeFace(this, "fonts/Roboto-Light.ttf"));
yourTextView.setTextAppearance(this, R.style.TextAppearance_GesicaManager_Title);
@tbruyelle
tbruyelle / FontableTextView.java
Created December 30, 2013 14:43
android custom font
package com.comalia.gesicamobile.manager.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.TextView;
import com.comalia.gesicamobile.manager.R;
@tbruyelle
tbruyelle / MyAndroid.java
Created December 18, 2013 15:28
ActionBarSherlock fest android
package com.comalia.gesicamobile.test;
import com.actionbarsherlock.app.ActionBar;
import org.fest.assertions.api.ANDROID;
public class MyANDROID extends ANDROID {
public static SupportActionBarAssert assertThat(ActionBar actionBar) {
return new SupportActionBarAssert(actionBar);
@tbruyelle
tbruyelle / build.gradle
Created December 18, 2013 07:53
android app test module
buildscript {
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'com.novoda:gradle-android-test-plugin:0.9.7-SNAPSHOT'
}