Skip to content

Instantly share code, notes, and snippets.

@stefanhoth
stefanhoth / tools_override.xml
Last active August 29, 2015 14:13
Override a views visibility at design time using the tools namespace. See line 13 how and don't forget to add line 2. See http://tools.android.com/tips/layout-designtime-attributes for details.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/group_image"
@frankiesardo
frankiesardo / QuickReturn.java
Last active December 14, 2015 22:49
A refactored version of LarsWerkman's QuickReturnListView. It should provide an easier to use API and an easier to understand library.
public class QuickReturn {
private final static int ANIMATION_DURATION_MILLIS = 250;
private final ListView listView;
private final View quickReturnView;
private final View headerPlaceholder;
private int itemCount;
private int itemOffsetY[];
@amlcurran
amlcurran / LoadHideHelper.java
Last active December 19, 2015 20:09
Utility class which makes it easy to hide and show areas of the UI until the data they represent is loaded. Simply initialise with a Fragment or view(s), and call show() to show, and hide() to hide the UI. You can automatically add a ProgressBar* which will show and hide exactly when you need it to, and even supply your own custom animations by …
/*
* Copyright (c) 2013 Alex Curran
*
* 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
@bdaylik
bdaylik / Dockerfile
Created March 9, 2015 08:19
Dockerfile used in the "Dockerize your development environment" blog post.
FROM ubuntu
RUN apt-get install -y x11-apps
ENV USER=myuser UID=1000 GID=1000
RUN addgroup --gid ${GID} ${USER}
RUN adduser --home /home/${USER} --shell /bin/bash --uid ${UID} --gid ${GID} --disabled-password ${USER}
RUN echo "${USER} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${USER}
RUN chmod 0440 /etc/sudoers.d/${USER}
@stefanhoth
stefanhoth / build.gradle
Last active March 3, 2017 12:03
Simple plugin for build.gradle to instruct Jetbrains IDEA-based IDEs (IntelliJ, Android Studio) to download sources of the dependencies. More settings can be found here: http://gradle.org/docs/current/dsl/org.gradle.plugins.ide.idea.model.IdeaModule.html
// your code
apply from: "build-plugins/idea-gradle-sources.gradle"
@izmajlowiczl
izmajlowiczl / TheLastSyncTimestamp.java
Created May 9, 2014 08:37
SharedPreferences with Robolectric
import android.content.SharedPreferences;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import static org.junit.Assert.assertEquals;
@RunWith(RobolectricTestRunner.class)
public class TheLastSyncTimestamp {
private static final int PEEK_DRAWER_TIME_SECONDS = 2;
private long downTime;
private long eventTime;
private float x = 0.0f;
private float y = 100.0f;
private int metaState = 0;
protected void peekDrawer() {
downTime = SystemClock.uptimeMillis();
eventTime = SystemClock.uptimeMillis() + 100;
@lorenzos
lorenzos / android-screen-to-gif.sh
Last active March 30, 2019 21:00
Captures screen from Android device via ADB and makes a 180x320 GIF
#!/bin/bash
# How to install:
# exo-open "http://developer.android.com/sdk/index.html#Other"
# sudo apt-get install libav-tools imagemagick
# wget https://gist.githubusercontent.com/lorenzos/e8a97c1992cddf9c1142/raw/android-screen-to-gif.sh
# chmod a+x android-screen-to-gif.sh
# Help message
function usage() {
@JakeWharton
JakeWharton / README.md
Last active January 8, 2020 02:13
A special activity which facilitates restarting your application process.
@nickbutcher
nickbutcher / 1_drawable_ic_hash_io16.xml
Last active June 16, 2020 19:28
Animated Stroke. The google I/O website this year (https://google.com/io) has some funky animated lettering. I especially liked the animated stroke around the letters and wondered how you might implement that on Android. Turns out that AnimatedVectorDrawable makes this very easy! Here's how it looks: https://twitter.com/crafty/status/71077957997…
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016 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