remove getActivity()

This commit is contained in:
adbenitez
2023-09-26 21:41:54 +02:00
parent c50ebe6e16
commit 9dbcff3908
@@ -132,7 +132,6 @@ public class AudioSlidePlayer {
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
Log.d(TAG, "onPlayerStateChanged(" + playWhenReady + ", " + playbackState + ")");
Activity activity;
switch (playbackState) {
case Player.STATE_READY:
@@ -293,7 +292,7 @@ public class AudioSlidePlayer {
}
public void keepScreenOn(boolean keepOn) {
Activity activity = getActivity(context);
Activity activity = (context instanceof Activity)? (Activity) context : null;
if (activity != null) {
if (keepOn) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
@@ -303,13 +302,6 @@ public class AudioSlidePlayer {
}
}
private Activity getActivity(Context context) {
if (context == null) return null;
if (context instanceof Activity) return (Activity) context;
if (context instanceof ContextWrapper) return getActivity(((ContextWrapper)context).getBaseContext());
return null;
}
private synchronized static void setPlaying(@NonNull AudioSlidePlayer player) {
if (playing.isPresent() && playing.get() != player) {
playing.get().notifyOnStop();