Skip to content

Instantly share code, notes, and snippets.

View jerrellmardis's full-sized avatar

Jerrell Mardis jerrellmardis

View GitHub Profile
@JakeWharton
JakeWharton / AspectRatioImageView.java
Created June 2, 2012 02:14
ImageView that respects an aspect ratio applied to a specific measurement.
// Copyright 2012 Square, Inc.
package com.squareup.widgets;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.ImageView;
/** Maintains an aspect ratio based on either width or height. Disabled by default. */
public class AspectRatioImageView extends ImageView {
@jgilfelt
jgilfelt / mapimports.sh
Created September 13, 2012 15:23
Toggle Google/Amazon Android map imports
#!/bin/bash
A_IMPORT="import com.amazon.geo.maps"
G_IMPORT="import com.google.android.maps"
A_VIEW="com.amazon.geo.maps.MapView"
G_VIEW="com.google.android.maps.MapView"
if [ "$1" = "a" ]; then
FR=$G_IMPORT
@romannurik
romannurik / CheatSheet.java
Last active May 16, 2023 13:42
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.
/*
* 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
@mikeseif
mikeseif / SlideTransformer (Zoom out transition)
Last active December 11, 2015 07:38
SlideTransformer I'm using for a presentation, it scales the slides down smoothly by the scaleFactor given in the constructor. @TargetApi set to Honeycomb for lint, I haven't tested on Gingerbread yet and it may need tweaking. Instantiate after setting your adapter for the ViewPager with: mViewPager.setPageTransformer(true, new SlideTransformer(…
/**
* {@link android.support.v4.view.ViewPager.PageTransformer} to scale pages
* as they are slid left / right.
*
* @author michaelseifollahi
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private class SlideTransformer implements PageTransformer {
private final float fScaleFactor;
@mikeseif
mikeseif / SlidingTransformer.java
Last active December 11, 2015 07:38
SlideTransformer for a Photo gallery pager I'm working on, it behaves similar to the paging of the stock App Launcher. Pages zoom / fade in as if they were stacked on top of each other, with the leaving page translating out to the left. @TargetApi set to Honeycomb for lint, I haven't tested on Gingerbread yet and it may need tweaking. Instantiat…
/**
* {@link android.support.v4.view.ViewPager.PageTransformer} to translate / transform pages
* as they are slid left / right.
*
* @author michaelseifollahi
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private class SlideTransformer implements PageTransformer {
private final float fScaleFactor;
@chrisbanes
chrisbanes / gist:5004907
Last active January 24, 2021 01:13
Blocking ListView
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ListView;
public class BlockingListView extends ListView {
private boolean mBlockLayoutChildren;
public BlockingListView(Context context) {
super(context);
@swankjesse
swankjesse / RetrofitCachingExample.java
Created June 29, 2013 03:03
Demonstrate HTTP caching with OkHttp and Retrofit.
/*
* Copyright (C) 2013 Square, 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
@cyrilmottier
cyrilmottier / _app_avelibRelease_res_values_config.xml
Last active November 20, 2020 11:27
Using the new Gradle-based Android build system: an example
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="config_app_name">AVélib</string>
<string name="config_authority">com.cyrilmottier.android.avelib.citybikes</string>
<string name="config_com.google.android.maps.v2.api_key">XXX</string>
</resources>
@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
@marianeum
marianeum / FloatingActionButton.java
Last active November 25, 2015 11:24
FloatingActionButton with custom ripple colours
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;