Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions app/src/main/java/org/schabi/newpipe/ktx/Bundle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,3 @@ import java.io.Serializable
inline fun <reified T : Serializable> Bundle.serializable(key: String?): T? {
return BundleCompat.getSerializable(this, key, T::class.java)
}

fun Bundle?.toDebugString(): String {
if (this == null) {
return "null"
}
val string = StringBuilder("Bundle{")
for (key in this.keySet()) {
@Suppress("DEPRECATION") // we want this[key] to return items of any type
string.append(" ").append(key).append(" => ").append(this[key]).append(";")
}
string.append(" }")
return string.toString()
}
6 changes: 6 additions & 0 deletions app/src/main/java/org/schabi/newpipe/ktx/Intent.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.schabi.newpipe.ktx

import android.content.Intent

// isEmpty unparcels the extras
fun Intent.extrasString(): String = extras?.takeIf { !it.isEmpty }?.toString() ?: ""
12 changes: 6 additions & 6 deletions app/src/main/java/org/schabi/newpipe/player/PlayerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

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

import org.schabi.newpipe.ktx.BundleKt;
import org.schabi.newpipe.ktx.IntentKt;
import org.schabi.newpipe.player.mediabrowser.MediaBrowserImpl;
import org.schabi.newpipe.player.mediabrowser.MediaBrowserPlaybackPreparer;
import org.schabi.newpipe.player.mediasession.MediaSessionPlayerUi;
Expand Down Expand Up @@ -126,9 +126,9 @@ public void onCreate() {
@Override
public int onStartCommand(final Intent intent, final int flags, final int startId) {
if (DEBUG) {
Log.d(TAG, "onStartCommand() called with: intent = [" + intent
+ "], extras = [" + BundleKt.toDebugString(intent.getExtras())
+ "], flags = [" + flags + "], startId = [" + startId + "]");
Log.d(TAG, "onStartCommand() called with: intent = [" + intent + "], "
+ "extras = [" + IntentKt.extrasString(intent) + "], flags = [" + flags + "], "
+ "startId = [" + startId + "]");
}

// All internal NewPipe intents used to interact with the player, that are sent to the
Expand Down Expand Up @@ -269,8 +269,8 @@ protected void attachBaseContext(final Context base) {
@Override
public IBinder onBind(final Intent intent) {
if (DEBUG) {
Log.d(TAG, "onBind() called with: intent = [" + intent
+ "], extras = [" + BundleKt.toDebugString(intent.getExtras()) + "]");
Log.d(TAG, "onBind() called with: intent = [" + intent + "], "
+ "extras = [" + IntentKt.extrasString(intent) + "]");
}

if (BIND_PLAYER_HOLDER_ACTION.equals(intent.getAction())) {
Expand Down