mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-09-01 03:55:47 +02:00
Prevent dashboard menu from showing on device list
This commit is contained in:
parent
977ab9d03e
commit
64887a5adf
@ -57,6 +57,7 @@ import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.core.view.MenuProvider;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
@ -240,9 +241,21 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
|
||||
// Sync ViewPager changes with BottomNavigationView
|
||||
viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||
private MenuProvider existingMenuProvider = null;
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
navigationView.getMenu().getItem(position).setChecked(true);
|
||||
|
||||
// Ensure the menu provider is set to the current fragment
|
||||
if (existingMenuProvider != null) {
|
||||
ControlCenterv2.this.removeMenuProvider(existingMenuProvider);
|
||||
}
|
||||
final Fragment fragment = getSupportFragmentManager().findFragmentByTag("f" + position);
|
||||
if (fragment instanceof MenuProvider) {
|
||||
existingMenuProvider = (MenuProvider) fragment;
|
||||
ControlCenterv2.this.addMenuProvider(existingMenuProvider);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -130,7 +130,6 @@ public class DashboardFragment extends Fragment implements MenuProvider {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
View dashboardView = inflater.inflate(R.layout.fragment_dashboard, container, false);
|
||||
requireActivity().addMenuProvider(this);
|
||||
textViewDate = dashboardView.findViewById(R.id.dashboard_date);
|
||||
gridLayout = dashboardView.findViewById(R.id.dashboard_gridlayout);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user