Example usage for android.app FragmentTransaction TRANSIT_FRAGMENT_FADE

List of usage examples for android.app FragmentTransaction TRANSIT_FRAGMENT_FADE

Introduction

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

Prototype

int TRANSIT_FRAGMENT_FADE

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

Click Source Link

Document

Fragment should simply fade in or out; that is, no strong navigation associated with it except that it is appearing or disappearing for some reason.

Usage

From source file:com.example.kyle.fragmentexample.MainActivity.java

public void replaceFragment(Fragment fragment) {
    FragmentManager manager = getFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();
    transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    transaction.replace(R.id.fragment_container, fragment);
    transaction.addToBackStack(null);/* w w w. j ava 2  s.c  o  m*/
    transaction.commit();
}

From source file:com.microsoft.office365.starter.FilesFolders.FileDetailActivity.java

private void updateActionHandler() {
    // Display the update fragment
    FileUpdateFragment updateFragment = new FileUpdateFragment();
    FragmentManager fragmentManager = getFragmentManager();
    android.app.FragmentTransaction ft = fragmentManager.beginTransaction();
    ft.replace(R.id.file_detail_container, updateFragment, UPDATE_FRAGMENT_STACK_STATE);
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    ft.addToBackStack(UPDATE_FRAGMENT_STACK_STATE);
    ft.commit();/*w w w  .  j a  va 2  s  .  c  o m*/
}

From source file:com.notriddle.budget.EnvelopesActivity.java

@Override
public void onCreate(Bundle state) {
    super.onCreate(state);
    setContentView(R.layout.activity);/*www  .  jav a2  s . c o  m*/
    setupActionBarBackground();
    setupDrawer();

    if (state == null) {
        final Intent i = getIntent();
        final Bundle args = i.getExtras();
        final Uri data = i.getData();
        final String fragmentName = data != null ? data.getHost() : EnvelopesFragment.class.getName();
        try {
            topFragment(Class.forName(fragmentName), FragmentTransaction.TRANSIT_FRAGMENT_FADE, args);
        } catch (Exception e) {
            throw new Error(e);
        }
    } else {
        configureFragment(getFragmentManager().findFragmentById(R.id.content_frame));
    }
}

From source file:com.afrozaar.jazzfestreporting.PlayActivity.java

public void panToVideo(final String youtubeId) {
    popPlayerFromBackStack();//from   w w  w . ja  va  2  s . c  om
    YouTubePlayerFragment playerFragment = YouTubePlayerFragment.newInstance();
    getFragmentManager().beginTransaction().replace(R.id.detail_container, playerFragment, YOUTUBE_FRAGMENT_TAG)
            .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).addToBackStack(null).commit();
    playerFragment.initialize(Auth.KEY, new YouTubePlayer.OnInitializedListener() {
        @Override
        public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer,
                boolean b) {
            youTubePlayer.loadVideo(youtubeId);
            mYouTubePlayer = youTubePlayer;
            youTubePlayer.setPlayerStateChangeListener(PlayActivity.this);
            youTubePlayer.setOnFullscreenListener(PlayActivity.this);
        }

        @Override
        public void onInitializationFailure(YouTubePlayer.Provider provider,
                YouTubeInitializationResult result) {
            showErrorToast(result.toString());
        }
    });
}

From source file:org.youtube.Youtube_PlayActivity.java

public void panToVideo(final String youtubeId) {
    popPlayerFromBackStack();// w  w w  . ja v a2 s. co  m
    YouTubePlayerFragment playerFragment = YouTubePlayerFragment.newInstance();
    getFragmentManager().beginTransaction().replace(R.id.detail_container, playerFragment, YOUTUBE_FRAGMENT_TAG)
            .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).addToBackStack(null).commit();
    playerFragment.initialize(Youtube_Auth.KEY, new YouTubePlayer.OnInitializedListener() {
        @Override
        public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer,
                boolean b) {
            youTubePlayer.loadVideo(youtubeId);
            mYouTubePlayer = youTubePlayer;
            youTubePlayer.setPlayerStateChangeListener(Youtube_PlayActivity.this);
            youTubePlayer.setOnFullscreenListener(Youtube_PlayActivity.this);
        }

        @Override
        public void onInitializationFailure(YouTubePlayer.Provider provider,
                YouTubeInitializationResult result) {
            showErrorToast(result.toString());
        }
    });
}

From source file:com.android.mail.ui.TwoPaneController.java

/**
 * Render the conversation list in the correct pane.
 *///  ww w.j  a  v a2 s.c  o m
private void renderConversationList() {
    if (mActivity == null) {
        return;
    }
    FragmentTransaction fragmentTransaction = mActivity.getFragmentManager().beginTransaction();
    // Use cross fading animation.
    fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    final Fragment conversationListFragment = ConversationListFragment.newInstance(mConvListContext);
    fragmentTransaction.replace(R.id.conversation_list_pane, conversationListFragment, TAG_CONVERSATION_LIST);
    fragmentTransaction.commitAllowingStateLoss();
}

From source file:com.cdhxqh.inventorymovement.ui.MainActivity.java

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
    mSelectPos = position;// ww w .j a v a 2s. co m

    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);

    switch (position) {
    case 0://
        titleTextView.setText(adapter.getTitle(position));
        searchButton.setVisibility(View.VISIBLE);
        if (newItemFragment == null) {
            newItemFragment = new ItemFragment();
            Bundle bundle = new Bundle();
            bundle.putString("text", adapter.getTitle(position));
            newItemFragment.setArguments(bundle);
        }
        fragmentTransaction.replace(R.id.content_frame, newItemFragment).commit();
        drawer.closeDrawer(mDrawerList);
        break;
    case 1://?
        titleTextView.setText(adapter.getTitle(position));
        searchButton.setVisibility(View.VISIBLE);
        if (newPoFragemnt == null) {
            newPoFragemnt = new PoFragment();
            Bundle bundle = new Bundle();
            bundle.putString("text", adapter.getTitle(position));
            newPoFragemnt.setArguments(bundle);
        }
        fragmentTransaction.replace(R.id.content_frame, newPoFragemnt).commit();
        drawer.closeDrawer(mDrawerList);
        break;
    case 2://?
        titleTextView.setText(adapter.getTitle(position));
        searchButton.setVisibility(View.VISIBLE);
        if (newWorkorderFragment == null) {
            newWorkorderFragment = new WorkorderFragment();
            Bundle bundle = new Bundle();
            bundle.putString("text", adapter.getTitle(position));
            newWorkorderFragment.setArguments(bundle);
        }
        fragmentTransaction.replace(R.id.content_frame, newWorkorderFragment).commit();
        drawer.closeDrawer(mDrawerList);
        break;
    case 3://
        titleTextView.setText(adapter.getTitle(position));
        searchButton.setVisibility(View.VISIBLE);
        if (newCheckFragment == null) {
            newCheckFragment = new CheckFragment();
            Bundle bundle = new Bundle();
            bundle.putString("text", adapter.getTitle(position));
            newCheckFragment.setArguments(bundle);
        }
        fragmentTransaction.replace(R.id.content_frame, newCheckFragment).commit();
        drawer.closeDrawer(mDrawerList);
        break;
    case 4://
        titleTextView.setText(adapter.getTitle(position));
        searchButton.setVisibility(View.VISIBLE);
        if (newPoFragemnt == null) {
            newLocationFragment = new LocationFragment();
            Bundle bundle = new Bundle();
            bundle.putString("text", adapter.getTitle(position));
            newLocationFragment.setArguments(bundle);
        }
        fragmentTransaction.replace(R.id.content_frame, newLocationFragment).commit();
        drawer.closeDrawer(mDrawerList);
        break;
    //            case 5://???
    //                titleTextView.setText(adapter.getTitle(position));
    //                searchButton.setVisibility(View.GONE);
    //                if (newTypoFragment == null) {
    //                    newTypoFragment = new TypoFragment();
    //                    Bundle bundle = new Bundle();
    //                    bundle.putString("text", adapter.getTitle(position));
    //                    newTypoFragment.setArguments(bundle);
    //                }
    //                fragmentTransaction.replace(R.id.content_frame, newTypoFragment).commit();
    //                drawer.closeDrawer(mDrawerList);
    //                break;
    case 5://
        titleTextView.setText(adapter.getTitle(position));
        searchButton.setVisibility(View.VISIBLE);
        if (newInVFragment == null) {
            newInVFragment = new InVFragment();
            Bundle bundle = new Bundle();
            bundle.putString("text", adapter.getTitle(position));
            newInVFragment.setArguments(bundle);
        }
        fragmentTransaction.replace(R.id.content_frame, newInVFragment).commit();
        drawer.closeDrawer(mDrawerList);
        break;
    case 6://?
        titleTextView.setText(adapter.getTitle(position));
        searchButton.setVisibility(View.VISIBLE);
        if (newItemreqFragment == null) {
            newItemreqFragment = new ItemreqFragment();
            Bundle bundle = new Bundle();
            bundle.putString("text", adapter.getTitle(position));
            newItemreqFragment.setArguments(bundle);
        }
        fragmentTransaction.replace(R.id.content_frame, newItemreqFragment).commit();
        drawer.closeDrawer(mDrawerList);
        break;

    case 7: //
        showAlertDialog();
        searchButton.setVisibility(View.GONE);
        drawer.closeDrawer(mDrawerList);
        break;
    default:
        titleTextView.setText(adapter.getTitle(position));
        Fragment contentFragment = new ContentFragment();
        Bundle args = new Bundle();
        args.putString("text", adapter.getTitle(position));
        contentFragment.setArguments(args);

        fragmentTransaction.replace(R.id.content_frame, contentFragment).commit();

        drawer.closeDrawer(mDrawerList);
        break;
    }

}

From source file:com.notriddle.budget.EnvelopesActivity.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
    mDrawerLayout.closeDrawers();//from  w w  w.ja v  a 2s. co m
    topFragment(mNavAdapter.getItem(pos), FragmentTransaction.TRANSIT_FRAGMENT_FADE, null);
}

From source file:com.ternup.caddisfly.activity.MainActivity.java

/**
 * Display view fragment for selected nav drawer menu option
 *///from   w  w  w. j  a v  a2 s.  com
public void displayView(int position, boolean addToBackStack) {

    int index = getCurrentFragmentIndex();

    if (index == position) {
        // requested fragment is already showing
        return;
    }

    Fragment fragment;
    showCheckUpdateOption = false;
    switch (position) {
    case Globals.HOME_SCREEN_INDEX:
        if (homeFragment == null) {
            homeFragment = new HomeFragment();
        }
        fragment = homeFragment;
        break;
    case Globals.LOCATION_LIST_SCREEN_INDEX:
        if (mLocationListFragment == null) {
            mLocationListFragment = new LocationListFragment();
        }
        fragment = mLocationListFragment;
        break;
    case Globals.CALIBRATE_SCREEN_INDEX:
        if (calibrateFragment == null) {
            calibrateFragment = new CalibrateFragment();
        }
        fragment = calibrateFragment;
        break;
    case Globals.SETTINGS_SCREEN_INDEX:
        showCheckUpdateOption = true;
        if (settingsFragment == null) {
            settingsFragment = new SettingsFragment();
        }
        fragment = settingsFragment;
        break;
    case Globals.HELP_SCREEN_INDEX:
        showCheckUpdateOption = true;
        if (helpFragment == null) {
            helpFragment = new HelpFragment();
        }
        fragment = helpFragment;
        break;
    case Globals.ABOUT_SCREEN_INDEX:
        showCheckUpdateOption = true;
        if (aboutFragment == null) {
            aboutFragment = new AboutItFragment();
        }
        fragment = aboutFragment;
        break;
    default:
        toggleTheme();
        return;
    }
    invalidateOptionsMenu();
    if (fragment != null) {

        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction ft = fragmentManager.beginTransaction();
        ft.replace(R.id.container, fragment, String.valueOf(position));
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        if (addToBackStack) {
            ft.addToBackStack(null);
        }
        ft.commit();
    }
    mNavigationDrawerFragment.checkItem(position);
}

From source file:fr.cph.chicago.activity.MainActivity.java

@Override
public final void onNavigationDrawerItemSelected(final int position) {
    int oldPosition = mCurrentPosition;
    mCurrentPosition = position;/*from  w w w. j av a  2  s .  c  om*/
    // update the main content by replacing fragments
    final FragmentManager fragmentManager = getFragmentManager();
    final FragmentTransaction ft = fragmentManager.beginTransaction();
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    switch (position) {
    case POSITION_FAVORITES:
        if (mFavoritesFragment == null) {
            mFavoritesFragment = FavoritesFragment.newInstance(position + 1);
        }
        if (!this.isFinishing()) {
            ft.replace(R.id.container, mFavoritesFragment).commit();
        }
        break;
    case POSITION_TRAIN:
        if (mTrainFragment == null) {
            mTrainFragment = TrainFragment.newInstance(position + 1);
        }
        if (!this.isFinishing()) {
            ft.replace(R.id.container, mTrainFragment).commit();
        }
        break;
    case POSITION_BUS:
        if (mBusFragment == null) {
            mBusFragment = BusFragment.newInstance(position + 1);
        }
        if (!this.isFinishing()) {
            ft.replace(R.id.container, mBusFragment).commit();
        }
        break;
    case POSITION_DIVVY:
        if (mBikeFragment == null) {
            mBikeFragment = BikeFragment.newInstance(position + 1);
        }
        if (!this.isFinishing()) {
            ft.replace(R.id.container, mBikeFragment).commit();
        }
        break;
    case POSITION_NEARBY:
        if (mNearbyFragment == null) {
            mNearbyFragment = NearbyFragment.newInstance(position + 1);
            if (!this.isFinishing()) {
                ft.replace(R.id.container, mNearbyFragment).commit();
            }
        } else {
            if (oldPosition == 4) {
                fragmentManager.beginTransaction().commit();
            } else {
                if (!this.isFinishing()) {
                    ft.replace(R.id.container, mNearbyFragment).commit();
                }
            }
        }
        break;
    case POSITION_ALERTS:
        if (mAlertFragment == null) {
            mAlertFragment = AlertFragment.newInstance(position + 1);
        }
        if (!this.isFinishing()) {
            ft.replace(R.id.container, mAlertFragment).commit();
        }
        break;
    case POSITION_MAP:
        if (mMapFragment == null) {
            mMapFragment = MapFragment.newInstance(position + 1);
        }
        if (!this.isFinishing()) {
            ft.replace(R.id.container, mMapFragment).commit();
        }
        break;
    case POSITION_SETTINGS:
        if (mSettingsFragment == null) {
            mSettingsFragment = SettingsFragment.newInstance(position + 1);
        }
        if (!this.isFinishing()) {
            ft.replace(R.id.container, mSettingsFragment).commit();
        }
        break;
    }
}