Skip to content

Instantly share code, notes, and snippets.

@tomhut
tomhut / CTTelephonyNetworkInfo+CellularConnectionNiceName.m
Created May 29, 2014 11:51
Nice name for current cellular connection technology for iOS 7 and above.
//
// CTTelephonyNetworkInfo+CellularConnectionNiceName.m
// Yoyo
//
// Created by Tom Hutchinson on 29/05/2014.
// Copyright (c) 2014 JustYoyoLtd. All rights reserved.
//
#import "CTTelephonyNetworkInfo+CellularConnectionNiceName.h"
@chrisjenx
chrisjenx / GsonBuilder.java
Last active October 19, 2015 18:47
Custom Gson Serialiser for android.support.v4.util.SimpleArrayMap;
return new GsonBuilder()
.registerTypeAdapter(SimpleArrayMapJsonSerializer.TYPE, new SimpleArrayMapJsonSerializer())
.create();
@jgilfelt
jgilfelt / FittingLinearLayout.java
Last active December 10, 2015 02:18
Custom LinearLayout needed for fullscreen YouTube player when using SYSTEM_UI_FLAG_HIDE_NAVIGATION
package com.readystatesoftware.views;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.LinearLayout;
public class FittingLinearLayout extends LinearLayout {
public FittingLinearLayout(Context context, AttributeSet attrs, int defStyle) {
@commonsguy
commonsguy / SQLCipherV3Helper.java
Last active December 25, 2015 23:39
SQLiteHookedHelper and SQLCipherV3Helper
/***
Copyright (c) 2013 CommonsWare, LLC
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 limitations under the License.
*/
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
public class SquaredImageView extends ImageView {
public SquaredImageView(Context context) {
super(context);
}
@ryanbateman
ryanbateman / gist:6667995
Last active September 6, 2017 21:03
Basic BlurTransformer for Square's Picasso
import android.content.Context;
import android.graphics.Bitmap;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur;
import com.squareup.picasso.Transformation;
public class BlurTransform implements Transformation {
@jgilfelt
jgilfelt / ScaleFadePageTransformer.java
Created December 3, 2012 20:05
An ICS+ app/widget drawer style PageTransformer for your ViewPager
/***
* 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.
@bomberstudios
bomberstudios / Export for Android from Sketch.md
Created May 14, 2013 15:41
Feature request: Export for Android from Sketch

For example xhdpi will be the reference for Android design and then we will able to export to ldpi, mdpi, hdpi and xxhdpi with only one click.

The export function creates a folder for each format named (ldpi, mdpi, hdpi, xhdpi, xxhdpi...) and each slice wil be resized like that :

  • xhdpi = 100%
  • ldpi = 37,5%
  • mdpi = 50%
  • hdpi = 75%
  • xxhpi = 150%
@clarkdave
clarkdave / pg_interval.rb
Last active July 9, 2019 00:57
Support for PostgreSQL `interval` type in Rails 4. Although ActiveRecord supports `interval` by default, it turns it into a string (and tells Postgres the column is type string, too). This means you don't get any proper interval goodness. By sticking this code into an initialiser, ActiveRecord will create proper `interval` column types in Postgr…
#
# This will force ActiveRecord to create proper `interval` column types in PostgreSQL
#
# def change
# add_column :leases, :period, :interval
# end
#
# This applies to a generated `schema.rb` file too.
#
# No special OID type is applied to an `interval` type. Rails will treat it as a string, although
@shekibobo
shekibobo / README.md
Last active March 2, 2020 11:04
Android: Base Styles for Button (not provided by AppCompat)

How to create custom button styles using Android's AppCompat-v7:21

Introduction

AppCompat is an Android support library to provide backwards-compatible functionality for Material design patterns. It currently comes bundled with a set of styles in the Theme.AppCompat and Widget.AppCompat namespaces. However, there is a critical component missing which I would have thought essential to provide the a default from which we could inherit our styles: Widget.AppCompat.Button. Sure, there's Widget.AppCompat.Light.ActionButton, but that doesn't actually inherit from Widget.ActionButton, which does not inherit from Widget.Button, so we might get some unexpected behavior using that as our base button style, mainly because Widget.ActionButton strictly belongs in the ActionBar.

So, if we want to have a decently normal default button style related to AppCompat, we need to make it ourselves. Let's start by digging into the Android SDK to see how it's doing default styles.

Digging In