List of usage examples for android.support.v4.view ViewPager setPageMargin
public void setPageMargin(int marginPixels)
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 av a2 s . c o m 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//from w w w .ja 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.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 w w . j av a 2s.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.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/* w ww . j a va 2s . 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.google.samples.apps.iosched.ui.SessionLivestreamActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); super.onCreate(savedInstanceState); setContentView(R.layout.activity_session_livestream); mIsTablet = UIUtils.isTablet(this); // Set up YouTube player mYouTubeFragment = (YouTubePlayerFragment) getFragmentManager().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); adjustMainLayoutForActionBar();// w w w . jav a 2 s. c o m 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); mTabsContentLayout = (LinearLayout) findViewById(R.id.livestream_tabs_layout); // Set up ViewPager and adapter ViewPager viewPager = (ViewPager) findViewById(R.id.livestream_pager); viewPager.setOffscreenPageLimit(2); viewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.page_margin_width)); mTabsAdapter = new TabsAdapter(getFragmentManager()); viewPager.setAdapter(mTabsAdapter); viewPager.setOnPageChangeListener(mTabsAdapter); if (mIsTablet) { // Tablet UI specific views mVideoLayout = (LinearLayout) findViewById(R.id.livestream_video_layout); } mTabsAdapter.addTab(getString(R.string.session_livestream_info), new SessionSummaryFragment(), TABNUM_SESSION_SUMMARY); mTabsAdapter.addTab(getString(R.string.session_livestream_captions), new SessionCaptionsFragment(), TABNUM_LIVE_CAPTIONS); // Set up sliding tabs w/ViewPager SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById(R.id.livestream_sliding_tabs); slidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1); Resources res = getResources(); slidingTabLayout.setSelectedIndicatorColors(res.getColor(R.color.tab_selected_strip)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(viewPager); // 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 getLoaderManager().initLoader(SessionsQuery._TOKEN, null, this); mLivestreamAdapter = new LivestreamAdapter(getActionBar().getThemedContext()); } }
From source file:com.saarang.samples.apps.iosched.ui.SessionLivestreamActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); super.onCreate(savedInstanceState); setContentView(com.saarang.samples.apps.iosched.R.layout.activity_session_livestream); mIsTablet = UIUtils.isTablet(this); // Set up YouTube player mYouTubeFragment = (YouTubePlayerFragment) getFragmentManager() .findFragmentById(com.saarang.samples.apps.iosched.R.id.livestream_player); mYouTubeFragment.initialize(Config.YOUTUBE_API_KEY, this); // Views that are common over all layouts mMainLayout = (LinearLayout) findViewById(com.saarang.samples.apps.iosched.R.id.livestream_mainlayout); adjustMainLayoutForActionBar();//from ww w . j ava2 s. c o m mPlayerContainer = (LinearLayout) findViewById( com.saarang.samples.apps.iosched.R.id.livestream_player_container); mFullscreenCaptions = (FrameLayout) findViewById(com.saarang.samples.apps.iosched.R.id.fullscreen_captions); final LayoutParams params = (LayoutParams) mFullscreenCaptions.getLayoutParams(); params.setMargins(0, getActionBarHeightPx(), 0, getActionBarHeightPx()); mFullscreenCaptions.setLayoutParams(params); mTabsContentLayout = (LinearLayout) findViewById( com.saarang.samples.apps.iosched.R.id.livestream_tabs_layout); // Set up ViewPager and adapter ViewPager viewPager = (ViewPager) findViewById(com.saarang.samples.apps.iosched.R.id.livestream_pager); viewPager.setOffscreenPageLimit(2); viewPager.setPageMargin( getResources().getDimensionPixelSize(com.saarang.samples.apps.iosched.R.dimen.page_margin_width)); mTabsAdapter = new TabsAdapter(getFragmentManager()); viewPager.setAdapter(mTabsAdapter); viewPager.setOnPageChangeListener(mTabsAdapter); if (mIsTablet) { // Tablet UI specific views mVideoLayout = (LinearLayout) findViewById( com.saarang.samples.apps.iosched.R.id.livestream_video_layout); } mTabsAdapter.addTab(getString(com.saarang.samples.apps.iosched.R.string.session_livestream_info), new SessionSummaryFragment(), TABNUM_SESSION_SUMMARY); mTabsAdapter.addTab(getString(com.saarang.samples.apps.iosched.R.string.session_livestream_captions), new SessionCaptionsFragment(), TABNUM_LIVE_CAPTIONS); // Set up sliding tabs w/ViewPager SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById( com.saarang.samples.apps.iosched.R.id.livestream_sliding_tabs); slidingTabLayout.setCustomTabView(com.saarang.samples.apps.iosched.R.layout.tab_indicator, android.R.id.text1); Resources res = getResources(); slidingTabLayout.setSelectedIndicatorColors( res.getColor(com.saarang.samples.apps.iosched.R.color.tab_selected_strip)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(viewPager); // 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 getLoaderManager().initLoader(SessionsQuery._TOKEN, null, this); mLivestreamAdapter = new LivestreamAdapter(getActionBar().getThemedContext()); } }
From source file:com.androguide.apkreator.MainActivity.java
@SuppressLint("NewApi") @SuppressWarnings("deprecation") @Override// w w w .j ava 2s. co m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.activity_main); /** * Before anything we need to check if the config files exist to avoid * FC is they don't * * @see #checkIfConfigExists() */ checkIfConfigExists(); /** * Now it's all good because if no configuration was found we have * copied a default one over. * * @see #checkIfConfigExists() */ setAppConfigInPrefs(); headers = getPluginTabs(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); /* * set a custom shadow that overlays the main content when the drawer * opens */ mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); /* set up the drawer's list view with items and click listener */ ArrayAdapter<String> pimpAdapter = new ArrayAdapter<String>(this, R.layout.drawer_list_item, mDrawerHeaders); mDrawerList.setAdapter(pimpAdapter); Log.e("FIRST POS", mDrawerList.getFirstVisiblePosition() + ""); Log.e("LAST POS", mDrawerList.getLastVisiblePosition() + ""); View child = mDrawerList.getChildAt(mDrawerList.getFirstVisiblePosition()); if (child != null && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) child.setBackground(getColouredTouchFeedback()); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); /** Set the user-defined ActionBar icon */ File file = new File(getFilesDir() + "/.APKreator/icon.png"); if (file.exists()) { try { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); Uri iconUri = Uri.fromFile(new File(getFilesDir() + "/.APKreator/icon.png")); Bitmap icon = BitmapFactory.decodeFile(iconUri.getPath()); Drawable ic = new BitmapDrawable(icon); getSupportActionBar().setIcon(ic); } catch (NullPointerException e) { Log.e("NPE", e.getMessage()); } } /* * ActionBarDrawerToggle ties together the proper interactions between * the sliding drawer and the action bar app icon */ mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.app_name, /* "open drawer" description for accessibility */ R.string.app_name /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { invalidateOptionsMenu(); /* * creates call to * onPrepareOptionsMenu() */ } public void onDrawerOpened(View drawerView) { invalidateOptionsMenu(); /* * creates call to * onPrepareOptionsMenu() */ } }; mDrawerLayout.setDrawerListener(mDrawerToggle); /** Tabs adapter using the PagerSlidingStrip library */ tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs); ViewPager pager = (ViewPager) findViewById(R.id.pager); MyPagerAdapter adapter = new MyPagerAdapter(this.getSupportFragmentManager()); pager.setAdapter(adapter); pager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int arg0) { } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }); final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); pager.setPageMargin(pageMargin); tabs.setViewPager(pager); tabs.setOnPageChangeListener(this); changeColor(Color.parseColor(getPluginColor())); pager.setOffscreenPageLimit(5); }
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); }/*from ww w. j a va 2s . 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 va 2 s.com*/ } }); 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/*www . j av a 2s. 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(); } }