Skip to content
edolganov edited this page May 1, 2013 · 10 revisions

Common Cases

Logger

  • Setup
static {
    LogFactory.setTagPrefix("SOME-TAG");
}
  • Use
Logger log = LogFactory.getLog(getClass());
log.info("some info msg");
log.error("ups error", e);

Activity safe functons

No need of super calls anymore:

import easydroid.core.BaseActivity;

public class YourActivity extends BaseActivity { 

    @Override
    protected void onCreateSafe(Bundle bundle) {
        //no need of super.onCreate(bundle)
    }
    
    @Override
    protected void onDestroySafe() {
        //no need of super.onDestroy()
    }

}

Views Injection

Use @InjectView annotation:

import easydroid.core.BaseActivity;

public class YourActivity extends BaseActivity { 

	@InjectView(R.id.browser_back)
	View backButton;
	
	@InjectView(R.id.browser_home)
	View homeButton;

        @Override
	protected void onCreateSafe(Bundle savedInstanceState) {
            setContentView(R.layout.browser);
            //access to backButton and homeButton
        }

}

Content View Injection

Use @ContentView instead of setContentView function:

import easydroid.core.BaseActivity;

@ContentView(R.layout.browser)
public class YourActivity extends BaseActivity { 

    @InjectView(R.id.browser_back)
    View backButton;
    
    @InjectView(R.id.browser_home)
    View homeButton;

    @Override
    protected void onCreateSafe(Bundle savedInstanceState) {
        //access to backButton and homeButton
    }

}

Clone this wiki locally