Skip to content

Instantly share code, notes, and snippets.

View cbeyls's full-sized avatar

Christophe Beyls cbeyls

View GitHub Profile
@cbeyls
cbeyls / PreferenceFragment.java
Last active April 6, 2023 09:07
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.
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 July 28, 2024 11:13
A CursorLoader to implement simple monitorable database queries without a ContentProvider.
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 August 29, 2015 13:57
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.
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 November 10, 2024 14:25
A fragment container enabling the use of android:fitsSystemWindows in fragment layouts.
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 August 10, 2014 18:57
ImageLoader implementation for my own fork of the Cast Companion Library using the Volley library. See: https://github.com/cbeyls/CastCompanionLibrary-android
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 September 15, 2018 14:54
Simplest implementation of a parallax header effect for Android.
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 January 1, 2019 14:37
A custom horizontal indeterminate progress bar which displays a smooth colored animation. (Google Now progress bar)
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 March 30, 2015 23:06
ImageLoader implementation for my own fork of the Cast Companion Library using the Picasso library. See: https://github.com/cbeyls/CastCompanionLibrary-android
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 April 21, 2015 18:44
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.
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 08:57
Vertical LinearLayout populated by a special adapter. Can be used as a lightweight ListView.
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;