(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| import rx.Observable; | |
| import rx.subjects.PublishSubject; | |
| import rx.subjects.SerializedSubject; | |
| import rx.subjects.Subject; | |
| /** | |
| * Simple pass-thru event bus with error handling and reconnect. | |
| */ | |
| public class EventBus { | 
| You can add this to your shell profile and then use it as dexcount file. | |
| This file should have a classes.dex in order to work, that means it has to be a android lib project or android apk. | |
| count(){ | |
| mkdir temp >/dev/null | |
| cp $1 temp/$1+copy > /dev/null | |
| unzip temp/$1+copy -d temp/ > /dev/null | |
| cat temp/classes.dex | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"' | |
| rm -R temp > /dev/null | |
| } | 
| public class ExampleActivity extends Activity implements WatchFaceLifecycle.Listener { | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_my_layout); | |
| WatchFaceLifecycle.attach(this, savedInstanceState, this); | |
| } | |
| @Override | 
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| public class CircularProgressDrawable extends Drawable | |
| implements Animatable { | |
| private static final Interpolator ANGLE_INTERPOLATOR = new LinearInterpolator(); | |
| private static final Interpolator SWEEP_INTERPOLATOR = new DecelerateInterpolator(); | |
| private static final int ANGLE_ANIMATOR_DURATION = 2000; | |
| private static final int SWEEP_ANIMATOR_DURATION = 600; | |
| private static final int MIN_SWEEP_ANGLE = 30; | |
| private final RectF fBounds = new RectF(); | 
I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!
\
| 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; | 
| /* | |
| * Copyright 2014 Chris Banes | |
| * | |
| * 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 | 
| package rx.android.observables; | |
| import rx.Observable; | |
| import rx.Observable.OnSubscribe; | |
| import rx.Subscriber; | |
| import rx.android.subscriptions.AndroidSubscriptions; | |
| import rx.functions.Action0; | |
| import android.content.BroadcastReceiver; | |
| import android.content.Context; | |
| import android.content.Intent; | 
| function dex-method-count() { | |
| cat $1 | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"' | |
| } | |
| function dex-method-count-by-package() { | |
| dir=$(mktemp -d -t dex) | |
| baksmali $1 -o $dir | |
| for pkg in `find $dir/* -type d`; do | |
| smali $pkg -o $pkg/classes.dex | |
| count=$(dex-method-count $pkg/classes.dex) | |
| name=$(echo ${pkg:(${#dir} + 1)} | tr '/' '.') |