Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Google I/O 2018’s Extensions🦔
Search
Hunachi
September 20, 2018
Technology
1
2.5k
Google I/O 2018’s Extensions🦔
Kotlin大好き!Kotlin愛好会 vol4で発表しました.
是非Googleさんを参考にしましょう!
Hunachi
September 20, 2018
Tweet
Share
More Decks by Hunachi
See All by Hunachi
PDF Viewer作成の今までとこれから
hunachi
0
2.3k
Google Play ポリシー対応周りの整理/改善をしてみた
hunachi
0
370
レビューダイアログ機能の取り組みAndroid編 / Review Dialog for Android
hunachi
0
1.3k
Git Hands On for my lab.
hunachi
0
100
ML Kitはいいぞ!
hunachi
0
860
Paging Library は便利だぞ!
hunachi
1
460
Androidについて.
hunachi
0
120
Other Decks in Technology
See All in Technology
統計データで2024年の クラウド・インフラ動向を眺める
ysknsid25
2
840
Qiita埋め込み用スライド
naoki_0531
0
860
Amazon VPC Lattice 最新アップデート紹介 - PrivateLink も似たようなアップデートあったけど違いとは
bigmuramura
0
190
podman_update_2024-12
orimanabu
1
260
サービスでLLMを採用したばっかりに振り回され続けたこの一年のあれやこれや
segavvy
2
390
ガバメントクラウドのセキュリティ対策事例について
fujisawaryohei
0
530
権威ドキュメントで振り返る2024 #年忘れセキュリティ2024
hirotomotaguchi
2
730
Oracle Cloudの生成AIサービスって実際どこまで使えるの? エンジニア目線で試してみた
minorun365
PRO
4
280
組織に自動テストを書く文化を根付かせる戦略(2024冬版) / Building Automated Test Culture 2024 Winter Edition
twada
PRO
12
3.5k
マルチプロダクト開発の現場でAWS Security Hubを1年以上運用して得た教訓
muziyoshiz
2
2.2k
KnowledgeBaseDocuments APIでベクトルインデックス管理を自動化する
iidaxs
1
260
AI時代のデータセンターネットワーク
lycorptech_jp
PRO
1
280
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
For a Future-Friendly Web
brad_frost
175
9.4k
Designing for Performance
lara
604
68k
Bash Introduction
62gerente
608
210k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
YesSQL, Process and Tooling at Scale
rocio
169
14k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Documentation Writing (for coders)
carmenintech
66
4.5k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Building Adaptive Systems
keathley
38
2.3k
Transcript
ˏ)VOBDIJ ,PUMJOѪձWPM (PPHMF*0`T &YUFOTJPOT
ࣗݾհ ;ͳͪ ߴઐੜ (JU)VC!)VOBDIJ 5XJUUFS!@IVOBDIJ ,PUMJOΛॻ͖࢝Ί͔ͯΒϓϩάϥϛϯά͕͖ʹͳͬͨɽ ࠓ8BOUFEMZ*OD͞ΜͷݩͰΠϯλʔϯதͰ͢ʗʢ,PUMJOಋೖ͠·ͨ͠ʣ
$PEFɿIUUQTHJUIVCDPNHPPHMFJPTDIFE 0⒏DJBM#MPHɿIUUQTNFEJVNDPNBOESPJEEFWFMPQFSTHPPHMFJPBQQ BSDIJUFDUVSFBOEUFTUJOHGFGDFC (PPHMF*0BQQ
w ,PUMJO w ࠓྫΑΓσεϚͯ͠ͳͦ͞͏ ʢ$POUSJCVUJPO͚ͩͰݴ͑ͳ͍͔ ͚ͩͲʣ
6TFE5PPMBOE-JCSBSZ w 'JSF4UPSFɼ'JSF#BTF"VUIFOUJDBUJPO w "OESPJEY w %BHHFSɼ5JNCFSɼ(TPOɼ5ISFF5FOɼ$SBTIMZUJDTɼ(MJEFɼ&TQSFTTPɼ .PDLJUPɼ+6OJUɼMFBLDBOBSZɽ
"SDIJUFDUVSF w $MFBO"SDIJUFDUVSF w 1SFTFOUBUJPOɿ7JFXˍ7JFX.PEFM w %PNBJOɿ6TF$BTF w %BUBɿ3FQPTJUPSZ 6TFS.BOBHFS
w .77.
None
&YUFOTJPOT /PUBMM FYUFOTJPOTPG NZGBWPSJUF
// Listͱ͔ͰView͕ΨλϯͬͯͳͬͨΓ͢ΔͷΛ͙༻ɽ inline fun <T : ViewDataBinding> T.executeAfter(block: T.() ->Unit){
block() // ͙͢ʹbinding͍ͤͨ࣌͞ʹ͏ɽ executePendingBindings() } // ༻ྫ binding.executeAfter { //͜͜Ͱbind͢Δɽ event = item } ᶃ
// TransitionΛԆͤ͞Δ fun Activity.postponeEnterTransition(timeout: Long) { postponeEnterTransition() window.decorView.postDelayed(timeout) { startPostponedEnterTransition()
} } // ༻ྫ activity?.postponeEnterTransition(500L) ᶄ
// ॳظԽɼࢀর͕ৗʹγϯάϧεϨουͰ͔͠ߦΘΕͳ͍࣌༻ɽ fun <T> lazyFast(operation: () -> T): Lazy<T> =
lazy(LazyThreadSafetyMode.NONE) { operation() } // SYNCRONIZED: σϑΥϧτɽ୯ҰεϨου͔ΒͷॳظԽͰɼෳεϨου͔Βͷࢀর͕Մೳɽ // PUBLICATION: ෳεϨου͔ΒॳظԽ͠Α͏ͱ͢Δࣄ͕Մೳɽ // ༻ྫ private val day: Int by lazyFast { val args = arguments ?: throw IllegalStateException("Missing arguments!") args.getInt(ARG_INT) } ᶅ
inline fun <reified VM : ViewModel> FragmentActivity.viewModelProvider( provider: ViewModelProvider.Factory )
= ViewModelProviders.of(this, provider).get(VM::class.java) // ༻ྫ // Before val viewModel: HogeViewModel = ViewModelProviders.of(this, viewModelFactory) .get(HogeViewModel::class.java) //After val viewModel: HogeViewModel = viewModelProvider(viewModelFactory) ᶆ
fun ViewGroup.inflate( @LayoutRes layout: Int, attachToRoot: Boolean = false ):
View { return LayoutInflater.from(context) .inflate(layout, this, attachToRoot) } // ༻ྫ … Holder( parent.inflate(VIEW_TYPE_HEADING, false) ) ᶇ
inline fun FragmentManager.inTransaction( func: FragmentTransaction.() -> FragmentTransaction ) { beginTransaction().func().commit()
} // ༻ྫ supportFragmentManager.inTransaction { add(FRAGMENT_ID, fragment) } ᶈ
// enumΫϥεΛbundleʹೖΕΕΔܗʹ͢Δ fun <T : Enum<T>> Bundle.putEnum(key: String, value: T)
= putString(key, value.name) // ↑ͰೖΕͨenumΫϥεΛऔΓग़͢ inline fun <reified T : Enum<T>> Bundle.getEnum(key: String): T = enumValueOf(getString(key)) // ParcelʹbooleanΛॻ͖ࠐΉ fun Parcel.writeBoolean(value: Boolean) = writeInt(if (value) 1 else 0) // ↑Ͱมͨ͠booleanΛಡΈࠐΉ fun Parcel.readBoolean() = readInt() != 0 ᶉ
// ༻ྫ // ಡΈ͍͢ʂ pacel.apply { writeInt(state) writeInt(peekHeight) writeBoolean(isFitToContents) writeBoolean(isHideable)
writeBoolean(skipCollapsed) writeBoolean(isDraggable) }
fun <T> MutableLiveData<T>.setValueIfNew(newValue: T) { if (this.value != newValue) value
= newValue } fun <T> MutableLiveData<T>.postValueIfNew(newValue: T) { if (this.value != newValue) postValue(newValue) } // ObserverଆͰఆͨ͠ํ͕҆શͳؾ͕͢Δ͚ͲͲ͏ͳΜͩΖ͏ɽɽ ᶊ
fun <X, Y> LiveData<X>.map(body: (X) -> Y): LiveData<Y> { return
Transformations.map(this, body) } fun <X, Y> LiveData<X>.switchMap(body: (X) -> LiveData<Y>): LiveData<Y> { return Transformations.switchMap(this, body) } ᶋ
// ༻ྫ liveData = parentLiveData.map { (it as? Result.Success)?.data?: 0
} liveData = parentLiveData.switchMap { if(value == null) dataLiveData else parentLiveData } // ࠷ॳ֦ுؔͬͯࣄʹؾ͔ͮͣɼڻ͍ͨɽ
val <T> T.checkAllMatched: T get() = this // ༻ྫ //
OK when (sealed) { ONE -> {…} TWO -> {…} }.checkAllMatch // error when (sealed) { ONE -> {…} //TWO -> {…} }.checkAllMatch ᶌ
w ஸೡʂ ͜ͷ࣮७ਮʹ಄ ͍͍ͱࢥ͏ɽ
5IBOLZPV ,PUMJOՄѪ͍ʂ