Java Code Examples for android.support.v4.app.FragmentTransaction

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  22 
vote

@Override public void onTabReselected(android.app.ActionBar.Tab tab,android.app.FragmentTransaction ft){
  if (mListener != null) {
    FragmentTransaction trans=null;
    if (mActivity instanceof SherlockFragmentActivity) {
      trans=((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack();
    }
    mListener.onTabReselected(this,trans);
    if (trans != null && !trans.isEmpty()) {
      trans.commit();
    }
  }
}
 

Example 2

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  22 
vote

@Override public void onTabReselected(android.app.ActionBar.Tab tab,android.app.FragmentTransaction ft){
  if (mListener != null) {
    FragmentTransaction trans=null;
    if (mActivity instanceof SherlockFragmentActivity) {
      trans=((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack();
    }
    mListener.onTabReselected(this,trans);
    if (trans != null && !trans.isEmpty()) {
      trans.commit();
    }
  }
}
 

Example 3

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  22 
vote

@Override public void onTabReselected(android.app.ActionBar.Tab tab,android.app.FragmentTransaction ft){
  if (mListener != null) {
    FragmentTransaction trans=null;
    if (mActivity instanceof FragmentActivity) {
      trans=((FragmentActivity)mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack();
    }
    mListener.onTabReselected(this,trans);
    if (trans != null && !trans.isEmpty()) {
      trans.commit();
    }
  }
}
 

Example 4

From project adg-android, under directory /src/com/analysedesgeeks/android/.

Source file: WebActivity.java

  22 
vote

@Override protected void onCreate(final Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  final FragmentManager fragmentManager=getSupportFragmentManager();
  final FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction();
  final Fragment fragment=WebFragment.newInstance(url);
  fragmentTransaction.replace(android.R.id.content,fragment,"fragment");
  fragmentTransaction.commit();
}
 

Example 5

From project agit, under directory /agit/src/main/java/com/madgag/agit/.

Source file: DashboardActivity.java

  22 
vote

void askUserToInstallFileManager(){
  FragmentTransaction ft=getSupportFragmentManager().beginTransaction();
  Fragment prev=getSupportFragmentManager().findFragmentByTag("dialog");
  if (prev != null) {
    ft.remove(prev);
  }
  ft.addToBackStack(null);
  InstallAppDialogFragment.newInstance(R.drawable.icon,open_git_repository,install_file_manager,"org.openintents.filemanager").show(ft,"dialog");
}
 

Example 6

From project Airports, under directory /src/com/nadmm/airports/.

Source file: ActivityBase.java

  22 
vote

protected Fragment addFragment(Class<?> clss,Bundle args,int id){
  String tag=clss.getSimpleName();
  FragmentManager fm=getSupportFragmentManager();
  Fragment f=fm.findFragmentByTag(tag);
  if (f == null) {
    f=Fragment.instantiate(this,clss.getName(),args);
    FragmentTransaction ft=fm.beginTransaction();
    ft.add(id,f,tag);
    ft.commit();
  }
  return f;
}
 

Example 7

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  22 
vote

@Override public void onTabReselected(android.app.ActionBar.Tab tab,android.app.FragmentTransaction ft){
  if (mListener != null) {
    FragmentTransaction trans=null;
    if (mActivity instanceof SherlockFragmentActivity) {
      trans=((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack();
    }
    mListener.onTabReselected(this,trans);
    if (trans != null && !trans.isEmpty()) {
      trans.commit();
    }
  }
}
 

Example 8

From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  22 
vote

@Override public void onTabReselected(android.app.ActionBar.Tab tab,android.app.FragmentTransaction ft){
  if (mListener != null) {
    FragmentTransaction trans=null;
    if (mActivity instanceof SherlockFragmentActivity) {
      trans=((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack();
    }
    mListener.onTabReselected(this,trans);
    if (trans != null && !trans.isEmpty()) {
      trans.commit();
    }
  }
}
 

Example 9

From project Android, under directory /app/src/main/java/com/github/mobile/ui/.

Source file: DialogFragmentHelper.java

  22 
vote

/** 
 * Show dialog
 * @param activity
 * @param fragment
 * @param arguments
 * @param tag
 */
protected static void show(DialogFragmentActivity activity,DialogFragmentHelper fragment,Bundle arguments,String tag){
  FragmentManager manager=activity.getSupportFragmentManager();
  FragmentTransaction transaction=manager.beginTransaction();
  Fragment current=manager.findFragmentByTag(tag);
  if (current != null)   transaction.remove(current);
  transaction.addToBackStack(null);
  fragment.setArguments(arguments);
  fragment.show(manager,tag);
}
 

Example 10

From project androidZenWriter, under directory /library/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  22 
vote

@Override public void onTabReselected(android.app.ActionBar.Tab tab,android.app.FragmentTransaction ft){
  if (mListener != null) {
    FragmentTransaction trans=null;
    if (mActivity instanceof SherlockFragmentActivity) {
      trans=((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack();
    }
    mListener.onTabReselected(this,trans);
    if (trans != null && !trans.isEmpty()) {
      trans.commit();
    }
  }
}
 

Example 11

From project android_7, under directory /src/org/immopoly/android/widget/.

Source file: TabManager.java

  22 
vote

public void addTab(TabHost.TabSpec tabSpec,Class<?> clss,Bundle args,boolean tabless){
  tabSpec.setContent(new DummyTabFactory(mActivity));
  String tag=tabSpec.getTag();
  TabManager.TabInfo info=new TabInfo(tag,clss,args);
  info.fragment=mActivity.getSupportFragmentManager().findFragmentByTag(tag);
  if (info.fragment != null && !info.fragment.isDetached()) {
    FragmentTransaction ft=mActivity.getSupportFragmentManager().beginTransaction();
    ft.detach(info.fragment);
    ft.commit();
  }
  mTabs.put(tag,info);
  if (!tabless)   mTabHost.addTab(tabSpec);
}
 

Example 12

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/.

Source file: AppDetailsFragment.java

  22 
vote

public void closeDetails(){
  if (mDualPane) {
    Fragment logFragment=LogFragment.newInstance();
    FragmentTransaction transaction=((FragmentActivity)getActivity()).getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.fragment_container,logFragment);
    transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    transaction.commit();
  }
 else {
    Util.goHome(getActivity());
  }
}
 

Example 13

From project Bitcoin-Wallet-for-Android, under directory /wallet/src/de/schildbach/wallet/ui/.

Source file: AmountCalculatorFragment.java

  22 
vote

public static void calculate(final FragmentManager fm,final Listener listener){
  final FragmentTransaction ft=fm.beginTransaction();
  final Fragment prev=fm.findFragmentByTag(FRAGMENT_TAG);
  if (prev != null)   ft.remove(prev);
  ft.addToBackStack(null);
  final DialogFragment newFragment=new AmountCalculatorFragment();
  newFragment.setTargetFragment((Fragment)listener,0);
  newFragment.show(ft,FRAGMENT_TAG);
}
 

Example 14

From project CineShowTime-Android, under directory /Libraries/CineShowTime/src/com/binomed/showtime/android/util/activity/.

Source file: AbstractSimpleCineShowTimeActivity.java

  22 
vote

@Override protected void initContentView(){
  Fragment fragmentRecycle=getSupportFragmentManager().findFragmentById(R.id.root_container);
  fragment=getFragment(fragmentRecycle);
  FragmentTransaction transaction=getSupportFragmentManager().beginTransaction();
  if (fragmentRecycle == null) {
    transaction.add(R.id.root_container,fragment);
  }
 else   if ((fragment != null) && !fragmentRecycle.equals(fragment)) {
    transaction.replace(R.id.root_container,fragment);
  }
  transaction.commit();
}
 

Example 15

From project com.juick.android, under directory /src/com/juick/android/.

Source file: ExploreActivity.java

  22 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  Utils.updateTheme(this);
  super.onCreate(savedInstanceState);
  setContentView(R.layout.explore);
  etSearch=(EditText)findViewById(R.id.editSearch);
  ((Button)findViewById(R.id.buttonFind)).setOnClickListener(this);
  FragmentTransaction ft=getSupportFragmentManager().beginTransaction();
  TagsFragment tf=new TagsFragment();
  ft.add(R.id.tagsfragment,tf);
  ft.commit();
}
 

Example 16

From project Common-Sense-Net-2, under directory /AndroidBarSherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  22 
vote

@Override public void onTabReselected(android.app.ActionBar.Tab tab,android.app.FragmentTransaction ft){
  if (mListener != null) {
    FragmentTransaction trans=null;
    if (mActivity instanceof SherlockFragmentActivity) {
      trans=((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack();
    }
    mListener.onTabReselected(this,trans);
    if (trans != null && !trans.isEmpty()) {
      trans.commit();
    }
  }
}
 

Example 17

From project cw-advandroid, under directory /Honeycomb/FeedFragments/src/com/commonsware/android/feedfrags/.

Source file: AbstractFeedsActivity.java

  22 
vote

public void onItemSelected(RSSItem item){
  FragmentManager fragMgr=getSupportFragmentManager();
  ContentFragment content=(ContentFragment)fragMgr.findFragmentById(R.id.third_pane);
  FragmentTransaction xaction=fragMgr.beginTransaction();
  if (content == null || content.isRemoving()) {
    content=new ContentFragment(item.getLink().toString());
    xaction.add(R.id.third_pane,content).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).addToBackStack(null).commit();
  }
 else {
    content.loadUrl(item.getLink().toString());
  }
}
 

Example 18

From project cw-omnibus, under directory /external/ActionBarSherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  22 
vote

@Override public void onTabReselected(android.app.ActionBar.Tab tab,android.app.FragmentTransaction ft){
  if (mListener != null) {
    FragmentTransaction trans=null;
    if (mActivity instanceof SherlockFragmentActivity) {
      trans=((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack();
    }
    mListener.onTabReselected(this,trans);
    if (trans != null && !trans.isEmpty()) {
      trans.commit();
    }
  }
}
 

Example 19

From project DeskSMS, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  22 
vote

@Override public void onTabReselected(android.app.ActionBar.Tab tab,android.app.FragmentTransaction ft){
  if (mListener != null) {
    FragmentTransaction trans=null;
    if (mActivity instanceof SherlockFragmentActivity) {
      trans=((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack();
    }
    mListener.onTabReselected(this,trans);
    if (trans != null && !trans.isEmpty()) {
      trans.commit();
    }
  }
}
 

Example 20

From project dmix, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  22 
vote

@Override public void onTabReselected(android.app.ActionBar.Tab tab,android.app.FragmentTransaction ft){
  if (mListener != null) {
    FragmentTransaction trans=null;
    if (mActivity instanceof SherlockFragmentActivity) {
      trans=((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack();
    }
    mListener.onTabReselected(this,trans);
    if (trans != null && !trans.isEmpty()) {
      trans.commit();
    }
  }
}
 

Example 21

From project dreamDroid, under directory /libraries/ABS/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  22 
vote

@Override public void onTabReselected(android.app.ActionBar.Tab tab,android.app.FragmentTransaction ft){
  if (mListener != null) {
    FragmentTransaction trans=null;
    if (mActivity instanceof SherlockFragmentActivity) {
      trans=((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack();
    }
    mListener.onTabReselected(this,trans);
    if (trans != null && !trans.isEmpty()) {
      trans.commit();
    }
  }
}
 

Example 22

From project droidparts, under directory /modern/src/org/droidparts/activity/.

Source file: FragmentActivity.java

  22 
vote

public void setFragmentVisible(int fragmentId,boolean visible){
  FragmentManager fm=getSupportFragmentManager();
  Fragment f=fm.findFragmentById(fragmentId);
  if (f != null) {
    FragmentTransaction ft=fm.beginTransaction();
    if (visible) {
      ft.show(f);
    }
 else {
      ft.hide(f);
    }
    ft.commit();
  }
}
 

Example 23

From project Dual-Battery-Widget, under directory /src/org/flexlabs/widgets/dualbattery/app/.

Source file: SettingsActivity.java

  22 
vote

@Override public void onItemClick(AdapterView<?> adapterView,View view,int position,long l){
  if (mCurrentTab == position)   return;
  mCurrentTab=position;
  FragmentTransaction transaction=getSupportFragmentManager().beginTransaction();
  transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
  transaction.replace(R.id.prefs,fragments[position]);
  transaction.commit();
  mList.setItemChecked(position,true);
}
 

Example 24

From project dungbeetle, under directory /src/edu/stanford/mobisocial/dungbeetle/ui/fragments/.

Source file: AppsViewFragment.java

  22 
vote

void showMenuForObj(int position){
  Cursor cursor=(Cursor)mObjects.getItem(position);
  long objId=cursor.getLong(0);
  DbObj obj=App.instance().getMusubi().objForId(objId);
  FragmentTransaction ft=getFragmentManager().beginTransaction();
  Fragment prev=getFragmentManager().findFragmentByTag("dialog");
  if (prev != null) {
    ft.remove(prev);
  }
  ft.addToBackStack(null);
  DialogFragment newFragment=ObjMenuDialogFragment.newInstance(obj);
  newFragment.show(ft,"dialog");
}
 

Example 25

From project evodroid, under directory /src/com/sonorth/evodroid/.

Source file: ViewComments.java

  22 
vote

private void goBlooey(Throwable t){
  Log.e("b2evolution","Exception!",t);
  FragmentTransaction ft=getFragmentManager().beginTransaction();
  AppAlertDialogFragment alert=AppAlertDialogFragment.newInstance(t.toString());
  alert.show(ft,"alert");
}
 

Example 26

From project examples_2, under directory /BackgroundThreadFragment/src/com/inazaruk/backgroundthread/.

Source file: MainActivity.java

  22 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  FragmentManager manager=getSupportFragmentManager();
  FragmentTransaction transaction=manager.beginTransaction();
  mBkthreadFragment=new BackgroundThreadFragment();
  transaction.add(R.id.bkthread,mBkthreadFragment);
  transaction.commit();
}
 

Example 27

From project farebot, under directory /libs/ActionBarSherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  22 
vote

@Override public void onTabReselected(android.app.ActionBar.Tab tab,android.app.FragmentTransaction ft){
  if (mListener != null) {
    FragmentTransaction trans=null;
    if (mActivity instanceof SherlockFragmentActivity) {
      trans=((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack();
    }
    mListener.onTabReselected(this,trans);
    if (trans != null && !trans.isEmpty()) {
      trans.commit();
    }
  }
}
 

Example 28

From project finch, under directory /libs/JakeWharton-ActionBarSherlock-2eabf25/library/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  22 
vote

@Override public void onTabReselected(android.app.ActionBar.Tab tab,android.app.FragmentTransaction ft){
  if (mListener != null) {
    FragmentTransaction trans=null;
    if (mActivity instanceof SherlockFragmentActivity) {
      trans=((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack();
    }
    mListener.onTabReselected(this,trans);
    if (trans != null && !trans.isEmpty()) {
      trans.commit();
    }
  }
}
 

Example 29

From project friendica-for-android, under directory /mw-android-friendica-01/src/de/wikilab/android/friendica01/.

Source file: HomeActivity.java

  22 
vote

private void navigateMainFragment(ContentFragment newFragment,String target){
  onNavMainFragment();
  FragmentTransaction t=getSupportFragmentManager().beginTransaction();
  Bundle b=new Bundle();
  b.putString("target",target);
  newFragment.setArguments(b);
  t.replace(R.id.view_fragment_container,newFragment);
  t.setCustomAnimations(R.anim.slide_in_right,android.R.anim.slide_out_right);
  t.addToBackStack(null);
  t.commit();
  newFragment.navigate(target);
}
 

Example 30

From project gast-lib, under directory /app/src/root/gast/playground/sensor/.

Source file: SensorSelectorFragment.java

  22 
vote

/** 
 * hide the list of sensors and show the sensor display fragment add these changes to the backstack
 */
private void showSensorFragment(Sensor sensor){
  sensorDisplay.displaySensor(sensor);
  FragmentTransaction ft=getActivity().getSupportFragmentManager().beginTransaction();
  ft.hide(this);
  ft.show(sensorDisplay);
  ft.addToBackStack("Showing sensor: " + sensor.getName());
  ft.commit();
}
 

Example 31

From project GnucashMobile, under directory /com_actionbarsherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  22 
vote

@Override public void onTabReselected(android.app.ActionBar.Tab tab,android.app.FragmentTransaction ft){
  if (mListener != null) {
    FragmentTransaction trans=null;
    if (mActivity instanceof SherlockFragmentActivity) {
      trans=((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack();
    }
    mListener.onTabReselected(this,trans);
    if (trans != null && !trans.isEmpty()) {
      trans.commit();
    }
  }
}
 

Example 32

From project gobandroid, under directory /src/org/ligi/gobandroid_hd/ui/.

Source file: GoActivity.java

  22 
vote

public void setFragment(Fragment newFragment){
  FragmentTransaction fragmentTransAction=getSupportFragmentManager().beginTransaction();
  if (actFragment == newFragment) {
    Log.i("GoFrag same same");
    return;
  }
  if (actFragment != null)   fragmentTransAction.remove(actFragment);
  fragmentTransAction.replace(R.id.game_extra_container,newFragment);
  fragmentTransAction.commit();
  actFragment=newFragment;
}
 

Example 33

From project Google-Tasks-Client, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  22 
vote

@Override public void onTabReselected(android.app.ActionBar.Tab tab,android.app.FragmentTransaction ft){
  if (mListener != null) {
    FragmentTransaction trans=null;
    if (mActivity instanceof SherlockFragmentActivity) {
      trans=((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack();
    }
    mListener.onTabReselected(this,trans);
    if (trans != null && !trans.isEmpty()) {
      trans.commit();
    }
  }
}
 

Example 34

From project HabReader, under directory /src/net/meiolania/apps/habrahabr/activities/.

Source file: CompaniesActivity.java

  22 
vote

private void loadCompanies(){
  CompaniesFragment fragment=new CompaniesFragment();
  FragmentTransaction fragmentTransaction=getSupportFragmentManager().beginTransaction();
  fragmentTransaction.replace(android.R.id.content,fragment);
  fragmentTransaction.commit();
}
 

Example 35

From project android-flash-cards, under directory /src/org/thomasamsler/android/flashcards/activity/.

Source file: MainActivity.java

  21 
vote

private void showCardSetsFragment(boolean addToBackStack){
  FragmentManager fragmentManager=getSupportFragmentManager();
  FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction();
  if (null == mActionbarFragment) {
    mActionbarFragment=ActionbarFragment.newInstance(LIST_FRAGMENT);
    fragmentTransaction.replace(R.id.actionbarContainer,mActionbarFragment);
  }
 else {
    mActionbarFragment.configureFor(LIST_FRAGMENT);
  }
  if (null == mCardSetsFragment) {
    mCardSetsFragment=new CardSetsFragment();
  }
  fragmentTransaction.replace(R.id.fragmentContainer,mCardSetsFragment);
  if (addToBackStack) {
    fragmentTransaction.addToBackStack(null);
  }
  fragmentTransaction.commit();
  mFragmentContainer.setVisibility(View.VISIBLE);
  mViewPager.setVisibility(View.GONE);
  mHelpContext=HELP_CONTEXT_CARD_SET_LIST;
  mActiveFragmentReference=LIST_FRAGMENT;
  mExitOnBackPressed=true;
}
 

Example 36

From project android-xbmcremote-sandbox, under directory /src/org/xbmc/android/remotesandbox/ui/base/.

Source file: ReloadableActionBarActivity.java

  21 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getActionBarHelper().setRefreshActionItemState(mSyncing);
  final FragmentManager fm=getSupportFragmentManager();
  final AbstractSyncBridge[] bridges=initSyncBridges();
  FragmentTransaction ft=null;
  for (  AbstractSyncBridge syncBridge : bridges) {
    if (ft == null) {
      ft=fm.beginTransaction();
    }
    AbstractSyncBridge checkSyncBridge=(AbstractSyncBridge)fm.findFragmentByTag(syncBridge.getTagName());
    if (checkSyncBridge != null) {
      ft.remove(checkSyncBridge);
      Log.i(TAG,"Updated refresh observers.");
      syncBridge.setRefreshObservers(mRefreshObservers);
    }
    Log.i(TAG,"Added " + syncBridge.getClass().getSimpleName() + " fragment to activity.");
    ft.add(syncBridge,syncBridge.getTagName());
  }
  if (ft != null) {
    ft.commit();
  }
}
 

Example 37

From project AquaNotesTest, under directory /src/com/google/android/apps/iosched/ui/.

Source file: BaseMultiPaneActivity.java

  21 
vote

/** 
 * {@inheritDoc} 
 */
@Override public void openActivityOrFragment(final Intent intent){
  final PackageManager pm=getPackageManager();
  List<ResolveInfo> resolveInfoList=pm.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);
  for (  ResolveInfo resolveInfo : resolveInfoList) {
    final FragmentReplaceInfo fri=onSubstituteFragmentForActivityLaunch(resolveInfo.activityInfo.name);
    if (fri != null) {
      final Bundle arguments=intentToFragmentArguments(intent);
      final FragmentManager fm=getSupportFragmentManager();
      try {
        Fragment fragment=(Fragment)fri.getFragmentClass().newInstance();
        fragment.setArguments(arguments);
        FragmentTransaction ft=fm.beginTransaction();
        ft.replace(fri.getContainerId(),fragment,fri.getFragmentTag());
        onBeforeCommitReplaceFragment(fm,ft,fragment);
        ft.commit();
      }
 catch (      InstantiationException e) {
        throw new IllegalStateException("Error creating new fragment.",e);
      }
catch (      IllegalAccessException e) {
        throw new IllegalStateException("Error creating new fragment.",e);
      }
      return;
    }
  }
  super.openActivityOrFragment(intent);
}
 

Example 38

From project badgescanner, under directory /src/net/tjohns/badgescanner/.

Source file: ScanActivity.java

  21 
vote

/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  if (savedInstanceState == null || (!savedInstanceState.containsKey(FRAGMENTS_ADDED) || !savedInstanceState.getBoolean(FRAGMENTS_ADDED,false))) {
    scanBadge();
    if (mBadge == null) {
      Log.e(TAG,"Badge is null");
      CharSequence text=getText(R.string.error_reading_badge);
      int duration=Toast.LENGTH_SHORT;
      Toast toast=Toast.makeText(this,text,duration);
      toast.show();
      finish();
      return;
    }
    mFront=new CardFront(new MwcContact(mBadge.getField("firstName"),mBadge.getField("lastName"),null,mBadge.getField("company"),mBadge.getField("email"),mBadge.getField("phone")));
    mBack=new CardBack();
    FragmentTransaction ft=getSupportFragmentManager().beginTransaction();
    ft.add(R.id.root,mFront);
    ft.add(R.id.root,mBack);
    ft.commit();
  }
}
 

Example 39

From project conference-mobile-app, under directory /android-app/src/com/google/android/apps/iosched/ui/.

Source file: BaseMultiPaneActivity.java

  21 
vote

/** 
 * {@inheritDoc} 
 */
@Override public void openActivityOrFragment(final Intent intent){
  final PackageManager pm=getPackageManager();
  List<ResolveInfo> resolveInfoList=pm.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);
  for (  ResolveInfo resolveInfo : resolveInfoList) {
    final FragmentReplaceInfo fri=onSubstituteFragmentForActivityLaunch(resolveInfo.activityInfo.name);
    if (fri != null) {
      final Bundle arguments=intentToFragmentArguments(intent);
      final FragmentManager fm=getSupportFragmentManager();
      try {
        Fragment fragment=(Fragment)fri.getFragmentClass().newInstance();
        fragment.setArguments(arguments);
        FragmentTransaction ft=fm.beginTransaction();
        ft.replace(fri.getContainerId(),fragment,fri.getFragmentTag());
        onBeforeCommitReplaceFragment(fm,ft,fragment);
        ft.commit();
      }
 catch (      InstantiationException e) {
        throw new IllegalStateException("Error creating new fragment.",e);
      }
catch (      IllegalAccessException e) {
        throw new IllegalStateException("Error creating new fragment.",e);
      }
      return;
    }
  }
  super.openActivityOrFragment(intent);
}
 

Example 40

From project dcnyc10-android, under directory /android/src/com/lullabot/android/apps/iosched/ui/.

Source file: BaseMultiPaneActivity.java

  21 
vote

/** 
 * {@inheritDoc} 
 */
@Override public void openActivityOrFragment(final Intent intent){
  final PackageManager pm=getPackageManager();
  List<ResolveInfo> resolveInfoList=pm.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);
  for (  ResolveInfo resolveInfo : resolveInfoList) {
    final FragmentReplaceInfo fri=onSubstituteFragmentForActivityLaunch(resolveInfo.activityInfo.name);
    if (fri != null) {
      final Bundle arguments=intentToFragmentArguments(intent);
      final FragmentManager fm=getSupportFragmentManager();
      try {
        Fragment fragment=(Fragment)fri.getFragmentClass().newInstance();
        fragment.setArguments(arguments);
        FragmentTransaction ft=fm.beginTransaction();
        ft.replace(fri.getContainerId(),fragment,fri.getFragmentTag());
        onBeforeCommitReplaceFragment(fm,ft,fragment);
        ft.commit();
      }
 catch (      InstantiationException e) {
        throw new IllegalStateException("Error creating new fragment.",e);
      }
catch (      IllegalAccessException e) {
        throw new IllegalStateException("Error creating new fragment.",e);
      }
      return;
    }
  }
  super.openActivityOrFragment(intent);
}
 

Example 41

From project devoxx-france-android-in-fine, under directory /src/com/infine/android/devoxx/ui/.

Source file: BaseMultiPaneActivity.java

  21 
vote

/** 
 * {@inheritDoc} 
 */
@Override public void openActivityOrFragment(final Intent intent){
  final PackageManager pm=getPackageManager();
  List<ResolveInfo> resolveInfoList=pm.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);
  for (  ResolveInfo resolveInfo : resolveInfoList) {
    final FragmentReplaceInfo fri=onSubstituteFragmentForActivityLaunch(resolveInfo.activityInfo.name);
    if (fri != null) {
      final Bundle arguments=intentToFragmentArguments(intent);
      final FragmentManager fm=getSupportFragmentManager();
      try {
        Fragment fragment=(Fragment)fri.getFragmentClass().newInstance();
        fragment.setArguments(arguments);
        FragmentTransaction ft=fm.beginTransaction();
        ft.replace(fri.getContainerId(),fragment,fri.getFragmentTag());
        onBeforeCommitReplaceFragment(fm,ft,fragment);
        ft.commit();
      }
 catch (      InstantiationException e) {
        throw new IllegalStateException("Error creating new fragment.",e);
      }
catch (      IllegalAccessException e) {
        throw new IllegalStateException("Error creating new fragment.",e);
      }
      return;
    }
  }
  super.openActivityOrFragment(intent);
}
 

Example 42

From project gddsched2, under directory /trunk/android/src/com/google/android/apps/iosched2/ui/.

Source file: BaseMultiPaneActivity.java

  21 
vote

/** 
 * {@inheritDoc} 
 */
@Override public void openActivityOrFragment(final Intent intent){
  final PackageManager pm=getPackageManager();
  List<ResolveInfo> resolveInfoList=pm.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);
  for (  ResolveInfo resolveInfo : resolveInfoList) {
    final FragmentReplaceInfo fri=onSubstituteFragmentForActivityLaunch(resolveInfo.activityInfo.name);
    if (fri != null) {
      final Bundle arguments=intentToFragmentArguments(intent);
      final FragmentManager fm=getSupportFragmentManager();
      try {
        Fragment fragment=(Fragment)fri.getFragmentClass().newInstance();
        fragment.setArguments(arguments);
        FragmentTransaction ft=fm.beginTransaction();
        ft.replace(fri.getContainerId(),fragment,fri.getFragmentTag());
        onBeforeCommitReplaceFragment(fm,ft,fragment);
        ft.commit();
      }
 catch (      InstantiationException e) {
        throw new IllegalStateException("Error creating new fragment.",e);
      }
catch (      IllegalAccessException e) {
        throw new IllegalStateException("Error creating new fragment.",e);
      }
      return;
    }
  }
  super.openActivityOrFragment(intent);
}
 

Example 43

From project Android_1, under directory /Fragments/simple/src/novoda/demo/fragments/list/frags/.

Source file: List.java

  19 
vote

void upateDetailsFragment(int index){
  mPositionChecked=index;
  if (mHasDetailsFrame) {
    getListView().setItemChecked(index,true);
    if (mPositionShown != mPositionChecked) {
      Detail df=Detail.newInstance(index);
      getFragmentManager().beginTransaction().replace(R.id.frame_details,df).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).commit();
      mPositionShown=index;
    }
  }
 else {
    Intent intent=new Intent();
    intent.setClass(getActivity(),Details.class);
    intent.putExtra("index",index);
    startActivity(intent);
  }
}
 

Example 44

From project be.norio.twunch.android, under directory /src/be/norio/twunch/android/ui/.

Source file: TwunchListActivity.java

  19 
vote

@Override public void onTabSelected(Tab tab,FragmentTransaction ft){
  int position=tab.getPosition();
  PrefsUtils.setLastTab(position);
  if (mViewPager.getCurrentItem() != position) {
    mViewPager.setCurrentItem(position,true);
    AnalyticsUtils.trackPageView(PAGES[position]);
  }
}