Skip to content

Instantly share code, notes, and snippets.

View ZacSweers's full-sized avatar

Zac Sweers ZacSweers

View GitHub Profile
@gabrielemariotti
gabrielemariotti / Toolbar.java
Created August 4, 2014 13:22
Android-L: A little example of the new Toolbar view.
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
//Title and subtitle
toolbar.setTitle("MY toolbar");
toolbar.setSubtitle("Subtitle");
//Menu
toolbar.inflateMenu(R.menu.toolbar_menu);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@gabrielemariotti
gabrielemariotti / Readme.md
Last active March 2, 2024 23:10
A SimpleSectionedRecyclerViewAdapter: use this class to realize a simple sectioned `RecyclerView.Adapter`.

You can use this class to realize a simple sectioned RecyclerView.Adapter without changing your code.

The RecyclerView should use a LinearLayoutManager. You can use this code also with the TwoWayView with the ListLayoutManager (https://github.com/lucasr/twoway-view)

This is a porting of the class SimpleSectionedListAdapter provided by Google

Screen

Example:

@chrisbanes
chrisbanes / SystemUiHelper.java
Last active March 2, 2024 18:57
SystemUiHelper
/*
* 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
@chrisbanes
chrisbanes / ForegroundLinearLayout.java
Created February 19, 2014 13:16
ForegroundLinearLayout
/*
* Copyright (C) 2006 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
@benjchristensen
benjchristensen / DebounceBuffer.java
Last active March 1, 2024 15:46
DebounceBuffer: Use publish(), debounce() and buffer() together to capture bursts of events.
import java.util.List;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import rx.Subscriber;
import rx.schedulers.Schedulers;
public class DebounceBuffer {
public static void main(String args[]) {
@dlew
dlew / themes-debug.xml
Last active March 1, 2024 15:46
With the new theming in AppCompat, a lot of assets are tinted automatically for you via theme attributes. That has often led me to wonder "where the hell did this color come from?" You can replace your normal theme with this debug theme to help figure out the source of that color.
<!-- You can change the parent around to whatever you normally use -->
<style name="DebugColors" parent="Theme.AppCompat">
<!-- System colors -->
<item name="android:windowBackground">@color/__debugWindowBackground</item>
<item name="android:colorPressedHighlight">#FF4400</item>
<item name="android:colorLongPressedHighlight">#FF0044</item>
<item name="android:colorFocusedHighlight">#44FF00</item>
<item name="android:colorActivatedHighlight">#00FF44</item>
@JakeWharton
JakeWharton / build.gradle
Created March 29, 2015 06:34
A Gradle task for installing all application variants at once. Placed in the public domain.
def installAll = tasks.create('installAll')
installAll.description = 'Install all applications.'
android.applicationVariants.all { variant ->
installAll.dependsOn(variant.install)
// Ensure we end up in the same group as the other install tasks.
installAll.group = variant.install.group
}
@JakeWharton
JakeWharton / UiThreadRule.java
Last active January 12, 2024 17:43
A JUnit @rule which runs individual tests on the Android UI thread. http://b.android.com/157356
/*
* Copyright (C) 2015 Jake Wharton
*
* 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
@indiesquidge
indiesquidge / homebrew.md
Last active December 14, 2023 14:45
How to and Best of Homebrew

Homebrew

How To

Homebrew is a package management system for OS X. You can read more about it here, or simply run

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

to install it.

@Jogan
Jogan / FloatingActionButton.java
Last active December 4, 2023 12:48
Implementation of Android L's floating action button pattern. API 14+
package your_package;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;