chore(android): add null checks (#4168)
This commit is contained in:
parent
84a27f3d9f
commit
b74cb59602
@ -899,17 +899,25 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
playbackServiceBinder = (PlaybackServiceBinder) service;
|
playbackServiceBinder = (PlaybackServiceBinder) service;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Activity currentActivity = themedReactContext.getCurrentActivity();
|
||||||
|
if (currentActivity != null) {
|
||||||
playbackServiceBinder.getService().registerPlayer(player,
|
playbackServiceBinder.getService().registerPlayer(player,
|
||||||
Objects.requireNonNull((Class<Activity>) (themedReactContext.getCurrentActivity()).getClass()));
|
(Class<Activity>) currentActivity.getClass());
|
||||||
|
} else {
|
||||||
|
// Handle the case where currentActivity is null
|
||||||
|
DebugLog.w(TAG, "Could not register ExoPlayer: currentActivity is null");
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
DebugLog.e(TAG, "Cloud not register ExoPlayer");
|
DebugLog.e(TAG, "Could not register ExoPlayer: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
try {
|
try {
|
||||||
|
if (playbackServiceBinder != null) {
|
||||||
playbackServiceBinder.getService().unregisterPlayer(player);
|
playbackServiceBinder.getService().unregisterPlayer(player);
|
||||||
|
}
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
|
|
||||||
playbackServiceBinder = null;
|
playbackServiceBinder = null;
|
||||||
@ -917,7 +925,7 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNullBinding(ComponentName name) {
|
public void onNullBinding(ComponentName name) {
|
||||||
DebugLog.e(TAG, "Cloud not register ExoPlayer");
|
DebugLog.e(TAG, "Could not register ExoPlayer");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ class VideoPlaybackService : MediaSessionService() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun buildNotification(session: MediaSession): Notification {
|
private fun buildNotification(session: MediaSession): Notification {
|
||||||
val returnToPlayer = Intent(this, sourceActivity).apply {
|
val returnToPlayer = Intent(this, sourceActivity ?: this.javaClass).apply {
|
||||||
flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user