Example usage for android.support.v4.view ViewPager setPageMarginDrawable

List of usage examples for android.support.v4.view ViewPager setPageMarginDrawable

Introduction

In this page you can find the example usage for android.support.v4.view ViewPager setPageMarginDrawable.

Prototype

public void setPageMarginDrawable(int resId) 

Source Link

Document

Set a drawable that will be used to fill the margin between pages.

Usage

From source file:com.matthewmitchell.peercoin_android_wallet.ui.AddressBookActivity.java

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

    setContentView(R.layout.address_book_content);

    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    final FragmentManager fragmentManager = getFragmentManager();

    walletAddressesFragment = (WalletAddressesFragment) fragmentManager.findFragmentByTag(TAG_LEFT);
    sendingAddressesFragment = (SendingAddressesFragment) fragmentManager.findFragmentByTag(TAG_RIGHT);

    final FragmentTransaction removal = fragmentManager.beginTransaction();

    if (walletAddressesFragment == null)
        walletAddressesFragment = new WalletAddressesFragment();
    else//from   w  w  w. j  av  a  2  s .  c o m
        removal.remove(walletAddressesFragment);

    if (sendingAddressesFragment == null)
        sendingAddressesFragment = new SendingAddressesFragment();
    else
        removal.remove(sendingAddressesFragment);

    if (!removal.isEmpty()) {
        removal.commit();
        fragmentManager.executePendingTransactions();
    }

    final ViewPager pager = (ViewPager) findViewById(R.id.address_book_pager);
    if (pager != null) {
        pager.setAdapter(
                new TwoFragmentAdapter(fragmentManager, walletAddressesFragment, sendingAddressesFragment));

        final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.address_book_pager_tabs);
        pagerTabs.addTabLabels(R.string.address_book_list_receiving_title,
                R.string.address_book_list_sending_title);

        pager.setOnPageChangeListener(pagerTabs);
        final int position = 1;
        pager.setCurrentItem(position);
        pager.setPageMargin(2);
        pager.setPageMarginDrawable(R.color.bg_less_bright);

        pagerTabs.onPageSelected(position);
        pagerTabs.onPageScrolled(position, 0, 0);
    } else {
        fragmentManager.beginTransaction()
                .add(R.id.wallet_addresses_fragment, walletAddressesFragment, TAG_LEFT)
                .add(R.id.sending_addresses_fragment, sendingAddressesFragment, TAG_RIGHT).commit();
    }

    runAfterLoad(new Runnable() {

        @Override
        public void run() {
            updateFragments();
        }

    });

}

From source file:cc.mintcoin.wallet.ui.AddressBookActivity.java

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

    setContentView(R.layout.address_book_content);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    FragmentManager fragmentManager = getSupportFragmentManager();

    walletAddressesFragment = (WalletAddressesFragment) fragmentManager.findFragmentByTag(TAG_LEFT);
    sendingAddressesFragment = (SendingAddressesFragment) fragmentManager.findFragmentByTag(TAG_RIGHT);

    FragmentTransaction remove = fragmentManager.beginTransaction();
    if (walletAddressesFragment == null) {
        walletAddressesFragment = new WalletAddressesFragment();
    } else {//from   w  w w .  j  ava 2  s  .c om
        remove.remove(walletAddressesFragment);
    }
    if (sendingAddressesFragment == null) {
        sendingAddressesFragment = new SendingAddressesFragment();
    } else {
        remove.remove(sendingAddressesFragment);
    }
    if (!remove.isEmpty()) {
        remove.commit();
        fragmentManager.executePendingTransactions();
    }

    final ViewPager pager = (ViewPager) findViewById(R.id.address_book_pager);
    if (pager != null) {
        pager.setAdapter(
                new TwoFragmentAdapter(fragmentManager, walletAddressesFragment, sendingAddressesFragment));

        final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.address_book_pager_tabs);
        pagerTabs.addTabLabels(R.string.address_book_list_receiving_title,
                R.string.address_book_list_sending_title);

        pager.setOnPageChangeListener(pagerTabs);
        final int position = getIntent().getBooleanExtra(EXTRA_SENDING, true) ? 1 : 0;
        pager.setCurrentItem(position);
        pager.setPageMargin(2);
        pager.setPageMarginDrawable(R.color.bg_less_bright);

        pagerTabs.onPageSelected(position);
        pagerTabs.onPageScrolled(position, 0, 0);
    } else {
        fragmentManager.beginTransaction()
                .add(R.id.wallet_addresses_fragment, walletAddressesFragment, TAG_LEFT)
                .add(R.id.sending_addresses_fragment, sendingAddressesFragment, TAG_RIGHT).commit();
    }

    updateFragments();
}

From source file:com.kncwallet.wallet.ui.AddressBookActivity.java

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

    setContentView(R.layout.address_book_content);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setIcon(R.drawable.ic_knclogo);
    final FragmentManager fragmentManager = getSupportFragmentManager();

    walletAddressesFragment = (WalletAddressesFragment) fragmentManager.findFragmentByTag(TAG_LEFT);
    sendingAddressesFragment = (SendingAddressesFragment) fragmentManager.findFragmentByTag(TAG_RIGHT);

    final FragmentTransaction removal = fragmentManager.beginTransaction();

    if (walletAddressesFragment == null)
        walletAddressesFragment = new WalletAddressesFragment();
    else//w ww.j  a v  a2  s . c  om
        removal.remove(walletAddressesFragment);

    if (sendingAddressesFragment == null)
        sendingAddressesFragment = new SendingAddressesFragment();
    else
        removal.remove(sendingAddressesFragment);

    if (!removal.isEmpty()) {
        removal.commit();
        fragmentManager.executePendingTransactions();
    }

    final ViewPager pager = (ViewPager) findViewById(R.id.address_book_pager);
    if (pager != null) {
        pager.setAdapter(
                new TwoFragmentAdapter(fragmentManager, walletAddressesFragment, sendingAddressesFragment));

        final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.address_book_pager_tabs);
        pagerTabs.addTabLabels(R.string.address_book_list_receiving_title,
                R.string.address_book_list_sending_title);

        pager.setOnPageChangeListener(pagerTabs);
        final int position = getIntent().getBooleanExtra(EXTRA_SENDING, true) ? 1 : 0;
        pager.setCurrentItem(position);
        pager.setPageMargin(2);
        pager.setPageMarginDrawable(R.color.bg_less_bright);

        pagerTabs.onPageSelected(position);
        pagerTabs.onPageScrolled(position, 0, 0);
    } else {
        fragmentManager.beginTransaction()
                .add(R.id.wallet_addresses_fragment, walletAddressesFragment, TAG_LEFT)
                .add(R.id.sending_addresses_fragment, sendingAddressesFragment, TAG_RIGHT).commit();
    }

    updateFragments();
}

From source file:com.mybitcoin.wallet.ui.AddressBookActivity.java

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

    setContentView(R.layout.address_book_content);

    //      final ActionBar actionBar = getSupportActionBar();
    //      actionBar.setDisplayHomeAsUpEnabled(true);

    final FragmentManager fragmentManager = getSupportFragmentManager();

    walletAddressesFragment = (WalletAddressesFragment) fragmentManager.findFragmentByTag(TAG_LEFT);
    sendingAddressesFragment = (SendingAddressesFragment) fragmentManager.findFragmentByTag(TAG_RIGHT);

    final FragmentTransaction removal = fragmentManager.beginTransaction();

    if (walletAddressesFragment == null)
        walletAddressesFragment = new WalletAddressesFragment();
    else/* w ww.  j a  v a  2s. c o m*/
        removal.remove(walletAddressesFragment);

    if (sendingAddressesFragment == null)
        sendingAddressesFragment = new SendingAddressesFragment();
    else
        removal.remove(sendingAddressesFragment);

    if (!removal.isEmpty()) {
        removal.commit();
        fragmentManager.executePendingTransactions();
    }

    final ViewPager pager = (ViewPager) findViewById(R.id.address_book_pager);
    if (pager != null) {
        pager.setAdapter(
                new TwoFragmentAdapter(fragmentManager, walletAddressesFragment, sendingAddressesFragment));

        final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.address_book_pager_tabs);
        pagerTabs.addTabLabels(R.string.address_book_list_receiving_title,
                R.string.address_book_list_sending_title);

        pager.setOnPageChangeListener(pagerTabs);
        final int position = getIntent().getBooleanExtra(EXTRA_SENDING, true) ? 1 : 0;
        pager.setCurrentItem(position);
        pager.setPageMargin(2);
        pager.setPageMarginDrawable(R.color.bg_less_bright);

        pagerTabs.onPageSelected(position);
        pagerTabs.onPageScrolled(position, 0, 0);
    } else {
        fragmentManager.beginTransaction()
                .add(R.id.wallet_addresses_fragment, walletAddressesFragment, TAG_LEFT)
                .add(R.id.sending_addresses_fragment, sendingAddressesFragment, TAG_RIGHT).commit();
    }

    updateFragments();
}

From source file:com.bushstar.htmlcoin_android_wallet.ui.AddressBookActivity.java

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

    setContentView(R.layout.address_book_content);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    final FragmentManager fragmentManager = getSupportFragmentManager();

    walletAddressesFragment = (WalletAddressesFragment) fragmentManager.findFragmentByTag(TAG_LEFT);
    sendingAddressesFragment = (SendingAddressesFragment) fragmentManager.findFragmentByTag(TAG_RIGHT);

    final FragmentTransaction removal = fragmentManager.beginTransaction();

    if (walletAddressesFragment == null)
        walletAddressesFragment = new WalletAddressesFragment();
    else/* www  .  j a  v  a2  s  .com*/
        removal.remove(walletAddressesFragment);

    if (sendingAddressesFragment == null)
        sendingAddressesFragment = new SendingAddressesFragment();
    else
        removal.remove(sendingAddressesFragment);

    if (!removal.isEmpty()) {
        removal.commit();
        fragmentManager.executePendingTransactions();
    }

    final ViewPager pager = (ViewPager) findViewById(R.id.address_book_pager);
    if (pager != null) {
        pager.setAdapter(
                new TwoFragmentAdapter(fragmentManager, walletAddressesFragment, sendingAddressesFragment));

        final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.address_book_pager_tabs);
        pagerTabs.addTabLabels(R.string.address_book_list_receiving_title,
                R.string.address_book_list_sending_title);

        pager.setOnPageChangeListener(pagerTabs);
        final int position = getIntent().getBooleanExtra(EXTRA_SENDING, true) ? 1 : 0;
        pager.setCurrentItem(position);
        pager.setPageMargin(2);
        pager.setPageMarginDrawable(R.color.bg_less_bright);

        pagerTabs.onPageSelected(position);
        pagerTabs.onPageScrolled(position, 0, 0);
    } else {
        fragmentManager.beginTransaction()
                .add(R.id.wallet_addresses_fragment, walletAddressesFragment, TAG_LEFT)
                .add(R.id.sending_addresses_fragment, sendingAddressesFragment, TAG_RIGHT).commit();
    }

    updateFragments();
}

From source file:com.fa.mastodon.activity.AccountActivity.java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_account);
    ButterKnife.bind(this);

    if (savedInstanceState != null) {
        accountId = savedInstanceState.getString("accountId");
        followState = (FollowState) savedInstanceState.getSerializable("followState");
        blocking = savedInstanceState.getBoolean("blocking");
        muting = savedInstanceState.getBoolean("muting");
    } else {/*from  w  w  w.  j av a 2s  .c  o  m*/
        Intent intent = getIntent();
        accountId = intent.getStringExtra("id");
        followState = FollowState.NOT_FOLLOWING;
        blocking = false;
        muting = false;
    }
    loadedAccount = null;

    SharedPreferences preferences = getPrivatePreferences();
    String loggedInAccountId = preferences.getString("loggedInAccountId", null);

    // Setup the toolbar.
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setTitle(null);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
    }

    // Add a listener to change the toolbar icon color when it enters/exits its collapsed state.
    AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.account_app_bar_layout);
    final CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(
            R.id.collapsing_toolbar);
    appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @AttrRes
        int priorAttribute = R.attr.account_toolbar_icon_tint_uncollapsed;

        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            @AttrRes
            int attribute;
            if (collapsingToolbar.getHeight() + verticalOffset < 2
                    * ViewCompat.getMinimumHeight(collapsingToolbar)) {
                if (getSupportActionBar() != null && loadedAccount != null) {
                    getSupportActionBar().setTitle(loadedAccount.getDisplayName());
                    toolbar.setTitleTextColor(
                            ThemeUtils.getColor(AccountActivity.this, android.R.attr.textColorPrimary));

                    String subtitle = String.format(getString(R.string.status_username_format),
                            loadedAccount.username);
                    getSupportActionBar().setSubtitle(subtitle);
                    toolbar.setSubtitleTextColor(
                            ThemeUtils.getColor(AccountActivity.this, android.R.attr.textColorSecondary));
                }
                attribute = R.attr.account_toolbar_icon_tint_collapsed;
            } else {
                if (getSupportActionBar() != null) {
                    getSupportActionBar().setTitle("");
                    getSupportActionBar().setSubtitle("");
                }
                attribute = R.attr.account_toolbar_icon_tint_uncollapsed;
            }
            if (attribute != priorAttribute) {
                priorAttribute = attribute;
                Context context = toolbar.getContext();
                ThemeUtils.setDrawableTint(context, toolbar.getNavigationIcon(), attribute);
                ThemeUtils.setDrawableTint(context, toolbar.getOverflowIcon(), attribute);
            }
        }
    });

    // Initialise the default UI states.
    floatingBtn.hide();

    // Obtain information to fill out the profile.
    obtainAccount();
    if (!accountId.equals(loggedInAccountId)) {
        isSelf = false;
        obtainRelationships();
    } else {
        /* Cause the options menu to update and instead show an options menu for when the
         * account being shown is their own account. */
        isSelf = true;
        invalidateOptionsMenu();
    }

    // Setup the tabs and timeline pager.
    AccountPagerAdapter adapter = new AccountPagerAdapter(getSupportFragmentManager(), this, accountId);
    pagerAdapter = adapter;
    String[] pageTitles = { getString(R.string.title_statuses), getString(R.string.title_follows),
            getString(R.string.title_followers) };
    adapter.setPageTitles(pageTitles);
    ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    int pageMargin = getResources().getDimensionPixelSize(R.dimen.tab_page_margin);
    viewPager.setPageMargin(pageMargin);
    Drawable pageMarginDrawable = ThemeUtils.getDrawable(this, R.attr.tab_page_margin_drawable,
            R.drawable.tab_page_margin_dark);
    viewPager.setPageMarginDrawable(pageMarginDrawable);
    viewPager.setAdapter(adapter);
    tabLayout.setupWithViewPager(viewPager);
    for (int i = 0; i < tabLayout.getTabCount(); i++) {
        TabLayout.Tab tab = tabLayout.getTabAt(i);
        if (tab != null) {
            tab.setCustomView(adapter.getTabView(i, tabLayout));
        }
    }
}

From source file:net.abcdroid.devfest12.ui.SessionLivestreamActivity.java

@Override
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);
    }/*  w w  w .  j  ava  2  s . co  m*/
    super.onCreate(savedInstanceState);
    YouTube.initialize(this, Config.YOUTUBE_API_KEY);
    setContentView(R.layout.activity_session_livestream);
    mIsTablet = UIUtils.isHoneycombTablet(this);

    // Set up YouTube player
    mYouTubePlayer = (YouTubePlayerSupportFragment) getSupportFragmentManager()
            .findFragmentById(R.id.livestream_player);
    mYouTubePlayer.enableCustomFullscreen(this);
    mYouTubePlayer.setOnPlaybackEventsListener(this);

    int fullscreenControlFlags = YouTubePlayer.FULLSCREEN_FLAG_CONTROL_SYSTEM_UI
            | YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION;
    if (!mIsTablet) {
        fullscreenControlFlags |= YouTubePlayer.FULLSCREEN_FLAG_FULLSCREEN_WHEN_DEVICE_LANDSCAPE;
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    }
    mYouTubePlayer.setFullscreenControlFlags(fullscreenControlFlags);

    // Views that are common over all layouts
    mMainLayout = (LinearLayout) findViewById(R.id.livestream_mainlayout);
    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);
    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(this);
        final ActionBar actionBar = getSupportActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
        actionBar.setListNavigationCallbacks(mLivestreamAdapter, this);
        actionBar.setDisplayShowTitleEnabled(false);
    }
}

From source file:piuk.blockchain.android.ui.WalletAddressesActivity.java

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

    setContentView(R.layout.address_book_content);

    final ActionBarFragment actionBar = getActionBarFragment();

    actionBar.setPrimaryTitle(R.string.address_book_activity_title);

    actionBar.setBack(new OnClickListener() {
        public void onClick(final View v) {
            finish();// w  w w.  j  a v  a 2s.c  o m
        }
    });

    actionBar.addButton(android.R.drawable.ic_menu_more).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            openOptionsMenu();
        }
    });

    final ViewPager pager = (ViewPager) findViewById(R.id.address_book_pager);

    if (pager != null) {
        final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.address_book_pager_tabs);
        pagerTabs.addTabLabels(R.string.address_book_list_receiving_title,
                R.string.address_book_list_archived_title, R.string.address_book_list_sending_title);

        final ProxyOnPageChangeListener pagerListener = new ProxyOnPageChangeListener(pagerTabs) {
            @Override
            public void onPageSelected(final int position) {
                super.onPageSelected(position);

                pagerPosition = position;
            }
        };

        final PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager());

        pager.getCurrentItem();

        pager.setAdapter(pagerAdapter);
        pager.setOnPageChangeListener(pagerListener);
        final int position = getIntent().getBooleanExtra(EXTRA_SENDING, true) == true ? 2 : 0;
        pager.setCurrentItem(position);
        pager.setPageMargin(2);
        pager.setPageMarginDrawable(R.color.background_less_bright);

        pagerListener.onPageSelected(position);
        pagerListener.onPageScrolled(position, 0, 0);

        archivedAddressesFragment = new WalletArchivedAddressesFragment();
        activeAddressesFragment = new WalletActiveAddressesFragment();
        sendingAddressesFragment = new SendingAddressesFragment();
    }

    updateFragments();
}

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

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override/*from  w w w. ja  va2s. c  o 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();
    }
}