Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Dart

8928b5277aa7234dbca4ff782952343a?s=47 funnelbit
January 30, 2017

 Dart

8928b5277aa7234dbca4ff782952343a?s=128

funnelbit

January 30, 2017
Tweet

Transcript

  1. %BSU

  2. ࣗݾ঺հ ๺ଜྋ גࣜձࣾ͸ͯͳ )BUFOBGVOOFMCJU 5XJUUFS!FYQFSPQFSP

  3. %SPJE,BJHJͰൃද͠·͢ w IUUQTESPJELBJHJHJUIVCJP w ೔໨3PPNd w IUUQTESPJELBJHJHJUIVCJP UJNFUBCMFIUNM

  4. *OUFOU ͷ ѻ͍Λ ؆୯ʹ͢Δ

  5. 4USJOH .BJO"DUJWJUZ .BJO"DUJWJUZ

  6. .BJO"DUJWJUZ public class MainActivity extends AppCompatActivity {
 …
 Intent intent

    = new Intent(MainActivity.this, Main2Activity.class); intent.putExtra(Main2Activity.EXTRA_TEXT, "ok");
 startActivity(intent);
 …
 }
  7. .BJO"DUJWJUZ public class Main2Activity extends AppCompatActivity { …
 public static

    final String EXTRA_TEXT = “text"; …
 Bundle extras = getIntent().getExtras();
 Log.e("extra_text", extras.getString(EXTRA_TEXT));
 …
 }
  8. 4USJOH PS /VMM .BJO"DUJWJUZ .BJO"DUJWJUZ

  9. .BJO"DUJWJUZ public class Main2Activity extends AppCompatActivity {
 public static final

    String EXTRA_TEXT = "text";
 …
 Bundle extras = getIntent().getExtras();
 if (extras != null) {
 Log.e(“extra_text", extras.getString(EXTRA_TEXT, "defaultValue")); }
 …
 }
  10. w ૿͑Δఆ਺ w ૿͑ΔJGจ w ૿͢ϨϏϡʔίετ

  11. %BSU %BSUBOE)FOTPO

  12. %BSU %BSUBOE)FOTPO w #VUUFS,OJGFΈͨ͘&YUSBͷ஋Λ*OKFDU͢Δ w ίϯύΠϧ࣌ʹ*OKFDU͢ΔίʔυΛੜ੒

  13. 4USJOH .BJO"DUJWJUZ .BJO"DUJWJUZ

  14. .BJO"DUJWJUZ public class MainActivity extends AppCompatActivity {
 …
 Intent intent

    = new Intent(MainActivity.this, Main2Activity.class); intent.putExtra(Main2Activity.EXTRA_TEXT, “ok"); …
 Intent intent = Henson.with(MainActivity.this)
 .gotoMain2Activity()
 .text("ok")
 .build();
 startActivity(intent);
 …
 }
  15. .BJO"DUJWJUZ public class Main2Activity extends AppCompatActivity {
 … @InjectExtra String

    text;
 public static final String EXTRA_TEXT = "text";
 …
 Dart.inject(this);
 Log.e("extra_text", text);
 …
 }
  16. 0QUJPOBM*OKFDUJPO

  17. 4USJOH PS /VMM .BJO"DUJWJUZ .BJO"DUJWJUZ

  18. .BJO"DUJWJUZ public class MainActivity extends AppCompatActivity {
 …
 Intent intent

    = new Intent(MainActivity.this, Main2Activity.class); intent.putExtra(Main2Activity.EXTRA_TEXT, “ok"); …
 Intent intent = Henson.with(MainActivity.this)
 .gotoMain2Activity()
 .text("ok")
 .build();
 startActivity(intent);
 …
 }
  19. .BJO"DUJWJUZ public class Main2Activity extends AppCompatActivity {
 … @Nullable @InjectExtra

    String text;
 public static final String EXTRA_TEXT = "text";
 …
 Dart.inject(this);
 if (!TextUtils.isEmpty(text)) {
 Log.e("extra_text", text);
 … Bundle extras = getIntent().getExtras();
 if (extras != null) {
 Log.e(“extra_text", extras.getString(EXTRA_TEXT, "defaultValue")); }
 }
  20. %FGBVMU7BMVFT

  21. .BJO"DUJWJUZ public class Main2Activity extends AppCompatActivity { …
 @Nullable @InjectExtra

    String text = "default";
 … }
  22. 'SBHNFOU

  23. %BSUJOKFDU 'SBHNFOU public class BlankFragment extends Fragment {
 @InjectExtra String

    param1;
 @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 Dart.inject(this);
  24. %BSUJOKFDU BOESPJEBQQ'SBHNFOU

  25. %BSUJOKFDU 0CKFDU #VOEMF

  26. .BJO"DUJWJUZ public class Main2Activity extends AppCompatActivity {
 …
 Bundle extras

    = Henson.with(this) .gotoBlankFragment() .param1(“??????”) .build() .getExtras(); 
 blankFragment = new BlankFragment();
 blankFragment.setArguments(extras);
 getSupportFragmentManager()
 .beginTransaction()
 .replace(R.id.fragment_container, blankFragment, TAG_FRAGMENT)
 .commit();
 …
 }
  27. #MBOL'SBHNFOU public class BlankFragment extends Fragment {
 @InjectExtra String param1;


    @Override public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 Dart.inject(this, getArguments());
 Log.e("param1", param1);
 }
 } w ͪΐͬͱେม
  28. .BJO"DUJWJUZ 
 public class MainActivity extends AppCompatActivity {
 …
 Bundle

    fragmentExtras = Henson.with(MainActivity.this)
 .gotoBlankFragment()
 .param1("!!!!!!!!!")
 .build()
 .getExtras();
 Intent intent = Henson.with(MainActivity.this)
 .gotoMain2Activity()
 .text("a")
 .build();
 intent.putExtras(fragmentExtras);
 startActivity(intent);
 … }
  29. .BJO"DUJWJUZ public class Main2Activity extends AppCompatActivity { …
 Fragment blankFragment

    = getSupportFragmentManager().findFragmentByTag(TAG_FRAGMENT);
 if (blankFragment == null) {
 getSupportFragmentManager()
 .beginTransaction()
 .replace(R.id.fragment_container, new BlankFragment(), TAG_FRAGMENT)
 .commit();
 } …
 }
  30. #MBOL'SBHNFOU public class BlankFragment extends Fragment {
 @InjectExtra String param1;


    @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 Log.e("param1", param1);
 }
 @Override
 public void onAttach(Context context) {
 super.onAttach(context);
 Dart.inject(this, getActivity());
 }
 } w ͍ͩͿେม
  31. ·ͱΊ w ίʔυྔͷ૿ՃΛ཈͑Δ͜ͱ͕ग़དྷΔ w Մಡੑ޲্ w ϨϏϡʔ͠΍͍͢ w 'SBHNFOUͰ࢖͏ʹ͸ͪΐͬͱบ͕͋Δ

  32. ࢀߟ w IUUQTHJUIVCDPNGQSBUFFLEBSU

  33. ͋Γ͕ͱ͏͍͟͝·ͨ͠