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
50
Designer's and Engineer's Thinking Styles
ninjinkun
0
140
Launchable Webinar テストを効率化して生産性を上げる方法
ninjinkun
2
510
ディープリンクの 設計と実装 - iOSDC2017
ninjinkun
18
9.9k
スマートフォンアプリ開発における共創的な開発チーム
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
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
380
From Translations to Multi Dimension Entities
alexanderschranz
2
130
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
360
DevFest Tokyo 2025 - Flutter のアプリアーキテクチャ現在地点
wasabeef
5
900
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
360
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
280
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
930
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
110
Recoilを剥がしている話
kirik
5
6.7k
命名をリントする
chiroruxx
1
410
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
405
66k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
Done Done
chrislema
181
16k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
RailsConf 2023
tenderlove
29
940
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
Designing for Performance
lara
604
68k
The Cost Of JavaScript in 2023
addyosmani
45
7k
Faster Mobile Websites
deanohume
305
30k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
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 ͦͷลΓΛཧղ্ͨ͠Ͱ͍͖ͬͯ·͠ΐ͏