Android Open Source - InfuseFactory Main Activity






From Project

Back to project page InfuseFactory.

License

The source code is released under:

/** * Copyright (c) 2014 Lazu Ioan-Bogdan * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from ...

If you think the Android project InfuseFactory listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.infuseexample;
//from  ww w.  j a v a  2  s  .c  o  m
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;

import com.example.other.mock.DatabaseAdapter;
import com.example.other.mock.NetworkingAdapter;
import com.example.other.mock.PreferencesAdapter;
import com.example.other.ui.adapter.TestListAdapter;
import com.example.other.ui.listener.HideListener;
import com.example.other.ui.listener.ListListener;
import com.factory.android.InfuseActivity;
import com.factory.infuse.annotation.Infuse;
import com.factory.infuse.annotation.InfuseView;
import com.factory.infuse.annotation.bindings.BindAdapter;
import com.factory.infuse.annotation.bindings.BindOnClick;
import com.factory.infuse.annotation.bindings.BindOnItemClick;

public class MainActivity extends InfuseActivity {
  private static final String TAG = "MAIN_ACTIVITY";
  
  @BindAdapter(TestListAdapter.class)
  @BindOnItemClick(ListListener.class)
  @InfuseView(R.id.listView1)
  private ListView mListView;
  
  @BindOnClick(value = HideListener.class, id = R.id.buttonHide)
  private Button mHide;
  
  @InfuseView(R.id.textView1)
  private TextView mHelloWorld;
  
  @InfuseView(R.id.editText1)
  private EditText mText;
  
  @BindOnClick(value = GetTextListener.class, id = R.id.buttonText)
  private Button mGetText;
  
  // Infuse other utils that are used globally by the application
  @Infuse private DatabaseAdapter mDbAdapter;
  @Infuse private NetworkingAdapter mNetAdapter;
  @Infuse private PreferencesAdapter mPrefAdapter;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    
    Log.d(TAG, "onCreate()");
  }
  
  @Override
  public void onContentChanged() {
    super.onContentChanged();
    
    Log.d(TAG, "onContentChanged");
    
    mHelloWorld.setText("Goodbye world!"); 
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_settings) {
      return true;
    }
    return super.onOptionsItemSelected(item);
  }
  
  private static class GetTextListener implements OnClickListener {    
    
    @InfuseView(R.id.editText1)
    private TextView mText;
    
    @InfuseView(R.id.buttonText)
    private Button mGetText;
    
    @Override
    public void onClick(View v) {
      String text = mText.getText().toString();
      
      Log.d(TAG, "Text got: " + text);
      if(text != null) mGetText.setText(text);
    }
  }
}




Java Source Code List

com.example.infuseexample.ExampleApplication.java
com.example.infuseexample.MainActivity.java
com.example.infuseexample.MainFragmentActivity.java
com.example.other.mock.DatabaseAdapter.java
com.example.other.mock.NetworkingAdapter.java
com.example.other.mock.PreferencesAdapter.java
com.example.other.ui.adapter.TestListAdapter.java
com.example.other.ui.listener.HideListener.java
com.example.other.ui.listener.ListListener.java
com.factory.InfuseFactory.java
com.factory.android.InfuseActivityActionBar.java
com.factory.android.InfuseActivity.java
com.factory.android.InfuseApplication.java
com.factory.android.InfuseFragment.java
com.factory.infuse.InfuseCreator.java
com.factory.infuse.Infuser.java
com.factory.infuse.Scope.java
com.factory.infuse.annotation.InfuseView.java
com.factory.infuse.annotation.Infuse.java
com.factory.infuse.annotation.InitializeViews.java
com.factory.infuse.annotation.Initialize.java
com.factory.infuse.annotation.Instantiate.java
com.factory.infuse.annotation.ScopedSingleton.java
com.factory.infuse.annotation.Singleton.java
com.factory.infuse.annotation.bindings.BindAdapter.java
com.factory.infuse.annotation.bindings.BindOnClick.java
com.factory.infuse.annotation.bindings.BindOnItemClick.java
com.factory.infuse.annotation.bindings.BindOnItemLongClick.java
com.factory.infuse.annotation.bindings.BindOnScroll.java
com.factory.infuse.annotation.bindings.BindOnText.java
com.factory.infuse.annotation.bindings.BindOnTouch.java
com.factory.infuse.internal.InfuseReflection.java
com.factory.infuse.internal.InfuserGlobal.java
com.factory.infuse.internal.InfuserScoped.java
com.factory.infuse.internal.ViewResolver.java
com.factory.infuse.internal.base.AbsInfuser.java
com.factory.infuse.internal.lock.SharedLock.java
com.factory.infuse.internal.scope.GlobalScope.java
com.factory.infuse.internal.scope.LocalScope.java
com.factory.infuse.internal.scope.ScopeFactory.java
com.factory.java.InfuseObject.java