Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Kotlin & Modern Libraries
Search
Takuji Nishibayashi
February 24, 2016
Technology
320
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Kotlin & Modern Libraries
Takuji Nishibayashi
February 24, 2016
More Decks by Takuji Nishibayashi
See All by Takuji Nishibayashi
compose-hot-reload を試そうとした話
takuji31
0
170
CameraX使ってみた
takuji31
0
320
kotlinx.datetime 使ってみた
takuji31
0
1.1k
HiltのCustom Componentについて
takuji31
0
410
java.timeをAndroidで使う
takuji31
0
210
KSPを使ってコード生成
takuji31
0
490
Kotlin Symbol Processing API (KSP) を使って Kotlin ア プリケーションの開発を効率化する
takuji31
1
3.3k
kotlinx.serialization
takuji31
0
710
kanmoba-returns-02.pdf
takuji31
0
300
Other Decks in Technology
See All in Technology
AIオーケストレーションを活用した 開発ワークフローの設計と実践
bqnq
0
170
10分で知る最近のOmarchy
komagata
0
280
絵ではじめるKubernetesセキュリティ
aoi1
3
320
Sigmaユーザーのための有用リソース一挙公開 & Sigmaで使えるMCP #sigma_ucj /useful-resources-for-sigma-computing-users-and-mcps-with-sigma
shinyaa31
0
210
Tab5をRubyで動くパソコンにする
kishima
2
360
Adaptive Warehouse を今すぐ導入すべき理由と迷ったときの判断基準
__allllllllez__
0
210
AI時代のAPI品質を支えるガードレール / API Guardrails for API quality in the AI era
yokawasa
1
250
AIに丸投げしないトイル削減 / Eliminating Toil Without Leaving It All to AI
kohbis
4
1.1k
AIを活用するために決めた "やらないこと" - 価値に注目する / Not betting on AI
soudai
PRO
1
460
2026-09-09 【sigma_ucj#1】Sigma を IaC 管理したい! / IaC for Sigma
civitaspo
0
130
Omarchy Quattro の日本語設定周り
simosako
2
170
消えない 動かない 効かない
yama3133
1
120
Featured
See All Featured
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
450
RailsConf 2023
tenderlove
30
1.5k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
230
Automating Front-end Workflow
addyosmani
1369
210k
Leo the Paperboy
mayatellez
9
2.3k
Testing 201, or: Great Expectations
jmmastey
46
8.3k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
370
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
830
How to Think Like a Performance Engineer
csswizardry
28
2.8k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
530
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
270
Transcript
Kotlin & modern libraries @takuji31
@takuji31 (Takuji Nishibayashi) Application Engineer at Hatena
Loves (AVG 160)
Loves Kotlin
Kotlin
Kotlin 1.0.0 released
JVM Language by JetBrains
Like Swift syntax
Like Swift syntax Swift is Kotlin like syntax!
Java Interoperability
Less boilerplate code
Android ready
Pretty name
Kotlin + modern libraries = happy
Dagger2
Provides in module constructor
Java @Module public class AppModule { private final Context context;
public AppModule(Context context) { this.context = context; } @Provides public Context context() { return context; } @Provides public NotificationManager notificationManager(Context context) { return (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); } }
Kotlin (Provider methods) @Module class AppModule( val context: Context )
{ @Provides fun context() : Context = context @Provides fun notificationManager(context: Context) : NotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager }
Use property
Kotlin (Constructor property) @Module class AppModule( @get:Provides val context: Context
) { @Provides fun notificationManager(context: Context) : NotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager }
Kotlin (Constructor property) @Module class AppModule( @get:Provides val context: Context,
@get:Provides val notificationManager: NotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager ) { }
Provides in component property
Java @Component(modules = AppModule.class) @Singleton public interface AppComponent { Context
context(); NotificationManager notificationManager(); }
Kotlin (functions) @Singleton @Component(modules = arrayOf(AppModule::class)) interface AppComponent { fun
context(): Context fun notificationManager(): NotificationManager }
Use property
Kotlin (properties) @Singleton @Component(modules = arrayOf(AppModule::class)) interface AppComponent { val
context : Context val notificationManager : NotificationManager }
Realm
Constructor and properties
Primary constructor and default value
Java public class User extends RealmObject { @PrimaryKey private String
uuid; private String name; public User() { this(UUID.randomUUID().toString(), null); } public User(String uuid, String name) { this.uuid = uuid; this.name = name; } public String getUuid() {return uuid;} public void setUuid(String uuid) {this.uuid = uuid;} public String getName() {return name;} public void setName(String name) {this.name = name;} }
Kotlin (default constructor) class User constructor() : RealmObject() { @PrimaryKey
var uuid: String? = UUID.randomUUID().toString() var name: String? = null }
Kotlin (with default value) open class User( @PrimaryKey open var
uuid: String = UUID.randomUUID().toString(), open var name: String? = null ) : RealmObject() {}
Computed property in model class
Use extension property
Java public class User extends RealmObject { private Date createdDate;
@Ignore private Instant createdAt; public Date getCreatedDate() {return createdDate;} public void setCreatedDate(Date createdDate) {this.createdDate = createdDate;} public Instant getCreatedAt() { return DateTimeUtils.toInstant(getCreatedDate()); } public void setCreatedAt(Instant createdAt) { setCreatedDate(DateTimeUtils.toDate(createdAt)); } }
Kotlin (property) Not available
Kotlin (extension property) open class User( … open var createdDate:
Date? = null ) : RealmObject() {} var User.createdAt : Instant get() = DateTimeUtils.toInstant(createdDate) set(value) { createdDate = DateTimeUtils.toDate(value) }
Enjoy Kotlin life!