Skip to content

Instantly share code, notes, and snippets.

@4brunu
4brunu / ProtocolDefaultImplementation.swift
Last active January 11, 2017 13:58
Swift - protocol default implementation
import Foundation
protocol Shakeable {
func shake()
func yooo()
}
extension Shakeable {
func shake() {
print("Extension -> shake")
@4brunu
4brunu / README.md
Created June 21, 2016 12:15 — forked from lopspower/README.md
Material Animations

Material Animations

Android Arsenal

[Android Transition Framework][transition-framework] can be used for three main things:

  1. Animate activity layout content when transitioning from one activity to another.
  2. Animate shared elements (Hero views) in transitions between activities.
  3. Animate view changes within same activity.
@4brunu
4brunu / ExpiringLruCache.java
Created April 7, 2016 10:12 — forked from christopherperry/ExpiringLruCache.java
LruCache for Android with expiring keys. Instead of modifying LruCache directly I used delegation to get around final keyword usage and a dirty hack to override everything else.
import android.os.SystemClock;
import android.support.v4.util.LruCache;
import java.util.HashMap;
import java.util.Map;
/**
* An Lru Cache that allows entries to expire after
* a period of time. Items are evicted based on a combination
* of time, and usage. Adding items past the {@code maxSize}
@4brunu
4brunu / Remove Submodule
Created March 30, 2016 10:57 — forked from kyleturner/Remove Submodule
How to remove a submodule from a Github project
To remove a submodule you need to:
Delete the relevant line from the .gitmodules file.
Delete the relevant section from .git/config.
Run git rm --cached path_to_submodule (no trailing slash).
Commit and delete the now untracked submodule files.
@4brunu
4brunu / README.md
Created February 24, 2016 11:21 — forked from lopspower/README.md
Android Tools Attributes

Android Tools Attributes

Twitter

Android has a dedicated XML namespace intended for tools to be able to record information in XML files, and have that information stripped when the application is packaged such that there is no runtime or download size penalty. The namespace URI is http://schemas.android.com/tools and is usually bound to the tools: prefix:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
@4brunu
4brunu / SomeFragment.java
Created November 9, 2015 21:57 — forked from joshdholtz/SomeFragment.java
Android Google Maps V2 - MapView in XML
public class SomeFragment extends Fragment {
MapView mapView;
GoogleMap map;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.some_layout, container, false);