Fixed NPE + Problems with context
This commit is contained in:
parent
2f99a217c3
commit
4c8dca5300
|
@ -657,7 +657,10 @@ public final class VideoDetailFragment
|
|||
binding.detailControlsPlayWithKodi.setOnClickListener(this);
|
||||
if (DEBUG) {
|
||||
binding.detailControlsCrashThePlayer.setOnClickListener(
|
||||
v -> VideoDetailPlayerCrasher.onCrashThePlayer(this.player, getLayoutInflater())
|
||||
v -> VideoDetailPlayerCrasher.onCrashThePlayer(
|
||||
this.getContext(),
|
||||
this.player,
|
||||
getLayoutInflater())
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.widget.RadioGroup;
|
|||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.google.android.exoplayer2.C;
|
||||
|
@ -85,9 +86,12 @@ public final class VideoDetailPlayerCrasher {
|
|||
: R.style.DarkTheme);
|
||||
}
|
||||
|
||||
public static void onCrashThePlayer(final Player player, final LayoutInflater layoutInflater) {
|
||||
final Context context = player.getContext();
|
||||
if (!isPlayerAvailable(player)) {
|
||||
public static void onCrashThePlayer(
|
||||
@NonNull final Context context,
|
||||
@Nullable final Player player,
|
||||
@NonNull final LayoutInflater layoutInflater
|
||||
) {
|
||||
if (player == null) {
|
||||
Log.d(TAG, "Player is not available");
|
||||
Toast.makeText(context, "Player is not available", Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
|
@ -152,8 +156,4 @@ public final class VideoDetailPlayerCrasher {
|
|||
exPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isPlayerAvailable(final Player player) {
|
||||
return player != null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue