88import android .os .Parcelable ;
99import android .support .annotation .IntDef ;
1010import android .support .annotation .Nullable ;
11+ import android .support .annotation .RequiresApi ;
12+ import android .support .v4 .app .ActivityOptionsCompat ;
1113import android .util .SparseArray ;
1214
1315import com .alibaba .android .arouter .facade .callback .NavigationCallback ;
2527 * A container that contains the roadmap.
2628 *
2729 * @author Alex <a href="mailto:zhilong.liu@aliyun.com">Contact me.</a>
28- * @version 1.0
30+ * @version 1.1. 0
2931 * @since 16/8/22 19:16
3032 */
3133public final class Postcard extends RouteMeta {
34+ // Base
3235 private Uri uri ;
3336 private Object tag ; // A tag prepare for some thing wrong.
34- private Bundle mBundle ; // Data to tranform
37+ private Bundle mBundle ; // Data to transform
3538 private int flags = -1 ; // Flags of route
36- private int timeout = 300 ; // Navigation timeout, TimeUnit.Second !
39+ private int timeout = 300 ; // Navigation timeout, TimeUnit.Second
3740 private IProvider provider ; // It will be set value, if this postcard was provider.
38- private boolean greenChannal ;
41+ private boolean greenChannel ;
42+
43+ // Animation
44+ private Bundle optionsCompat ; // The transition animation of activity
45+ private int enterAnim ;
46+ private int exitAnim ;
47+
48+ public Bundle getOptionsBundle () {
49+ return optionsCompat ;
50+ }
51+
52+ public int getEnterAnim () {
53+ return enterAnim ;
54+ }
55+
56+ public int getExitAnim () {
57+ return exitAnim ;
58+ }
3959
4060 public IProvider getProvider () {
4161 return provider ;
@@ -61,8 +81,8 @@ public Postcard(String path, String group, Uri uri, Bundle bundle) {
6181 this .mBundle = (null == bundle ? new Bundle () : bundle );
6282 }
6383
64- public boolean isGreenChannal () {
65- return greenChannal ;
84+ public boolean isGreenChannel () {
85+ return greenChannel ;
6686 }
6787
6888 public Object getTag () {
@@ -149,12 +169,12 @@ public void navigation(Activity mContext, int requestCode, NavigationCallback ca
149169 }
150170
151171 /**
152- * Green channal , it will skip all of interceptors.
172+ * Green channel , it will skip all of interceptors.
153173 *
154174 * @return this
155175 */
156176 public Postcard greenChannel () {
157- this .greenChannal = true ;
177+ this .greenChannel = true ;
158178 return this ;
159179 }
160180
@@ -540,8 +560,47 @@ public Postcard withBundle(@Nullable String key, @Nullable Bundle value) {
540560 return this ;
541561 }
542562
563+ /**
564+ * Set normal transition anim
565+ *
566+ * @param enterAnim enter
567+ * @param exitAnim exit
568+ * @return current
569+ */
570+ public Postcard withTransition (int enterAnim , int exitAnim ) {
571+ this .enterAnim = enterAnim ;
572+ this .exitAnim = exitAnim ;
573+ return this ;
574+ }
575+
576+ /**
577+ * Set options compat
578+ *
579+ * @param compat compat
580+ * @return this
581+ */
582+ @ RequiresApi (16 )
583+ public Postcard withOptionsCompat (ActivityOptionsCompat compat ) {
584+ if (null != compat ) {
585+ this .optionsCompat = compat .toBundle ();
586+ }
587+ return this ;
588+ }
589+
543590 @ Override
544591 public String toString () {
545- return "Postcard " + super .toString ();
592+ return "Postcard{" +
593+ "uri=" + uri +
594+ ", tag=" + tag +
595+ ", mBundle=" + mBundle +
596+ ", flags=" + flags +
597+ ", timeout=" + timeout +
598+ ", provider=" + provider +
599+ ", greenChannel=" + greenChannel +
600+ ", optionsCompat=" + optionsCompat +
601+ ", enterAnim=" + enterAnim +
602+ ", exitAnim=" + exitAnim +
603+ "}\n " +
604+ super .toString ();
546605 }
547606}
0 commit comments