use of android.support.design.internal.NavigationMenuView 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 android.support.design.internal.NavigationMenuView in project Dxditor by kimi2009.
the class MainActivity method setNavigationMenuLineStyle.
/**
* 给 NavigationView 的Menu的分割线 设置高度和颜色
*
* @param navigationView
* @param color
* @param height
*/
public static void setNavigationMenuLineStyle(NavigationView navigationView, @ColorInt final int color, final int height) {
try {
Field fieldByPressenter = navigationView.getClass().getDeclaredField("mPresenter");
fieldByPressenter.setAccessible(true);
NavigationMenuPresenter menuPresenter = (NavigationMenuPresenter) fieldByPressenter.get(navigationView);
Field fieldByMenuView = menuPresenter.getClass().getDeclaredField("mMenuView");
fieldByMenuView.setAccessible(true);
final NavigationMenuView mMenuView = (NavigationMenuView) fieldByMenuView.get(menuPresenter);
mMenuView.addOnChildAttachStateChangeListener(new RecyclerView.OnChildAttachStateChangeListener() {
@Override
public void onChildViewAttachedToWindow(View view) {
RecyclerView.ViewHolder viewHolder = mMenuView.getChildViewHolder(view);
if (viewHolder != null && "SeparatorViewHolder".equals(viewHolder.getClass().getSimpleName()) && viewHolder.itemView != null) {
if (viewHolder.itemView instanceof FrameLayout) {
FrameLayout frameLayout = (FrameLayout) viewHolder.itemView;
View line = frameLayout.getChildAt(0);
line.setBackgroundColor(color);
line.getLayoutParams().height = height;
line.setLayoutParams(line.getLayoutParams());
}
}
}
@Override
public void onChildViewDetachedFromWindow(View view) {
}
});
} catch (Throwable e) {
e.printStackTrace();
}
}
Aggregations