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

Develop Apps Super fast with Android Jetpack!

Divya Jain
February 02, 2019

Develop Apps Super fast with Android Jetpack!

Divya Jain

February 02, 2019
Tweet

More Decks by Divya Jain

Other Decks in Technology

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 lambdas
  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. Responsive Layout ViewGroup View View ViewGroup View View <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/root_view"

    android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/margin">
  16. 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) }
  17. 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 } }
  18. 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 ✅
  19. Animations 1. Visual Cue to notify users of changes! •

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

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

    model • Persistence of data • Independent testing
  22. 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
  23. 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}" />
  24. BEHAVIOUR Notifications Permissions Sharing Slices Media & Playback Download Manager

    * Integrate with other Android services *help interact with user
  25. 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
  26. 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
  27. 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
  28. DevFest MN App 2019 Data --------- --------- --------- --------- ---------

    ------- ----- User Interface Repository Model View ViewModel Livedata Room Fragments Animations Layouts Navigation Caching Notifications ShareActionProvider
  29. 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!