Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Exploring View-Base Application with Conductor

Esa Firman
December 08, 2017

Exploring View-Base Application with Conductor

Esa Firman

December 08, 2017

More Decks by Esa Firman

Other Decks in Programming


  1. Exploring View-Based Application with Conductor Esa Firman

  2. What’s the worst thing that could happen when you’re using

    Android Activity as your page representation?
  3. ¯\_(ツ)_/¯ #MintaPutus

  4. Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {...};

    have you declared this activity in your AndroidManifest.xml?
  5. None
  6. Task and Back Stack Intent intent = new Intent(LoginActivity.this, MainMenuActivity.class);

    intent.addFlags(...) // FLAG_ACTIVITY_CLEAR_TOP, NEW_TASK, etc ... startActivity(intent); finish(); Or use `launchMode` in AndroidManifest.xml
  7. Task and Back Stack TaskStackBuilder -> https://developer.android.com/reference/android/support/v4/app/TaskStackBuil der.html

  8. What about Fragment? • Introduce more complex lifecycle • Never

    use it since last year ( expect for Google Map ) • ¯\_(ツ)_/¯
  9. What about Fragment? IllegalStateException: Can not perform this action after

  10. What about Fragment? Advocation Against Android Fragments - Piwai https://medium.com/square-corner-blog/advocating-against-android-fragments-81fd0b462c97

  11. What’s the option? • Flow + Custom / Compound View

    • Scoop • Conductor
  12. Conductor A small, yet full-featured framework that allows building View-based

    Android applications. Conductor provides a light-weight wrapper around standard Android Views that does just about everything you'd want
  13. None
  14. #SimpleTapiPasten

  15. Components • Controller • Router • ControllerChangeHandler • ControllerTransaction

  16. Controller The Controller is the View wrapper that will give

    you all of your lifecycle management features. Think of it as a lighter-weight and more predictable Fragment alternative with an easier to manage lifecycle. TL;DR this is your Fragment
  17. Controller

  18. Router A Router implements navigation and backstack handling for Controllers.

    Router objects are attached to Activity/containing ViewGroup pairs. Routers do not directly render or push Views to the container ViewGroup, but instead defer this responsibility to the ControllerChangeHandler specified in a given transaction. TL;DR this is your FragmentManager
  19. Router

  20. ControllerChangeHandlers ControllerChangeHandlers are responsible for swapping the View for one

    Controller to the View of another. They can be useful for performing animations and transitions between Controllers. Several default ControllerChangeHandlers are included.
  21. ControllerTransaction Transactions are used to define data about adding Controllers.

    RouterControllerTransactions are used to push a Controller to a Router with specified ControllerChangeHandlers, while ChildControllerTransactions are used to add child Controllers. TL;DR this is your FragmentTransaction
  22. ControllerTransaction

  23. None
  24. None
  25. DEMO TIME!

  26. None
  27. #CodeRelationshipGoal

  28. Bonus ~ Conductor Extra #Kemevvahan

  29. Bonus ~ Android Conductor Generator #SayaSukaKemevvahan

  30. Links • https://github.com/bluelinelabs/Conductor • https://github.com/esafirm/conductor-extra • https://github.com/esafirm/generator-android-conductor • https://github.com/esafirm/android-conductor-boilerplate •

  31. Thank You! Esa Firman Github: https://github.com/esafirm Twitter: https://twitter.com/esafirm Telegram: @esafirm

    Tinder: Belum buat Check out my portfolio -> bit.ly/re-portfolio