Example usage for android.app FragmentTransaction commit

List of usage examples for android.app FragmentTransaction commit

Introduction

In this page you can find the example usage for android.app FragmentTransaction commit.

Prototype

public abstract int commit();

Source Link

Document

Schedules a commit of this transaction.

Usage

From source file:com.example.corppool.controller.MainActivity.java

public void showConfirmPage(Feed feed) {

    Fragment fragment = ConfirmFeedSubmit.newInstance(feed);
    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.container, fragment); // fragment container id in first parameter is the  container(Main layout id) of Activity
    transaction.addToBackStack(null); // this will manage backstack
    transaction.commit();
}

From source file:com.example.corppool.controller.MainActivity.java

private void showAddNewFeed() {
    Fragment fragment = new AddNewFeed();
    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.container, fragment); // fragment container id in first parameter is the  container(Main layout id) of Activity
    transaction.addToBackStack("newfeed"); // this will manage backstack
    transaction.commit();
}

From source file:de.bigboot.qcircleview.cover.CoverFragment.java

@AfterViews
protected void init() {
    Preferences preferences = new Preferences(getActivity());

    FragmentManager fragMan = getChildFragmentManager();
    FragmentTransaction fragTransaction = fragMan.beginTransaction();

    Clock clock = preferences.getActiveClock();
    if (clock == null) {
        clock = Clock.STATIC_CLOCKS[0];
    }//from   www.  j  av a2 s  .  c  o  m
    Fragment fragment;
    if (clock instanceof Clock.StaticClock) {
        Clock.StaticClock staticClock = (Clock.StaticClock) clock;
        fragment = staticClock.getFragment();
    } else {
        fragment = CoverAnalogClockFragment_.builder().clock(clock).build();
    }
    fragTransaction.add(R.id.clock_layout, fragment);
    fragTransaction.commit();

    adapter = new CoverAdapter(getActivity());
    mediaSessionListener = new MediaSessionListener();
    mediaSessionManager = (MediaSessionManager) getActivity().getSystemService(Context.MEDIA_SESSION_SERVICE);
    try {
        List<MediaController> mediaControllers = mediaSessionManager
                .getActiveSessions(new ComponentName(getActivity(), NotificationService_.class));
        adapter.onActiveSessionsChanged(mediaControllers);
        mediaSessionManager.addOnActiveSessionsChangedListener(mediaSessionListener,
                new ComponentName(getActivity(), NotificationService_.class));
    } catch (SecurityException ex) {
        // No notification access
    }

    mViewPager.setAdapter(adapter);
    mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            if (position == adapter.getDefaultFragmentPosition()) {
                currentNotification = null;
                menuSlide.setPanelHeight(getResources().getDimensionPixelSize(R.dimen.menu_panel_height));
            } else {
                currentNotification = adapter.getNotification(position);
                menuSlide.setPanelHeight(0);
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });
    new SwipeDetector(mViewPager, true).setOnSwipeListener(new SwipeDetector.onSwipeEvent() {
        @Override
        public void SwipeEventDetected(View v, SwipeDetector.SwipeTypeEnum SwipeType) {
            if (SwipeType == SwipeDetector.SwipeTypeEnum.TOP_TO_BOTTOM && menuSlide.getPanelHeight() > 0) {
                menuSlide.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED);
            }
        }
    });
}

From source file:de.lespace.apprtc.CallActivity.java

public void toggleCallControlFragmentVisibility() {
    if (!iceConnected || !callFragment.isAdded()) {
        return;/*from   w  w  w.ja  v  a2 s. co  m*/
    }
    // Show/hide call control fragment
    callControlFragmentVisible = !callControlFragmentVisible;
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    if (callControlFragmentVisible) {
        ft.show(callFragment);
        ft.show(hudFragment);
    } else {
        ft.hide(callFragment);
        ft.hide(hudFragment);
    }
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    ft.commit();
}

From source file:blackman.matt.infinitebrowser.NavigationDrawerFragment.java

/**
 * Users of this fragment must call this method to set up the navigation drawer interactions.
 *
 * @param fragmentId   The android:id of this fragment in its activity's layout.
 * @param drawerLayout The DrawerLayout containing this fragment's UI.
 *///  w  w  w  .j a v a  2s . co m
public void setUp(int fragmentId, DrawerLayout drawerLayout) {
    mFragmentContainerView = getActivity().findViewById(fragmentId);
    mDrawerLayout = drawerLayout;

    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the navigation drawer and the action bar app icon.
    mDrawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.navigation_drawer_open, /* "open drawer" description for accessibility */
            R.string.navigation_drawer_close /* "close drawer" description for accessibility */
    ) {
        /**
         * Handles the drawer being closed.
         *
         * @param drawerView The drawer being closed.
         */
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (!isAdded()) {
                return;
            }

            getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu()
        }

        /**
         * Handles the drawer being opened.
         *
         * @param drawerView The drawer being opened.
         */
        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (!isAdded()) {
                return;
            }

            if (!mUserLearnedDrawer) {
                // The user manually opened the drawer; store this flag to prevent auto-showing
                // the navigation drawer automatically in the future.
                mUserLearnedDrawer = true;
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
                sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
            }

            setUpListAdapter();
            getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu()
        }
    };

    mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String boardRoot = "/tech/";
            if (view instanceof TextView) {
                boardRoot = ((TextView) view).getText().toString();
            }

            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

            Board newBoard = Board.newInstance(boardRoot);

            fragmentTransaction.replace(R.id.container, newBoard, boardRoot);
            fragmentTransaction.addToBackStack(null);

            fragmentTransaction.commit();

            closeDrawer();
        }
    });

    // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer,
    // per the navigation drawer design guidelines.
    if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
        mDrawerLayout.openDrawer(mFragmentContainerView);
    }

    // Defer code dependent on restoration of previous instance state.
    mDrawerLayout.post(new Runnable() {
        @Override
        public void run() {
            mDrawerToggle.syncState();
        }
    });

    mDrawerLayout.setDrawerListener(mDrawerToggle);
}

From source file:com.telestax.restcomm_olympus.CallActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Set window styles for fullscreen-window size. Needs to be done before
    // adding content.
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN
            | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
            | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
            | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
    setContentView(R.layout.activity_call);

    // Initialize UI
    btnHangup = (ImageButton) findViewById(R.id.button_hangup);
    btnHangup.setOnClickListener(this);
    btnAnswer = (ImageButton) findViewById(R.id.button_answer);
    btnAnswer.setOnClickListener(this);
    btnAnswerAudio = (ImageButton) findViewById(R.id.button_answer_audio);
    btnAnswerAudio.setOnClickListener(this);
    btnMuteAudio = (ImageButton) findViewById(R.id.button_mute_audio);
    btnMuteAudio.setOnClickListener(this);
    btnMuteVideo = (ImageButton) findViewById(R.id.button_mute_video);
    btnMuteVideo.setOnClickListener(this);
    btnKeypad = (ImageButton) findViewById(R.id.button_keypad);
    btnKeypad.setOnClickListener(this);
    lblCall = (TextView) findViewById(R.id.label_call);
    lblStatus = (TextView) findViewById(R.id.label_status);
    lblTimer = (TextView) findViewById(R.id.label_timer);

    alertDialog = new AlertDialog.Builder(CallActivity.this).create();

    device = RCClient.listDevices().get(0);

    PreferenceManager.setDefaultValues(this, "preferences.xml", MODE_PRIVATE, R.xml.preferences, false);
    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    // Get Intent parameters.
    final Intent intent = getIntent();
    if (intent.getAction().equals(RCDevice.OUTGOING_CALL)) {
        btnAnswer.setVisibility(View.INVISIBLE);
        btnAnswerAudio.setVisibility(View.INVISIBLE);
    } else {/* w w  w  .  ja va 2s .  c  o  m*/
        btnAnswer.setVisibility(View.VISIBLE);
        btnAnswerAudio.setVisibility(View.VISIBLE);
    }

    keypadFragment = new KeypadFragment();

    lblTimer.setVisibility(View.INVISIBLE);
    // these might need to be moved to Resume()
    btnMuteAudio.setVisibility(View.INVISIBLE);
    btnMuteVideo.setVisibility(View.INVISIBLE);
    btnKeypad.setVisibility(View.INVISIBLE);

    activityVisible = true;

    // open keypad
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.add(R.id.keypad_fragment_container, keypadFragment);
    ft.hide(keypadFragment);
    ft.commit();

    //handleCall(intent);
}

From source file:com.example.corppool.controller.MainActivity.java

private void showFeedresults() {
    Fragment fragment = new Feeds_results();
    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.container, fragment); // fragment container id in first parameter is the  container(Main layout id) of Activity
    transaction.addToBackStack("feedresults"); // this will manage backstack
    transaction.commit();
}

From source file:com.dono.psakkos.dono.MainActivity.java

private void removeAllFragments() {
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

    LonelyFragment lonelyFragment = new LonelyFragment();
    fragmentTransaction.remove(lonelyFragment);

    LabelsFragment labelsFragment = new LabelsFragment();
    fragmentTransaction.remove(labelsFragment);

    AddLabelFragment addlabelFragment = new AddLabelFragment();
    fragmentTransaction.remove(addlabelFragment);

    KeyFragment keyFragment = new KeyFragment();
    fragmentTransaction.remove(keyFragment);

    fragmentTransaction.commit();

}

From source file:robert843.o2.pl.player.ui.PlaceholderActivity.java

private void navigateToBrowser(String mediaId) {
    LogHelper.d(TAG, "navigateToBrowser, mediaId=" + mediaId);
    MediaBrowserFragment fragment = getBrowseFragment();

    if (fragment == null || !TextUtils.equals(fragment.getMediaId(), mediaId)) {
        fragment = new MediaBrowserFragment();
        fragment.setMediaId(mediaId);//  w  w w. j  av  a2  s  .  co m
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.setCustomAnimations(R.animator.slide_in_from_right, R.animator.slide_out_to_left,
                R.animator.slide_in_from_left, R.animator.slide_out_to_right);
        transaction.replace(R.id.container, fragment);
        // If this is not the top level media (root), we add it to the fragment back stack,
        // so that actionbar toggle and Back will work appropriately:
        if (mediaId != null) {
            transaction.addToBackStack(null);
        }
        transaction.commit();
    }
}

From source file:com.example.corppool.controller.MainActivity.java

private void showMyFeeds() {
    Fragment fragment = new MyFeeds();
    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.container, fragment); // fragment container id in first parameter is the  container(Main layout id) of Activity
    transaction.addToBackStack("feedresultsTemp"); // this will manage backstack
    transaction.commit();
}