List of usage examples for android.support.v4.app FragmentManager findFragmentById
public abstract Fragment findFragmentById(int id);
From source file:com.amansoni.tripbook.activity.FacebookActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Add code to print out the key hash try {//from w w w. j a v a 2 s .c o m PackageInfo info = getPackageManager().getPackageInfo("com.amansoni.tripbook", PackageManager.GET_SIGNATURES); for (Signature signature : info.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT)); } } catch (PackageManager.NameNotFoundException e) { } catch (NoSuchAlgorithmException e) { } uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); if (savedInstanceState != null) { String name = savedInstanceState.getString(PENDING_ACTION_BUNDLE_KEY); pendingAction = PendingAction.valueOf(name); } setContentView(R.layout.facebook_activity); loginButton = (LoginButton) findViewById(R.id.login_button); loginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() { @Override public void onUserInfoFetched(GraphUser user) { FacebookActivity.this.user = user; updateUI(); // It's possible that we were waiting for this.user to be populated in order to post a // status update. handlePendingAction(); } }); profilePictureView = (ProfilePictureView) findViewById(R.id.profilePicture); greeting = (TextView) findViewById(R.id.greeting); postStatusUpdateButton = (Button) findViewById(R.id.postStatusUpdateButton); postStatusUpdateButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPostStatusUpdate(); } }); postPhotoButton = (Button) findViewById(R.id.postPhotoButton); postPhotoButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPostPhoto(); } }); pickFriendsButton = (Button) findViewById(R.id.pickFriendsButton); pickFriendsButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPickFriends(); } }); pickPlaceButton = (Button) findViewById(R.id.pickPlaceButton); pickPlaceButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPickPlace(); } }); controlsContainer = (ViewGroup) findViewById(R.id.main_ui_container); final FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(R.id.fragment_container); if (fragment != null) { // If we're being re-created and have a fragment, we need to a) hide the main UI controls and // b) hook up its listeners again. controlsContainer.setVisibility(View.GONE); if (fragment instanceof FriendPickerFragment) { setFriendPickerListeners((FriendPickerFragment) fragment); } else if (fragment instanceof PlacePickerFragment) { setPlacePickerListeners((PlacePickerFragment) fragment); } } // Listen for changes in the back stack so we know if a fragment got popped off because the user // clicked the back button. fm.addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() { @Override public void onBackStackChanged() { if (fm.getBackStackEntryCount() == 0) { // We need to re-show our UI. controlsContainer.setVisibility(View.VISIBLE); } } }); // Can we present the share dialog for regular links? canPresentShareDialog = FacebookDialog.canPresentShareDialog(this, FacebookDialog.ShareDialogFeature.SHARE_DIALOG); // Can we present the share dialog for photos? canPresentShareDialogWithPhotos = FacebookDialog.canPresentShareDialog(this, FacebookDialog.ShareDialogFeature.PHOTOS); }
From source file:com.esri.android.ecologicalmarineunitexplorer.MainActivity.java
/** * Remove the water column profile fragment *///from www.ja v a2 s. c om private void removeChartContainer() { final FragmentManager fm = getSupportFragmentManager(); final Fragment fragment = fm.findFragmentById(R.id.chartContainer); if (fragment != null) { final FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.remove(fragment); transaction.commit(); fm.popBackStack(); } }
From source file:com.namnv.project.kidpaint.HelloFacebookSampleActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Add code to print out the key hash try {/*from w w w . j av a 2s. c o m*/ PackageInfo info = getPackageManager().getPackageInfo("com.facebook.samples.hellofacebook", PackageManager.GET_SIGNATURES); for (Signature signature : info.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT)); } } catch (PackageManager.NameNotFoundException e) { } catch (NoSuchAlgorithmException e) { } uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); if (savedInstanceState != null) { String name = savedInstanceState.getString(PENDING_ACTION_BUNDLE_KEY); pendingAction = PendingAction.valueOf(name); } setContentView(R.layout.sample_main); loginButton = (LoginButton) findViewById(R.id.login_button); loginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() { @Override public void onUserInfoFetched(GraphUser user) { HelloFacebookSampleActivity.this.user = user; updateUI(); // It's possible that we were waiting for this.user to be populated in order to post a // status update. handlePendingAction(); } }); profilePictureView = (ProfilePictureView) findViewById(R.id.profilePicture); greeting = (TextView) findViewById(R.id.greeting); postStatusUpdateButton = (Button) findViewById(R.id.postStatusUpdateButton); postStatusUpdateButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPostStatusUpdate(); } }); postPhotoButton = (Button) findViewById(R.id.postPhotoButton); postPhotoButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPostPhoto(); } }); pickFriendsButton = (Button) findViewById(R.id.pickFriendsButton); pickFriendsButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPickFriends(); } }); pickPlaceButton = (Button) findViewById(R.id.pickPlaceButton); pickPlaceButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPickPlace(); } }); controlsContainer = (ViewGroup) findViewById(R.id.main_ui_container); final FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(R.id.fragment_container); if (fragment != null) { // If we're being re-created and have a fragment, we need to a) hide the main UI controls and // b) hook up its listeners again. controlsContainer.setVisibility(View.GONE); if (fragment instanceof FriendPickerFragment) { setFriendPickerListeners((FriendPickerFragment) fragment); } else if (fragment instanceof PlacePickerFragment) { setPlacePickerListeners((PlacePickerFragment) fragment); } } // Listen for changes in the back stack so we know if a fragment got popped off because the user // clicked the back button. fm.addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() { @Override public void onBackStackChanged() { if (fm.getBackStackEntryCount() == 0) { // We need to re-show our UI. controlsContainer.setVisibility(View.VISIBLE); } } }); // Can we present the share dialog for regular links? canPresentShareDialog = FacebookDialog.canPresentShareDialog(this, FacebookDialog.ShareDialogFeature.SHARE_DIALOG); // Can we present the share dialog for photos? canPresentShareDialogWithPhotos = FacebookDialog.canPresentShareDialog(this, FacebookDialog.ShareDialogFeature.PHOTOS); }
From source file:com.hyperaware.conference.android.activity.MainActivity.java
private void updateTitle() { final FragmentManager fm = getSupportFragmentManager(); final Fragment fragment = fm.findFragmentById(R.id.v_content); if (fragment instanceof Titled) { setTitle(((Titled) fragment).getTitle()); }//from w ww.j ava 2s . co m }
From source file:com.jbirdvegas.mgerrit.GerritControllerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { mTheme = Prefs.getCurrentThemeID(this); setTheme(mTheme);/* w ww. ja v a 2 s . c om*/ super.onCreate(savedInstanceState); // check if caller has a gerrit instance start screen preference String suppliedGerritInstance = getIntent().getStringExtra(GERRIT_INSTANCE); if (suppliedGerritInstance != null && !suppliedGerritInstance.isEmpty() && suppliedGerritInstance.contains("http")) { // just set the prefs and allow normal loading Prefs.setCurrentGerrit(this, suppliedGerritInstance); } GoogleAnalytics googleAnalytics = GoogleAnalytics.getInstance(this); String trackingId = getString(R.string.ga_trackingId); Tracker tracker = googleAnalytics.getTracker(trackingId); googleAnalytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE); tracker.send(MapBuilder.createAppView().build()); // keep a log of what ROM our users run AnalyticsHelper.sendAnalyticsEvent(this, AnalyticsHelper.GA_APP_OPEN, AnalyticsHelper.GA_ROM_VERSION, ROMHelper.determineRom(this), null); // Keep track of what theme is being used AnalyticsHelper.sendAnalyticsEvent(this, AnalyticsHelper.GA_APP_OPEN, AnalyticsHelper.GA_THEME_SET_ON_OPEN, Prefs.getCurrentTheme(this), null); setContentView(R.layout.main); FragmentManager fm = getSupportFragmentManager(); if (findViewById(R.id.change_detail_fragment) != null) { // The detail container view will be present only in // large-screen layouts(res/values-sw600dp). If this view is present, // then the activity should be in two-pane mode. mTwoPane = true; mChangeDetail = (PatchSetViewerFragment) fm.findFragmentById(R.id.change_detail_fragment); } Prefs.setTabletMode(this, mTwoPane); mChangeList = (ChangeListFragment) fm.findFragmentById(R.id.change_list_fragment); mGerritWebsite = Prefs.getCurrentGerrit(this); // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); mSearchView = (GerritSearchView) findViewById(R.id.search); mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); }
From source file:com.esri.android.ecologicalmarineunitexplorer.MainActivity.java
/** * Configure the map fragment/*from w w w. j a v a 2s . c om*/ */ private void setUpMagFragment() { // Set up the toolbar for the map fragment setUpMapToolbar(); final FragmentManager fm = getSupportFragmentManager(); MapFragment mapFragment = (MapFragment) fm.findFragmentById(R.id.map_container); if (mapFragment == null) { mapFragment = MapFragment.newInstance(); mMapPresenter = new MapPresenter(mapFragment, mDataManager); ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), mapFragment, R.id.map_container, getString(R.string.fragment_map)); } }
From source file:it.gulch.linuxday.android.activities.MainActivity.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Decrease position by 1 since the listView has a header view. Section section = menuAdapter.getItem(position - 1); if (section != currentSection) { // Switch to new section FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); Fragment f = fm.findFragmentById(R.id.content); if (f != null) { if (currentSection.shouldKeep()) { ft.detach(f);/*w w w .j a va 2 s. c o m*/ } else { ft.remove(f); } } String fragmentClassName = section.getFragmentClassName(); if (section.shouldKeep() && ((f = fm.findFragmentByTag(fragmentClassName)) != null)) { ft.attach(f); } else { f = Fragment.instantiate(this, fragmentClassName); ft.add(R.id.content, f, fragmentClassName); } ft.commit(); currentSection = section; menuAdapter.notifyDataSetChanged(); } drawerLayout.closeDrawer(mainMenu); }
From source file:com.money.manager.ex.reports.IncomeVsExpensesActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.report_chart_fragments_activity); // set actionbar getSupportActionBar().setDisplayShowHomeEnabled(true); // check if is dual panel mIsDualPanel = findViewById(R.id.fragmentChart) != null; FragmentManager fm = getSupportFragmentManager(); // get application currencyUtils = new CurrencyUtils(this); // attach fragment activity if (fm.findFragmentById(R.id.fragmentContent) == null) { fm.beginTransaction()/* ww w. j ava 2 s . c om*/ .replace(R.id.fragmentContent, listFragment, IncomeVsExpensesListFragment.class.getSimpleName()) .commit(); } }
From source file:com.pindroid.activity.BrowseBookmarks.java
@Override protected void changeAccount() { FragmentManager fm = getSupportFragmentManager(); ((BookmarkBrowser) bookmarkFrag).setUsername(app.getUsername()); ((BookmarkBrowser) bookmarkFrag).refresh(); ViewBookmarkFragment viewFrag = (ViewBookmarkFragment) fm.findFragmentById(R.id.maincontent); if (viewFrag != null) { viewFrag.clearView();/*w ww . jav a 2 s.co m*/ } BrowseTagsFragment tagFrag = (BrowseTagsFragment) fm.findFragmentById(R.id.tagcontent); if (tagFrag != null) { tagFrag.setAccount(app.getUsername()); tagFrag.refresh(); } }
From source file:com.gh4a.fragment.PullRequestFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { FragmentManager fm = getChildFragmentManager(); mCommentFragment = (CommentBoxFragment) fm.findFragmentById(R.id.comment_box); fillData();// w w w. java2 s . c o m updateCommentLockState(); super.onActivityCreated(savedInstanceState); getLoaderManager().initLoader(1, null, mCollaboratorCallback); loadStatusIfOpen(); }