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

A Joy ride with Jetpack

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.
Avatar for Hardy Hardy
July 18, 2018

A Joy ride with Jetpack

As we all know google io'18 announced jetpack.. as a set of library including architectural components i am sharing some of components which would be helpful to us for improved coding archituecture in our application.

Avatar for Hardy

Hardy

July 18, 2018

More Decks by Hardy

Other Decks in Programming

Transcript

  1. What is Room? • An Abstract layer that wraps the

    standard Sqlite and adopted by Android. • Part of Architecture components which simplifies the database operation & Reduces the boilerplate code by adding the annotation. • Combination of Entity DAO Database
  2. Roles of Main Components of ROOM 1.Database:- A Simple abstract

    class which includes entities and defines the dao which extends RoomDatabase 2.DAO:- A mediator for accessing the objects into the database 3.Entity:- Class or table to save in the database. Each table is created for each entity.
  3. What is slice? A “slice” is a way to surface

    your app’s UI inside of the Google Assistant as a result of a search. Some advantages using Slices API: • Templated • Interactive • Updatable • Backwards-compatible What is slice?
  4. Roles of Main Components of Slice 1.SliceView:- A view in

    the host application which contains a slice.Which is structured data that contains slices,content,hints. 2.SliceLiveData:- Tracks the slices and can request a slice by URI,Intent or attaching a observer. 3.SliceProvider:- Provider class which is in the provider app and controls the slices which host get.
  5. class CoffeeSliceProvider : SliceProvider() { override fun onCreateSliceProvider(): Boolean =

    true override fun onBindSlice(sliceUri: Uri): Slice? = when (sliceUri.path) { …..createyourslice(sliceUri) } fun createyourslice(sliceUri: Uri){ ListBuilder(context, sliceUri, ListBuilder.INFINITY) .setAccentColor(0xfff4b4) // Specify color for tinting icons .setHeader { it.apply { setTitle("Create new note") setSubtitle("Easily done with this note taking app") } } .addAction(noteAction) .addAction(voiceNoteAction) .addAction(cameraNoteAction) .build() }
  6. The Navigation Editor in Android Studio 3.2 allows you to

    see and manage your navigation properties visually:
  7. Principles of Navigation:- • App should have fixed start destination.

    • The UP button should never exit the application. • UP and BACK should be equivalent to your application.
  8. What is pagination? Paging Library is a part of Android

    Jetpack. The Paging Library makes it easier for you to load data gradually and gracefully within your app’s RecyclerView.
  9. • PagedList:- PagedList is a collection that loads data in

    pages, asynchronously. A PagedList can be used to load data from sources you define, and present it easily in your UI with a RecyclerView. Roles of Main Components of Paging init { val pagedListConfig = PagedList.Config.Builder() .setPageSize(30) .setPrefetchDistance(30) .build() userListLiveData = teamDao.getTeamsAsLivePagedLi stProvider().create(0, pagedListConfig) }
  10. • PagedListAdapter:- PagedListAdapter is a RecyclerView.Adapter that presents paged data

    from PagedLists in a RecyclerView. PagedListAdapter listens to PagedList loading callbacks as pages are loaded, and uses DiffUtil to compute fine grained updates as new PagedLists are received and then display the list to user in your UI with a recyclerView. • DataSource:- DataSource holds the content from external sources such as network APIs or database itself and serves as a local storage for PagedLists.
  11. PagedListBuilder val pagedList: PagedList<Team> = PagedList.Builder<Int, Team>() .setInitialKey(100) .setConfig(pagedListConfig) .setDataSource(viewModel.tiledDataSource)

    .setMainThreadExecutor(AppToolkitTaskExecutor.getMainThreadExecutor()) .setBackgroundThreadExecutor(AppToolkitTaskExecutor.getIOThreadExecutor()) .build()