Skip to content

Instantly share code, notes, and snippets.

View allenatwork's full-sized avatar

Allen Walker allenatwork

View GitHub Profile
@allenatwork
allenatwork / PagedRecyclerViewAdapter.java
Created June 21, 2016 09:53 — forked from erseno/PagedRecyclerViewAdapter.java
A base adapter for RecyclerView to handle the loading of more data once a scroll threshold has been reached. Also shows a progress bar as a footer view to show that the next page is loading. If the next page fails to load, a retry button is displayed along with an error message so that the page can be retried.
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
/**
@allenatwork
allenatwork / TinableTextView
Last active July 1, 2016 04:14 — forked from tylerchesley/TintableImageView.java
Backwards compatible TintableImageView
package biz.nadia.rola.widget.tablayout;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import biz.nadia.rola.R;
import biz.nadia.rola.layout.RolaTextView;
@allenatwork
allenatwork / EndlessRecyclerViewScrollListener.java
Created July 11, 2016 09:31
EndlessRecyclerViewScrollListener
package com.codepath.twitterclient.listeners;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerViewScrollListener extends RecyclerView.OnScrollListener {
// The minimum amount of items to have below your current scroll position
// before loading more.
private int visibleThreshold = 5;
// The current offset index of data you have loaded
@allenatwork
allenatwork / .gitignore
Created July 20, 2016 01:55
Default GitIgnore for Android
# Created by .ignore support plugin (hsz.mobi)
### Android template
# Built application files
*.apk
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
package biz.nadia.rola.fragments;
import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import java.util.ArrayList;
import java.util.List;
package biz.nadia.rola.database;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.text.TextUtils;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
@allenatwork
allenatwork / AlertDialogFragment.java
Created September 16, 2016 03:42 — forked from noxi515/AlertDialogFragment.java
DialogFragment like AlertDialog.Builder
package jp.co.noxi.app;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
@allenatwork
allenatwork / In Layout file
Created November 29, 2016 07:01
Loading Drawable
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:progressDrawable="@drawable/circular_progress_bar"
android:layout_below="@+id/button"
android:layout_alignRight="@+id/textView"
android:layout_alignEnd="@+id/textView"
android:layout_alignLeft="@+id/textview"
@allenatwork
allenatwork / BlurBuilder
Created December 1, 2016 07:51
Blue Image
package allen.blurimage;
import android.content.Context;
import android.graphics.Bitmap;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur;
/**
@allenatwork
allenatwork / CustomView.java
Created January 6, 2017 04:17 — forked from f2prateek/CustomView.java
Event Bus in view
public class CustomView extends View {
private final Bus bus;
public CustomView(Bus bus, ....) {
super(....);
this.bus = bus;
}
@Override protected void onAttachedToWindow() {