public SystemUiHelper( @NonNull final Activity activity, final int level, final int flags, @Nullable final OnVisibilityChangeListener listener) { mHandler = new Handler(Looper.getMainLooper()); mHideRunnable = new HideRunnable(); if (AndroidHelper.api() >= AndroidHelper.API_19) { mImpl = new SystemUiHelperImplKK(activity, level, flags, listener); } else if (AndroidHelper.api() >= AndroidHelper.API_16) { mImpl = new SystemUiHelperImplJB(activity, level, flags, listener); } else if (AndroidHelper.api() >= AndroidHelper.API_14) { mImpl = new SystemUiHelperImplICS(activity, level, flags, listener); } else if (AndroidHelper.api() >= AndroidHelper.API_11) { mImpl = new SystemUiHelperImplHC(activity, level, flags, listener); } else { mImpl = new SystemUiHelperImplBase(activity, level, flags, listener); } }
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sk_navigationdraweractivity); home(true); mDrawerLayout = (DrawerLayout) findViewById(R.id.sk_drawerLayout); if (mDrawerLayout == null) { LogHelper.warning("DrawerLayout was NULL"); return; } mDrawerToggle = new ActionBarDrawerToggle( SkeletonNavigationDrawerActivity.this, mDrawerLayout, android.R.string.ok, android.R.string.cancel) { @Override public void onDrawerOpened(@NonNull final View view) { onNavigationDrawerOpened(); } @Override public void onDrawerClosed(@NonNull final View view) { onNavigationDrawerClosed(); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); mNavigationView = (NavigationView) findViewById(R.id.sk_navigationView); if (mNavigationView == null) { LogHelper.warning("NavigationView was NULL"); return; } if (AndroidHelper.api() >= AndroidHelper.API_21) { mNavigationView.setPadding(0, (int) getResources().getDimension(R.dimen.statusBar), 0, 0); } mNavigationView.setNavigationItemSelectedListener( new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull final MenuItem menuItem) { navigationDrawer(menuItem.getItemId()); return true; } }); }