Exemplo n.º 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);

    mStorageComponent = ((MyApplication) this.getApplication()).getStorageComponent();
    mStorageComponent.inject(this); // 注入MainActivity
    mStorageComponent.execute().storage(); // 执行储存操作
  }
Exemplo n.º 2
0
 @OnClick({R.id.button1, R.id.button2, R.id.button3})
 void onButtonClicked(View v) {
   switch (v.getId()) {
     case R.id.button1:
       // Toast.makeText(this,mPreferences.getString(KEY,"---"),Toast.LENGTH_SHORT).show();
       Toast.makeText(this, mStorageComponent.execute().getStorage(), Toast.LENGTH_SHORT).show();
       break;
     case R.id.button2:
       Toast.makeText(this, mPerson.getName() + "----" + mPerson.getAge(), Toast.LENGTH_SHORT)
           .show();
       break;
     case R.id.button3:
       Intent intent = new Intent(this, SecondActivity.class);
       startActivity(intent);
       break;
   }
 }