Skip to content

Instantly share code, notes, and snippets.

@mttkay
mttkay / Pager.java
Created Nov 4, 2015
A simple Rx based pager
View Pager.java
public class Pager<I, O> {
private static final Observable FINISH_SEQUENCE = Observable.never();
private PublishSubject<Observable<I>> pages;
private Observable<I> nextPage = finish();
private Subscription subscription = Subscriptions.empty();
private final PagingFunction<I> pagingFunction;
private final Func1<I, O> pageTransformer;
@marianeum
marianeum / FloatingActionButton.java
Last active Nov 25, 2015
FloatingActionButton with custom ripple colours
View FloatingActionButton.java
package com.marianeum.fab;
import android.animation.AnimatorInflater;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Outline;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.RippleDrawable;
import android.util.AttributeSet;
@jgilfelt
jgilfelt / ScaleFadePageTransformer.java
Created Dec 3, 2012
An ICS+ app/widget drawer style PageTransformer for your ViewPager
View ScaleFadePageTransformer.java
/***
* Copyright (c) 2012 readyState Software Ltd
*
* 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
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@romannurik
romannurik / CheatSheet.java
Last active Mar 9, 2022
Android helper class for showing cheat sheets (tooltips) for icon-only UI elements on long-press. This is already default platform behavior for icon-only action bar items and tabs. This class provides this behavior for any other such UI element.
View CheatSheet.java
/*
* Copyright 2012 Google Inc.
*
* 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
@keyboardsurfer
keyboardsurfer / .gitignore
Last active Dec 11, 2019
Android gitignore
View .gitignore
# Copyright: Benjamin Weiss (keyboardsurfer) https://github.com/keyboardsurfer
# Under CC-BY-SA V3.0 (https://creativecommons.org/licenses/by-sa/3.0/legalcode)
# built application files
*.apk
*.ap_
*.jar
!gradle/wrapper/gradle-wrapper.jar
# lint folder
View gist:3104053
package com.hubstep;
import android.accounts.*;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
View Han.java
import static junit.framework.Assert.assertTrue;
import com.jayway.android.robotium.solo.Solo;
import android.app.Activity;
import android.app.Instrumentation;
import java.util.regex.Pattern;
@JakeWharton
JakeWharton / ContractFragment.java
Created May 6, 2012
Base fragment to ensure the parent activity implements a contract interface.
View ContractFragment.java
/* Base fragment to ensure the parent activity implements a contract interface. */
public abstract class ContractFragment<T> extends Fragment {
private T mContract;
@Override
public void onAttach(Activity activity) {
try {
mContract = (T)activity;
} catch (ClassCastException e) {
throw new IllegalStateException(activity.getClass().getSimpleName()
@romannurik
romannurik / button_bar_layout.xml
Created Apr 10, 2012
How to make a proper button bar on ICS
View button_bar_layout.xml
<!--
A button bar is a set of buttons at the bottom of an activity.
An example is an AlertDialog with OK/Cancel buttons.
Note that something similar can be accomplished using a
split action bar and text-only action buttons, but this is an
alternate presentation that's often preferred.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
@chirags
chirags / gist:984703
Created May 21, 2011
OAuth 2.0 for Android Apps
View gist:984703
/*
* Copyright 2011 Google Inc.
*
* 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
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and