use of com.simplecity.amp_library.ui.fragments.NavigationDrawerFragment in project Shuttle by timusus.
the class MainActivity method onCreate.
@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
if (!ShuttleUtils.isUpgraded() && !ShuttleUtils.isAmazonBuild()) {
IabManager.getInstance();
}
ThemeUtils.setTheme(this);
if (!ShuttleUtils.hasLollipop() && ShuttleUtils.hasKitKat()) {
getWindow().setFlags(FLAG_TRANSLUCENT_STATUS, FLAG_TRANSLUCENT_STATUS);
mTintManager = new SystemBarTintManager(this);
}
if (ShuttleUtils.hasLollipop()) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
getWindow().setStatusBarColor(Color.TRANSPARENT);
}
if (SettingsManager.getInstance().canTintNavBar()) {
getWindow().setNavigationBarColor(ColorUtils.getPrimaryColorDark(this));
}
supportRequestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
// Now call super to ensure the theme was properly set
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mIsSlidingEnabled = getResources().getBoolean(R.bool.isSlidingEnabled);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mDummyStatusBar = (FrameLayout) findViewById(R.id.dummyStatusBar);
if (ShuttleUtils.hasKitKat()) {
mDummyStatusBar.setVisibility(View.VISIBLE);
mDummyStatusBar.setBackgroundColor(ColorUtils.getPrimaryColorDark(this));
LinearLayout.LayoutParams statusBarParams = new LinearLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, (int) ActionBarUtils.getStatusBarHeight(this));
mDummyStatusBar.setLayoutParams(statusBarParams);
}
setSupportActionBar(mToolbar);
ThemeUtils.themeStatusBar(this, mTintManager);
mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
mTitle = getString(R.string.library_title);
mDrawerLayout = (CustomDrawerLayout) findViewById(R.id.drawer_layout);
if (ShuttleUtils.hasLollipop() && ShuttleUtils.hasKitKat()) {
getWindow().setStatusBarColor(Color.TRANSPARENT);
}
mDrawerLayout.setStatusBarBackgroundColor(ShuttleUtils.hasLollipop() ? ColorUtils.getPrimaryColorDark(this) : ColorUtils.getPrimaryColor());
mNavigationDrawerFragment.setup((DrawerLayout) findViewById(R.id.drawer_layout));
if (mIsSlidingEnabled) {
mSlidingUpPanelLayout = (SlidingUpPanelLayout) findViewById(R.id.container);
setDragView(null, false);
//The second panel slide offset is mini player height + toolbar height + status bar height.
//This gets our 'up next' sitting snugly underneath the toolbar
int offset = (int) (ActionBarUtils.getActionBarHeight(this) + (ShuttleUtils.hasKitKat() ? ActionBarUtils.getStatusBarHeight(this) : 0) - getResources().getDimension(R.dimen.mini_player_height));
mSlidingUpPanelLayout.setSlidePanelOffset(-offset);
mSlidingUpPanelLayout.hidePanel();
mSlidingUpPanelLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View panel, float slideOffset) {
setActionBarAlpha(slideOffset, false);
boolean canChangeElevation = true;
Fragment playingFragment = getSupportFragmentManager().findFragmentById(R.id.player_container);
if (playingFragment != null) {
Fragment childFragment = playingFragment.getChildFragmentManager().findFragmentById(R.id.queue_container);
if (childFragment != null && childFragment instanceof QueueFragment) {
canChangeElevation = false;
}
}
if (canChangeElevation) {
getSupportActionBar().setElevation(ResourceUtils.toPixels(4) * slideOffset);
}
mNavigationDrawerFragment.animateDrawerToggle(slideOffset);
}
@Override
public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {
switch(newState) {
case COLLAPSED:
{
setDragView(null, false);
mTitle = getString(R.string.library_title);
supportInvalidateOptionsMenu();
toggleQueue(false);
mNavigationDrawerFragment.toggleDrawerLock(false);
break;
}
case EXPANDED:
{
Fragment playerFragment = getSupportFragmentManager().findFragmentById(R.id.player_container);
if (playerFragment != null && playerFragment instanceof PlayerFragment) {
setDragView(((PlayerFragment) playerFragment).getDragView(), true);
if (((PlayerFragment) playerFragment).isQueueShowing()) {
toggleQueue(true);
}
}
mTitle = getString(R.string.nowplaying_title);
supportInvalidateOptionsMenu();
mNavigationDrawerFragment.toggleDrawerLock(true);
break;
}
}
}
});
}
if (savedInstanceState != null && mIsSlidingEnabled) {
if (savedInstanceState.getBoolean(ARG_EXPANDED, false)) {
final ActionBar actionBar = getSupportActionBar();
//If the sliding panel was previously expanded, expand it again.
mSlidingUpPanelLayout.post(() -> {
mSlidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED, false);
setActionBarAlpha(1f, false);
});
mTitle = getString(R.string.nowplaying_title);
if (actionBar != null) {
actionBar.setTitle(mTitle);
}
Fragment playingFragment = getSupportFragmentManager().findFragmentById(R.id.player_container);
if (playingFragment != null) {
Fragment childFragment = playingFragment.getChildFragmentManager().findFragmentById(R.id.queue_container);
if (childFragment != null && childFragment instanceof QueueFragment) {
toggleQueue(true);
}
}
}
}
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction().add(R.id.main_container, MainFragment.newInstance()).commit();
getSupportFragmentManager().beginTransaction().add(R.id.mini_player_container, MiniPlayerFragment.newInstance()).commit();
if (mIsSlidingEnabled) {
getSupportFragmentManager().beginTransaction().add(R.id.player_container, PlayerFragment.newInstance()).commit();
}
}
themeTaskDescription();
handleIntent(getIntent());
}
Aggregations