Skip to content
This repository was archived by the owner on Jul 9, 2019. It is now read-only.

PushBody

bkolarov-appolica edited this page Apr 11, 2017 · 5 revisions

As you already know, all fragments are added using a FragmentTransaction. PushBody is a wrapper object of such transaction.

API

PushBody.Builder

Set all properties for the FragmentTransaction by using this builder.

  • Builder addToBackStack(boolean) - Pass true if you want the transaction for showing your fragment to be added to FragmentManager's back stack, false otherwise.
  • Builder fragment(FragmentProvider) - Tell which fragment you want to show, by passing a corresponding FragmentProvider implementation. The tag for this fragment will be obtained from the FragmentProvider.
  • Builder fragment(FragmentProvider,String) - Same as PushBody.Builder#fragment(FragmentProvider), but you have pass the fragment's tag explicitly.
  • Builder withAnimation(boolean) - Pass true to this method if you like to show your fragment using default animations. There is no animation by default.
  • TransitionAnimationBody customAnimation() - If you want to set a custom animation for showing your fragment, this is what you have to use.This method will return a TransitionAnimationBody object, to which you have to set your animations.
  • Builder immediate(boolean) - Pass true if you want the operation for adding your fragment to be committed immediately. If you pass true to this method, there will be no need of calling FragmentManager#executePendingTransactions() afterwards.
  • PushBody build() - Create the PushBody object for your fragment. This object can be passed then to FragmentController#push(PushBody).
  • void push() - Directly push the fragment which's PushBody your were building for. This method calls Builder#build() internally.

TransitionAnimationBody

This class holds the four animation ids for animating the fragments when executing the transaction for showing you fragment. The default animations in this class are:

  • enter - sline in right
  • exit - slide out left
  • popEnter - slide in left
  • popExit - slide out right

Methods:

  • TransitionAnimationBody enter(int) - Set the resource id for your enter animation.
  • TransitionAnimationBody exit(int) - Set the resource id for your exit animation.
  • TransitionAnimationBody popEnter(int) - Set the resource id for your popEnter animation.
  • TransitionAnimationBody popExit(int) - Set the resource id for your popExit animation.
  • PushBody.Builder end() - Return back to building your PushBody.
Clone this wiki locally