Created
November 5, 2014 12:59
-
-
Save geftimov/304863eded96f8e79108 to your computer and use it in GitHub Desktop.
BaseActivity Otto and Dagger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.os.Bundle; | |
import android.support.v7.app.ActionBarActivity; | |
import com.eftimoff.jokes.JokesApplication; | |
import com.eftimoff.jokes.utils.SharedPrefs; | |
import com.squareup.otto.Bus; | |
import javax.inject.Inject; | |
public class BaseActivity extends ActionBarActivity { | |
@Inject | |
SharedPrefs sharedPrefs; | |
@Inject | |
Bus bus; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
// Perform injection so that when this call returns all dependencies will be available for use. | |
JokesApplication.inject(this); | |
bus.register(this); | |
} | |
@Override | |
protected void onResume() { | |
super.onResume(); | |
bus.register(this); | |
} | |
@Override | |
protected void onPause() { | |
super.onPause(); | |
bus.unregister(this); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment