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.5k
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
55
Designer's and Engineer's Thinking Styles
ninjinkun
0
150
Launchable Webinar テストを効率化して生産性を上げる方法
ninjinkun
2
510
ディープリンクの 設計と実装 - iOSDC2017
ninjinkun
18
10k
スマートフォンアプリ開発における共創的な開発チーム
ninjinkun
61
18k
ReSwiftでアプリの状態管理 / Reactive Swift Meetup
ninjinkun
9
16k
フリルのアプリ開発今昔物語
ninjinkun
3
2.2k
プロトタイピング合宿によるデザインリニューアル
ninjinkun
1
3k
デザイナーが仕事をしやすいアプリエンジニアを考える
ninjinkun
4
630
Other Decks in Programming
See All in Programming
shadcn/uiを使ってReactでの開発を加速させよう!
lef237
0
300
Flatt Security XSS Challenge 解答・解説
flatt_security
0
730
rails newと同時に型を書く
aki19035vc
5
710
ASP.NET Core の OpenAPIサポート
h455h1
0
120
return文におけるstd::moveについて
onihusube
1
1.4k
Androidアプリのモジュール分割における:x:commonを考える
okuzawats
1
280
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
6
1.4k
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
6
700
.NETでOBS Studio操作してみたけど…… / Operating OBS Studio by .NET
skasweb
0
120
Amazon Nova Reelの可能性
hideg
0
200
AHC041解説
terryu16
0
390
KMP와 kotlinx.rpc로 서버와 클라이언트 동기화
kwakeuijin
0
300
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
335
57k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Agile that works and the tools we love
rasmusluckow
328
21k
RailsConf 2023
tenderlove
29
970
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
What's in a price? How to price your products and services
michaelherold
244
12k
Making the Leap to Tech Lead
cromwellryan
133
9k
The Language of Interfaces
destraynor
155
24k
Bash Introduction
62gerente
610
210k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
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 ͦͷลΓΛཧղ্ͨ͠Ͱ͍͖ͬͯ·͠ΐ͏