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

Develop Apps Super fast with Android Jetpack!

Divya Jain
October 22, 2018

Develop Apps Super fast with Android Jetpack!

Worried about writing tons of boilerplate code and managing tedious activities and tasks while writing Android apps? Well here comes Android Jetpack to the rescue.
Agenda: 1. A brief introduction about the four different Android Jetpack component categories -Foundation, Architecture,Behavior, UI. 2. Deep dive into the Android component libraries that are individually adoptable but work well together to develop robust and high quality apps with great user experience.

Divya Jain

October 22, 2018
Tweet

More Decks by Divya Jain

Other Decks in Programming

Transcript

  1. Put the pieces of the puzzle together... To create something

    beautiful , user friendly & serves a purpose
  2. Challenges in Android Dev • Tons of Boilerplate Code •

    Clean Architecture • Testing • Backward compatibility
  3. What is it? • Collection of individual software components -

    libraries and tools • Independently adoptable • Built to work together • Unbundled from Platform APIs
  4. FOUNDATION AppCompat Android KTX Multidex Testing * Core System Components

    *Kotlin *Backward Compatibility *Testing Libraries
  5. UI Layout Fragment Palette Emoji Animations and Transitions Auto TV

    Wear * Widgets and helpers *Easy to use *Enhanced User experience
  6. ARCHITECTURE Lifecycles Livedata Paging Navigation WorkManager Room Viewmodel Data Binding

    *Clean & Recommended *Data Management *Robust, scalable & Maintainable
  7. BEHAVIOUR Notifications Permissions Sharing Slices Media & Playback Download Manager

    * Integrate with other Android services *help interact with user
  8. Foundation UI Architecture Behaviour Easier to Develop Follow Best Practices

    Reduces Boilerplate code Simplify tasks Reduces Memory crashes Lessens memory leaks
  9. AndroidX New improved Android Support Library with consistent Namespacing ,

    faster updates , feature parity & new libraries androidx.* androidx.<feature>.ClassName androidx.<feature>:<feature>-<sub-feature>
  10. Migrate to AndroidX gradle.properties file : Changes in Package and

    Maven Artifact names https://developer.android.com/jetpack/androidx/migrate
  11. FOUNDATION AppCompat Android KTX Multidex Testing * Core System Components

    *Kotlin *Backward Compatibility *Testing Libraries
  12. Android KTX Kotlin Extension Function Null Safety Default & named

    arguments Higher order functions Smart Cast Leverages Kotlin Features Optimizes Android APIs with Kotlin Makes Android Development - concise - enjoyable - intuitive
  13. Android KTX Parse a string to a URI val uri

    = Uri.parse(custom_string) Val uri = custom_string.toUri() import android.view.Menu import androidx.core.view.get import androidx.core.view.minusAssign fun myFunction(menu : Menu) { val firstMenuItem = menu[0] //Gets the first menu item. menu -= firstMenuItem // Removes the menu item } Menu Class • Core KTX • Fragment KTX • Palette KTX • Collections KTX • SQLite KTX • Navigation KTX Build.gradle implementation "androidx.core:core-ktx:$androidx_version"
  14. UI Layout Fragment Palette Emoji Animations and Transitions Auto TV

    Wear * Widgets and helpers *Easy to use *Enhanced User experience
  15. Fragment • Dynamic and Flexible UI Designs • Support different

    screens • Reusable UI components 1. implementation 'androidx.fragment:fragment-ktx:$currentVersion' supportFragmentManager.transaction(now = false, allowStateLoss = false) { replace(R.id.frag_container, myFragment,FRAGMENT_TAG) }
  16. Palette API 1. • Vibrant color schemes • Visually appealing

    • Pick and choose • Various layout themes fun createPaletteSync(bitmap: Bitmap): Palette = Palette.from(bitmap).generate() fun createPaletteAsync(bitmap: Bitmap) { Palette.from(bitmap).generate { palette -> // Use generated instance } }
  17. Emoji Compat 1. • Device up to date with Latest

    • No need to wait for OS updates • Prevents showing missing ✋ • Identifies emoji for a given CharSequence, replaces them with EmojiSpan & renders ✅
  18. Animations 1. Visual Cue to notify users of changes! •

    Informative • Focus • Expressive
  19. ARCHITECTURE Lifecycles Livedata Paging Navigation WorkManager Room Viewmodel Data Binding

    *Clean & Recommended *Data Management *Robust, scalable & Maintainable
  20. Architecture Components • Separation of concerns • Drive UI from

    model • Persistence of data • Independent testing
  21. Paging ➔ Lazy Loading of Data ➔ Economical use of

    system resources ➔ Responsive to the user input without a lag DataSource DataSource Factory ViewModel PagedList PagedList Adapter
  22. Data Binding Bind UI elements to the data sources programmatically

    UI Framework methods findViewById() Bind UI elements to the data sources in a declarative format Remove UI Framework methods <TextView android:text="@{viewmodel.userName}" />
  23. BEHAVIOUR Notifications Permissions Sharing Slices Media & Playback Download Manager

    * Integrate with other Android services *help interact with user
  24. Want to download something? Download Manager • System service •

    Handles HTTP Downloads • Background • Handles interactions • Takes care of retrying Want to share something? ShareActionProvider • Menu item • Handles appearance & behaviour • Needs a share intent
  25. Want to Notify user? NotificationCompat • Info to user outside

    App • Informative/action oriented • Timely reminders • Frequent interruptions are annoying Permissions <uses-permission> • Privacy of user • Permission to access sensitive user data • Dangerous permission on demand
  26. Slices Embed App content in Google Search through flexible templates

    Templated Show relevant app content in a dynamic, app theme user interface Interactive Enable user to perform inline, app actions, deep link, update, toggle Modular
  27. Valley Devfest 2018 App Data --------- --------- --------- --------- ---------

    ------- ----- User Interface Repository Model View ViewModel Livedata Room Fragments Animations Layouts Navigation Caching Notifications ShareActionProvider
  28. Android Jetpack has all the pieces needed for putting together

    the app Choose and pick the ones you need, integrate App is Ready in no time!