List of usage examples for android.support.v4.app FragmentManager findFragmentByTag
public abstract Fragment findFragmentByTag(String tag);
From source file:com.androzic.MainActivity.java
@Override public void onTrackEdit(Track track) { FragmentManager fm = getSupportFragmentManager(); TrackProperties trackProperties = (TrackProperties) fm.findFragmentByTag("track_properties"); if (trackProperties == null) trackProperties = (TrackProperties) Fragment.instantiate(this, TrackProperties.class.getName()); trackProperties.setTrack(track);/*from w ww . j a v a 2s .c om*/ addFragment(trackProperties, "track_properties"); }
From source file:com.androzic.MainActivity.java
@Override public void onWaypointDetails(Waypoint waypoint) { Location loc = application.getLocationAsLocation(); FragmentManager fm = getSupportFragmentManager(); WaypointDetails waypointDetails = (WaypointDetails) fm.findFragmentByTag("waypoint_details"); if (waypointDetails == null) waypointDetails = new WaypointDetails(); waypointDetails.setWaypoint(waypoint); Bundle args = new Bundle(); args.putDouble("lat", loc.getLatitude()); args.putDouble("lon", loc.getLongitude()); waypointDetails.setArguments(args);//from ww w. j a v a2 s . com addFragment(waypointDetails, "waypoint_details"); }
From source file:com.androzic.MainActivity.java
@Override public void onWaypointEdit(Waypoint waypoint) { FragmentManager fm = getSupportFragmentManager(); WaypointProperties waypointProperties = (WaypointProperties) fm.findFragmentByTag("waypoint_properties"); if (waypointProperties == null) waypointProperties = (WaypointProperties) Fragment.instantiate(this, WaypointProperties.class.getName()); waypointProperties.setWaypoint(waypoint); addFragment(waypointProperties, "waypoint_properties"); }
From source file:com.androzic.MainActivity.java
@Override public void onRouteWaypointEdit(Route route, Waypoint waypoint) { FragmentManager fm = getSupportFragmentManager(); WaypointProperties waypointProperties = (WaypointProperties) fm.findFragmentByTag("waypoint_properties"); if (waypointProperties == null) waypointProperties = (WaypointProperties) Fragment.instantiate(this, WaypointProperties.class.getName()); waypointProperties.setWaypoint(waypoint, route); addFragment(waypointProperties, "waypoint_properties"); }
From source file:com.nekomeshi312.whiteboardcorrection.WhiteBoardCorrectionActivity.java
@Override public void onCreate(Bundle savedInstanceState) { setTheme(R.style.Theme_Sherlock);// w ww. j a v a 2s. c o m super.onCreate(savedInstanceState); //action bar ???s??status bar? final android.view.Window wnd = getWindow(); wnd.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); wnd.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); setContentView(R.layout.activity_white_board_correction); mCameraSetting = CameraAndParameters.newInstance(this); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayShowHomeEnabled(true); //actionbar????) actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_background)); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag"); FragmentManager fm = getSupportFragmentManager(); mFragCameraView = (CameraViewFragment) fm.findFragmentByTag(FRAG_CAMERA_VIEW_TAG); mBoardCheckFragment = (WhiteBoardCheckFragment) fm.findFragmentByTag(FRAG_WB_CHECK_TAG); mBoardResultFragment = (WhiteBoardResultFragment) fm.findFragmentByTag(FRAG_WB_RESULT_TAG); Intent intent = (Intent) getIntent(); if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction()) && intent.getType() != null) { if (!intent.getType().equals("image/jpeg") && !intent.getType().equals("image/jpg")) { Toast.makeText(this, R.string.error_msg_non_supported_image_format, Toast.LENGTH_SHORT).show(); Log.w(LOG_TAG, "Intent unsupported image format"); } else { int[] size = new int[2]; String fn = MyUtils.getImageInfoFromIntent(this, intent, size); if (fn != null) { //OpenCV?????? String[] newFn = new String[2]; if (copyImageToSD(fn, newFn) == true) { mWhiteBoardCheckInfo.mFilePath = newFn[0]; mWhiteBoardCheckInfo.mFileName = newFn[1]; mWhiteBoardCheckInfo.mPicWidth = size[0]; mWhiteBoardCheckInfo.mPicHeight = size[1]; mWhiteBoardCheckInfo.mIsCaptured = false; mWhiteBoardCheckInfo.mPrevWidth = 0; mWhiteBoardCheckInfo.mPrevHeight = 0; } } } } }
From source file:biz.easymenu.easymenung.ReviewPlaceFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.reviewandplace, container, false); tlf = (TableLayout) v.findViewById(R.id.tableFixed); tlc = (TableLayout) v.findViewById(R.id.tableCarte); pbar = (ProgressBar) v.findViewById(R.id.pBarOrder); btnSend = (Button) v.findViewById(R.id.btnSend); btnSend.setOnClickListener(new View.OnClickListener() { @Override// w w w . j a va 2 s. c om public void onClick(View v) { FragmentManager fm = getActivity().getSupportFragmentManager(); FragmentTransaction ft; ConfirmDialog f = new ConfirmDialog(getResources().getString(R.string.confirm) + "?", getResources().getString(R.string.yes), getResources().getString(R.string.notyet), new View.OnClickListener() { @Override public void onClick(View v) { FragmentManager fm = getActivity().getSupportFragmentManager(); FragmentTransaction ft; Fragment prev = fm.findFragmentByTag("confirmDialog"); ft = fm.beginTransaction(); if (prev != null) { ft.remove(prev); ft.commit(); } pbar.setVisibility(View.VISIBLE); new Thread(new SendOrderRun()).start(); } }, new View.OnClickListener() { @Override public void onClick(View v) { FragmentManager fm = getActivity().getSupportFragmentManager(); FragmentTransaction ft; Fragment prev = fm.findFragmentByTag("confirmDialog"); ft = fm.beginTransaction(); if (prev != null) { ft.remove(prev); ft.commit(); } } }); Fragment prev = fm.findFragmentByTag("confirmDialog"); ft = fm.beginTransaction(); if (prev != null) { ft.remove(prev); ft.commit(); } f.show(ft, "confirmDialog"); } }); new Thread(new BillItemsRun()).start(); return v; }
From source file:com.nextgis.forestinspector.activity.MainActivity.java
protected void createFirstStartView() { setContentView(R.layout.activity_main_first); setToolbar(R.id.main_toolbar);// w ww . j a v a 2 s . c o m setTitle(getText(R.string.first_run)); FragmentManager fm = getSupportFragmentManager(); NGWLoginFragment ngwLoginFragment = (NGWLoginFragment) fm.findFragmentByTag("NGWLogin"); if (ngwLoginFragment == null) { ngwLoginFragment = new LoginFragment(); ngwLoginFragment.setForNewAccount(true); } ngwLoginFragment.setOnAddAccountListener(this); FragmentTransaction ft = fm.beginTransaction(); ft.add(com.nextgis.maplibui.R.id.login_frame, ngwLoginFragment, "NGWLogin"); ft.commit(); }
From source file:com.example.android.mediarouter.player.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // Be sure to call the super class. super.onCreate(savedInstanceState); if (savedInstanceState != null) { mPlayer = (Player) savedInstanceState.getSerializable("mPlayer"); }// w w w. j a v a 2 s . c o m // Get the media router service. mMediaRouter = MediaRouter.getInstance(this); // Create a route selector for the type of routes that we care about. mSelector = new MediaRouteSelector.Builder().addControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO) .addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO) .addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK) .addControlCategory(SampleMediaRouteProvider.CATEGORY_SAMPLE_ROUTE).build(); // Add a fragment to take care of media route discovery. // This fragment automatically adds or removes a callback whenever the activity // is started or stopped. FragmentManager fm = getSupportFragmentManager(); DiscoveryFragment fragment = (DiscoveryFragment) fm.findFragmentByTag(DISCOVERY_FRAGMENT_TAG); if (fragment == null) { fragment = new DiscoveryFragment(mMediaRouterCB); fragment.setRouteSelector(mSelector); fm.beginTransaction().add(fragment, DISCOVERY_FRAGMENT_TAG).commit(); } else { fragment.setCallback(mMediaRouterCB); fragment.setRouteSelector(mSelector); } // Populate an array adapter with streaming media items. String[] mediaNames = getResources().getStringArray(R.array.media_names); String[] mediaUris = getResources().getStringArray(R.array.media_uris); mLibraryItems = new LibraryAdapter(); for (int i = 0; i < mediaNames.length; i++) { mLibraryItems.add(new MediaItem("[streaming] " + mediaNames[i], Uri.parse(mediaUris[i]), "video/mp4")); } // Scan local external storage directory for media files. File externalDir = Environment.getExternalStorageDirectory(); if (externalDir != null) { File list[] = externalDir.listFiles(); if (list != null) { for (int i = 0; i < list.length; i++) { String filename = list[i].getName(); if (filename.matches(".*\\.(m4v|mp4)")) { mLibraryItems.add(new MediaItem("[local] " + filename, Uri.fromFile(list[i]), "video/mp4")); } } } } mPlayListItems = new PlaylistAdapter(); // Initialize the layout. setContentView(R.layout.sample_media_router); TabHost tabHost = (TabHost) findViewById(R.id.tabHost); tabHost.setup(); String tabName = getResources().getString(R.string.library_tab_text); TabSpec spec1 = tabHost.newTabSpec(tabName); spec1.setContent(R.id.tab1); spec1.setIndicator(tabName); tabName = getResources().getString(R.string.playlist_tab_text); TabSpec spec2 = tabHost.newTabSpec(tabName); spec2.setIndicator(tabName); spec2.setContent(R.id.tab2); tabName = getResources().getString(R.string.statistics_tab_text); TabSpec spec3 = tabHost.newTabSpec(tabName); spec3.setIndicator(tabName); spec3.setContent(R.id.tab3); tabHost.addTab(spec1); tabHost.addTab(spec2); tabHost.addTab(spec3); tabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String arg0) { updateUi(); } }); mLibraryView = (ListView) findViewById(R.id.media); mLibraryView.setAdapter(mLibraryItems); mLibraryView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); mLibraryView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { updateButtons(); } }); mPlayListView = (ListView) findViewById(R.id.playlist); mPlayListView.setAdapter(mPlayListItems); mPlayListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); mPlayListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { updateButtons(); } }); mInfoTextView = (TextView) findViewById(R.id.info); mPauseResumeButton = (ImageButton) findViewById(R.id.pause_resume_button); mPauseResumeButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mPaused = !mPaused; if (mPaused) { mSessionManager.pause(); } else { mSessionManager.resume(); } } }); mStopButton = (ImageButton) findViewById(R.id.stop_button); mStopButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mPaused = false; mSessionManager.stop(); } }); mSeekBar = (SeekBar) findViewById(R.id.seekbar); mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { PlaylistItem item = getCheckedPlaylistItem(); if (fromUser && item != null && item.getDuration() > 0) { long pos = progress * item.getDuration() / 100; mSessionManager.seek(item.getItemId(), pos); item.setPosition(pos); item.setTimestamp(SystemClock.elapsedRealtime()); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { mSeeking = true; } @Override public void onStopTrackingTouch(SeekBar seekBar) { mSeeking = false; updateUi(); } }); // Schedule Ui update mHandler.postDelayed(mUpdateSeekRunnable, 1000); // Build the PendingIntent for the remote control client mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); mEventReceiver = new ComponentName(getPackageName(), SampleMediaButtonReceiver.class.getName()); Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(mEventReceiver); mMediaPendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0); // Create and register the remote control client registerRemoteControlClient(); // Set up playback manager and player mPlayer = Player.create(MainActivity.this, mMediaRouter.getSelectedRoute()); mSessionManager.setPlayer(mPlayer); mSessionManager.setCallback(new SessionManager.Callback() { @Override public void onStatusChanged() { updateUi(); } @Override public void onItemChanged(PlaylistItem item) { } }); updateUi(); }
From source file:com.example.android.mediarouter.player.RadioActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // Be sure to call the super class. super.onCreate(savedInstanceState); if (savedInstanceState != null) { mPlayer = (RadioPlayer) savedInstanceState.getSerializable("mPlayer"); }//from www . j a v a 2 s . c o m // Get the media router service. mMediaRouter = MediaRouter.getInstance(this); // Create a route selector for the type of routes that we care about. mSelector = new MediaRouteSelector.Builder().addControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO) .addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO) .addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK) .addControlCategory(SampleMediaRouteProvider.CATEGORY_SAMPLE_ROUTE).build(); // Add a fragment to take care of media route discovery. // This fragment automatically adds or removes a callback whenever the activity // is started or stopped. FragmentManager fm = getSupportFragmentManager(); DiscoveryFragment fragment = (DiscoveryFragment) fm.findFragmentByTag(DISCOVERY_FRAGMENT_TAG); if (fragment == null) { fragment = new DiscoveryFragment(mMediaRouterCB); fragment.setRouteSelector(mSelector); fm.beginTransaction().add(fragment, DISCOVERY_FRAGMENT_TAG).commit(); } else { fragment.setCallback(mMediaRouterCB); fragment.setRouteSelector(mSelector); } // Populate an array adapter with streaming media items. String[] mediaNames = getResources().getStringArray(R.array.media_names); String[] mediaUris = getResources().getStringArray(R.array.media_uris); mLibraryItems = new LibraryAdapter(); for (int i = 0; i < mediaNames.length; i++) { mLibraryItems.add(new MediaItem("[streaming] " + mediaNames[i], Uri.parse(mediaUris[i]), "video/mp4")); } // Scan local external storage directory for media files. File externalDir = Environment.getExternalStorageDirectory(); if (externalDir != null) { File list[] = externalDir.listFiles(); if (list != null) { for (int i = 0; i < list.length; i++) { String filename = list[i].getName(); if (filename.matches(".*\\.(m4v|mp4)")) { mLibraryItems.add(new MediaItem("[local] " + filename, Uri.fromFile(list[i]), "video/mp4")); } } } } mPlayListItems = new PlaylistAdapter(); // Initialize the layout. setContentView(R.layout.sample_radio_router); TabHost tabHost = (TabHost) findViewById(R.id.tabHost); tabHost.setup(); String tabName = getResources().getString(R.string.library_tab_text); TabSpec spec1 = tabHost.newTabSpec(tabName); spec1.setContent(R.id.tab1); spec1.setIndicator(tabName); tabName = getResources().getString(R.string.playlist_tab_text); TabSpec spec2 = tabHost.newTabSpec(tabName); spec2.setIndicator(tabName); spec2.setContent(R.id.tab2); tabName = getResources().getString(R.string.statistics_tab_text); TabSpec spec3 = tabHost.newTabSpec(tabName); spec3.setIndicator(tabName); spec3.setContent(R.id.tab3); tabHost.addTab(spec1); tabHost.addTab(spec2); tabHost.addTab(spec3); tabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String arg0) { updateUi(); } }); mLibraryView = (ListView) findViewById(R.id.media); mLibraryView.setAdapter(mLibraryItems); mLibraryView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); mLibraryView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { updateButtons(); } }); mPlayListView = (ListView) findViewById(R.id.playlist); mPlayListView.setAdapter(mPlayListItems); mPlayListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); mPlayListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { updateButtons(); } }); mInfoTextView = (TextView) findViewById(R.id.info); mPauseResumeButton = (ImageButton) findViewById(R.id.pause_resume_button); mPauseResumeButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mPaused = !mPaused; if (mPaused) { mSessionManager.pause(); } else { mSessionManager.resume(); } } }); mStopButton = (ImageButton) findViewById(R.id.stop_button); mStopButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mPaused = false; mSessionManager.stop(); } }); mSeekBar = (SeekBar) findViewById(R.id.seekbar); mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { PlaylistItem item = getCheckedPlaylistItem(); if (fromUser && item != null && item.getDuration() > 0) { long pos = progress * item.getDuration() / 100; mSessionManager.seek(item.getItemId(), pos); item.setPosition(pos); item.setTimestamp(SystemClock.elapsedRealtime()); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { mSeeking = true; } @Override public void onStopTrackingTouch(SeekBar seekBar) { mSeeking = false; updateUi(); } }); // Schedule Ui update mHandler.postDelayed(mUpdateSeekRunnable, 1000); // Build the PendingIntent for the remote control client mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); mEventReceiver = new ComponentName(getPackageName(), SampleMediaButtonReceiver.class.getName()); Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(mEventReceiver); mMediaPendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0); // Create and register the remote control client registerRemoteControlClient(); // Set up playback manager and player mPlayer = RadioPlayer.create(RadioActivity.this, mMediaRouter.getSelectedRoute()); mSessionManager.setPlayer(mPlayer); mSessionManager.setCallback(new RadioSessionManager.Callback() { @Override public void onStatusChanged() { updateUi(); } @Override public void onItemChanged(PlaylistItem item) { } }); updateUi(); }
From source file:com.granita.tasks.TaskListActivity.java
@SuppressLint("NewApi") @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @Override//from w w w . ja v a 2 s.co m protected void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate called again"); super.onCreate(savedInstanceState); // check for single pane activity change mTwoPane = getResources().getBoolean(R.bool.has_two_panes); resolveIntentAction(getIntent()); //custom start Tracker t = ((com.granita.tasks.Tasks) getApplication()) .getTracker(com.granita.tasks.Tasks.TrackerName.APP_TRACKER); t.setScreenName("Tasks: List activity"); t.send(new HitBuilders.AppViewBuilder().build()); //check if sync for icloud calendar exists String packageName = "com.granita.caldavsync"; Intent intent = this.getPackageManager().getLaunchIntentForPackage(packageName); if (intent == null) { /* bring user to the market or let them choose an app? */ intent = new Intent(this, installicloud.class); startActivity(intent); } try { //Start premium features String base64EncodedPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvczcgR9FJqJ/LK94t4VcmdfVizoy66QWJRxF+o0ZZbFeMi1jQ6kBcYb1kogQnLLBeS+Q0DtRjsxap9Z6B8yP5rcZxIs51yF2LKy9+nmcLeJF0wPU2cvIjZLf7dD7Umh/LMi88VHSLExwkDMb2vBpcROz7DwjhgF5fzXHWh986ZxWmJiMiYLX1cg5toWaOPYgxcSELyCsfkvfmtX8ctJ+QcovWXevSBJsOQCLNkmKdBd5biExy96WicjVUZ/e31/CCjb8xYcMJnMaBGXEBDdtJFMFAczpdrB+Zyw6gEr1ZUH1U7trsbTrC2TvOa1MTcwXHE2JwqjU2eke4FLYIcAdbwIDAQAB"; mHelper = new IabHelper(this, base64EncodedPublicKey); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { if (!result.isSuccess()) { Log.d(TAG, "In-app Billing setup failed: " + result); } else { mHelper.queryInventoryAsync(mGotInventoryListener); Log.d(TAG, "In-app Billing is set up OK"); } } }); //End premium features } catch (Exception e) { } //custom end if (mSelectedTaskUri != null) { if (mShouldShowDetails && mShouldSwitchToDetail) { Intent viewTaskIntent = new Intent(Intent.ACTION_VIEW); viewTaskIntent.setData(mSelectedTaskUri); startActivity(viewTaskIntent); mSwitchedToDetail = true; mShouldSwitchToDetail = false; mTransientState = true; } } else { mShouldShowDetails = false; } setContentView(R.layout.activity_task_list); //custom start mAuthority = getString(R.string.org_dmfs_tasks_authority); //custom end mSearchHistoryHelper = new SearchHistoryHelper(this); if (findViewById(R.id.task_detail_container) != null) { // In two-pane mode, list items should be given the // 'activated' state when touched. // get list fragment // mTaskListFrag = (TaskListFragment) getSupportFragmentManager().findFragmentById(R.id.task_list); // mTaskListFrag.setListViewScrollbarPositionLeft(true); // mTaskListFrag.setActivateOnItemClick(true); /* * Create a detail fragment, but don't load any URL yet, we do that later when the fragment gets attached */ mTaskDetailFrag = ViewTaskFragment.newInstance(mSelectedTaskUri); getSupportFragmentManager().beginTransaction() .replace(R.id.task_detail_container, mTaskDetailFrag, DETAIL_FRAGMENT_TAG).commit(); } else { FragmentManager fragmentManager = getSupportFragmentManager(); Fragment detailFragment = fragmentManager.findFragmentByTag(DETAIL_FRAGMENT_TAG); if (detailFragment != null) { fragmentManager.beginTransaction().remove(detailFragment).commit(); } } mGroupingFactories = new AbstractGroupingFactory[] { new ByList(mAuthority), new ByDueDate(mAuthority), new ByStartDate(mAuthority), new ByPriority(mAuthority), new ByProgress(mAuthority), new BySearch(mAuthority, mSearchHistoryHelper) }; // set up pager adapter try { mPagerAdapter = new TaskGroupPagerAdapter(getSupportFragmentManager(), mGroupingFactories, this, R.xml.listview_tabs); } catch (XmlPullParserException e) { // TODO Automatisch generierter Erfassungsblock e.printStackTrace(); } catch (IOException e) { // TODO Automatisch generierter Erfassungsblock e.printStackTrace(); } catch (XmlObjectPullParserException e) { // TODO Automatisch generierter Erfassungsblock e.printStackTrace(); } // Setup ViewPager mPagerAdapter.setTwoPaneLayout(mTwoPane); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mPagerAdapter); int currentPageIndex = mPagerAdapter.getPagePosition(mCurrentPageId); if (currentPageIndex >= 0) { mCurrentPagePosition = currentPageIndex; mViewPager.setCurrentItem(currentPageIndex); if (VERSION.SDK_INT >= 14 && mCurrentPageId == R.id.task_group_search) { if (mSearchItem != null) { // that's actually quite impossible to happen MenuItemCompat.expandActionView(mSearchItem); } else { mAutoExpandSearchView = true; } } } updateTitle(currentPageIndex); // Bind the tabs to the ViewPager mTabs = (PagerSlidingTabStrip) findViewById(R.id.tabs); mTabs.setViewPager(mViewPager); mTabs.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int position) { mSelectedTaskUri = null; mCurrentPagePosition = position; int newPageId = mPagerAdapter.getPageId(position); if (newPageId == R.id.task_group_search) { int oldPageId = mCurrentPageId; mCurrentPageId = newPageId; // store the page position we're coming from mPreviousPagePosition = mPagerAdapter.getPagePosition(oldPageId); } else if (mCurrentPageId == R.id.task_group_search) { // we've been on the search page before, so commit the search and close the search view mSearchHistoryHelper.commitSearch(); mHandler.post(mSearchUpdater); mCurrentPageId = newPageId; hideSearchActionView(); } mCurrentPageId = newPageId; updateTitle(mCurrentPageId); } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageScrollStateChanged(int state) { if (state == ViewPager.SCROLL_STATE_IDLE && mCurrentPageId == R.id.task_group_search) { // the search page is selected now, expand the search view mHandler.post(new Runnable() { @Override public void run() { MenuItemCompat.expandActionView(mSearchItem); } }); } } }); // make sure the status bar color is set properly on Android 5+ devices if (VERSION.SDK_INT >= 21) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(getResources().getColor(R.color.colorPrimaryDarker)); } }