Skip to content

Commit de6dc54

Browse files
Use native Bundle.toString() implementation
1 parent 47299c9 commit de6dc54

2 files changed

Lines changed: 10 additions & 19 deletions

File tree

app/src/main/java/org/schabi/newpipe/ktx/Bundle.kt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,3 @@ import java.io.Serializable
77
inline fun <reified T : Serializable> Bundle.serializable(key: String?): T? {
88
return BundleCompat.getSerializable(this, key, T::class.java)
99
}
10-
11-
fun Bundle?.toDebugString(): String {
12-
if (this == null) {
13-
return "null"
14-
}
15-
val string = StringBuilder("Bundle{")
16-
for (key in this.keySet()) {
17-
@Suppress("DEPRECATION") // we want this[key] to return items of any type
18-
string.append(" ").append(key).append(" => ").append(this[key]).append(";")
19-
}
20-
string.append(" }")
21-
return string.toString()
22-
}

app/src/main/java/org/schabi/newpipe/player/PlayerService.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector;
3939

40-
import org.schabi.newpipe.ktx.BundleKt;
4140
import org.schabi.newpipe.player.mediabrowser.MediaBrowserImpl;
4241
import org.schabi.newpipe.player.mediabrowser.MediaBrowserPlaybackPreparer;
4342
import org.schabi.newpipe.player.mediasession.MediaSessionPlayerUi;
@@ -126,9 +125,11 @@ public void onCreate() {
126125
@Override
127126
public int onStartCommand(final Intent intent, final int flags, final int startId) {
128127
if (DEBUG) {
129-
Log.d(TAG, "onStartCommand() called with: intent = [" + intent
130-
+ "], extras = [" + BundleKt.toDebugString(intent.getExtras())
131-
+ "], flags = [" + flags + "], startId = [" + startId + "]");
128+
final var extras = intent.getExtras();
129+
// isEmpty unparcels the bundle
130+
final var extrasString = extras != null && !extras.isEmpty() ? extras.toString() : "";
131+
Log.d(TAG, "onStartCommand() called with: intent = [" + intent + "], extras = ["
132+
+ extrasString + "], flags = [" + flags + "], startId = [" + startId + "]");
132133
}
133134

134135
// All internal NewPipe intents used to interact with the player, that are sent to the
@@ -269,8 +270,11 @@ protected void attachBaseContext(final Context base) {
269270
@Override
270271
public IBinder onBind(final Intent intent) {
271272
if (DEBUG) {
272-
Log.d(TAG, "onBind() called with: intent = [" + intent
273-
+ "], extras = [" + BundleKt.toDebugString(intent.getExtras()) + "]");
273+
final var extras = intent.getExtras();
274+
// isEmpty unparcels the bundle
275+
final var extrasString = extras != null && !extras.isEmpty() ? extras.toString() : "";
276+
Log.d(TAG, "onBind() called with: intent = [" + intent + "], extras = ["
277+
+ extrasString + "]");
274278
}
275279

276280
if (BIND_PLAYER_HOLDER_ACTION.equals(intent.getAction())) {

0 commit comments

Comments
 (0)