use of org.videolan.vlc.gui.browser.ExtensionBrowser 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.ExtensionBrowser 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.ExtensionBrowser in project vlc-android by videolan.
the class ContentActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
mMenu = menu;
if (getSupportFragmentManager().findFragmentById(R.id.fragment_placeholder) instanceof AboutFragment)
return true;
getMenuInflater().inflate(R.menu.activity_option, menu);
if (getCurrentFragment() instanceof ExtensionBrowser) {
menu.findItem(R.id.ml_menu_last_playlist).setVisible(false);
menu.findItem(R.id.ml_menu_sortby).setVisible(false);
}
if (getCurrentFragment() instanceof Filterable) {
MenuItem searchItem = menu.findItem(R.id.ml_menu_filter);
mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
mSearchView.setQueryHint(getString(R.string.search_list_hint));
mSearchView.setOnQueryTextListener(this);
MenuItemCompat.setOnActionExpandListener(searchItem, this);
} else
menu.findItem(R.id.ml_menu_filter).setVisible(false);
menu.findItem(R.id.ml_menu_renderers).setVisible(showRenderers);
menu.findItem(R.id.ml_menu_renderers).setIcon(RendererDelegate.INSTANCE.getSelectedRenderer() == null ? R.drawable.ic_am_renderer_normal_w : R.drawable.ic_am_renderer_on_w);
return super.onCreateOptionsMenu(menu);
}
use of org.videolan.vlc.gui.browser.ExtensionBrowser in project vlc-android by GeoffreyMetais.
the class ContentActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (getSupportFragmentManager().findFragmentById(R.id.fragment_placeholder) instanceof AboutFragment)
return true;
getMenuInflater().inflate(R.menu.activity_option, menu);
if (getCurrentFragment() instanceof ExtensionBrowser) {
menu.findItem(R.id.ml_menu_last_playlist).setVisible(false);
menu.findItem(R.id.ml_menu_sortby).setVisible(false);
}
if (getCurrentFragment() instanceof Filterable) {
final MenuItem searchItem = menu.findItem(R.id.ml_menu_filter);
mSearchView = (SearchView) searchItem.getActionView();
mSearchView.setQueryHint(getString(R.string.search_list_hint));
mSearchView.setOnQueryTextListener(this);
searchItem.setOnActionExpandListener(this);
} else
menu.findItem(R.id.ml_menu_filter).setVisible(false);
menu.findItem(R.id.ml_menu_renderers).setVisible(showRenderers);
menu.findItem(R.id.ml_menu_renderers).setIcon(!RendererDelegate.INSTANCE.hasRenderer() ? R.drawable.ic_am_renderer_normal_w : R.drawable.ic_am_renderer_on_w);
return super.onCreateOptionsMenu(menu);
}
use of org.videolan.vlc.gui.browser.ExtensionBrowser in project vlc-android by videolan.
the class MainActivity method displayExtensionItems.
@Override
public void displayExtensionItems(int extensionId, String title, List<VLCExtensionItem> items, boolean showParams, boolean refresh) {
if (refresh && getCurrentFragment() instanceof ExtensionBrowser) {
ExtensionBrowser browser = (ExtensionBrowser) getCurrentFragment();
browser.doRefresh(title, items);
} else {
ExtensionBrowser fragment = new ExtensionBrowser();
ArrayList<VLCExtensionItem> list = new ArrayList<>(items);
Bundle args = new Bundle();
args.putParcelableArrayList(ExtensionBrowser.KEY_ITEMS_LIST, list);
args.putBoolean(ExtensionBrowser.KEY_SHOW_FAB, showParams);
args.putString(ExtensionBrowser.KEY_TITLE, title);
fragment.setArguments(args);
fragment.setExtensionService(mExtensionManagerService);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
if (!(mCurrentFragment instanceof ExtensionBrowser)) {
// case: non-extension to extension root
if (mCurrentFragment != null)
ft.hide(mCurrentFragment);
ft.add(R.id.fragment_placeholder, fragment, title);
mCurrentFragment = fragment;
} else if (mCurrentFragmentId == extensionId) {
// case: extension root to extension sub dir
ft.hide(mCurrentFragment);
ft.add(R.id.fragment_placeholder, fragment, title);
ft.addToBackStack(getTag(mCurrentFragmentId));
} else {
// case: extension to other extension root
clearBackstackFromClass(ExtensionBrowser.class);
while (getSupportFragmentManager().popBackStackImmediate()) ;
ft.remove(mCurrentFragment);
ft.add(R.id.fragment_placeholder, fragment, title);
mCurrentFragment = fragment;
}
ft.commit();
mNavigationView.getMenu().findItem(extensionId).setCheckable(true);
updateCheckedItem(extensionId);
mCurrentFragmentId = extensionId;
}
}
Aggregations