Skip to content

Instantly share code, notes, and snippets.

@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);
@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 / 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 / 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 / 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 / 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 / ProtocolExtensionsSample.swift
Last active January 11, 2017 14:05
Swift - Protocol extensions
//https://speakerdeck.com/realm/natasha-murashev-practical-protocol-oriented-programming?slide=19
import UIKit
protocol Shakeable {
}
extension Shakeable where Self: UIView {
func shake() {
print("shake")
}
@4brunu
4brunu / ButtonProblemSample.swift
Last active January 11, 2017 14:11
Button with gradient and round courners doesn't show text
import UIKit
extension UIButton {
func applyBackgroundGradientStyle() {
roundCorners()
applyGradient()
self.setTitleColor(UIColor.white, for: .normal)
}
@4brunu
4brunu / SampleViewController.swift
Created January 20, 2017 15:17 — forked from JaviSoto/SampleViewController.swift
Init based Storyboard View Controller Instantiation
final class SampleViewController: StoryboardBackedViewController {
// Unfortunately this must be an IUO var, so that we can set the value after super.init
private var member: Foo!
// Proper dependency injection in a storyboard backed VC!
init(foo: Foo) {
super.init(storyboardIdentifier: "SampleViewControllerIdentifier")
// We have to set the members *after* calling super.init, since it changes the instance of `self`.
self.member = foo
@4brunu
4brunu / check_static_library_bitcode_support.txt
Created March 10, 2017 11:29
Check if a static library supports bitcode
otool -l path/to/libxpto.a | grep bitcode | wc -l
OUTPUT:
0 - No bitcode support
>1 - Bitcode support