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
recyclerview-selection
Search
Shinnosuke Kugimiya
April 19, 2018
Programming
2.5k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
recyclerview-selection
at potatotips #50
Shinnosuke Kugimiya
April 19, 2018
More Decks by Shinnosuke Kugimiya
See All by Shinnosuke Kugimiya
Claude Code x Androidアプリ 開発
kgmyshin
1
2.7k
AndroidアプリエンジニアもMCPを触ろう
kgmyshin
2
1.5k
15分で分かった気になる dumpsys
kgmyshin
1
400
UIテストはもうMaestroでいいのかもしれない話
kgmyshin
28
14k
新規開発を始めるときにやるべきこと
kgmyshin
19
9.3k
android app error handling
kgmyshin
1
1.6k
solid+cqs+dry
kgmyshin
35
10k
Paging Library ~ アイテムの更新 ~
kgmyshin
2
3.5k
KotlinでReact Native(expo) を使いたい
kgmyshin
2
1.2k
Other Decks in Programming
See All in Programming
우리의 Nitro Modules는 당신의 Turbo Modules보다 아름답다
l2hyunwoo
0
260
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
200
Getting Started with Vibe Coding
miccheng
0
190
Spec-driven Development with AI
simas
PRO
0
2.3k
動画プレイヤーはなぜカクつくのか 〜Flutterのレンダリングとネイティブの境界を解剖する〜
naruogram
0
330
エージェントを使い続けるためのメタワーク / Meta-work for keeping using the agent
rkaga
6
2.2k
느린 네트워크와 저사양 디바이스 사용자를 위한 웹뷰 로딩 시간 개선기
kmkim
1
220
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
1.6k
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
420
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
220
Distance field of Julia set
kinakomoti321
0
310
あなたの await、OS まで届いてる? strace で覗く JavaScript の非同期
hasutosasaki
1
2.3k
Featured
See All Featured
Docker and Python
trallard
47
4.3k
The Curse of the Amulet
leimatthew05
3
17k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
240
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
280
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
670
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
Building an army of robots
kneath
307
47k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
290
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.2k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
470
SEO for Brand Visibility & Recognition
aleyda
0
4.9k
Statistics for Hackers
jakevdp
799
230k
Transcript
CONFIDENTIAL © DMM.com !LHNZTIJO QPUPUJQT 4VQQPSU-JCSBSZBMQIB SFDZDMFSWJFXTFMFDUJPO
© DMM.com X w LHNZTIJOఝٶ ͗͘Έ w "OESPJEΤϯδχΞ w
%..DPNϥϘ$50ࣨॴଐ w ݄͔Β ࣗݾհ
© DMM.com X BHFOEB
© DMM.com X w SFDZDMFSWJFXTFMFDUJPOͱʁ w ͍ํ w લ४උ w
4FMFDUJPO5SBDLFSΛ࡞Δ w બঢ়ଶΛ7JFXʹө͢Δ BHFOEB
© DMM.com X SFDZDMFSWJFXTFMFDUJPO ͱʁ
© DMM.com X TVQQPSUMJCSBSZBMQIB͔Β BMQIB͔Βಋೖ ͪΖΜQSFWJFXͰ͢ ઌߦͯ͠ϦϦʔε͞Ε͍ͯΔBOESPJELUYͱಉ͡ ABOESPJEYAύοέʔδɻ ABOESPJEYAকདྷͷαϙʔτϥΠϒϥϦͰ༻͞ΕΔ ύοέʔδͰ͢ɻ
SFDZDMFSWJFXTFMFDUJPOͦͷlকདྷͷαϙʔτϥΠϒϥ ϦzͷҰͭ
© DMM.com X ͲΜͳػೳʁ
© DMM.com X ͍ํ
© DMM.com X લ४උ data class Book( val id: Long,
val title: String, val subTitle: String ) ͜ͷ#PPLͷϦετΛෳબͰ͖ΔΑ͏ʹ͠·͢
© DMM.com X લ४උ 3FDZDMFS7JFXɺ7JFX)PMEFSɺ"EBQUFSҰ୴௨ৗ௨Γ ͨͩɺTUBCMF*EΛ͏Α͏ʹ͢Δ class BookAdapter( context: Context,
private val bookList: List<Book> ) : RecyclerView.Adapter<BookViewHolder>() { init { setHasStableIds(true) } : override fun getItemId(position: Int): Long = bookList[position].id : }
© DMM.com X લ४උ 3FDZDMFS7JFXɺ7JFX)PMEFSɺ"EBQUFSҰ୴௨ৗ௨Γ ͨͩɺTUBCMF*EΛ͏Α͏ʹ͢Δ class BookAdapter( context: Context,
private val bookList: List<Book> ) : RecyclerView.Adapter<BookViewHolder>() { init { setHasStableIds(true) } : override fun getItemId(position: Int): Long = bookList[position].id : }
© DMM.com X 4FMFDUJPO5SBDLFSΠϯελϯεΛ࡞Δ selectionTracker = SelectionTracker.Builder<Long>( "my-selection-id", binding.recyclerView, StableIdKeyProvider(binding.recyclerView),
BookIdDetailsLookup(binding.recyclerView), StorageStrategy.createLongStorage()) .withOnItemActivatedListener { item, e -> Log.e("MainActivity", item.toString()) return@withOnItemActivatedListener true } .build()
© DMM.com X 4FMFDUJPO5SBDLFSΠϯελϯεΛ࡞Δ selectionTracker = SelectionTracker.Builder<Long>( "my-selection-id", binding.recyclerView, StableIdKeyProvider(binding.recyclerView),
BookIdDetailsLookup(binding.recyclerView), StorageStrategy.createLongStorage()) .withOnItemActivatedListener { item, e -> Log.e("MainActivity", item.toString()) return@withOnItemActivatedListener true } .build() ୈҰҾɻϢχʔΫͳจࣈྻΛɻ #VOEMFʹೖΕΔ,FZͱͯ͠ΘΕ·͢ɻ
© DMM.com X 4FMFDUJPO5SBDLFSΠϯελϯεΛ࡞Δ selectionTracker = SelectionTracker.Builder<Long>( "my-selection-id", binding.recyclerView, StableIdKeyProvider(binding.recyclerView),
BookIdDetailsLookup(binding.recyclerView), StorageStrategy.createLongStorage()) .withOnItemActivatedListener { item, e -> Log.e("MainActivity", item.toString()) return@withOnItemActivatedListener true } .build() ୈೋҾɻ ֘ͷ3FDZDMFS7JFXΛࢦఆ͢Δɻ
© DMM.com X 4FMFDUJPO5SBDLFSΠϯελϯεΛ࡞Δ selectionTracker = SelectionTracker.Builder<Long>( "my-selection-id", binding.recyclerView, StableIdKeyProvider(binding.recyclerView),
BookIdDetailsLookup(binding.recyclerView), StorageStrategy.createLongStorage()) .withOnItemActivatedListener { item, e -> Log.e("MainActivity", item.toString()) return@withOnItemActivatedListener true } .build() ୈࡾҾɻબதͷΞΠςϜͱબதͷLFZͷରԠΛղܾ͢ Δ*E,FZ1SPWJEFSΛࢦఆ͢Δɻࠓճͩͱ͋ΔTUBCMF*E CPPLJE ʹ͍ͨͯ͠ͲΕ͕ରͷ#PPL͔ͷؔΛղܾ͢Δɻ
© DMM.com X 4FMFDUJPO5SBDLFSΠϯελϯεΛ࡞Δ selectionTracker = SelectionTracker.Builder<Long>( "my-selection-id", binding.recyclerView, StableIdKeyProvider(binding.recyclerView),
BookIdDetailsLookup(binding.recyclerView), StorageStrategy.createLongStorage()) .withOnItemActivatedListener { item, e -> Log.e("MainActivity", item.toString()) return@withOnItemActivatedListener true } .build() ୈ࢛Ҿɻ.PUJPO&WFOUΛͱʹࠓͲ͜ͷΞΠςϜΛબͯ͠ Δͷ͔Λղܾ͢ΔɻTUBCMF*E༻͚࣌ͩࣗ͜͜࡞ɻ TUBCMF*Eඇ༻͚࣌ͩ͜͜Ͱͳ͘*E,FZ1SPWJEFSࣗ࡞͢Δɻ
© DMM.com X 4FMFDUJPO5SBDLFSΠϯελϯεΛ࡞Δ selectionTracker = SelectionTracker.Builder<Long>( "my-selection-id", binding.recyclerView, StableIdKeyProvider(binding.recyclerView),
BookIdDetailsLookup(binding.recyclerView), StorageStrategy.createLongStorage()) .withOnItemActivatedListener { item, e -> Log.e("MainActivity", item.toString()) return@withOnItemActivatedListener true } .build() ୈޒҾɻ TBWFE4UBUFʹԿΛอ࣋͢Δͷ͔Λղܾ͢Δਓɻ *UFNΛ4FMFDUJPO#VOEMFʹม͢ΔϝιουΛ࣋ͭɻ
© DMM.com X 4FMFDUJPO5SBDLFSΠϯελϯεΛ࡞Δ selectionTracker = SelectionTracker.Builder<Long>( "my-selection-id", binding.recyclerView, StableIdKeyProvider(binding.recyclerView),
BookIdDetailsLookup(binding.recyclerView), StorageStrategy.createLongStorage()) .withOnItemActivatedListener { item, e -> Log.e("MainActivity", item.toString()) return@withOnItemActivatedListener true } .build() ඞཁͩͬͨΒϦεφʔొɻ
© DMM.com X #PPL*E%FUBJMT-PPLVQΛ࡞Δ class BookIdDetailsLookup( private val recyclerView: RecyclerView
) : ItemDetailsLookup<Long>() { override fun getItemDetails(e: MotionEvent): ItemDetails<Long>? = recyclerView.findChildViewUnder( e.x, e.y )?.let { (recyclerView.getChildViewHolder(it) as? BookViewHolder)?.getItemIdDetails() } } ୈࡾҾͩͬͨ#PPL*E%FUBJMT-PPLVQͷ࣮ɻ λονΠϕϯτͷ࠲ඪ͔Βɺ֘ͷΞΠςϜΛฦ͚ͩ͢ ͷγϯϓϧͳ࣮ɻ
© DMM.com X ͜͜·Ͱ࣮ͨ͠ͷΛݟͯΈΔ
© DMM.com X 7JFXʹબঢ়ଶ͔Ͳ͏͔Λө͢Δ class BookAdapter( context: Context, private val
bookList: List<Book> ) : RecyclerView.Adapter<BookViewHolder>() { ɿ override fun onBindViewHolder( holder: BookViewHolder, position: Int ) { val item = bookList[position] holder.bind( selectionChecker?.isSelected(item.id) ?: false, position, bookList[position] ) } } TFMFDUPSΛηοτ͓͍ͯͯ͠4FMFDUJPO5SBDLFSJT4FMFDUFEͷ݁ՌΛ 7JFXTFU"DUJWBUFEͰηοτ͢Δɻ
© DMM.com X 7JFXʹબঢ়ଶ͔Ͳ͏͔Λө͢Δ class BookAdapter( context: Context, private val
bookList: List<Book> ) : RecyclerView.Adapter<BookViewHolder>() { ɿ override fun onBindViewHolder( holder: BookViewHolder, position: Int ) { val item = bookList[position] holder.bind( selectionChecker?.isSelected(item.id) ?: false, position, bookList[position] ) } } TFMFDUPSΛηοτ͓͍ͯͯ͠4FMFDUJPO5SBDLFSJT4FMFDUFEͷ݁ՌΛ 7JFXTFU"DUJWBUFEͰηοτ͢Δɻ
© DMM.com X ʂ
© DMM.com X ऴΘΓʹ
© DMM.com X ฐࣾϒϩάͰɺ͏গ͠ৄ͘͠հͯ͠·͢ IUUQTJOTJEFENNDPNFOUSZSFDZDMFSWJFXTFMFDUJPO
© DMM.com X αϯϓϧஔ͍ͯ·͢ɻ IUUQTHJUIVCDPNLHNZTIJOSFDZDMFSWJFXTFMFDUJPOTBNQMF ANBTUFSATUBCMFJEඇ༻ϒϥϯν AVTF@TUBCMF@JEATUBCMFJE༻ϒϥϯν
© DMM.com X ࠓि༵Կͯ͠·͔͢ʁ͍͠Ͱ͔͢ʁٕज़ॻయདྷͯΒ͍͍ͬͯͰ͔͢ʁ ؔͳ͍༰Ͱ͝ΊΜͳ͍͞ʂ ,6(*#",0ͱ͍͏αʔΫϧ໊Ͱग़ళ͠·͢ʂ͓࣌ؒ͋Εੋඇʂ IUUQTNPUJEBKBQBOIBUFOBCMPHDPNFOUSZ
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ