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
pixiv SUMMER BOOT CAMP 2015 講義資料
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Keisuke SASAKI
September 24, 2015
Technology
3.5k
0
Share
pixiv SUMMER BOOT CAMP 2015 講義資料
Androidのはなしをしました
Keisuke SASAKI
September 24, 2015
More Decks by Keisuke SASAKI
See All by Keisuke SASAKI
ピクシブのAndroidアプリ事情
rooandqoo
1
4.4k
Rails寺子屋 x kosenconf 告知
rooandqoo
0
73
高専カンファレンス in 釧路 発表資料
rooandqoo
2
820
Other Decks in Technology
See All in Technology
Revisiting [CLS] and Patch Token Interaction in Vision Transformers
yu4u
0
400
エージェントスキルを作って自分のインプットに役立てよう
tsubakimoto_s
0
440
コードや知識を組み込む / Incorporate Code and Knowledge
ks91
PRO
0
170
Shipping AI Agents — Lessons from Production
vvatanabe
0
280
実践ハーネスエンジニアリング:TAKTで実現するAIエージェント制御 / Practical Harness Engineering: AI Agent Control Enabled by TAKT
nrslib
13
4.9k
Practical TypeProf: Lessons from Analyzing Optcarrot
mame
0
1.1k
Rapid Start: Faster Internet Connections, with Ruby's Help
kazuho
2
770
20260423_執筆の工夫と裏側 技術書の企画から刊行まで / From the planning to the publication of technical book
nash_efp
3
450
需要創出(Chatwork)×供給(BPaaS) フライホイールとMoat 実行能力の最適配置とAI戦略
kubell_hr
0
850
Anthropic「Long-running a gents」をGeminiで再現してみた
tkikuchi
0
290
AIコーディング時代における、ソフトウェアサプライチェーン攻撃に対する防衛術(簡易版)
soysoysoyb
0
130
スクラムの中で AI-DLC workflow を 使い始めて3ヶ月の振り返り
kaminashi
0
130
Featured
See All Featured
Designing Experiences People Love
moore
143
24k
Between Models and Reality
mayunak
3
270
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
30 Presentation Tips
portentint
PRO
1
280
Making Projects Easy
brettharned
120
6.6k
Side Projects
sachag
455
43k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
150
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
300
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Transcript
Androidのはなし るーく@RooandQoo
About me 佐々木 佳祐@るーく 社歴2(4)年目 アプリ@マンガプロジェクト インターネットで二児の父をしています
pixiv マンガ
pixiv マンガ ・(ほぼ)毎日届く編集部のオススメマンガ ・読みやすい縦読みビューワー ・pixivコミックの連載も読めちゃう ・無料!!!!!!!!!!!!
pixiv マンガ Android / iOS
pixiv マンガ このアプリを つくる上での テクニックとかを 紹介していきます
º iOSのみなさんゴメンナサイ…。
Activityはなるべくスリムにする
画面を構成する基本要素 Activity Fragment (Custom)View
Activity
Fragment
Fragment
(Custom)View
(Custom)View
(Custom)View
その気になればActivity1つでなんでもできる
その気になればActivity1つでなんでもできる なんでもは言いすぎたかも
値の処理 バリデーション アニメーション ネットワーク処理 DB操作 メニュー 画面回転の対応 Intentの処理 Fragment管理 KeyEvent
戻るボタン テーマの設定 他の画面から呼び出される etcetc…
全部やらせたら当然太る
肥大化したクラスはメンテしたくない
Activity, Fragment, View 得意分野がそれぞれ異なるので 任せることが大事
特にActivityは Activityにしかできないことを やらせる方が良い
値の処理 バリデーション アニメーション ネットワーク処理 DB操作 メニュー 画面回転の対応 Intentの処理 Fragment管理 KeyEvent
戻るボタン テーマの設定 他の画面から呼び出される etcetc…
メニュー Intentの処理 Fragment管理 テーマの設定 他の画面から呼び出される
FragmentとViewは 何をすべきか?
・Viewの集合をユーザに見せる Fragment 定義されたレイアウトを表示する 画面を切り替える
・ライフサイクルに応じた処理 Fragment Activityにくっついた、離れた Viewが生まれた、死んだ 画面が回転された
・ネットワーク処理 Fragment リクエストを投げる 結果を受け取って何かする
・DB, ファイルの操作 Fragment
・画面パーツとして利用する (Custom)View パーツにユーザが操作を加えたとき なんらかの値が変わる場合 CustomViewが処理する
CustomViewの使用例
pixivマンガのトップ
CustomView
CustomView ここが 変わる
CustomView ちなみに これも CustomView
Activity(この場合はFragment)でもできる 1. GridViewとTextViewをFragment内で定義 2. ジャンル一覧のGridViewにListenerを設定 3. Listener内のonItemSelectedでTextViewの中身を更新
処理をViewに譲渡することで 見通しがよくなる Fragmentから GenreLabelView.setGenreTextView(“ジャンル名”) を呼ぶだけ!!
CustomViewのつくりかた 1. CustomViewとして使うもののレイアウトファイルをつくる 2. なんちゃらLayoutを継承したクラスをつくる 3. コンストラクタを書く 4. あるActivity(Fragment)のレイアウトに埋め込む 5.
または、使いたい場面で直接インスタンスを作って使う
レイアウト埋め込み型
インスタンスつくる型
たのしいCustomViewライフを!!
Fragmentは闇が深い
Fragmentは人類には早すぎたんや… @choco_biimu
とはいえ使わないわけにもいかない
用法・用量を守ろう 1. コンストラクタのつくりかたを守る 2. 初期値の設定はset/getArguments()で 3. startActivityはあんましないほうが良い 4. 特にstartActivityForResult()は怪しい 5.
などなど ググるといい感じの資料が出てくる
用法・用量を守ろう 1. コンストラクタのつくりかたを守る 2. 初期値の設定はset/getArguments()で 3. startActivityはあんましないほうが良い 4. 特にstartActivityForResult()は怪しい 5.
などなど というかこの資料もリファレンスがあるので あとで教えます
細かいこといろいろ
画面遷移はcreateIntent()で! Activity1 Activity2
よくあるパターン Activity1.startActivity(this, Activity2.class)
よくあるパターン Intent intent = new Intent(this, Activity2.class) intent.putExtra(“hoge”, 1) startActivity(intent)
遷移先のことを常に意識しないといけない
createIntent public static Intent createIntent(Activity fromactivity) { Intent intent =
new Intent(fromActivity, Activity2.class); return intent; } 呼び出される側(Activity2)
createIntent startActivity(Activity2.createIntent(this)) 呼び出す側(Activity1)
createIntent public static Intent createIntent(Activity fromactivity, int a) { Intent
intent = new Intent(fromActivity, Activity2.class); intent.putExtra(“hoge”, a) return intent; } 値を渡したいとき
createIntent startActivity(Activity2.createIntent(this, 1)) 値を渡したいとき キーの名前を意識しなくて済む
List(Grid)Viewを使うときは ViewHolderを実装する スクロール した時に Viewを 使いまわす
List(Grid)Viewを使うときは ViewHolderを実装する DataBindingで 置き換えられそう スクロール した時に Viewを 使いまわす
Activityはなるべくスリムに まとめ Fragment, CustomViewをうまく使おう Fragmentを使うときはルールを守ろう 画面遷移はcreateIntent()で DataBindingすごそう
参考資料 IUUQXXXTMJEFTIBSFOFUZBO[NESPJELBJHJZBO[N "DUJWJUZ 'SBHNFOU $VTUPN7JFXͷ͍͚Ϛονϣͳ "DUJWJUZʹ͞ΑͳΒ͢Δํ๏
参考資料 IUUQHGYIBUFOBCMPHDPNFOUSZ "OESPJE%BUB#JOEJOHಋೖͷୈҰา #VUUFS,OJGF 7JFX)PMEFSύλʔϯΛஔ͖͑Δ