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
Square Fragmentやめるってよ
Search
ninjinkun
October 22, 2014
Programming
13
3.4k
Square Fragmentやめるってよ
『【翻訳】Android Fragmentへの反対声明』の解説
http://ninjinkun.hatenablog.com/entry/2014/10/16/234611
ninjinkun
October 22, 2014
Tweet
Share
More Decks by ninjinkun
See All by ninjinkun
買収から2ヶ月でシステム統合した話
ninjinkun
0
43
Designer's and Engineer's Thinking Styles
ninjinkun
0
120
Launchable Webinar テストを効率化して生産性を上げる方法
ninjinkun
2
500
ディープリンクの 設計と実装 - iOSDC2017
ninjinkun
18
9.8k
スマートフォンアプリ開発における共創的な開発チーム
ninjinkun
61
18k
ReSwiftでアプリの状態管理 / Reactive Swift Meetup
ninjinkun
9
16k
フリルのアプリ開発今昔物語
ninjinkun
3
2.2k
プロトタイピング合宿によるデザインリニューアル
ninjinkun
1
3k
デザイナーが仕事をしやすいアプリエンジニアを考える
ninjinkun
4
620
Other Decks in Programming
See All in Programming
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
1.8k
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
870
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
610
CSC509 Lecture 12
javiergs
PRO
0
160
Outline View in SwiftUI
1024jp
1
320
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
170
Remix on Hono on Cloudflare Workers
yusukebe
1
280
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
100
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
役立つログに取り組もう
irof
28
9.6k
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
A Tale of Four Properties
chriscoyier
156
23k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Making Projects Easy
brettharned
115
5.9k
Thoughts on Productivity
jonyablonski
67
4.3k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
YesSQL, Process and Tooling at Scale
rocio
169
14k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
4 Signs Your Business is Dying
shpigford
180
21k
Transcript
4RVBSF 'SBHNFOUΊΔͬͯΑ OJOKJOLVO
ʲ༁ʳ"OESPJE'SBHNFOUͷ ର໌ w "EWPDBUJOH"HBJOTU"OESPJE'SBHNFOUT w 4RVBSF͕'SBHNFOUΛΊͨ w ษڧ͕ͯΒ༁ͨ͠ͷͰɺղઆ͠·͢ w !IPUDIFNJ͞Μʹ༁νΣοΫ͖ͯ͠·ͨ͠
IUUQOJOKJOLVOIBUFOBCMPHDPNFOUSZ
'SBHNFOUͷ w ϥΠϑαΠΫϧ͕ෳࡶ w σόοά͕͍͠ w 7JFXͱϏδωεϩδοΫͷ͕ͮ͠Β͍ w ࠶ੜ͕ࠇຐज़
ϥΠϑαΠΫϧ͕ෳࡶ w "DUJWJUZ͔Βड͚ܧ͍ͩϥΠϑαΠΫϧ w "DUJWJUZͱ࿈ܞ͢ΔҝͷϥΠϑαΠΫϧ w 'SBHNFOU5SBOTBDUJPOͱ࿈ܞ͢ΔͨΊ ͷϥΠϑαΠΫϧ
σόοάͷ͠͞ w ελοΫΛ͍ͬͯ͘ͱ'SBHNFOU.BOBHFS*NQM ʹͿ͔ͭͬͯࢮ͵
7JFX$POUSPMMFSͨΓಘΔ͔ w 'SBHNFOU7JFXʹؔ͢ΔϩδοΫ͍ͩͿ࣋ͬͯ ͍Δ w ϏδωεϩδοΫͱ྆ํࠞࡏͯ͠͠·͏
'SBHNFOU5SBOTBDUJPO w DPNNJU͕ඇಉظ w ϝΠϯεϨουͷϋϯυϥΩϡʔͷ͋ͱͰ·ͱΊͯ ࣮ߦ͞ΕΔ w ͙͢ʹ݁ՌΛ͍͍ͨͳΒ FYFDVUF1FOEJOH5SBOTBDUJPOT
'SBHNFOUΛੜ͢Δຐ๏ w 'SBHNFOUϦϑϨΫγϣϯΛͬͯ࠶ੜ͞ΕΔ w ಗ໊ΫϥεͰ'SBHNFOUΛ࡞Δͱɺ0VUFS$MBTTͷ ࢀর͕ͳͯ͘࠶ੜ࣌ʹࢮ͵ w +BWBͷϥΠϑαΠΫϧͱ'SBHNFOUͷϥΠϑαΠΫ ϧ͕ϛεϚον DialogFragment
dialogFragment = new DialogFragment() { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { ... } }; dialogFragment.show(fragmentManager, tag);
ʢิʣ'SBHNFOUΛੜ͢Δຐ๏ w -JTUFOFSอ࣋Ͱ͖ͳ͍ w ͱ௨৴͠Α͏ͱࢥͬͨΒɺʹ-JTUFOFSΛ࣮͢ Δඞཁ͕͋Δ w 'SBHNFOU͔Β"DUJWJUZʹίʔϧόοΫ͢Δํ๏ IUUQZBO[NCMPHTQPUKQGSBHNFOUBDUJWJUZIUNM
public class MainFragment extends Fragment { public interface OnOkBtnClickListener {
public void onOkClicked(); } private OnOkBtnClickListener mListener; public void setOnOkBtnClickListener(OnOkBtnClickListener l) { mListener = l; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Button okBtn = new Button(inflater.getContext()); okBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(mListener != null) { mListener.onOkClicked(); } } }); return okBtn; } } ࠶ੜ࣌ʹ-JTUFOFS͕ফ͑Δ IUUQZBO[NCMPHTQPUKQGSBHNFOUBDUJWJUZIUNM
public class MainFragment2 extends Fragment { public interface OnOkBtnClickListener {
public void onOkClicked(); } private OnOkBtnClickListener mListener; @Override public void onAttach(Activity activity) { super.onAttach(activity); if (activity instanceof OnOkBtnClickListener == false) { throw new ClassCastException("activity ͕ OnOkBtnClickListener Λ࣮͍ͯ͠·ͤΜ."); } mListener = ((OnOkBtnClickListener) activity); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Button okBtn = new Button(inflater.getContext()); okBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mListener != null) { mListener.onOkClicked(); } } }); return okBtn; } }
'SBHNFOU͔ΒֶΜͩ͜ͱ w ୯Ұͷ"DUJWJUZ w ը໘ຖʹ"DUJWJUZΛ͚Δඞཁແ͍ w ΞχϝʔγϣϯͱϥΠϑαΠΫϧ͕؆୯ʹͳΔ
'SBHNFOU͔ΒֶΜͩ͜ͱ w όοΫελοΫ"DUJWJUZಛ༗ͷ֓೦Ͱͳ͍ w "DUJWJUZͷதʹ࣮Ͱ͖Δ
'SBHNFOU͔ΒֶΜͩ͜ͱ w ඞཁͳͷશ෦ॳΊ͔Βἧ͍ͬͯͨ w "DUJWJUZ 7JFX -BZPVU*OqBUPS
ΧελϜϏϡʔ w $POUBJOFSͷಋೖ w ຕͷը໘Λ7JFXͰදݱ͢Δ w 7JFXPS-BZPVUͷαϒΫϥε w 7JFXͱͯ͠ͷׂ όοΫૢ࡞ͷཧ
public class DualPaneContainer extends LinearLayout implements Container { private MyDetailView
detailView; ! public DualPaneContainer(Context context, AttributeSet attrs) { super(context, attrs); } ! @Override protected void onFinishInflate() { super.onFinishInflate(); detailView = (MyDetailView) getChildAt(1); } ! public boolean onBackPressed() { return false; } ! @Override public void showItem(String item) { detailView.setItem(item); } }
public class MainActivity extends Activity { private Container container; !
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); container = (Container) findViewById(R.id.container); } ! public Container getContainer() { return container; } ! @Override public void onBackPressed() { boolean handled = container.onBackPressed(); if (!handled) { finish(); } } }
7JFXͱ1SFTFOUFS w ϏδωεϩδοΫͱ$POUSPMMFSͷ w 1SFTFOUFS w .PEFMΛૢ࡞͢Δ w 7JFXΛૢ࡞͢Δ
ʢิʣ.71ύλʔϯ w .7$ͱͷҧ͍ w $POUSPMMFS͕ϢʔβʔೖྗΛड͚ͱΒͳ͍ w ड͚ͱΔͷ7JFX
public class MyDetailView extends LinearLayout { TextView textView; DetailPresenter presenter;
! public MyDetailView(Context context, AttributeSet attrs) { super(context, attrs); presenter = new DetailPresenter(); } ! @Override protected void onFinishInflate() { super.onFinishInflate(); presenter.setView(this); textView = (TextView) findViewById(R.id.text); findViewById(R.id.button).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { presenter.buttonClicked(); } }); } ! public void setItem(String item) { textView.setText(item); } }
class EditDiscountPresenter { // ... public void saveDiscount() { EditDiscountView
view = getView(); String name = view.getName(); if (isBlank(name)) { view.showNameRequiredWarning(); return; } if (isNewDiscount()) { createNewDiscountAsync(name, view.getAmount(), view.isPercentage()); } else { updateNewDiscountAsync(discountId, name, view.getAmount(), view.isPercentage()); } close(); } }
OJOKJOLVOࢲݟ w "DUJWJUZͷܽؕʢͱ͍͏͔χʔζʹ߹͍ͬͯͳ͔ͬ ͨͱ͜Ζʣ w "DUJWJUZؒͷૄ݁߹ઃܭ w ը໘લఏ
OJOKJOLVOࢲݟ w "DUJWJUZͷܽΛิ͢ΔͨΊͷ'SBHNFOU w "DUJWJUZͱͷ߹ੑΛऔΖ͏ͱ͗ͯ͢͠ઃܭ͕ෳ ࡶʹͳͬͯ͠·͍ͬͯΔ w 4RVBSF߹ੑΛࣺͯͯɺಠࣗͷεςʔτϑϧੈ քΛߏங͢ΔΞϓϩʔν
OJOKJOLVOࢲݟ w ϖʔδભҠ͢Δ8FCΞϓϦͱ4JOHMF1BHF "QQMJDBUJPOͷؔʹࣅͯΔ w ͳͷͰࢀߟʹͳΔ͜ͱ͋Δ͔
OJOKJOLVOࢲݟ w ฐࣾͰ'SBHNFOUࣺͯͳ͍ w ಠࣗͰੈք؍Λ࡞Δ༨༟ͳ͍ w ͔͠͠'SBHNFOUͷਏ͞ೝ͓͖ࣝͯͩ͘͠ͱࢥ ͏
ձσΟεΧογϣϯ w #BDLTUBDLʹ٧Έ͍ͨͱ͖͚ͩ'SBHNFOUΛ͏ύ λʔϯΛࢼ͍ͯ͠Δํ͕͍Βͬ͠Όͬͨ w $VTUPN7JFXΛͬͱ͏Α͏ʹ͢Ε'SBHNFOU ґଘݮΒͤΔ w 'SBHNFOUʹԿͰॻ͘ͷԿʹͤΑΞϯνύλʔ ϯ
w 1SFTFOUFS'SBHNFOUΛ͍ͬͯͯ༗༻ͦ͏
ձσΟεΧογϣϯ w Ͱ͖Δ͚ͩ"DUJWJUZ͚ͩͰ࡞Δͷํ w "DUJWJUZʹ͍ͭͯ͋·Γέ͕ྑ͘ͳ͔ͬͨ
ձσΟεΧογϣϯ w 'SBHNFOUͷਏ͞ʹ͍ͭͯ݁ߏίϯηϯαε͕औ Εͨͱࢥ͏ w ͦͷลΓΛཧղ্ͨ͠Ͱ͍͖ͬͯ·͠ΐ͏