Skip to content

Instantly share code, notes, and snippets.

@icastell
icastell / Pointers.java
Created November 4, 2014 08:08
Knowladge test
class Aux {
String var;
public Aux(String var) {
this.var = var;
this.var = "aux";
}
public void setVar(String var) {
@icastell
icastell / AndroidManifest.xml
Last active August 29, 2015 14:04
ContentProvider authority renaming
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="package.name" >
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<provider android:name=".contentprovider.Provider" android:authorities="@string/authority" />
@icastell
icastell / ColoredDrawable.java
Created July 14, 2014 06:44
Runtime asset coloring in Android
public static Drawable getColoredDrawable(Context context, int whiteDrawableResId, int targetColor) {
Drawable drawable = context.getResources().getDrawable(whiteDrawableResId);
ColorFilter filter = new LightingColorFilter(targetColor, 0);
drawable.mutate().setColorFilter(filter);
return drawable;
}
@icastell
icastell / loading_footer.java
Last active August 29, 2015 13:57
Android loading footer
@icastell
icastell / NetworkServiceDiscovery.java
Last active March 17, 2021 17:25
Using Network Service Discovery (Bonjour) in Android
package com.solarfighter.activities;
import java.io.IOException;
import java.net.InetAddress;
import javax.jmdns.JmDNS;
import javax.jmdns.ServiceEvent;
import javax.jmdns.ServiceListener;
import android.content.Context;
@icastell
icastell / NotifyingScrollView.java
Created May 26, 2013 10:29
Pushing the ActionBar to the next level
private boolean mIsOverScrollEnabled = true;
public void setOverScrollEnabled(boolean enabled) {
mIsOverScrollEnabled = enabled;
}
public boolean isOverScrollEnabled() {
return mIsOverScrollEnabled;
}
@icastell
icastell / activity_home.xml
Created May 26, 2013 10:27
Pushing the ActionBar to the next level
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/daft_punk"/>
@icastell
icastell / gradient.xml
Created May 26, 2013 10:22
Pushing the ActionBar to the next level
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:height="100dp"/>
<gradient
android:angle="270"
android:startColor="#8000"
android:endColor="#0000"/>
@icastell
icastell / HomeActivity.java
Created May 26, 2013 10:17
Pushing the ActionBar to the next level
package com.cyrilmottier.android.translucentactionbar;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.util.Log;
import android.view.Menu;
@icastell
icastell / activity_home.xml
Created May 26, 2013 10:12
Pushing the ActionBar to the next level
<?xml version="1.0" encoding="utf-8"?>
<com.cyrilmottier.android.translucentactionbar.NotifyingScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"