public interface ViewWithActivity {
// Using android-gradle-plugin 3.0, which has the desugar step for default methods on interfaces
default Activity getActivity() {
// https://android.googlesource.com/platform/frameworks/support/+/03e0f3daf3c97ee95cd78b2f07bc9c1be05d43db/v7/mediarouter/src/android/support/v7/app/MediaRouteButton.java#276
Context context = getContext();
while (context instanceof ContextWrapper) {
if (context instanceof Activity) {
class F { | |
constructor(protected a: string) { | |
console.log("F.a", a); | |
console.log("F.this.a", this.a); | |
} | |
b() { | |
console.log("F.b.this.a", this.a); | |
} | |
} |
A couple months ago while at Venmo, @chrismaddern and I discussed the lack of a bidirectional dictionary/vocab list of parallel terms in Android and iOS. It's important to know what your teammates are refering when they talk about code, even if you're not engaged with it every day. This is a beginning attempt to finally break down that knowledge gap. The goal is to allow developers of one framework to understand the basics of the other and should someone want to make the switch, this can be a resource in helping learn the new framework.
If there's a topic that you think would be interesting to discuss, tweet at me and we'll get include it in this list. I'll be updating this post with links to all future posts.
Disclaimer: I'm an Android developer and have done minimal iOS/Objective-C programming. If there is anything incorrect, reach out and I'll fix it as soon as possible. I'm assuming iOS developer are
Most Dagger errors are in the format:
src/main/java/dagger/playground/Playground.java:20: [Dagger/DuplicateBindings] dagger.playground.E is bound multiple times:
A a();
^
@Provides dagger.playground.E dagger.playground.Mod.first()
@Provides dagger.playground.E dagger.playground.Mod.second()
dagger.playground.E is injected at
@Subcomponent | |
public abstract class MonolithicActivityInjector implements AndroidInjector<Activity> { | |
@Override | |
public final void inject(Activity activity) { | |
if (activity instanceof RedActivity) { | |
inject((RedActivity) activity); | |
} else if (activity instanceof BlueActivity) { | |
inject((BlueActivity) activity); | |
} else if (activity instanceof YellowActivity) { | |
inject((YellowActivity) activity); |
class Parent { | |
// Somewhere in here, a lot of external service modules are included and contribute their `Service` impls to this multibinding | |
@Inject lateinit var services: Map<String, Provider<Service>> | |
fun showChild() { | |
addChildController(serviceKey = "barServiceKey") // Key into the services map | |
} | |
} |
package me.ronshapiro.rxjavatest.app; | |
import java.util.concurrent.Executors; | |
import rx.Observable; | |
import rx.Observable.OnSubscribe; | |
import rx.Scheduler; | |
import rx.Subscriber; | |
import rx.Subscription; | |
import rx.android.schedulers.AndroidSchedulers; |
Follow steps 2 and 3 here to create an account on Sonatype: https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide
https://docs.sonatype.org/display/Repository/How+To+Generate+PGP+Signatures+With+Maven
If you don't have gpg
installed: brew install gpg
Create a key by running gpg --gen-key
and make sure to save your passphrase.
# easily parse Logcat output | |
alog () { | |
parser=ack | |
if [[ -e `which ack` ]]; then | |
parser=grep | |
fi | |
if (( $# == 0 )); then | |
adb logcat -v time | |
elif [[ $1 == "runtime" ]]; then | |
pattern='E/AndroidRuntime' |
############################################# | |
# Attach tmux to the first detached session | |
############################################# | |
if [[ -z $TMUX ]]; then | |
TMUX_SESSIONS=`tmux list-sessions -F "#{session_name}ABC#{?session_attached,attached,not_attached}" 2>&1` | |
TMUX_FOUND=0 | |
for i in $TMUX_SESSIONS | |
do | |
IS_ATTACHED=`echo $i | awk '{split($0,array,"ABC"); print array[2]}'` |