Example usage for android.app FragmentTransaction TRANSIT_ENTER_MASK

List of usage examples for android.app FragmentTransaction TRANSIT_ENTER_MASK

Introduction

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

Prototype

int TRANSIT_ENTER_MASK

To view the source code for android.app FragmentTransaction TRANSIT_ENTER_MASK.

Click Source Link

Document

Bit mask that is set for all enter transitions.

Usage

From source file:com.smart.taxi.activities.ContainerActivity.java

public void selectItem(int position) {
    Fragment fragment;/*  w  w  w  . java 2 s.  c o  m*/
    String tag = null;
    if (lastIndex == position && lastFragment instanceof TripRequestFragment
            && SplashActivity.isTripRequested) {
        if (tripRequestRef != null) {
            tripRequestRef.reset(null);
        }
        return;
    } else {
        if (position != 5)
            lastIndex = position;
        switch (position) {
        case 0:
            if (SplashActivity.isTripRequested && SplashActivity.getTripNewDetails() != null) {
                fragment = new TripRequestFragment();
                tag = TripRequestFragment.TAG;
            } else {
                fragment = new FindARideFragment();
                tag = FindARideFragment.TAG;
            }
            break;
        case 1:
            fragment = new CurrentTripFragment();
            tag = CurrentTripFragment.TAG;
            break;
        case 2:
            fragment = new TripHistoryFragment();
            tag = TripHistoryFragment.TAG;
            break;

        case 3:
            fragment = new ProfileFragment();
            tag = ProfileFragment.TAG;
            break;

        case 4:
            if (SplashActivity.loggedInUser.isCorporateUser()) {
                lastIndex = 0;
                Intent intent = new Intent(this, BarcodeActivity.class);
                startActivity(intent);
                return;
            } else {
                fragment = new PaymentOptionsFragment();
                tag = PaymentOptionsFragment.TAG;
                break;
            }
        case 5:
            fragment = new ChangeTipFragment();
            tag = ChangeTipFragment.TAG;
            break;

        case 6:
            SplashActivity.doLogoutAction = true;
            SplashActivity.logout();
            lastIndex = 0;
            lastFragment = null;
            finish();
            return;

        default:
            mDrawerLayout.closeDrawer(mDrawer);
            return;
        }
        lastFragment = fragment;

        FragmentManager manager = getFragmentManager();

        manager.beginTransaction().setTransition(FragmentTransaction.TRANSIT_ENTER_MASK)
                .replace(R.id.content_frame, fragment).addToBackStack(tag).commit();
        mDrawerList.setItemChecked(position, true);
        setTitle(mNavigationLabels[position]);
        mDrawerLayout.closeDrawer(mDrawer);
    }

    // update the main content by replacing fragments
    /*Fragment fragment = new PlanetFragment();
    Bundle args = new Bundle();
    args.putInt(PlanetFragment.ARG_PLANET_NUMBER, position);
    fragment.setArguments(args);
            
    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
            
    // update selected item and title, then close the drawer
    mDrawerList.setItemChecked(position, true);
    setTitle(mNavigationLabels[position]);
    mDrawerLayout.closeDrawer(mDrawerList);*/
}