use of com.simplecity.amp_library.ui.fragments.FolderFragment in project Shuttle by timusus.
the class MainActivity method onBackPressed.
@Override
public void onBackPressed() {
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) {
((PlayerFragment) playingFragment).toggleQueue();
toggleQueue(false);
return;
}
}
if (mIsSlidingEnabled) {
if (mSlidingUpPanelLayout.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
mSlidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED, true);
return;
}
}
boolean isShowingFolders = false;
Fragment containerFragment = getSupportFragmentManager().findFragmentById(R.id.main_container);
if (containerFragment != null && containerFragment instanceof FolderFragment) {
isShowingFolders = true;
} else if (containerFragment instanceof MainFragment) {
Fragment currentPagerFragment = ((MainFragment) containerFragment).getCurrentFragment();
if (currentPagerFragment != null && currentPagerFragment instanceof FolderFragment) {
isShowingFolders = true;
}
}
if (isShowingFolders) {
if (mBackPressListenerReference != null && mBackPressListenerReference.get() != null) {
if (mBackPressListenerReference.get().onBackPressed()) {
return;
}
}
}
super.onBackPressed();
if (isShowingFolders || containerFragment instanceof MainFragment) {
if (mNavigationDrawerFragment != null) {
mNavigationDrawerFragment.setDrawerItem(0);
}
mTitle = getString(R.string.library_title);
supportInvalidateOptionsMenu();
}
}
use of com.simplecity.amp_library.ui.fragments.FolderFragment in project Shuttle by timusus.
the class MainActivity method onItemClicked.
@Override
public void onItemClicked(DrawerGroupItem drawerGroupItem) {
switch(drawerGroupItem.type) {
case DrawerGroupItem.Type.LIBRARY:
if (getCurrentFragment() instanceof MainFragment) {
return;
} else {
for (int i = 0, count = getSupportFragmentManager().getBackStackEntryCount(); i < count; i++) {
try {
getSupportFragmentManager().popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
} catch (IllegalStateException e) {
Log.e(TAG, "Error popping backstack: " + e);
CrashlyticsCore.getInstance().logException(e);
}
}
mTitle = getString(R.string.library_title);
}
break;
case DrawerGroupItem.Type.FOLDERS:
if (getCurrentFragment() instanceof FolderFragment) {
return;
}
if (ShuttleUtils.isUpgraded()) {
//Folder
swapFragments(FolderFragment.newInstance(null), true);
} else {
DialogUtils.showUpgradeDialog(this, (materialDialog, dialogAction) -> {
if (ShuttleUtils.isAmazonBuild()) {
ShuttleUtils.openShuttleLink(MainActivity.this, "com.simplecity.amp_pro");
} else {
AnalyticsManager.logUpgrade(AnalyticsManager.UpgradeType.FOLDER);
purchasePremiumUpgrade();
}
});
}
break;
case DrawerGroupItem.Type.SETTINGS:
startActivity(new Intent(this, SettingsActivity.class));
break;
case DrawerGroupItem.Type.SUPPORT:
Intent intent = new Intent(this, SettingsActivity.class);
intent.putExtra(SettingsActivity.EXTRA_SUPPORT, true);
startActivity(intent);
break;
}
}
Aggregations