Share
Embed
What's new in Jetpack / I/O Extended Japan 2022
star_zero
June 05, 2022
Transcript
28 slides
-
• KSPサポート • Auto Migrations • Relational Query Methods •
Paging 3.0サポート(androidx.room:room-paging) • Kotlinへの書き換え Room -
@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 -
@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 -
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 -
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 -
TraceSectionMetric benchmarkRule.measureRepeated( packageName = TARGET_PACKAGE, metrics = listOf( FrameTimingMetric(), TraceSectionMetric("RV
CreateView"), TraceSectionMetric("RV OnBindView"), ), // ... } trace("RV OnBindView") { // ... } -
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 } } } -
DragAndDrop val options = DropHelper.Options.Builder() .setHighlightColor(highlightColor) .setHighlightCornerRadiusPx(cornerRadiusPx) .build() DropHelper.configureView( activity,
targetView, arrayOf(ClipDescription.MIMETYPE_TEXT_PLAIN), options, ) { view, payload -> // ... } -
val appLocale = LocaleListCompat.forLanguageTags("ja") AppCompatDelegate.setApplicationLocales(appLocale) <service android:name="androidx.appcompat.app.AppLocalesMetadataHolderService" android:enabled="false" android:exported="false"> <meta-data
android:name="autoStoreLocales" android:value="true" /> </service> アプリ言語設定 -
• 1.2 Beta • Nested Scrollとの相互互換 • Downloadable Fonts •
Lazy Layout • and more… Jetpack Compose -
Thank you! Android, Kotlin GDE he / him @STAR_ZERO https://www.youtube.com/watch
?v=jTd82lcuHTU Resources Kenji Abe