List of usage examples for android.app FragmentTransaction commit
public abstract int commit();
From source file:com.reallynourl.nourl.fmpfoldermusicplayer.ui.activity.MainActivity.java
private void loadFragmentToContent(IMainContent content) { FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.content_panel, content.getFragment(), CONTENT_FRAGMENT_TAG); ft.commit(); SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(this).edit(); edit.putString(getString(R.string.pref_last_main_content_fragment), content.getName()); edit.apply();// ww w. jav a 2 s .c o m mActiveContent = content; }
From source file:com.dono.psakkos.dono.MainActivity.java
private void showLonelyFragment() { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); LonelyFragment lonelyFragment = new LonelyFragment(); fragmentTransaction.replace(R.id.mainFragment, lonelyFragment); fragmentTransaction.commit(); }
From source file:com.dono.psakkos.dono.MainActivity.java
private void showLabelsFragment() { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); LabelsFragment labelsFragment = new LabelsFragment(); fragmentTransaction.replace(R.id.mainFragment, labelsFragment); fragmentTransaction.commit(); }
From source file:com.example.google.touroflondon.MainActivity.java
@Override protected void onResume() { super.onResume(); // Verify that Google Play Services is available int playStatus = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()); if (playStatus != ConnectionResult.SUCCESS) { // Google Play services is not available, prompt user and close // application when dialog is dismissed Dialog dialog = GooglePlayServicesUtil.getErrorDialog(playStatus, this, 0); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override/* w w w . j av a 2 s. com*/ public void onCancel(DialogInterface dialog) { finish(); } }); dialog.show(); // Hide all active fragments FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.hide(mMapFragment); if (mPoiListFragment != null) { ft.hide(mPoiListFragment); } ft.commit(); } else { // Make sure active fragments are shown when returning from Play // Services dialog interaction FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.show(mMapFragment); if (mPoiListFragment != null) { ft.show(mPoiListFragment); } ft.commit(); } }
From source file:com.dono.psakkos.dono.MainActivity.java
private void showAddLabelFragment() { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); AddLabelFragment addlabelFragment = new AddLabelFragment(); fragmentTransaction.replace(R.id.mainFragment, addlabelFragment); fragmentTransaction.commit(); }
From source file:com.ppgllrd.alfil.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.d("ppgllrd", "onCreate: " + savedInstanceState); super.onCreate(savedInstanceState); setContentView(R.layout.main_double); DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); ListView drawerList = (ListView) findViewById(R.id.drawer_list); Course[] courses = Course.getCourses(); String currentYear = ""; drawerItems = new ArrayList<DrawerItem>(); for (Course course : courses) { if (course.getYear().compareTo(currentYear) != 0) { currentYear = course.getYear(); drawerItems.add(new DrawerSection(currentYear)); }//w w w.j ava2 s .c om drawerItems.add(new DrawerCourse(course)); } // set up the drawer's list view with items and click listener drawerList.setAdapter(new DrawerAdapter(this, R.layout.drawer_course_item, drawerItems)); drawerList.setOnItemClickListener(new DrawerItemClickListener()); // enable ActionBar app icon to behave as action to toggle nav drawer getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); actionBarTitleController = new ActionBarTitleController(this, /* host Activity */ drawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ); FragmentManager fm = getFragmentManager(); drawerSelectedIdx = 1; // start by selecting first course if (fm.findFragmentByTag(StudentsListFragment.FragmentTag) == null) { DrawerCourse drawerCourse = (DrawerCourse) drawerItems.get(drawerSelectedIdx); studentsListFragment = new StudentsListFragment(); Bundle args = new Bundle(); args.putParcelable(StudentsListFragment.ARG_GROUP_STUDENTS_COURSE, drawerCourse.getCourse()); studentsListFragment.setArguments(args); FragmentTransaction ft = fm.beginTransaction(); ft.add(R.id.list_Fragment_Placeholder, studentsListFragment, StudentsListFragment.FragmentTag); ft.commit(); } else { studentsListFragment = (StudentsListFragment) getFragmentManager() .findFragmentByTag(StudentsListFragment.FragmentTag); } if (fm.findFragmentByTag(StudentInfoFragment.FragmentTag) == null) { studentInfoFragment = new StudentInfoFragment(); Bundle args = new Bundle(); args.putParcelable(StudentInfoFragment.ARG_STUDENT, new Student(((DrawerCourse) drawerItems.get(drawerSelectedIdx)).getCourse())); studentInfoFragment.setArguments(args); FragmentTransaction ft = fm.beginTransaction(); ft.add(R.id.info_Fragment_Placeholder, studentInfoFragment, StudentInfoFragment.FragmentTag); ft.commit(); } else { studentInfoFragment = (StudentInfoFragment) getFragmentManager() .findFragmentByTag(StudentInfoFragment.FragmentTag); } FragmentTransaction ft = fm.beginTransaction(); ft.hide(studentInfoFragment); ft.show(studentsListFragment); //ft.addToBackStack(null); ft.commit(); // ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this); // DrawerLayout lowestLayout = (DrawerLayout)this.findViewById(R.id.drawer_layout); // lowestLayout.setOnTouchListener(activitySwipeDetector); }
From source file:com.royclarkson.springagram.MainActivity.java
private void showPhotoAddFragment() { FragmentManager fragmentManager = getFragmentManager(); String url = this.apiResource.getLink(ApiResource.REL_ITEMS).getHref(); PhotoAddFragment photoAddFragment = PhotoAddFragment.newInstance(url); FragmentTransaction transaction = fragmentManager.beginTransaction().add(R.id.container, photoAddFragment) .addToBackStack(null);/* w ww. ja va2s. com*/ transaction.commit(); }
From source file:com.royclarkson.springagram.MainActivity.java
private void showGalleryAddFragment() { FragmentManager fragmentManager = getFragmentManager(); String url = this.apiResource.getLink(ApiResource.REL_GALLERIES).getHref(); GalleryAddFragment galleryAddFragment = GalleryAddFragment.newInstance(url); FragmentTransaction transaction = fragmentManager.beginTransaction().add(R.id.container, galleryAddFragment) .addToBackStack(null);/* w w w .j a v a2 s .c o m*/ transaction.commit(); }
From source file:rtdc.android.presenter.MainActivity.java
public void goToFragment(FragmentType type) { User sessionUser = (User) Cache.getInstance().get("sessionUser"); switch (type) { case CAPACITY_OVERVIEW: fragment = new CapacityOverviewFragment(); if (sessionUser.getPermission().equals(User.Permission.MANAGER)) isAtHome = true;//w w w . j a va2 s . c om break; case ACTION_PLAN: fragment = new ActionPlanFragment(); if (sessionUser.getPermission().equals(User.Permission.USER)) isAtHome = true; break; case MESSAGES: fragment = new MessagesFragment(); break; case MANAGE_UNITS: if (sessionUser.getPermission().equals(User.Permission.MANAGER)) isAtHome = true; fragment = new ManageUnitsFragment(); break; case MANAGE_USERS: fragment = new ManageUsersFragment(); break; case PROFILE: fragment = new ProfileFragment(); break; } // Insert the fragment by replacing any existing fragment FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.main_fragment_wrapper, fragment); transaction.addToBackStack(null); transaction.commit(); }
From source file:com.example.koppa.driverlicensev2.MainActivity.java
public void addLoginFragment() { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); LoginFragment loginFragment = new LoginFragment(); fragmentTransaction.add(R.id.fragment_container, loginFragment); fragmentTransaction.commit(); }