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 / 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 / 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() {
@allenatwork
allenatwork / android_eventbus.md
Created January 6, 2017 06:53 — forked from SandNerd/android_eventbus.md
Android EventBus

Event Bus

(EventBus) - Android optimized event bus that simplifies communication between Activities, Fragments, Threads, Services, etc. Less code, better quality.

An EventBus is a great tool for decoupling components in your application. Over the next few posts I will describe the ways that I have been using it to make my code cleaner, easier to read, and easier to test. But first, this week I want to discuss why I use an EventBus in the first place. In particular, I will compare its use to some alternative techniques.

package jp.co.neo.DCChat.common.utils;
import android.content.Context;
import android.support.annotation.StringRes;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software