Example usage for android.view Window FEATURE_ACTION_BAR_OVERLAY

List of usage examples for android.view Window FEATURE_ACTION_BAR_OVERLAY

Introduction

In this page you can find the example usage for android.view Window FEATURE_ACTION_BAR_OVERLAY.

Prototype

int FEATURE_ACTION_BAR_OVERLAY

To view the source code for android.view Window FEATURE_ACTION_BAR_OVERLAY.

Click Source Link

Document

Flag for requesting an Action Bar that overlays window content.

Usage

From source file:com.android.camera.ActivityBase.java

@Override
public void onCreate(Bundle icicle) {
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
    super.disableToggleStatusBar();
    // Set a theme with action bar. It is not specified in manifest because
    // we want to hide it by default. setTheme must happen before
    // setContentView.
    ///*  ww  w . j  a va  2 s.co m*/
    // This must be set before we call super.onCreate(), where the window's
    // background is removed.
    setTheme(R.style.Theme_Gallery);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);

    super.onCreate(icicle);
}

From source file:com.klinker.android.twitter.activities.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    UpdateUtils.checkUpdate(this);

    MainActivity.sendHandler = new Handler();

    context = this;
    sContext = this;
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    DrawerActivity.settings = AppSettings.getInstance(context);

    try {/*from   w  w  w .  jav a  2  s  .c  o m*/
        requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    } catch (Exception e) {

    }

    sharedPrefs.edit().putBoolean("refresh_me", getIntent().getBooleanExtra("from_notification", false))
            .commit();

    setUpTheme();
    setUpWindow();
    setContentView(R.layout.main_activity);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    setUpDrawer(0, getResources().getString(R.string.timeline));

    MainActivity.sendLayout = (LinearLayout) findViewById(R.id.send_layout);
    MainActivity.sendHandler.postDelayed(showSend, 1000);
    MainActivity.sendButton = (ImageButton) findViewById(R.id.send_button);
    MainActivity.sendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent compose = new Intent(context, ComposeActivity.class);
            startActivity(compose);
        }
    });

    actionBar = getActionBar();

    if (!settings.isTwitterLoggedIn) {
        Intent login = new Intent(context, LoginActivity.class);
        startActivity(login);
    }

    mSectionsPagerAdapter = new TimelinePagerAdapter(getFragmentManager(), context, sharedPrefs,
            getIntent().getBooleanExtra("from_launcher", false));
    int currAccount = sharedPrefs.getInt("current_account", 1);
    int defaultPage = sharedPrefs.getInt("default_timeline_page_" + currAccount, 0);
    actionBar.setTitle(mSectionsPagerAdapter.getPageTitle(defaultPage));

    mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        public void onPageScrollStateChanged(int state) {
        }

        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            if (!actionBar.isShowing()) {
                actionBar.show();

                if (translucent) {
                    statusBar.setVisibility(View.VISIBLE);
                }
            }
            MainActivity.sendHandler.post(showSend);
        }

        public void onPageSelected(int position) {

            String title = "" + mSectionsPagerAdapter.getPageTitle(position);

            MainDrawerArrayAdapter.setCurrent(context, position);
            drawerList.invalidateViews();

            actionBar.setTitle(title);
        }
    });

    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOverScrollMode(View.OVER_SCROLL_NEVER);
    mViewPager.setCurrentItem(defaultPage);
    MainDrawerArrayAdapter.setCurrent(this, defaultPage);

    drawerList.invalidateViews();

    if (getIntent().getBooleanExtra("from_launcher", false)) {
        actionBar.setTitle(mSectionsPagerAdapter.getPageTitle(getIntent().getIntExtra("launcher_page", 0)));
    }

    mViewPager.setOffscreenPageLimit(TimelinePagerAdapter.MAX_EXTRA_PAGES);

    if (getIntent().getBooleanExtra("tutorial", false) && !sharedPrefs.getBoolean("done_tutorial", false)) {
        getIntent().putExtra("tutorial", false);
        sharedPrefs.edit().putBoolean("done_tutorial", true).commit();
        registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                try {
                    Log.v("tutorial_activity", "close drawer");
                    mDrawerLayout.closeDrawer(Gravity.LEFT);
                    unregisterReceiver(this);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, new IntentFilter(TutorialActivity.ACTION_CLOSE_DRAWER));

        registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                try {
                    Log.v("tutorial_activity", "open drawer");
                    mDrawerLayout.openDrawer(Gravity.LEFT);
                    unregisterReceiver(this);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, new IntentFilter(TutorialActivity.ACTION_OPEN_DRAWER));

        registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                try {
                    Log.v("tutorial_activity", "page left");
                    mViewPager.setCurrentItem(mViewPager.getCurrentItem() - 1, true);
                    unregisterReceiver(this);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, new IntentFilter(TutorialActivity.ACTION_PAGE_LEFT));

        registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                try {
                    Log.v("tutorial_activity", "page right");
                    mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1, true);
                    unregisterReceiver(this);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, new IntentFilter(TutorialActivity.ACTION_PAGE_RIGHT));

        startActivity(new Intent(context, TutorialActivity.class));
        overridePendingTransition(0, 0);
    }

    setLauncherPage();

    if (getIntent().getBooleanExtra("from_drawer", false)) {
        mViewPager.setCurrentItem(getIntent().getIntExtra("page_to_open", 1));
    }
}

From source file:lewa.support.v7.app.ActionBarImplBase.java

public ActionBarImplBase(ActionBarActivity activity, Callback callback) {
    mActivity = activity;/*from  w ww .  j  av a 2s .  co  m*/
    mContext = activity;
    mCallback = callback;
    init(mActivity);
    if (!mActivity.getWindow().hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) {
        mContentView = mActivity.findViewById(android.R.id.content);
    }
}

From source file:com.tandong.sa.sherlock.internal.app.ActionBarImpl.java

public ActionBarImpl(Activity activity, int features) {
    mActivity = activity;//from   w ww. j  av  a2  s  . c  o  m
    Window window = activity.getWindow();
    View decor = window.getDecorView();
    init(decor);

    // window.hasFeature() workaround for pre-3.0
    if ((features & (1 << Window.FEATURE_ACTION_BAR_OVERLAY)) == 0) {
        mContentView = (NineFrameLayout) decor.findViewById(android.R.id.content);
    }
}

From source file:com.klinker.android.twitter.ui.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    MainActivity.sendHandler = new Handler();

    context = this;
    sContext = this;
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences",
            Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);
    DrawerActivity.settings = AppSettings.getInstance(context);

    try {/*from   w w  w .  j a va  2s  .c o  m*/
        requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    } catch (Exception e) {

    }

    sharedPrefs.edit().putBoolean("refresh_me", getIntent().getBooleanExtra("from_notification", false))
            .commit();

    setUpTheme();
    setUpWindow();
    setContentView(R.layout.main_activity);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    setUpDrawer(0, getResources().getString(R.string.timeline));

    MainActivity.sendLayout = (LinearLayout) findViewById(R.id.send_layout);
    MainActivity.sendHandler.postDelayed(showSend, 1000);
    MainActivity.sendButton = (ImageButton) findViewById(R.id.send_button);
    MainActivity.sendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent compose = new Intent(context, ComposeActivity.class);
            startActivity(compose);
        }
    });

    actionBar = getActionBar();
    actionBar.setTitle(getResources().getString(R.string.timeline));

    if (!settings.isTwitterLoggedIn) {
        Intent login = new Intent(context, LoginActivity.class);
        startActivity(login);
    } /*else if (!sharedPrefs.getBoolean("setup_v_two", false) && !PreferenceManager.getDefaultSharedPreferences(context).getBoolean("setup_v_two", false)) {
      Intent setupV2 = new Intent(context, Version2Setup.class);
      startActivity(setupV2);
      }*/

    mSectionsPagerAdapter = new TimelinePagerAdapter(getFragmentManager(), context, sharedPrefs,
            getIntent().getBooleanExtra("from_launcher", false));

    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOverScrollMode(View.OVER_SCROLL_NEVER);
    mViewPager.setCurrentItem(mSectionsPagerAdapter.getCount() - 3);

    if (getIntent().getBooleanExtra("from_launcher", false)) {
        actionBar.setTitle(mSectionsPagerAdapter.getPageTitle(getIntent().getIntExtra("launcher_page", 0)));
    }

    mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        public void onPageScrollStateChanged(int state) {
        }

        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            if (!actionBar.isShowing()) {
                actionBar.show();

                if (translucent) {
                    statusBar.setVisibility(View.VISIBLE);
                }
            }
            MainActivity.sendHandler.post(showSend);
        }

        public void onPageSelected(int position) {

            String title = "" + mSectionsPagerAdapter.getPageTitle(position);

            if (title.equals(getResources().getString(R.string.mentions))) {
                MainDrawerArrayAdapter.current = 1;
            } else if (title.equals(getResources().getString(R.string.direct_messages))) {
                MainDrawerArrayAdapter.current = 2;
            } else if (title.equals(getResources().getString(R.string.timeline))) {
                MainDrawerArrayAdapter.current = 0;
            } else {
                MainDrawerArrayAdapter.current = -1;
            }

            drawerList.invalidateViews();

            actionBar.setTitle(title);
        }
    });

    mViewPager.setOffscreenPageLimit(4);

    if (getIntent().getBooleanExtra("tutorial", false) && !sharedPrefs.getBoolean("done_tutorial", false)) {
        getIntent().putExtra("tutorial", false);
        sharedPrefs.edit().putBoolean("done_tutorial", true).commit();
        registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                try {
                    Log.v("tutorial_activity", "close drawer");
                    mDrawerLayout.closeDrawer(Gravity.LEFT);
                    unregisterReceiver(this);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, new IntentFilter(TutorialActivity.ACTION_CLOSE_DRAWER));

        registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                try {
                    Log.v("tutorial_activity", "open drawer");
                    mDrawerLayout.openDrawer(Gravity.LEFT);
                    unregisterReceiver(this);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, new IntentFilter(TutorialActivity.ACTION_OPEN_DRAWER));

        registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                try {
                    Log.v("tutorial_activity", "page left");
                    mViewPager.setCurrentItem(mViewPager.getCurrentItem() - 1, true);
                    unregisterReceiver(this);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, new IntentFilter(TutorialActivity.ACTION_PAGE_LEFT));

        registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                try {
                    Log.v("tutorial_activity", "page right");
                    mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1, true);
                    unregisterReceiver(this);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, new IntentFilter(TutorialActivity.ACTION_PAGE_RIGHT));

        startActivity(new Intent(context, TutorialActivity.class));
        overridePendingTransition(0, 0);
    }

    setLauncherPage();

    if (getIntent().getBooleanExtra("from_drawer", false)) {
        mViewPager.setCurrentItem(getIntent().getIntExtra("page_to_open", 3));
    }
}

From source file:net.zorgblub.typhon.activity.ReadingActivity.java

@Override
protected void requestFeatures() {
    super.requestFeatures();
    if (config.isFullScreenEnabled())
        supportRequestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
}

From source file:org.ulteo.ovd.AndRdpActivity.java

@Override
@TargetApi(Build.VERSION_CODES.KITKAT)/*from  ww  w  . ja  v a2  s.c  o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    context = this;

    Log.i(Config.TAG, "Android SDK " + android.os.Build.VERSION.SDK_INT);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
        getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_bg));
        getActionBar().hide();
    } else {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    }
    int flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
    if (Settings.getFullscreen(this)) {
        flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
    }
    getWindow().addFlags(flags);

    view = new Panel(this);
    view.threeFingersHandler = this;
    setContentView(view);

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB
            && Settings.getSystemUiLowProfile(this)) {
        hideSystemUi();
        view.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int visibility) {
                Log.i(Config.TAG, "SystemUiVisibilityChange to " + visibility);
                if (visibility == View.SYSTEM_UI_FLAG_VISIBLE
                        && Settings.getSystemUiLowProfile(AndRdpActivity.this))
                    dimHandler.sendEmptyMessageDelayed(MSG_DIM_SU, Config.SYSTEM_UI_DIM_TIME);
            }
        });
    }

    // add callback if sm is allocated
    smHandler.listenSm();
    smHandler.startStatusPoll();

    view.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            startSession(view.getWidth(), view.getHeight());
            view.surfaceCreated();
        }
    });
}

From source file:com.opencabinetlabs.destinycommunityhub.ui.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Crashlytics.start(this);
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);

    if (isFinishing()) {
        return;//from w w w  .j a v  a2 s  .c  om
    }

    setContentView(R.layout.activity_main);

    bindViews();

    // Enabling Up navigation
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setDisplayShowHomeEnabled(true);
    getActionBar().setIcon(R.drawable.action_bar_icon);

    if (savedInstanceState != null) {
        mCommunityNewsFragment = (CommunityNewsFragment) getSupportFragmentManager()
                .getFragment(savedInstanceState, CommunityNewsFragment.class.getName());
        mVideosFragment = (VideosFragment) getSupportFragmentManager().getFragment(savedInstanceState,
                VideosFragment.class.getName());
        mCommunityFragment = (CommunityFragment) getSupportFragmentManager().getFragment(savedInstanceState,
                CommunityFragment.class.getName());
        mTwitterStreamFragment = (TwitterStreamFragment) getSupportFragmentManager()
                .getFragment(savedInstanceState, TwitterStreamFragment.class.getName());
        mPodcastFragment = (PodcastFragment) getSupportFragmentManager().getFragment(savedInstanceState,
                PodcastFragment.class.getName());
    }
    if (mCommunityNewsFragment == null) {
        mCommunityNewsFragment = new CommunityNewsFragment();
    }
    if (mVideosFragment == null) {
        mVideosFragment = new VideosFragment();
    }
    if (mCommunityFragment == null) {
        mCommunityFragment = new CommunityFragment();
    }
    if (mTwitterStreamFragment == null) {
        mTwitterStreamFragment = new TwitterStreamFragment();
    }
    if (mPodcastFragment == null) {
        mPodcastFragment = new PodcastFragment();
    }

    //Initialize sharedPrefs
    mPrefs = getSharedPreferences(CommunityHubConfig.PREFS_NAME, Context.MODE_PRIVATE);

    mLastTimeApiRequestsMade = mPrefs.getLong("lastTimeApiRequestsMade", 0);

    // Instantiate a ViewPager and a PagerAdapter.
    mPager = (ViewPager) findViewById(R.id.pager);

    HomePagerAdapter mPagerAdapter = new HomePagerAdapter(getSupportFragmentManager());
    mPager.setAdapter(mPagerAdapter);
    mNumFragments = mPagerAdapter.getCount();

    mPager.setPageTransformer(true, new DepthPageTransformer());

    //mNumFragments = mPagerAdapter.getCount();

    // Getting an array of link names
    mNavDrawerLinks = getResources().getStringArray(R.array.navdrawer_links);

    // Title of the activity
    // = (String)getTitle();

    // Getting a reference to the drawer listview
    mDrawerList = (ListView) findViewById(R.id.drawer_list);
    final TypedArray styledAttributes = this.getTheme()
            .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
    int mActionBarSize = (int) styledAttributes.getDimension(0, 0);
    styledAttributes.recycle();
    mDrawerList.setPadding(0, mActionBarSize, 0, 0);

    // Getting a reference to the sidebar drawer ( Title + ListView )
    mDrawer = (LinearLayout) findViewById(R.id.drawer);

    mList = new ArrayList<HashMap<String, String>>();
    for (int i = 0; i < 5; i++) {
        HashMap<String, String> hm = new HashMap<String, String>();
        hm.put(TITLE, mNavDrawerLinks[i]);
        hm.put(ICON, Integer.toString(mIcons[i]));
        mList.add(hm);
    }

    // Keys used in Hashmap
    String[] from = { ICON, TITLE };

    // Ids of views in listview_layout
    int[] to = { R.id.icon, R.id.title };

    // Instantiating an adapter to store each items
    // R.layout.drawer_layout defines the layout of each item
    mAdapter = new SimpleAdapter(this, mList, R.layout.drawer_layout, from, to) {

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = super.getView(position, convertView, parent);

            TextView textView = (TextView) view.findViewById(R.id.title);
            textView.setTextColor(Color.WHITE);

            return view;
        }
    };

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    // Creating a ToggleButton for NavigationDrawer with drawer event listener
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open,
            R.string.drawer_close) {

        /** Called when drawer is closed */
        public void onDrawerClosed(View view) {
            getActionBar().setTitle(R.string.app_name);
            supportInvalidateOptionsMenu();
        }

        /** Called when a drawer is opened */
        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(R.string.title_nav_opened);
            supportInvalidateOptionsMenu();
        }
    };

    // Setting event listener for the drawer
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    // ItemClick event handler for the drawer items
    mDrawerList.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {

            // Increment hit count of the drawer list item
            //incrementHitCount(position);

            if (position <= mNumFragments) { // Show fragment
                showFragment(position);
            }

            // Closing the drawer
            mDrawerLayout.closeDrawer(mDrawer);
        }
    });

    // Setting the adapter to the listView
    mDrawerList.setAdapter(mAdapter);

    PagerTabStrip strip = (PagerTabStrip) findViewById(R.id.pagertitlestrip);
    strip.setDrawFullUnderline(true);
    strip.setTabIndicatorColor(Color.WHITE);
    strip.setNonPrimaryAlpha(0.5f);
    strip.setTextSpacing(25);
    strip.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);

    /* Sliding Panel Layout Setup */
    mSlidingLayout.setShadowDrawable(getResources().getDrawable(R.drawable.above_shadow));
    //mSlidingLayout.setAnchorPoint(0.3f);
    mSlidingLayout.setDragView(mDraggableView);
    mSlidingLayout.setPanelSlideListener(new PanelSlideListener() {

        @Override
        public void onPanelSlide(View panel, float slideOffset) {
            if (slideOffset < 0.2) {
                if (getActionBar().isShowing()) {
                    getActionBar().hide();
                }
            } else {
                if (!getActionBar().isShowing()) {
                    getActionBar().show();
                }
            }
        }

        @Override
        public void onPanelExpanded(View panel) {

        }

        @Override
        public void onPanelCollapsed(View panel) {

        }

        @Override
        public void onPanelAnchored(View panel) {

        }
    });

    //Initially hide the podcast panel
    mPodcastPanel.setVisibility(View.GONE);

    mHasMadeCommunityNewsRequest = savedInstanceState == null ? false
            : savedInstanceState.getBoolean(KEY_HAS_MADE_COMMUNITY_NEWS_FEED_REQUEST, false);
    mHasMadeTwitterFeedRequest = savedInstanceState == null ? false
            : savedInstanceState.getBoolean(KEY_HAS_MADE_TWITTER_FEED_REQUEST, false);
    mHasMadePodcastsRequest = savedInstanceState == null ? false
            : savedInstanceState.getBoolean(KEY_HAS_MADE_PODCAST_FEED_REQUEST, false);

    boolean actionBarHidden = savedInstanceState != null
            ? savedInstanceState.getBoolean(SAVED_STATE_ACTION_BAR_HIDDEN, false)
            : false;
    if (actionBarHidden) {
        getActionBar().hide();
    }
}

From source file:com.actionbarsherlock.internal.app.ActionBarImpl.java

public ActionBarImpl(Activity activity, int features) {
    mActivity = activity;//from   w  w  w .j  a  va 2 s  . co  m
    Window window = activity.getWindow();
    View decor = window.getDecorView();
    init(decor);

    //window.hasFeature() workaround for pre-3.0
    if ((features & (1 << Window.FEATURE_ACTION_BAR_OVERLAY)) == 0) {
        mContentView = (NineFrameLayout) decor.findViewById(android.R.id.content);
    }
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.SessionLivestreamActivity.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override//  ww  w  .  ja v  a 2 s .  co m
protected void onCreate(Bundle savedInstanceState) {
    if (UIUtils.hasICS()) {
        // We can't use this mode on HC as compatible ActionBar doesn't work well with the YT
        // player in full screen mode (no overlays allowed).
        requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_session_livestream);
    mIsTablet = UIUtils.isHoneycombTablet(this);

    // Set up YouTube player
    mYouTubeFragment = (YouTubePlayerSupportFragment) getSupportFragmentManager()
            .findFragmentById(R.id.livestream_player);
    mYouTubeFragment.initialize(Config.YOUTUBE_API_KEY, this);

    // Views that are common over all layouts
    mMainLayout = (LinearLayout) findViewById(R.id.livestream_mainlayout);
    mPresentationControls = (FrameLayout) findViewById(R.id.presentation_controls);
    adjustMainLayoutForActionBar();
    mPlayerContainer = (LinearLayout) findViewById(R.id.livestream_player_container);
    mFullscreenCaptions = (FrameLayout) findViewById(R.id.fullscreen_captions);
    final LayoutParams params = (LayoutParams) mFullscreenCaptions.getLayoutParams();
    params.setMargins(0, getActionBarHeightPx(), 0, getActionBarHeightPx());
    mFullscreenCaptions.setLayoutParams(params);

    ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setOffscreenPageLimit(2);
    if (!mIsTablet) {
        viewPager.setPageMarginDrawable(R.drawable.grey_border_inset_lr);
    }
    viewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.page_margin_width));

    // Set up tabs w/ViewPager
    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup();
    mTabsAdapter = new TabsAdapter(this, mTabHost, viewPager);

    if (mIsTablet) {
        // Tablet UI specific views
        getSupportFragmentManager().beginTransaction()
                .add(R.id.livestream_summary, new SessionSummaryFragment(), TAG_SESSION_SUMMARY).commit();
        mVideoLayout = (LinearLayout) findViewById(R.id.livestream_videolayout);
        mExtraLayout = (LinearLayout) findViewById(R.id.livestream_extralayout);
        mSummaryLayout = (FrameLayout) findViewById(R.id.livestream_summary);
    } else {
        // Handset UI specific views
        mTabsAdapter.addTab(getString(R.string.session_livestream_info), new SessionSummaryFragment(),
                TABNUM_SESSION_SUMMARY);
    }

    mTabsAdapter.addTab(getString(R.string.title_stream), new SocialStreamFragment(), TABNUM_SOCIAL_STREAM);
    mTabsAdapter.addTab(getString(R.string.session_livestream_captions), new SessionLiveCaptionsFragment(),
            TABNUM_LIVE_CAPTIONS);

    if (savedInstanceState != null) {
        mTabHost.setCurrentTabByTag(savedInstanceState.getString(EXTRA_TAB_STATE));
    }

    // Reload all other data in this activity
    reloadFromIntent(getIntent());

    // Update layout based on current configuration
    updateLayout(getResources().getConfiguration());

    // Set up action bar
    if (!mLoadFromExtras) {
        // Start sessions query to populate action bar navigation spinner
        getSupportLoaderManager().initLoader(SessionsQuery._TOKEN, null, this);

        // Set up action bar
        mLivestreamAdapter = new LivestreamAdapter(getSupportActionBar().getThemedContext());
        final ActionBar actionBar = getSupportActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
        actionBar.setListNavigationCallbacks(mLivestreamAdapter, this);
        actionBar.setDisplayShowTitleEnabled(false);
    }

    // Media Router and Presentation set up
    if (UIUtils.hasJellyBeanMR1()) {
        mMediaRouterCallback = new MediaRouter.SimpleCallback() {
            @Override
            public void onRouteSelected(MediaRouter router, int type, MediaRouter.RouteInfo info) {
                LOGD(TAG, "onRouteSelected: type=" + type + ", info=" + info);
                updatePresentation();
            }

            @Override
            public void onRouteUnselected(MediaRouter router, int type, MediaRouter.RouteInfo info) {
                LOGD(TAG, "onRouteUnselected: type=" + type + ", info=" + info);
                updatePresentation();
            }

            @Override
            public void onRoutePresentationDisplayChanged(MediaRouter router, MediaRouter.RouteInfo info) {
                LOGD(TAG, "onRoutePresentationDisplayChanged: info=" + info);
                updatePresentation();
            }
        };

        mMediaRouter = (MediaRouter) getSystemService(Context.MEDIA_ROUTER_SERVICE);
        final ImageButton playPauseButton = (ImageButton) findViewById(R.id.play_pause_button);
        playPauseButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mYouTubePlayer != null) {
                    if (mYouTubePlayer.isPlaying()) {
                        mYouTubePlayer.pause();
                        playPauseButton.setImageResource(R.drawable.ic_livestream_play);
                    } else {
                        mYouTubePlayer.play();
                        playPauseButton.setImageResource(R.drawable.ic_livestream_pause);
                    }
                }
            }
        });
        updatePresentation();
    }
}