@Override protected void initComponents(Bundle savedInstanceState) { if (isShutdown(getIntent())) { return; } drawerLayout = findView(R.id.drawer_layout); drawerLayout.setDrawerListener( new SimpleDrawerListener() { @Override public void onDrawerStateChanged(int newState) { refreshPlayerItem(); syncSlideMenu(); } @Override public void onDrawerSlide(View drawerView, float slideOffset) {} @Override public void onDrawerOpened(View drawerView) {} @Override public void onDrawerClosed(View drawerView) {} }); leftDrawer = findView(R.id.activity_main_left_drawer); listMenu = findView(R.id.left_drawer); playerItem = findView(R.id.slidemenu_player_menuitem); playerItem.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { controller.launchPlayerActivity(); } }); setupFragments(); setupMenuItems(); setupInitialFragment(savedInstanceState); playerSubscription = TimerService.subscribe((TimerObserver) findView(R.id.activity_main_player_notifier), 1); onNewIntent(getIntent()); SoftwareUpdater.instance().addConfigurationUpdateListener(this); setupActionBar(); setupDrawer(); // PlaybackService.get(this); }
@Override protected void onDestroy() { super.onDestroy(); if (playerSubscription != null) { playerSubscription.unsubscribe(); } // avoid memory leaks when the device is tilted and the menu gets recreated. SoftwareUpdater.instance().removeConfigurationUpdateListener(this); if (playerItem != null) { playerItem.unbindDrawables(); } if (mToken != null) { MusicUtils.unbindFromService(mToken); mToken = null; } }
private void refreshPlayerItem() { if (playerItem != null) { playerItem.refresh(); } }