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

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 ActionBarSherlock, under directory /samples/fragments/src/com/actionbarsherlock/sample/fragments/.

Source file: FragmentArgumentsSupport.java

  18 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  setTheme(SampleList.THEME);
  super.onCreate(savedInstanceState);
  setContentView(R.layout.fragment_arguments_support);
  if (savedInstanceState == null) {
    FragmentTransaction ft=getSupportFragmentManager().beginTransaction();
    Fragment newFragment=MyFragment.newInstance("From Arguments");
    ft.add(R.id.created,newFragment);
    ft.commit();
  }
}
 

Example 2

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

Source file: WebActivity.java

  18 
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 3

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

Source file: DashboardActivity.java

  18 
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 4

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

Source file: ActivityBase.java

  18 
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 5

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

Source file: DialogFragmentHelper.java

  18 
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 6

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

Source file: AppDetailsActivity.java

  18 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  Configuration config=getResources().getConfiguration();
  if (config.orientation == Configuration.ORIENTATION_LANDSCAPE && (config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
    finish();
    return;
  }
  setContentView(R.layout.activity_app_details);
  if (savedInstanceState == null) {
    Fragment fragment=Fragment.instantiate(this,AppDetailsFragment.class.getName(),getIntent().getExtras());
    getSupportFragmentManager().beginTransaction().add(R.id.container,fragment).commit();
  }
}
 

Example 7

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

Source file: AmountCalculatorFragment.java

  18 
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 8

From project callmeter, under directory /src/de/ub0r/android/callmeter/ui/.

Source file: Plans.java

  18 
vote

/** 
 * {@inheritDoc}
 */
public void showLogsFragment(final long planId){
  int p=this.fadapter.getLogsFragmentPos();
  Fragment f=this.fadapter.getActiveFragment(this.pager,p);
  if (f != null && f instanceof LogsFragment) {
    ((LogsFragment)f).setPlanId(planId);
  }
  this.pager.setCurrentItem(p,true);
}
 

Example 9

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

Source file: AbstractSimpleCineShowTimeActivity.java

  18 
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 10

From project cw-android, under directory /Fragments/EU4You_6/src/com/commonsware/android/eu4you6/.

Source file: EU4You.java

  18 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  CountriesFragment countries=(CountriesFragment)getSupportFragmentManager().findFragmentById(R.id.countries);
  countries.setCountryListener(this);
  Fragment f=getSupportFragmentManager().findFragmentById(R.id.details);
  detailsInline=(f != null && (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE));
  if (detailsInline) {
    countries.enablePersistentSelection();
  }
 else   if (f != null) {
    f.getView().setVisibility(View.GONE);
  }
}
 

Example 11

From project cw-omnibus, under directory /EmPubLite/T11-HelpAbout/src/com/commonsware/empublite/.

Source file: SimpleContentActivity.java

  18 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (getSupportFragmentManager().findFragmentById(android.R.id.content) == null) {
    String file=getIntent().getStringExtra(EXTRA_FILE);
    Fragment f=SimpleContentFragment.newInstance(file);
    getSupportFragmentManager().beginTransaction().add(android.R.id.content,f).commit();
  }
}
 

Example 12

From project dmix, under directory /MPDroid/src/com/namelessdev/mpdroid/.

Source file: MainMenuActivity.java

  18 
vote

@Override public Fragment getItem(int i){
  Fragment fragment=null;
switch (i) {
case 0:
    fragment=new NowPlayingFragment();
  break;
case 1:
fragment=new PlaylistFragment();
break;
}
return fragment;
}
 

Example 13

From project dreamDroid, under directory /src/net/reichholf/dreamdroid/activities/.

Source file: FragmentMainActivity.java

  18 
vote

@Override public void onSaveInstanceState(Bundle outState){
  getSupportFragmentManager().putFragment(outState,"navigation",mNavigationFragment);
  Fragment currentDetailFragment=getCurrentDetailFragment();
  if (currentDetailFragment != null) {
    getSupportFragmentManager().putFragment(outState,"current",currentDetailFragment);
  }
  super.onSaveInstanceState(outState);
}
 

Example 14

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

Source file: FragmentActivity.java

  18 
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 15

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

Source file: AppsViewFragment.java

  18 
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 16

From project empub, under directory /src/com/commonsware/empub/.

Source file: ContentsAdapter.java

  18 
vote

@Override public Fragment getItem(int position){
  Fragment frag=null;
  if (position == 0) {
    frag=ImageFragment.newInstance(contents.getCoverImage(),contents.getTitle());
  }
 else   if (position == 1) {
    frag=ChapterFragment.newInstance(contents.getTOCFile());
  }
 else {
    String path=contents.getChapterFile(position - 2);
    frag=ChapterFragment.newInstance(path);
  }
  return (frag);
}
 

Example 17

From project eoit, under directory /EOIT/src/fr/eoit/activity/.

Source file: Blueprint2Activity.java

  18 
vote

@Override public Fragment getItem(int i){
  Fragment fragment=null;
switch (i) {
case 0:
    fragment=Fragment.instantiate(getApplicationContext(),"fr.eoit.activity.fragment.blueprint.BlueprintInfoFragment",getIntent().getExtras());
  break;
case 1:
fragment=Fragment.instantiate(getApplicationContext(),"fr.eoit.activity.fragment.blueprint.InventionFragment",getIntent().getExtras());
break;
default :
break;
}
return fragment;
}
 

Example 18

From project farebot, under directory /src/com/codebutler/farebot/.

Source file: TabPagerAdapter.java

  18 
vote

@Override public Object instantiateItem(View view,int position){
  TabInfo info=mTabs.get(position);
  if (mCurTransaction == null) {
    mCurTransaction=mActivity.getSupportFragmentManager().beginTransaction();
  }
  Fragment fragment=Fragment.instantiate(mActivity,info.clss.getName(),info.args);
  mCurTransaction.add(R.id.pager,fragment);
  return fragment;
}
 

Example 19

From project finch, under directory /libs/JakeWharton-ActionBarSherlock-2eabf25/samples/fragments/src/com/actionbarsherlock/sample/fragments/.

Source file: FragmentArgumentsSupport.java

  18 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  setTheme(SampleList.THEME);
  super.onCreate(savedInstanceState);
  setContentView(R.layout.fragment_arguments_support);
  if (savedInstanceState == null) {
    FragmentTransaction ft=getSupportFragmentManager().beginTransaction();
    Fragment newFragment=MyFragment.newInstance("From Arguments");
    ft.add(R.id.created,newFragment);
    ft.commit();
  }
}
 

Example 20

From project GnucashMobile, under directory /GnucashMobile/src/org/gnucash/android/ui/accounts/.

Source file: AccountsListFragment.java

  18 
vote

/** 
 * Displays the dialog for exporting transactions in OFX
 */
public void showExportDialog(){
  FragmentManager manager=getSherlockActivity().getSupportFragmentManager();
  FragmentTransaction ft=manager.beginTransaction();
  Fragment prev=manager.findFragmentByTag(AccountsActivity.FRAGMENT_EXPORT_OFX);
  if (prev != null) {
    ft.remove(prev);
  }
  ft.addToBackStack(null);
  DialogFragment exportFragment=new ExportDialogFragment();
  exportFragment.show(ft,AccountsActivity.FRAGMENT_EXPORT_OFX);
}
 

Example 21

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

Source file: TrackDetailActivity.java

  18 
vote

@Override public Fragment getItem(int position){
  boolean allTracks=(ScheduleContract.Tracks.ALL_TRACK_ID.equals(mTrackId));
  if (position == 0) {
    Fragment fragment=new SessionsFragment();
    fragment.setArguments(BaseActivity.intentToFragmentArguments(new Intent(Intent.ACTION_VIEW,allTracks ? ScheduleContract.Sessions.CONTENT_URI : ScheduleContract.Tracks.buildSessionsUri(mTrackId))));
    return fragment;
  }
 else {
    Fragment fragment=new VendorsFragment();
    fragment.setArguments(BaseActivity.intentToFragmentArguments(new Intent(Intent.ACTION_VIEW,allTracks ? ScheduleContract.Vendors.CONTENT_URI : ScheduleContract.Tracks.buildVendorsUri(mTrackId))));
    return fragment;
  }
}
 

Example 22

From project maven-android-plugin-samples, under directory /support4demos/src/com/example/android/supportv4/app/.

Source file: FragmentArgumentsSupport.java

  18 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.fragment_arguments_support);
  if (savedInstanceState == null) {
    FragmentTransaction ft=getSupportFragmentManager().beginTransaction();
    Fragment newFragment=MyFragment.newInstance("From Arguments");
    ft.add(R.id.created,newFragment);
    ft.commit();
  }
}
 

Example 23

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

Source file: ItemActivateFragment.java

  17 
vote

@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  mTracker=GoogleAnalyticsTracker.getInstance();
  mTracker.startNewSession(TrackingManager.UA_ACCOUNT,Const.ANALYTICS_INTERVAL,getActivity().getApplicationContext());
  mTracker.trackPageView(TrackingManager.VIEW_ACTION_ITEM_SPY);
  ImmopolyActionItem item=ImmopolyUser.getInstance().getActionItems().get(mItemId);
  return new AlertDialog.Builder(getActivity()).setTitle(item.getText()).setMessage(item.getDescription()).setPositiveButton("Aktivieren",new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      Fragment fragment=getFragmentManager().findFragmentByTag(ImmopolyActivity.FRAGMENT_MAP);
      if (fragment instanceof MapFragment) {
        ((MapFragment)fragment).filterFreeFlats();
      }
    }
  }
).setNegativeButton("Abbrechen",null).create();
}
 

Example 24

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

Source file: BaseMultiPaneActivity.java

  17 
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 25

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

Source file: BaseMultiPaneActivity.java

  17 
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 26

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

Source file: BaseMultiPaneActivity.java

  17 
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 27

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

Source file: BaseMultiPaneActivity.java

  17 
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 28

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

Source file: HomeActivity.java

  17 
vote

@Override public void onBackPressed(){
  if (!isLargeMode) {
    View leftBar=findViewById(R.id.left_bar);
    if (leftBar.getVisibility() != View.GONE) {
      leftBar.setVisibility(View.GONE);
      return;
    }
  }
  Fragment viewerFragment=(Fragment)getSupportFragmentManager().findFragmentById(R.id.view_fragment_container);
  if (viewerFragment instanceof ContentFragment) {
    if (((ContentFragment)viewerFragment).onBackPressed()) {
      return;
    }
  }
  super.onBackPressed();
}
 

Example 29

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

Source file: BaseMultiPaneActivity.java

  17 
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 30

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

Source file: BaseMultiPaneActivity.java

  17 
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 31

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

Source file: BaseMultiPaneActivity.java

  17 
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 32

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

Source file: BaseMultiPaneActivity.java

  17 
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 33

From project Android-FFXIEQ, under directory /ffxieq/src/com/github/kanata3249/ffxieq/android/.

Source file: AtmaSelector.java

  15 
vote

static public boolean startActivity(Fragment from,int request,FFXICharacter charInfo,int index,long current){
  Intent intent=new Intent(from.getActivity(),AtmaSelector.class);
  intent.putExtra("Current",current);
  intent.putExtra("Index",index);
  intent.putExtra("Filter",(long)-1);
  from.startActivityForResult(intent,request);
  return true;
}
 

Example 34

From project androidquery, under directory /demo/src/com/androidquery/test/image/.

Source file: ImageLoadingPageGridActivity.java

  15 
vote

@Override public Fragment getItem(int pos){
  AQUtility.debug("primary",topics[pos]);
  Bundle args=new Bundle();
  args.putString("topic",topics[pos]);
  ImageGridFragment fragment=(ImageGridFragment)Fragment.instantiate(ImageLoadingPageGridActivity.this,ImageGridFragment.class.getName(),args);
  return fragment;
}
 

Example 35

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

Source file: TwunchListActivity.java

  15 
vote

@Override public Fragment getItem(int position){
  if (position == 0 || position == 1) {
    TwunchListFragment fragment=new TwunchListFragment();
    Bundle args=new Bundle();
    args.putString(TwunchListFragment.EXTRA_SORT,SORTS[position]);
    fragment.setArguments(args);
    return fragment;
  }
 else {
    return new TwunchesMapFragment();
  }
}
 

Example 36

From project BF3-Battlelog, under directory /src/com/ninetwozero/battlelog/activity/aboutapp/.

Source file: AboutActivity.java

  15 
vote

public void setup(){
  if (mListFragments == null) {
    mListFragments=new ArrayList<Fragment>();
    mListFragments.add(Fragment.instantiate(this,AboutMainFragment.class.getName()));
    mListFragments.add(Fragment.instantiate(this,AboutFAQFragment.class.getName()));
    mListFragments.add(Fragment.instantiate(this,AboutCreditsFragment.class.getName()));
    mViewPager=(ViewPager)findViewById(R.id.viewpager);
    mTabs=(SwipeyTabs)findViewById(R.id.swipeytabs);
    mPagerAdapter=new SwipeyTabsPagerAdapter(mFragmentManager,new String[]{getString(R.string.label_about),getString(R.string.label_faq),getString(R.string.label_credits)},mListFragments,mViewPager,mLayoutInflater);
    mViewPager.setAdapter(mPagerAdapter);
    mTabs.setAdapter(mPagerAdapter);
    mViewPager.setOnPageChangeListener(mTabs);
    mViewPager.setCurrentItem(0);
  }
}
 

Example 37

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

Source file: SettingsActivity.java

  15 
vote

public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  fragments=new Fragment[4];
  fragments[0]=new SettingsFragment();
  fragments[1]=new FeedbackFragment();
  fragments[2]=new DonateFragment();
  fragments[3]=new AboutFragment();
  titles=new String[4];
  titles[0]=getString(R.string.settings);
  titles[1]=getString(R.string.propHeader_Feedback);
  titles[2]=getString(R.string.propHeader_Donate);
  titles[3]=getString(R.string.propHeader_About);
  int screenLayout=getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && screenLayout > Configuration.SCREENLAYOUT_SIZE_LARGE) {
    setContentView(R.layout.preference_list_large);
    ArrayAdapter adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_activated_1,titles);
    mList=(ListView)findViewById(android.R.id.list);
    mList.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
    mList.setOnItemClickListener(this);
    mList.setAdapter(adapter);
    mList.setItemChecked(0,true);
    mList.performClick();
    getSupportFragmentManager().beginTransaction().replace(R.id.prefs,fragments[0]).commit();
  }
 else {
    setContentView(R.layout.widgetsettings);
    PagerTabAdapter mPagerAdapter=new PagerTabAdapter(getSupportFragmentManager());
    ViewPager mPager=(ViewPager)findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    PageIndicator mIndicator=(TabPageIndicator)findViewById(R.id.indicator);
    mIndicator.setViewPager(mPager);
  }
}
 

Example 38

From project ElectricSleep, under directory /src/com/androsz/electricsleepbeta/app/wizard/.

Source file: CalibrationWizardActivity.java

  15 
vote

@Override public Fragment getItem(int position){
switch (position) {
case FRAG_ABOUT:
    return new CalibrationAboutFragment();
case FRAG_LIGHT_SLEEP_INSTRUCT:
  return new CalibrateLightSleepInstructionsFragment();
case FRAG_LIGHT_SLEEP:
return calibrateLightSleepFragment;
case FRAG_SCREEN_BUG:
return checkForScreenBugFragment;
case FRAG_RESULTS:
return new CalibrationResultsFragment();
default :
throw new IllegalStateException("Could not find the correct fragment.");
}
}
 

Example 39

From project gauges-android, under directory /app/src/main/java/com/github/mobile/gauges/ui/.

Source file: GaugePagerAdapter.java

  15 
vote

@Override public Fragment getItem(int position){
  Bundle bundle=new Bundle();
  bundle.putSerializable(GAUGE,gauge);
  bundle.putString(GAUGE_ID,gauge.getId());
switch (position) {
case 0:
    ContentListFragment contentFragment=new ContentListFragment();
  contentFragment.setArguments(bundle);
return contentFragment;
case 1:
TrafficListFragment trafficFragment=new TrafficListFragment();
trafficFragment.setArguments(bundle);
return trafficFragment;
case 2:
ReferrerListFragment referrerFragment=new ReferrerListFragment();
referrerFragment.setArguments(bundle);
return referrerFragment;
default :
return null;
}
}
 

Example 40

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

Source file: GoActivity.java

  15 
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 41

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

Source file: TabListener.java

  15 
vote

@Override public void onTabSelected(Tab tab,FragmentTransaction ft){
  if (fragment == null) {
    fragment=Fragment.instantiate(context,fragmentClass.getName());
    if (arguments != null)     fragment.setArguments(arguments);
  }
  ft.replace(android.R.id.content,fragment,tag);
}
 

Example 42

From project HSR-Timetable, under directory /HSRTimeTable/src/ch/scythe/hsr/.

Source file: TimeTableActivity.java

  15 
vote

@Override public Fragment getItem(int position){
  DayFragment fragment=new DayFragment();
  Weekday weekDay=getWeekday(position);
  Bundle args=new Bundle();
  args.putSerializable(DayFragment.FRAGMENT_PARAMETER_DATA,week);
  args.putSerializable(DayFragment.FRAGMENT_PARAMETER_WEEKDAY,weekDay);
  fragment.setArguments(args);
  activeFragments.put(position,fragment);
  return fragment;
}
 

Example 43

From project k-9, under directory /src/com/fsck/k9/crypto/.

Source file: Apg.java

  15 
vote

/** 
 * Start the decrypt activity.
 * @param fragment
 * @param data
 * @param pgpData
 * @return success or failure
 */
@Override public boolean decrypt(Fragment fragment,String data,PgpData pgpData){
  android.content.Intent intent=new android.content.Intent(Apg.Intent.DECRYPT_AND_RETURN);
  intent.putExtra(EXTRA_INTENT_VERSION,INTENT_VERSION);
  intent.setType("text/plain");
  if (data == null) {
    return false;
  }
  try {
    intent.putExtra(EXTRA_TEXT,data);
    fragment.startActivityForResult(intent,Apg.DECRYPT_MESSAGE);
    return true;
  }
 catch (  ActivityNotFoundException e) {
    Toast.makeText(fragment.getActivity(),R.string.error_activity_not_found,Toast.LENGTH_SHORT).show();
    return false;
  }
}
 

Example 44

From project mWater-Android-App, under directory /android/src/co/mwater/clientapp/ui/.

Source file: TabListener.java

  15 
vote

public void onTabSelected(Tab tab,FragmentTransaction ft){
  if (fragment == null) {
    fragment=Fragment.instantiate(activity,clazz.getName(),args);
    ft.add(android.R.id.content,fragment,tag);
  }
 else {
    ft.attach(fragment);
  }
}