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
aa0c74b55b
1 changed files with 69 additions and 62 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue