Created
October 5, 2015 07:30
-
-
Save TheLester/003ec8b6310a1b6f9843 to your computer and use it in GitHub Desktop.
Abstract Activity
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
public abstract class EffectiveActivity extends AppCompatActivity { | |
private ViewGroup mainFrame; | |
private ScreenContainer screenContainer; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
screenContainer = createScreenContainer(); | |
mainFrame = screenContainer.bind(this); | |
getLayoutInflater().inflate(getLayout(), mainFrame); | |
ButterKnife.bind(this); | |
} | |
ScreenContainer createScreenContainer() { | |
return new ScreenContainerImpl(); | |
} | |
@NonNull | |
abstract Integer getLayout(); | |
@Override | |
public boolean onOptionsItemSelected(MenuItem item) { | |
switch (item.getItemId()) { | |
case android.R.id.home: | |
screenContainer.getDrawerLayout().openDrawer(GravityCompat.START); | |
return true; | |
} | |
return super.onOptionsItemSelected(item); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment