Skip to content

Instantly share code, notes, and snippets.

View KennyGoers's full-sized avatar

Kenny Goers KennyGoers

View GitHub Profile
@nanopc
nanopc / gist:7b693607e673c4bcafed701b5d3f54ab
Last active May 12, 2019 09:11
SVG-VectorDrawable as Maps Marker icon on Android
BitmapDescriptor markerIcon = vectorToBitmap(R.drawable.vectordrawableicon,
ContextCompat.getColor(getApplicationContext(),
R.color.marker));
mMap.addMarker(new MarkerOptions()
.icon(markerIcon)
.position(LatLng())
);
private BitmapDescriptor vectorToBitmap(@DrawableRes int id, @ColorInt int color) {
@paour
paour / ReverseProxyDispatcher.java
Created October 14, 2016 07:40
An OkHttp MockWebServer dispatcher that makes it possible to proxy requests to an upstream server while checking the request and response in tests.
interface ReverseProxyValidator {
void validate(RecordedRequest request, Response response);
}
class ReverseProxyDispatcher extends Dispatcher {
private final OkHttpClient client;
private final HttpUrl serverUrl;
private final ReverseProxyValidator validator;
public ReverseProxyDispatcher(HttpUrl url, ReverseProxyValidator validator) {
@imminent
imminent / MapMarkerBounce.java
Created June 16, 2015 23:44
Makes a Android Google Maps marker animate a bounce
import android.os.Handler;
import android.os.SystemClock;
import android.view.animation.BounceInterpolator;
import android.view.animation.Interpolator;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.Marker;
/**
* Performs a bounce animation on a {@link Marker} when it is clicked.
@jaredrummler
jaredrummler / MenuTint.java
Last active July 6, 2024 16:37
Helper class to set the color and transparency for menu icons in an ActionBar or Toolbar.
/*
* Copyright (C) 2015. Jared Rummler <jared.rummler@gmail.com>
*
* 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
@oguzbilgener
oguzbilgener / FloationgActionButtonRotation.java
Last active August 29, 2015 14:12
an example usage of FloatingActionMenu.MenuStateChangeListener to rotate the icon on the button when the menu is opened or closed
// Set up the white button on the lower right corner
// more or less with default parameter
final ImageView fabIconNew = new ImageView(this);
fabIconNew.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_new_light));
final FloatingActionButton rightLowerButton = new FloatingActionButton.Builder(this)
.setContentView(fabIconNew)
.build();
SubActionButton.Builder rLSubBuilder = new SubActionButton.Builder(this);
ImageView rlIcon1 = new ImageView(this);
@markormesher
markormesher / GetSmallCapsString.java
Last active November 21, 2023 19:13
Create a small-caps spannable string that will work with any font
/**
* Produce a formatted SpannableString object from a given String
* input, with all lowercase characters converted to smallcap
* characters. Uses only standard A-Z characters, so works with
* any font.
*
* @param input The input string, e.g. "Small Caps"
* @return A formatted SpannableString, e.g. "Sᴍᴀʟʟ Cᴀᴘs"
*/
public static SpannableString getSmallCapsString(String input) {
@f2prateek
f2prateek / ActivitySubscriptionManager.java
Last active October 23, 2017 14:30
Managing Subscriptions in Android with RxJava
/*
* Copyright 2014 Prateek Srivastava
*
* 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
@JakeWharton
JakeWharton / Truss.java
Last active August 12, 2024 07:31
Extremely simple wrapper around SpannableStringBuilder to make the API more logical and less awful. Apache 2 licensed.
import android.text.SpannableStringBuilder;
import java.util.ArrayDeque;
import java.util.Deque;
import static android.text.Spanned.SPAN_INCLUSIVE_EXCLUSIVE;
/** A {@link SpannableStringBuilder} wrapper whose API doesn't make me want to stab my eyes out. */
public class Truss {
private final SpannableStringBuilder builder;
private final Deque<Span> stack;
@mscharhag
mscharhag / Java8DateTimeExamples.java
Created February 24, 2014 19:53
Examples for using the Java 8 Date and Time API (JSR 310)
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import static java.time.temporal.TemporalAdjusters.*;
public class Java8DateTimeExamples {
@HenokT
HenokT / GenericAsyncTaskLoader.java
Last active July 28, 2024 11:13
An example of a Generic AsyncTaskLoader for Android
package com.yourcompany.util;
import android.content.Context;
import android.support.v4.content.AsyncTaskLoader;
import android.util.Log;
import com.yourcompany.util.GenericAsyncTaskLoader.ServiceData;
/**
* A generic Loader that delegates its actual loading operation to a
* CustomLoaderCallbacks<T> instance passed through the constructor.