mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 00:20:32 +00:00
Added comments and improved the code
This commit is contained in:
parent
c1d5a5cd98
commit
6665d630ec
@ -460,7 +460,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
if (!isChangingConfigurations()) {
|
||||
StateSaver.clearStateFiles();
|
||||
}
|
||||
unregisterReceiver(broadcastReceiver);
|
||||
if (broadcastReceiver != null) {
|
||||
unregisterReceiver(broadcastReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -811,8 +813,20 @@ public class MainActivity extends AppCompatActivity {
|
||||
final Fragment fragmentPlayer = getSupportFragmentManager()
|
||||
.findFragmentById(R.id.fragment_player_holder);
|
||||
if (fragmentPlayer == null) {
|
||||
/*
|
||||
* We still don't have a fragment attached to the activity.
|
||||
* It can happen when a user started popup or background players
|
||||
* without opening a stream inside the fragment.
|
||||
* Adding it in a collapsed state (only mini player will be visible)
|
||||
* */
|
||||
NavigationHelper.showMiniPlayer(getSupportFragmentManager());
|
||||
}
|
||||
/*
|
||||
* At this point the player is added 100%, we can unregister.
|
||||
* Other actions are useless since the fragment will not be removed after that
|
||||
* */
|
||||
unregisterReceiver(broadcastReceiver);
|
||||
broadcastReceiver = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -304,7 +304,7 @@ public class VideoDetailFragment
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static VideoDetailFragment getInstanceCollapsed() {
|
||||
public static VideoDetailFragment getInstanceInCollapsedState() {
|
||||
final VideoDetailFragment instance = new VideoDetailFragment();
|
||||
instance.bottomSheetState = BottomSheetBehavior.STATE_COLLAPSED;
|
||||
return instance;
|
||||
|
@ -392,7 +392,7 @@ public final class NavigationHelper {
|
||||
}
|
||||
|
||||
public static void showMiniPlayer(final FragmentManager fragmentManager) {
|
||||
final VideoDetailFragment instance = VideoDetailFragment.getInstanceCollapsed();
|
||||
final VideoDetailFragment instance = VideoDetailFragment.getInstanceInCollapsedState();
|
||||
defaultTransaction(fragmentManager)
|
||||
.replace(R.id.fragment_player_holder, instance)
|
||||
.runOnCommit(() -> sendPlayerStartedEvent(instance.requireActivity()))
|
||||
|
Loading…
Reference in New Issue
Block a user