use of org.videolan.vlc.gui.browser.BaseBrowserFragment in project vlc-android by videolan.
the class MainActivity method onNavigationItemSelected.
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// This should not happen
if (item == null)
return false;
int id = item.getItemId();
final Fragment current = getCurrentFragment();
if (item.getGroupId() == R.id.extensions_group) {
if (mCurrentFragmentId == id) {
clearBackstackFromClass(ExtensionBrowser.class);
mDrawerLayout.closeDrawer(mNavigationView);
return false;
} else
mExtensionManagerService.openExtension(id);
} else {
if (mExtensionServiceConnection != null)
mExtensionManagerService.disconnect();
if (current == null) {
mDrawerLayout.closeDrawer(mNavigationView);
return false;
}
if (mCurrentFragmentId == id) {
// Go back at root level of current browser
if (current instanceof BaseBrowserFragment && !((BaseBrowserFragment) current).isRootDirectory()) {
getSupportFragmentManager().popBackStackImmediate(getTag(id), FragmentManager.POP_BACK_STACK_INCLUSIVE);
} else {
mDrawerLayout.closeDrawer(mNavigationView);
return false;
}
} else
switch(id) {
case R.id.nav_about:
showSecondaryFragment(SecondaryActivity.ABOUT);
break;
case R.id.nav_settings:
startActivityForResult(new Intent(this, PreferencesActivity.class), ACTIVITY_RESULT_PREFERENCES);
break;
case R.id.nav_mrl:
new MRLPanelFragment().show(getSupportFragmentManager(), "fragment_mrl");
break;
case R.id.nav_directories:
if (TextUtils.equals(BuildConfig.FLAVOR_target, "chrome")) {
final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("audio/* video/*");
startActivityForResult(intent, ACTIVITY_RESULT_OPEN);
mDrawerLayout.closeDrawer(mNavigationView);
return true;
}
default:
/* Slide down the audio player */
slideDownAudioPlayer();
/* Switch the fragment */
showFragment(id);
}
}
mDrawerLayout.closeDrawer(mNavigationView);
return true;
}
use of org.videolan.vlc.gui.browser.BaseBrowserFragment in project vlc-android by videolan.
the class MainActivity method showFragment.
public void showFragment(int id) {
final FragmentManager fm = getSupportFragmentManager();
final String tag = getTag(id);
// Get new fragment
Fragment fragment = null;
final WeakReference<Fragment> wr = mFragmentsStack.get(tag);
final boolean add = wr == null || (fragment = wr.get()) == null;
if (add) {
fragment = getNewFragment(id);
mFragmentsStack.put(tag, new WeakReference<>(fragment));
}
if (mCurrentFragment != null)
if (mCurrentFragment instanceof ExtensionBrowser)
fm.beginTransaction().remove(mCurrentFragment).commit();
else {
if (mCurrentFragment instanceof BaseBrowserFragment && !((BaseBrowserFragment) getCurrentFragment()).isRootDirectory())
fm.popBackStackImmediate("root", FragmentManager.POP_BACK_STACK_INCLUSIVE);
fm.beginTransaction().hide(mCurrentFragment).commit();
}
final FragmentTransaction ft = fm.beginTransaction();
if (add)
ft.add(R.id.fragment_placeholder, fragment, tag);
else
ft.show(fragment);
ft.commit();
updateCheckedItem(id);
mCurrentFragment = fragment;
mCurrentFragmentId = id;
}
use of org.videolan.vlc.gui.browser.BaseBrowserFragment in project vlc-android by videolan.
the class MainActivity method onBackPressed.
@Override
public void onBackPressed() {
/* Close the menu first */
if (mDrawerLayout.isDrawerOpen(mNavigationView)) {
mDrawerLayout.closeDrawer(mNavigationView);
return;
}
/* Close playlist search if open or Slide down the audio player if it is shown entirely. */
if (isAudioPlayerReady() && (mAudioPlayer.clearSearch() || slideDownAudioPlayer()))
return;
// If it's the directory view, a "backpressed" action shows a parent.
final Fragment fragment = getCurrentFragment();
if (fragment instanceof BaseBrowserFragment && ((BaseBrowserFragment) fragment).goBack()) {
return;
} else if (fragment instanceof ExtensionBrowser) {
((ExtensionBrowser) fragment).goBack();
return;
}
if (AndroidUtil.isNougatOrLater && isInMultiWindowMode()) {
UiTools.confirmExit(this);
return;
}
finish();
}
use of org.videolan.vlc.gui.browser.BaseBrowserFragment in project vlc-android by GeoffreyMetais.
the class MainActivity method onBackPressed.
@Override
public void onBackPressed() {
/* Close the menu first */
if (mDrawerLayout.isDrawerOpen(mNavigationView)) {
closeDrawer();
return;
}
/* Close playlist search if open or Slide down the audio player if it is shown entirely. */
if (isAudioPlayerReady() && (mAudioPlayer.clearSearch() || slideDownAudioPlayer()))
return;
// If it's the directory view, a "backpressed" action shows a parent.
final Fragment fragment = getCurrentFragment();
if (fragment instanceof BaseBrowserFragment && ((BaseBrowserFragment) fragment).goBack()) {
return;
} else if (fragment instanceof ExtensionBrowser) {
((ExtensionBrowser) fragment).goBack();
return;
}
if (AndroidUtil.isNougatOrLater && isInMultiWindowMode()) {
UiTools.confirmExit(this);
return;
}
finish();
}
Aggregations