List of usage examples for android.support.v4.app FragmentManager findFragmentById
public abstract Fragment findFragmentById(int id);
From source file:org.androidsoft.app.permission.ui.MainActivity.java
/** * {@inheritDoc }/*ww w. java 2 s. c om*/ */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } setContentView(R.layout.main); mButtonSortByName = (TextView) findViewById(R.id.button_sort_name); mButtonSortByName.setOnClickListener(this); mButtonSortByScore = (TextView) findViewById(R.id.button_sort_score); mButtonSortByScore.setOnClickListener(this); mButtonShowTrusted = (ImageView) findViewById(R.id.button_show_trusted); mButtonShowTrusted.setOnClickListener(this); mButtonFilter = (ImageView) findViewById(R.id.button_filter); mButtonFilter.setOnClickListener(this); mTvFilter = (TextView) findViewById(R.id.label_filter); mLayoutFilter = findViewById(R.id.label_filter); mLayoutFilter.setOnClickListener(this); mIndicatorName = findViewById(R.id.indicator_name); mIndicatorScore = findViewById(R.id.indicator_score); mIndicatorTrusted = findViewById(R.id.indicator_trusted); mIndicatorFilter = findViewById(R.id.indicator_filter); FragmentManager fm = getSupportFragmentManager(); mApplicationsListFragment = (ApplicationsListFragment) fm.findFragmentById(R.id.fragment_applications_list); ApplicationChangesService.registerListener(this); mInvalidate = true; }
From source file:edu.mit.mobile.android.livingpostcards.CardViewActivity.java
private void loadCardMedia(boolean useVideo) { final FragmentManager fm = getSupportFragmentManager(); final FragmentTransaction ft = fm.beginTransaction(); final Fragment cardView = fm.findFragmentById(R.id.card_view_fragment); if (useVideo) { if (cardView != null && cardView instanceof CardViewVideoFragment) { mCardViewFragment = cardView; } else {/* w w w .j av a2 s .c om*/ mCardViewFragment = CardViewVideoFragment.newInstance(mCard); ft.replace(R.id.card_view_fragment, mCardViewFragment); } } else { if (cardView != null && cardView instanceof CardViewFragment) { mCardViewFragment = cardView; } else { mCardViewFragment = CardViewFragment.newInstance(mCard); ft.replace(R.id.card_view_fragment, mCardViewFragment); } } ft.commit(); }
From source file:com.iskrembilen.quasseldroid.gui.MainActivity.java
@Subscribe public void onInitProgressed(InitProgressEvent event) { FragmentManager manager = getSupportFragmentManager(); if (event.done) { if (manager.findFragmentById(R.id.connecting_fragment_container) != null) { FragmentTransaction trans = manager.beginTransaction(); trans.remove(manager.findFragmentById(R.id.connecting_fragment_container)); trans.commit();/*www. j a v a 2 s. c o m*/ pager.setVisibility(View.VISIBLE); findViewById(R.id.connecting_fragment_container).setVisibility(View.GONE); //Doing this seems to fix a bug where menu items doesn't show up in the actionbar pager.setCurrentItem(FragmentAdapter.BUFFERS_POS); } } else { if (manager.findFragmentById(R.id.connecting_fragment_container) == null) { findViewById(R.id.connecting_fragment_container).setVisibility(View.VISIBLE); pager.setVisibility(View.GONE); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); ConnectingFragment fragment = ConnectingFragment.newInstance(); fragmentTransaction.add(R.id.connecting_fragment_container, fragment, "connect"); fragmentTransaction.commit(); } } }
From source file:com.jefftharris.passwdsafe.FileListActivity.java
@Override public void onBackPressed() { FragmentManager mgr = getSupportFragmentManager(); Fragment frag = mgr.findFragmentById(R.id.files); boolean handled = (frag instanceof FileListFragment) && frag.isVisible() && ((FileListFragment) frag).doBackPressed(); if (!handled) { if (itsIsLegacyChooserChanged) { showFiles(true, null);/*from w ww . j a v a2 s. c o m*/ } else { super.onBackPressed(); } } }
From source file:com.qubling.sidekick.ui.module.ModuleSearchActivity.java
private boolean convertToRealViewFragment() { FragmentManager fragmentManager = getSupportFragmentManager(); ModuleViewThingyFragment fragment = (ModuleViewThingyFragment) fragmentManager .findFragmentById(R.id.module_view_fragment_container); if (fragment == null) return false; // We do in fact have a placeholder to convert? if (fragment instanceof ModuleViewPlaceholderFragment) { FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.module_view_fragment_container, new ModuleViewFragment()); // Do not add to back stack. We don't want to go back to the placeholder fragmentTransaction.commit();//from w w w . j a v a 2s . c o m // Go ahead and execute because we do this only immediately before showing the POD // TODO There's probably a better, concurrent way of doing this fragmentManager.executePendingTransactions(); } return true; }
From source file:com.gruporaido.tasker_library.util.Helper.java
/** * Remove the specified fragment./*from ww w . j a v a 2s. c o m*/ * <b><i>Note: Transaction done with possible state loss</i></b> * * @param fragmentManager * @param resourceId */ public void removeFragment(FragmentManager fragmentManager, int resourceId) { Fragment fragment = fragmentManager.findFragmentById(resourceId); if (fragment != null) { fragmentManager.beginTransaction().remove(fragment).commitAllowingStateLoss(); } }
From source file:com.actionbarsherlock.sample.hcgallery.MainActivity.java
public void toggleVisibleTitles() { // Use these for custom animations. final FragmentManager fm = getSupportFragmentManager(); final TitlesFragment f = (TitlesFragment) fm.findFragmentById(R.id.frag_title); final View titlesView = f.getView(); mLabelIndex = 1 - mLabelIndex;/*from w ww .jav a 2 s .co m*/ // Determine if we're in portrait, and whether we're showing or hiding the titles // with this toggle. final boolean isPortrait = getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; final boolean shouldShow = f.isHidden() || mCurrentTitlesAnimator != null; // Cancel the current titles animation if there is one. if (mCurrentTitlesAnimator != null) mCurrentTitlesAnimator.cancel(); // Begin setting up the object animator. We'll animate the bottom or right edge of the // titles view, as well as its alpha for a fade effect. ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(titlesView, PropertyValuesHolder.ofInt(isPortrait ? "bottom" : "right", shouldShow ? getResources().getDimensionPixelSize(R.dimen.titles_size) : 0), PropertyValuesHolder.ofFloat("alpha", shouldShow ? 1 : 0)); // At each step of the animation, we'll perform layout by calling setLayoutParams. final ViewGroup.LayoutParams lp = titlesView.getLayoutParams(); objectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator valueAnimator) { // *** WARNING ***: triggering layout at each animation frame highly impacts // performance so you should only do this for simple layouts. More complicated // layouts can be better served with individual animations on child views to // avoid the performance penalty of layout. if (isPortrait) { lp.height = (Integer) valueAnimator.getAnimatedValue(); } else { lp.width = (Integer) valueAnimator.getAnimatedValue(); } titlesView.setLayoutParams(lp); } }); if (shouldShow) { fm.beginTransaction().show(f).commit(); objectAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { mCurrentTitlesAnimator = null; } }); } else { objectAnimator.addListener(new AnimatorListenerAdapter() { boolean canceled; @Override public void onAnimationCancel(Animator animation) { canceled = true; super.onAnimationCancel(animation); } @Override public void onAnimationEnd(Animator animator) { if (canceled) return; mCurrentTitlesAnimator = null; fm.beginTransaction().hide(f).commit(); } }); } // Start the animation. objectAnimator.start(); mCurrentTitlesAnimator = objectAnimator; invalidateOptionsMenu(); // Manually trigger onNewIntent to check for ACTION_DIALOG. onNewIntent(getIntent()); }
From source file:com.example.google.location.LocationActivity.java
private void init() { // Initialize map if (mMap == null) { FragmentManager myFragmentManager = getSupportFragmentManager(); SupportMapFragment myMapFragment = (SupportMapFragment) myFragmentManager.findFragmentById(R.id.map); mMap = myMapFragment.getMap();/*w w w.jav a 2 s .c om*/ } // Initialize Location Client mLocationStatus = (TextView) findViewById(R.id.location_status); if (mLocationClient == null) { mLocationClient = new LocationClient(this, mLocationCallback, mLocationCallback); Log.v(LocationActivity.TAG, "Location Client connect"); if (!(mLocationClient.isConnected() || mLocationClient.isConnecting())) { mLocationClient.connect(); } } // Initialize Action Recognition if (mActivityRecognitionClient == null) { mActivityRecognitionClient = new ActivityRecognitionClient(this, mActivityRecognitionCallback, mActivityRecognitionCallback); } mSwitch = (Switch) findViewById(R.id.swtich); mSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { startActivityDetection(buttonView); } else { stopActivityDetection(buttonView); } } }); if (mActivityRecognitionIntentReceiver == null) { mActivityRecognitionIntentReceiver = new ActivityRecognitionIntentReceiver(); registerReceiver(mActivityRecognitionIntentReceiver, new IntentFilter(LocationActivity.ACTION_ACTIVITY_RECOGNITION)); } // Initialize Geo Fencing }
From source file:com.gao.im.ui.contact.ContactSelectListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FragmentManager fm = getSupportFragmentManager(); mNeedResult = getIntent().getBooleanExtra("group_select_need_result", false); mShowGroup = getIntent().getBooleanExtra("select_type", true); // Create the list fragment and add it as our sole content. if (fm.findFragmentById(R.id.contact_container) == null) { ContactListFragment list = ContactListFragment .newInstance(mShowGroup ? ContactListFragment.TYPE_SELECT : ContactListFragment.TYPE_NON_GROUP); fm.beginTransaction().add(R.id.contact_container, list).commit(); }//from w w w . ja v a 2 s. com mTopBarView = getTopBarView(); String actionBtn = getString(R.string.radar_ok_count, getString(R.string.dialog_ok_button), 0); mTopBarView.setTopBarToStatus(1, R.drawable.topbar_back_bt, R.drawable.btn_style_green, null, actionBtn, getString(R.string.select_contacts), null, this); mTopBarView.setRightBtnEnable(false); }
From source file:com.yairkukielka.feedhungry.EntryListFragment.java
private void addLoadingFragment() { if (loadingFragment == null) { loadingFragment = new LoadingFragment_(); }/* w w w . ja v a 2 s . co m*/ FragmentManager fragmentManager = getSherlockActivity().getSupportFragmentManager(); if (fragmentManager.findFragmentById(loadingFragment.getId()) == null) { fragmentManager.beginTransaction().add(R.id.content_frame, loadingFragment).commit(); } }