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

Dart

funnelbit
January 30, 2017

 Dart

funnelbit

January 30, 2017
Tweet

More Decks by funnelbit

Other Decks in Programming

Transcript

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

    = new Intent(MainActivity.this, Main2Activity.class); intent.putExtra(Main2Activity.EXTRA_TEXT, "ok");
 startActivity(intent);
 …
 }
  2. .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));
 …
 }
  3. .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")); }
 …
 }
  4. .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);
 …
 }
  5. .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);
 …
 }
  6. .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);
 …
 }
  7. .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")); }
 }
  8. %BSUJOKFDU 'SBHNFOU public class BlankFragment extends Fragment {
 @InjectExtra String

    param1;
 @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 Dart.inject(this);
  9. .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();
 …
 }
  10. #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 ͪΐͬͱେม
  11. .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);
 … }
  12. .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();
 } …
 }
  13. #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 ͍ͩͿେม