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

What's new in Jetpack / I/O Extended Japan 2022

What's new in Jetpack / I/O Extended Japan 2022

star_zero

June 05, 2022
Tweet

More Decks by star_zero

Other Decks in Programming

Transcript

  1. • KSPサポート • Auto Migrations • Relational Query Methods •

    Paging 3.0サポート(androidx.room:room-paging) • Kotlinへの書き換え Room
  2. @Database( entities = [ /* .. */ ], version =

    3, autoMigrations = [ AutoMigration(from = 1, to = 2), AutoMigration( from = 2, to = 3, spec = AppDatabase.AutoMigration2to3::class ) ] ) abstract class AppDatabase : RoomDatabase() { @RenameTable(fromTableName = "user", toTableName = "users") class AutoMigration2to3 : AutoMigrationSpec } Auto Migrations
  3. @Query( "SELECT * FROM user " + "JOIN book on

    user.id = book.user_id" ) fun getUserAndBook(): Map<User, List<Book>> @MapInfo(keyColumn = "userName", valueColumn = "bookName") @Query( "SELECT user.name AS userName, book.name AS bookName FROM user " + "JOIN book on user.id = book.user_id" ) fun getUserAndBookNames(): Map<String, List<String>> Relational Query Methods
  4. class ListDetailFragment: AbstractListDetailFragment() { override fun onCreateListPaneView(/* */): View {

    return inflater.inflate(R.layout.list_pane, container, false) } override fun onListPaneViewCreated(/* */) { super.onListPaneViewCreated(view, savedInstanceState) val recyclerView = view as RecyclerView recyclerView.adapter = ListDetailAdapter(/* */) } override fun onCreateDetailPaneNavHostFragment(): NavHostFragment { return NavHostFragment.create(R.navigation.list_detail_nav_graph) } } AbstractListDetailFragment
  5. val metricsStateHolder = PerformanceMetricsState.getForHierarchy(view) val jankStats = JankStats.createAndTrack( window =

    window, executor = Dispatchers.Default.asExecutor(), frameListener = { frameData -> if (frameData.isJank) { // ... } } ) metricsStateHolder.state?.addState("Activity", javaClass.simpleName) JankStats
  6. TraceSectionMetric benchmarkRule.measureRepeated( packageName = TARGET_PACKAGE, metrics = listOf( FrameTimingMetric(), TraceSectionMetric("RV

    CreateView"), TraceSectionMetric("RV OnBindView"), ), // ... } trace("RV OnBindView") { // ... }
  7. Foldable lifecycleScope.launch { lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) { WindowInfoTracker.getOrCreate(activity) .windowLayoutInfo(activity) .collect { layoutInfo

    -> val foldingFeature = layoutInfo.displayFeatures.firstOrNull() as? FoldingFeature foldingFeature?.state // => FLAT, HALF_OPENED foldingFeature?.orientation // => VERTICAL, HORIZONTAL foldingFeature?.bounds // > Rect } } }