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
Glide 4 with Kotlin
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Hiroyuki Kusu
April 19, 2018
Programming
2.5k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Glide 4 with Kotlin
Hiroyuki Kusu
April 19, 2018
More Decks by Hiroyuki Kusu
See All by Hiroyuki Kusu
モノレポのプルリクエストに最近、導入したもの
hkusu
2
600
GitHub composite actions
hkusu
2
450
Android の静的解析における SARIF ファイルの活用
hkusu
0
5.7k
CI_でライブラリのバージョンの変化をレポートする.pdf
hkusu
0
420
Maestro を GitHub Actions で動かす 〜Android編〜
hkusu
1
1.8k
Android の CI(GitHub Actions)の改善で、最近やったこと
hkusu
0
740
Tauri Mobile で生成される Android のコードを見てみる
hkusu
0
1.6k
Custom GitHub Actions を作って Organization 内で共有する
hkusu
1
600
GitHub Actions でユニットテストの結果をレポートする
hkusu
0
3.9k
Other Decks in Programming
See All in Programming
変わらないものが、変わるものを決める — 意図駆動開発 × イベントソーシング × イミュータブル | What Doesn't Change Decides What Can — IDD × Event Sourcing × Immutability
tomohisa
0
1.3k
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
4k
Japan Community Day at Kubecon + CloudNativeCon Japan 2026: Learning Container Privilege Control by Building My Own Low-Level Container Runtime
ternbusty
1
140
全PRの83%がAIレビューだけでマージできるようになった開発組織はその後どうなったか
athug
1
1.5k
React本体のコードリーディング
high_g_engineer
1
140
torikago - Ruby::Boxで照らすモジュラモノリスの実行境界
se4weed
1
350
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
1.7k
源内ハンズオン概要編
hideg
0
120
Apache Hive: そしてCloud Native Lakehouseへ
okumin
1
210
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
150
Apache Hive: Toward a Cloud Native Lakehouse
okumin
0
180
ITヒヤリハットを整理してみた ~ライフサイクルと原因から考える再発防止策~
koukimiura
1
140
Featured
See All Featured
How to Ace a Technical Interview
jacobian
281
24k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
Visualization
eitanlees
152
17k
Everyday Curiosity
cassininazir
0
270
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
680
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
240
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
300
Making Projects Easy
brettharned
120
6.7k
Transcript
Glide 4 with Kotlin Hiroyuki Kusu (@hkusu_) 2018/4/19 potatotips #50
None
Image loading library for Android Vector ܗࣜͷը૾औΓѻ͑Δ
͞ͳ͍͜ͱ Glide 4 ͷಋೖํ๏ Glide 3 ͔Β 4 ͷҠߦͷํ๏ ύϑΥʔϚϯεɾΩϟογϡઓུͳͲ
Glide Module @GlideModule class MyGlideModule : AppGlideModule() { override fun
applyOptions(context: Context, builder: GlideBuilder) { // GlideશମͷઃఆΛهड़ } override fun registerComponents(context: Context, glide: Glide, registry: Registry) { // Component(ྫ:OkHttpμϯϩʔυ)ͷઃఆొͳͲΛهड़ } } GlideApp.with(context) .load(url) .into(imageView) #BTJD6TBHF (MJEF"QQBOOPUBUJPOQSPDFTTPSͰੜ͑Δ
Transformation • ԁܗΫϩοϓɾؙ֯ Glide 4 Ͱඪ४Ͱ༻ҙ͞Ε͍ͯΔ • ෳͷ Transformation Λಉ࣌ʹద༻͢Δ͜ͱՄ
GlideApp.with(context) .load(url) .transforms( CenterCrop(), RoundedCorners( resources.getDimensionPixelSize(R.dimen.something_radius) ) ) .into(imageView)
Glide Transformations #SJHIUOFTT'JMUFS #MVS
Transition // ϑΣʔυ .transition(DrawableTransitionOptions.withCrossFade()) // Ξχϝʔγϣϯ .transition(DrawableTransitionOptions().transition { view ->
view.scaleX = 0F view.scaleY = 0F view.animate() .scaleX(1.0f) .scaleY(1.0f) .setDuration(300) .setInterpolator(FastOutSlowInInterpolator()) }) // or .transition(DrawableTransitionOptions().transition(R.anim.show)) Glide 4 Glide 3 ͱҧ͍ɺσϑΥϧτͰϑΣʔυͳ͠ͳͷͰҙ
Glide Option (in Glide Extension) @GlideExtension object GlideExtension { @GlideOption
@JvmStatic @NonNull fun roundedCornersCrop( options: RequestOptions, context: Context ): RequestOptions { val radius = context .resources .getDimensionPixelSize(R.dimen.something_radius) return options.transforms(CenterCrop(), RoundedCorners(radius)) } } Glide Extension Java Ͱ Public ίϯελϥΫλͳ͠ˍΦϓγϣϯ ฦΓ͕NonNull ͳ static ϝιουͰ࡞͢Δඞཁ͕͋Δ ˡୈҰҾ 3FRVFTU0QUJPOT ඞͣඞཁ Α͘͏ΦϓγϣϯΛఆٛͯ͠࠶ར༻
GlideApp.with(context) .load(url) .roundedCornersCrop(context) .into(imageView) (MJEF0QUJPOͰఆٛͨ͠Φϓγϣϯͷར༻ annotation processor Ͱϝιου͕ੜ͑ͯΔ
@GlideExtension object GlideExtension { @GlideOption @JvmStatic @NonNull fun override( options:
RequestOptions, layoutParams: ViewGroup.LayoutParams ): RequestOptions { val width = layoutParams.width val height = layoutParams.height return options.override(width, height) } } GlideApp.with(context) .load(url) .override(imageView.layoutParams) .into(imageView)
• Transition αϜωΠϧɾϦεφʔͷઃఆͳͲ Glide Option Ͱఆ ٛͰ͖ͳ͍ • Glide
Type ͱͯ͠ఆٛͰ͖Δ੍͕͕͋Δ • Ұͷը૾ಡΈࠐΈͰࢦఆͰ͖Δ Glide Type 1ͭͷΈ • ҾΛ͢͜ͱ͕Ͱ͖ͳ͍ • ϦιʔεΞΫηεͷҝͷ Context ઃఆͨ͘͠ͳΔ
Kotlin Extension Functions Λ͔ͭ͏
// ϑΣʔυ fun GlideRequest<Drawable>.withCrossFade(duration: Int = 300) = transition(DrawableTransitionOptions.withCrossFade(duration)) //
Ξχϝʔγϣϯ fun GlideRequest<Drawable>.withShowAnimation(duration: Long = 300, interpolator: Interpolator = LinearInterpolator()) = transition(DrawableTransitionOptions().transition { view -> view.scaleX = 0F view.scaleY = 0F view.animate() .scaleX(1.0f) .scaleY(1.0f) .setDuration(duration) .setInterpolator(interpolator) }) // ϑΣʔυ GlideApp.with(context) .load(url) .withCrossFade(duration = 600) .into(imageView) // Ξχϝʔγϣϯ GlideApp.with(context) .load(url) .withShowAnimation(interpolator = FastOutSlowInInterpolator()) .into(imageView)
ࢀߟϦϯΫ Glide 4 ͷಋೖํ๏ GitHub ϦϙδτϦ https://github.com/bumptech/glide ެࣜυΩϡϝϯτ https://bumptech.github.io/glide/ Glide
3 ͔Β 4 ͷҠߦͷํ๏ Migrate Glide v3 to v4 (Qiita) https://qiita.com/ronnnnn/items/9d82130985b5f1f6b77e Migrating from v3 to v4 (ެࣜυΩϡϝϯτ) https://bumptech.github.io/glide/doc/migrating.html
Thank you ! @hkusu_
ิεϥΠυ
GlideApp.with(context) .load(url) .circleCrop() .into(imageView)
GlideApp.with(context) .load(url) .transform( RoundedCorners( resources.getDimensionPixelSize(R.dimen.something_radius) ) ) .into(imageView) ̐ͭͷ֯ʹର͢Δؙ֯ͷద༻Λݸผʹ੍ޚ(ྫ:ӈ্ͷΈؙ֯)͢Δ߹
Glide Transformations ͷ RoundedCornersTransformation Λར༻
ϓϨʔεϗϧμͱϑΣʔυΛಉ࣌ʹద༻͢Δ ͱϓϨʔεϗϧμ͕ফ͑ͳ͍ .transition(DrawableTransitionOptions.withCrossFade()) .transition( DrawableTransitionOptions() .crossFade( DrawableCrossFadeFactory .Builder() .setCrossFadeEnabled(true) .build()
) ) ରࡦ
@GlideModule class GlideModule : AppGlideModule() { override fun applyOptions(context: Context,
builder: GlideBuilder) { builder.setDefaultTransitionOptions( Drawable::class.java, DrawableTransitionOptions() .crossFade( DrawableCrossFadeFactory .Builder() .setCrossFadeEnabled(true) .build() ) ) } } શը૾ϦΫΤετʹϑΣʔυΛద༻͔ͭରࡦίʔυΛಋೖ ϓϨʔεϗϧμͱϑΣʔυΛಉ࣌ʹద༻͢Δ ͱϓϨʔεϗϧμ͕ফ͑ͳ͍