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
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
6
1.7k
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
610
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
230
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
480
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
300
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
Amazon Qを使ってIaCを触ろう!
maruto
0
410
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.8k
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
Remix on Hono on Cloudflare Workers
yusukebe
1
300
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
The Cult of Friendly URLs
andyhume
78
6k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
130
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Scaling GitHub
holman
458
140k
Typedesign – Prime Four
hannesfritz
40
2.4k
Ruby is Unlike a Banana
tanoku
97
11k
It's Worth the Effort
3n
183
27k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
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 ͦͷลΓΛཧղ্ͨ͠Ͱ͍͖ͬͯ·͠ΐ͏