Example usage for android.app FragmentTransaction setCustomAnimations

List of usage examples for android.app FragmentTransaction setCustomAnimations

Introduction

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

Prototype

public abstract FragmentTransaction setCustomAnimations(@AnimatorRes int enter, @AnimatorRes int exit,
        @AnimatorRes int popEnter, @AnimatorRes int popExit);

Source Link

Document

Set specific animation resources to run for the fragments that are entering and exiting in this transaction.

Usage

From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java

public static void add(FragmentManager fm, SettingsLayoutFragment f) {
    boolean hasDialog = fm.findFragmentByTag(TAG_LEAN_BACK_DIALOG_FRAGMENT) != null;
    FragmentTransaction ft = fm.beginTransaction();

    if (hasDialog) {
        ft.setCustomAnimations(ANIMATION_FRAGMENT_ENTER, ANIMATION_FRAGMENT_EXIT, ANIMATION_FRAGMENT_ENTER_POP,
                ANIMATION_FRAGMENT_EXIT_POP);
        ft.addToBackStack(null);//from www  .j av a 2  s.  c om
    }
    ft.replace(android.R.id.content, f, TAG_LEAN_BACK_DIALOG_FRAGMENT).commit();
}

From source file:com.classiqo.nativeandroid_32bitz.ui.MusicPlayerActivity.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);//  www  .  j  a  va  2 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, FRAGMENT_TAG);

        if (mediaId != null) {
            transaction.addToBackStack(null);
        }
        transaction.commit();
    }
}

From source file:com.example.android.AudioArchive.ui.MusicPlayerActivity.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);/*from  w  w w . j ava2s  .  com*/
        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, FRAGMENT_TAG);
        // 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:ua.boberproduction.bbr.notes.NoteEditorFragment.java

@Override
public void showNote() {
    // put data into bundle
    Bundle bundle = new Bundle();
    bundle.putInt(getString(R.string.tag_noteId), note.getId());
    bundle.putString(getString(R.string.tag_articleid), note.getArticleId());
    bundle.putString(getString(R.string.notes_title), note.getTitle());
    bundle.putString(getString(R.string.notes_note_content), note.getText());
    // create and display fragment
    Fragment fragment = new NoteViewerFragment();
    fragment.setArguments(bundle);/*from  ww  w  . j  av  a 2  s.  c o  m*/
    FragmentTransaction ft = getActivity().getFragmentManager().beginTransaction();
    ft.setCustomAnimations(R.animator.slide_in_right, R.animator.slide_out_left, R.animator.slide_in_left,
            R.animator.slide_out_right);
    ft.replace(R.id.main_frame, fragment, getString(R.string.tag_content_fragment)).addToBackStack("edit")
            .commit();
}

From source file:rocks.stalin.android.app.ui.MusicPlayerActivity.java

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

    if (fragment == null || !TextUtils.equals(fragment.getMediaId(), mediaId)) {
        fragment = new MediaBrowserFragment();
        fragment.setMediaId(mediaId);//from w  w w. j  a va  2  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, FRAGMENT_TAG);
        // 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: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);/*from   w w w. j a  va  2  s .c  o 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.bayapps.android.robophish.ui.MusicPlayerActivity.java

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

    if (fragment == null || !TextUtils.equals(fragment.getMediaId(), mediaId)) {
        fragment = new MediaBrowserFragment();
        fragment.setMediaId(title, subtitle, mediaId);
        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, FRAGMENT_TAG);
        // 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);
        }//from   w  ww  .  j a  va  2  s  .c om
        transaction.commit();
    }
}

From source file:org.catnut.ui.PluginsActivity.java

public void flipCard(Fragment fragment, String tag, boolean backStack) {
    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    fragmentTransaction
            .setCustomAnimations(R.animator.card_flip_right_in, R.animator.card_flip_right_out,
                    R.animator.card_flip_left_in, R.animator.card_flip_left_out)
            .replace(android.R.id.content, fragment, tag);
    if (backStack) {
        fragmentTransaction.addToBackStack(null);
    }/* w  w  w  .j ava 2 s .  c  o m*/
    fragmentTransaction.commit();
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            invalidateOptionsMenu();
        }
    });
}

From source file:com.android.tv.settings.dialog.DialogFragment.java

public static void add(FragmentManager fm, DialogFragment f) {
    boolean hasDialog = fm.findFragmentByTag(TAG_LEAN_BACK_DIALOG_FRAGMENT) != null;
    FragmentTransaction ft = fm.beginTransaction();

    if (hasDialog) {
        ft.setCustomAnimations(ANIMATION_FRAGMENT_ENTER, ANIMATION_FRAGMENT_EXIT, ANIMATION_FRAGMENT_ENTER_POP,
                ANIMATION_FRAGMENT_EXIT_POP);
        ft.addToBackStack(null);//from  www . ja  va2  s.  c  o  m
    }
    ft.replace(android.R.id.content, f, TAG_LEAN_BACK_DIALOG_FRAGMENT).commit();
}

From source file:com.kriminal.main_activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//from www  . ja v  a2 s  .c  om

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);

    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null)
                    .show();
        }
    });

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    //Set fragments
    Class tasksView = TasksView.class;
    try {
        tasksList = (Fragment) tasksView.newInstance();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    //load list fragment
    Log.d(Utils.TAG, "before load fragment");
    if (savedInstanceState == null) {
        Log.d(Utils.TAG, "Going to load fragment");
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        //set animations
        transaction.setCustomAnimations(R.anim.enter, R.anim.exit, R.anim.pop_enter, R.anim.pop_exit);
        // transaction.addToBackStack(null);
        transaction.add(R.id.container, tasksList).commit();
    }

    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}