Skip to content

Instantly share code, notes, and snippets.

Avatar

Christophe Beyls cbeyls

View GitHub Profile
@cbeyls
cbeyls / PreferenceFragment.java
Last active May 4, 2020
A PreferenceFragment for the Android support library. Based on the platform's code with some removed features and a basic ListView layout.It uses reflection but works with every device I've tested so far.
View PreferenceFragment.java
package android.support.v4.preference;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
@cbeyls
cbeyls / SimpleCursorLoader.java
Last active Jan 26, 2018
A CursorLoader to implement simple monitorable database queries without a ContentProvider.
View SimpleCursorLoader.java
package be.digitalia.fosdem.loaders;
import android.content.Context;
import android.database.Cursor;
import android.support.v4.content.AsyncTaskLoader;
/**
* A CursorLoader that doesn't need a ContentProvider.
*
* @author Christophe Beyls
@cbeyls
cbeyls / GenericAlphabetIndexer.java
Last active Aug 29, 2015
An optimized version of the Android framework's AlphabetIndexer which is compatible with any Adapter returning non-null items with a meaningful toString() representation. Section indexes will be updated automatically when the Adapter's data set changes.
View GenericAlphabetIndexer.java
package be.digitalia.common.adapters;
import android.database.DataSetObserver;
import android.util.SparseIntArray;
import android.widget.Adapter;
import android.widget.SectionIndexer;
/**
* An optimized version of the framework's AlphabetIndexer which is compatible with any Adapter
* returning non-null items with a meaningful toString() representation. Section indexes will be
@cbeyls
cbeyls / WindowInsetsFrameLayout.java
Last active Feb 5, 2020
A fragment container enabling the use of android:fitsSystemWindows in fragment layouts.
View WindowInsetsFrameLayout.java
package be.digitalia.common.widgets;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Rect;
import android.os.Build;
import android.support.v4.util.ObjectsCompat;
import android.util.AttributeSet;
import android.view.View;
@cbeyls
cbeyls / VolleyImageLoader.java
Created Aug 10, 2014
ImageLoader implementation for my own fork of the Cast Companion Library using the Volley library. See: https://github.com/cbeyls/CastCompanionLibrary-android
View VolleyImageLoader.java
package com.google.sample.castcompanionlibrary.cast.imageloader;
import android.content.Context;
import android.util.DisplayMetrics;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.ImageLoader.ImageContainer;
import com.android.volley.toolbox.ImageLoader.ImageListener;
/**
@cbeyls
cbeyls / ParallaxScrollView.java
Last active Sep 15, 2018
Simplest implementation of a parallax header effect for Android.
View ParallaxScrollView.java
package be.digitalia.common.widgets;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ScrollView;
@cbeyls
cbeyls / RefreshProgressBar.java
Last active Jan 1, 2019
A custom horizontal indeterminate progress bar which displays a smooth colored animation. (Google Now progress bar)
View RefreshProgressBar.java
package android.support.v4.widget;
import android.content.Context;
import android.graphics.Canvas;
import android.os.Handler;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
@cbeyls
cbeyls / PicassoImageLoader.java
Created Mar 30, 2015
ImageLoader implementation for my own fork of the Cast Companion Library using the Picasso library. See: https://github.com/cbeyls/CastCompanionLibrary-android
View PicassoImageLoader.java
package com.google.sample.castcompanionlibrary.cast.imageloader;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Target;
@cbeyls
cbeyls / textpattern.rb
Created Apr 21, 2015
TextPattern import plugin for Jekyll that uses a YAML dump file of the "Textpattern" table from PHPMyAdmin instead of a local database. It also imports categories in addition to tags.
View textpattern.rb
module JekyllImport
module Importers
class TextPattern < Importer
def self.require_deps
JekyllImport.require_with_fallback(%w[
rubygems
fileutils
safe_yaml
])
end
@cbeyls
cbeyls / AdapterLinearLayout.java
Last active May 11, 2020
Vertical LinearLayout populated by a special adapter. Can be used as a lightweight ListView.
View AdapterLinearLayout.java
package be.digitalia.common.widgets;
import android.content.Context;
import android.database.DataSetObservable;
import android.database.DataSetObserver;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;