Skip to content

Navigation

kyleduo edited this page Mar 12, 2018 · 1 revision

The most frequently used API should be From-To-Start pattern. And now I’m going to tell you the detail of it.

There are all the support APIs when you invoke this pattern.

Rabbit.from(this)
    .to(P.P_TEST)
    .putExtra("param", "value")
    .putExtras(new Bundle())
    .putExtras(new HashMap<String, Object>())
    .addInterceptor(new Interceptor() {})
    .addInterceptor(new Interceptor() {}, new Rule() {})
    .ignoreInterceptors()
    .ignoreFallback()
    .redirect()
    .setTransitionAnimations(new int[]{})
    .forResult(0)
    .addIntentFlags(0)
    .setIntentFlags(0)
    .singleTop()
    .clearTop()
    .newTask()
    .justObtain()
    .start();
  • Rabbit.from(Object) Create a Builder instance.
  • Rabbit.Builder.to(String) This is the only method of Builder. It will create a Navigation instance witch will handler all the configuration before you start an Action.
  • Navigation.putExtra(String, Object) Add a param in any format.
  • Navigation.putExtras(Bundle) Add a batch of params in Bundle format.
  • Navigation.putExtras(Map<String, Object>) Add a batch of params in Map format.
  • Navigation.addInterceptor(Interceptor) Add an interceptor only for this Navigation.
  • Navigation.addInterceptor(Interceptor, Rule) Add an interceptor only for this Navigation works only if the Rule match the Action.
  • Navigation.ignoreInterceptors() Ignore custom Interceptors both add to Rabbit and this Navigation.
  • Navigation.ignoreFallback() Ignore fallback. Nothing happened if the url does not match any pages.
  • Navigation.redirect() close previous page.
  • Navigation.setTransitionAnimations(int[]) literal meaning
  • Navigation.forResult(int) If called, start() will works like startForResult(int).
  • Navigation.addIntentFlags(int) literal meaning
  • Navigation.setIntentFlags(int) literal meaning
  • Navigation.singleTop() add Intent.FLAG_ACTIVITY_SINGLE_TOP flag.
  • Navigation.clearTop() add Intent.FLAG_ACTIVITY_CLEAR_TOP flag.
  • Navigation.newTask() add Intent.FLAG_ACTIVITY_NEW_TASK flag.
  • Navigation.justObtain() If called, start() will works like obtain().

The start() method can be replace to other methods:

  • startForResult(int) Same as Activity.startForResult(int), equals to Navigation.forResult(int).start().
  • obtain() Do not perform a navigation, but return the target, an Intent or a Fragment instance. Equals to Navigation.justObtain().start().

Result

Invoke this API will get a RabbitResult instance. You can get state, error reason and event the target instance from it.