1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 16:40:32 +00:00

use viewBinding correctly

This commit is contained in:
evermind 2021-06-23 16:53:01 +02:00
parent e30a552b6c
commit 435813355f

View File

@ -304,7 +304,8 @@ public final class VideoDetailFragment
@Override @Override
public View onCreateView(@NonNull final LayoutInflater inflater, final ViewGroup container, public View onCreateView(@NonNull final LayoutInflater inflater, final ViewGroup container,
final Bundle savedInstanceState) { final Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_video_detail, container, false); binding = FragmentVideoDetailBinding.inflate(inflater, container, false);
return binding.getRoot();
} }
@Override @Override
@ -355,7 +356,6 @@ public final class VideoDetailFragment
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
binding = null;
// Stop the service when user leaves the app with double back press // Stop the service when user leaves the app with double back press
// if video player is selected. Otherwise unbind // if video player is selected. Otherwise unbind
@ -388,6 +388,12 @@ public final class VideoDetailFragment
} }
} }
@Override
public void onDestroyView() {
super.onDestroyView();
binding = null;
}
@Override @Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
@ -586,10 +592,9 @@ public final class VideoDetailFragment
// Init // Init
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/
@Override @Override // called from onViewCreated in {@link BaseFragment#onViewCreated}
protected void initViews(final View rootView, final Bundle savedInstanceState) { protected void initViews(final View rootView, final Bundle savedInstanceState) {
super.initViews(rootView, savedInstanceState); super.initViews(rootView, savedInstanceState);
binding = FragmentVideoDetailBinding.bind(rootView);
pageAdapter = new TabAdapter(getChildFragmentManager()); pageAdapter = new TabAdapter(getChildFragmentManager());
binding.viewPager.setAdapter(pageAdapter); binding.viewPager.setAdapter(pageAdapter);