Skip to content

Commit 2f0670e

Browse files
committed
Guard the log calls
1 parent 135b6c1 commit 2f0670e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

rxjava-contrib/rxjava-android/src/main/java/rx/operators/OperatorWeakBinding.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,24 @@ private boolean shouldForwardNotification(Subscriber<? super T> sub) {
8787

8888
private void handleLostBinding(Subscriber<? super T> sub, String context) {
8989
if (sub == null) {
90-
Log.d(LOG_TAG, "subscriber gone; skipping " + context);
90+
log("subscriber gone; skipping " + context);
9191
} else {
9292
final R r = boundRef.get();
9393
if (r != null) {
9494
// the predicate failed to validate
95-
Log.d(LOG_TAG, "bound component has become invalid; skipping " + context);
95+
log("bound component has become invalid; skipping " + context);
9696
} else {
97-
Log.d(LOG_TAG, "bound component gone; skipping " + context);
97+
log("bound component gone; skipping " + context);
9898
}
9999
}
100-
Log.d(LOG_TAG, "unsubscribing...");
100+
log("unsubscribing...");
101101
unsubscribe();
102102
}
103+
104+
private void log(String message) {
105+
if (Log.isLoggable(LOG_TAG, Log.DEBUG)) {
106+
Log.d(LOG_TAG, message);
107+
}
108+
}
103109
}
104110
}

0 commit comments

Comments
 (0)