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
460
Android の静的解析における SARIF ファイルの活用
hkusu
0
5.7k
CI_でライブラリのバージョンの変化をレポートする.pdf
hkusu
0
430
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
610
GitHub Actions でユニットテストの結果をレポートする
hkusu
0
3.9k
Other Decks in Programming
See All in Programming
From 6 People Classroom Meetup to 100 People Regional Conference / FOSS4G Hiroshima 2026
furukawayasuto
0
110
DynamoDBの基礎を振り返りながらベクトル検索機能を理解する
musan
3
270
『寄り添うラジオ』をAIで作る 体験価値から逆算した、会話しないUXと品質設計
theoriatec2024
2
120
Kiroで創り、AgentCoreで繋ぐ!AWSで実践する「AI-DLC」から「AIエージェント統合」までの最新地図
licux
2
330
レビュー履歴をAIに食わせて、 Compose移行を加速するs
shihochan
0
270
30年振りにコンパイラの定数整数除算を改善した
herumi
9
4.4k
ソフトウェアエンジニアにとっての生成AI - 特性を知って使い倒す / generative ai for software enginner
kishida
7
2.3k
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.5k
変化を抱擁するドキュメントの作り方 - ビジネスルール駆動開発がもたらす、コードとの新しい関係
ioki
2
110
Swift愛好会100回記念 第1回を振り返る
jollyjoester
0
120
新卒PdEのリアル
ryu1013
1
410
LLMは4年分のCompose移行を再現できるのか?実プロダクト279件のXMLで探る自動化の境界線
makun
0
420
Featured
See All Featured
What does AI have to do with Human Rights?
axbom
PRO
1
2.4k
Design in an AI World
tapps
1
300
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.5k
How STYLIGHT went responsive
nonsquared
100
6.3k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.1k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
69
65k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
Google's AI Overviews - The New Search
badams
0
1.6k
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() ) ) } } શը૾ϦΫΤετʹϑΣʔυΛద༻͔ͭରࡦίʔυΛಋೖ ϓϨʔεϗϧμͱϑΣʔυΛಉ࣌ʹద༻͢Δ ͱϓϨʔεϗϧμ͕ফ͑ͳ͍