use of org.videolan.vlc.gui.browser.MediaBrowserFragment in project vlc-android by videolan.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!VLCInstance.testCompatibleCPU(this)) {
finish();
return;
}
Permissions.checkReadStoragePermission(this, false);
/**
* Start initializing the UI **
*/
setContentView(R.layout.main);
mDrawerLayout = (HackyDrawerLayout) findViewById(R.id.root_container);
setupNavigationView();
initAudioPlayerContainerActivity();
if (savedInstanceState != null) {
final FragmentManager fm = getSupportFragmentManager();
mCurrentFragment = fm.getFragment(savedInstanceState, "current_fragment");
// Restore fragments stack
restoreFragmentsStack(savedInstanceState, fm);
mCurrentFragmentId = savedInstanceState.getInt("current", mSettings.getInt("fragment_id", R.id.nav_video));
} else {
if (getIntent().getBooleanExtra(Constants.EXTRA_UPGRADE, false)) {
/*
* The sliding menu is automatically opened when the user closes
* the info dialog. If (for any reason) the dialog is not shown,
* open the menu after a short delay.
*/
mActivityHandler.postDelayed(new Runnable() {
@Override
public void run() {
mDrawerLayout.openDrawer(mNavigationView);
}
}, 500);
}
reloadPreferences();
}
/* Set up the action bar */
prepareActionBar();
/* Set up the sidebar click listener
* no need to invalidate menu for now */
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
final Fragment current = getCurrentFragment();
if (current instanceof MediaBrowserFragment)
((MediaBrowserFragment) current).setReadyToDisplay(true);
}
// Hack to make navigation drawer browsable with DPAD.
// see https://code.google.com/p/android/issues/detail?id=190975
// and http://stackoverflow.com/a/34658002/3485324
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
if (mNavigationView.requestFocus())
((NavigationMenuView) mNavigationView.getFocusedChild()).setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
}
};
// Set the drawer toggle as the DrawerListener
mDrawerLayout.setDrawerListener(mDrawerToggle);
// set a custom shadow that overlays the main content when the drawer opens
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
/* Reload the latest preferences */
mScanNeeded = savedInstanceState == null && mSettings.getBoolean("auto_rescan", true);
mExtensionsManager = ExtensionsManager.getInstance();
mMediaLibrary = VLCApplication.getMLInstance();
}
use of org.videolan.vlc.gui.browser.MediaBrowserFragment in project vlc-android by GeoffreyMetais.
the class ContentActivity method makeRoomForSearch.
// Hide options menu items to make room for filter EditText
protected void makeRoomForSearch(Fragment current, boolean hide) {
final Menu menu = mToolbar.getMenu();
menu.findItem(R.id.ml_menu_renderers).setVisible(!hide && showRenderers);
if (current instanceof MediaBrowserFragment) {
menu.findItem(R.id.ml_menu_sortby).setVisible(!hide && ((MediaBrowserFragment) current).getProvider().canSortByName());
}
if (current instanceof VideoGridFragment || current instanceof AudioBrowserFragment) {
menu.findItem(R.id.ml_menu_last_playlist).setVisible(!hide);
}
}
use of org.videolan.vlc.gui.browser.MediaBrowserFragment in project vlc-android by videolan.
the class MainActivity method restoreFragmentsStack.
private void restoreFragmentsStack(Bundle savedInstanceState, FragmentManager fm) {
final List<Fragment> fragments = fm.getFragments();
if (fragments != null) {
final FragmentTransaction ft = fm.beginTransaction();
final Fragment displayed = fm.getFragment(savedInstanceState, "current_fragment_visible");
for (Fragment fragment : fragments) if (fragment != null) {
if (fragment instanceof ExtensionBrowser) {
ft.remove(fragment);
} else if ((fragment instanceof MediaBrowserFragment)) {
mFragmentsStack.put(fragment.getTag(), new WeakReference<>(fragment));
if (!TextUtils.equals(fragment.getTag(), displayed.getTag()))
ft.hide(fragment);
}
}
ft.commit();
}
}
Aggregations