mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-08-29 13:47:55 +00:00
Merge pull request #12083 from har-123/bugfix/11894_fix_duplicate_menu_options
Fix duplicate menu options in ChannelFragment
This commit is contained in:
commit
c232193a46
@ -121,8 +121,22 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
|
|||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(final Bundle savedInstanceState) {
|
public void onAttach(@NonNull final Context context) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onAttach(context);
|
||||||
|
subscriptionManager = new SubscriptionManager(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull final LayoutInflater inflater,
|
||||||
|
@Nullable final ViewGroup container,
|
||||||
|
@Nullable final Bundle savedInstanceState) {
|
||||||
|
binding = FragmentChannelBinding.inflate(inflater, container, false);
|
||||||
|
return binding.getRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(@NonNull final View rootView, final Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(rootView, savedInstanceState);
|
||||||
menuProvider = new MenuProvider() {
|
menuProvider = new MenuProvider() {
|
||||||
@Override
|
@Override
|
||||||
public void onCreateMenu(@NonNull final Menu menu,
|
public void onCreateMenu(@NonNull final Menu menu,
|
||||||
@ -181,20 +195,6 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
|
|||||||
activity.addMenuProvider(menuProvider);
|
activity.addMenuProvider(menuProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(@NonNull final Context context) {
|
|
||||||
super.onAttach(context);
|
|
||||||
subscriptionManager = new SubscriptionManager(activity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(@NonNull final LayoutInflater inflater,
|
|
||||||
@Nullable final ViewGroup container,
|
|
||||||
@Nullable final Bundle savedInstanceState) {
|
|
||||||
binding = FragmentChannelBinding.inflate(inflater, container, false);
|
|
||||||
return binding.getRoot();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override // called from onViewCreated in BaseFragment.onViewCreated
|
@Override // called from onViewCreated in 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);
|
||||||
@ -232,6 +232,14 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
|
|||||||
binding.subChannelTitleView.setOnClickListener(openSubChannel);
|
binding.subChannelTitleView.setOnClickListener(openSubChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
if (menuProvider != null) {
|
||||||
|
activity.removeMenuProvider(menuProvider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
@ -240,7 +248,6 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
|
|||||||
}
|
}
|
||||||
disposables.clear();
|
disposables.clear();
|
||||||
binding = null;
|
binding = null;
|
||||||
activity.removeMenuProvider(menuProvider);
|
|
||||||
menuProvider = null;
|
menuProvider = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user