public abstract class BaseActivity
extends AppCompatActivity
AppCompatActivity class that all classes that wants to extend AppCompatActivity must extend. Handles a lot of the repetitive initializations. For example
to load the layout and menu, you provide the super constructor with the layout and menu resIds
and it will automatically setup the layout and menu for you.| Modifier and Type | Field and Description |
|---|---|
protected int |
mLayout
Layout resource id
|
protected int |
mMenu
Menu resource id
|
| Constructor and Description |
|---|
BaseActivity(int layout,
int menu) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addFragment(int containerViewId,
Fragment fragment)
Adds a
Fragment to this activity's layout. |
protected void |
addFragment(int containerViewId,
Fragment fragment,
java.lang.String tag)
Adds a
Fragment to this activity's layout. |
protected android.view.View |
fadeIn(android.view.View view,
boolean animate) |
protected android.view.View |
fadeOut(android.view.View view,
boolean animate) |
protected ActivityModule |
getActivityModule()
Gets an Activity module for dependency injection.
|
ApplicationComponent |
getApplicationComponent()
Gets the Main Application component for dependency injection.
|
boolean |
onContextItemSelected(android.view.MenuItem item) |
void |
onCreate(android.os.Bundle savedInstanceState) |
boolean |
onCreateOptionsMenu(android.view.Menu menu) |
boolean |
onOptionsItemSelected(android.view.MenuItem item) |
protected void |
onPause() |
protected void |
onResume() |
protected void |
replaceFragment(int containerViewId,
Fragment fragment)
Replaces an existing
Fragment in the activity. |
protected void |
replaceFragment(int containerViewId,
Fragment fragment,
java.lang.String tag)
Replaces an existing
Fragment in the activity. |
protected void |
setActionBarTitle(java.lang.String title) |
protected <V extends android.view.View> |
setViewGone(V view) |
protected <V extends android.view.View> |
setViewGone(V view,
boolean gone) |
protected void |
showSnabackar(android.view.View view,
int resId)
Shows a simple
Snackbar |
protected void |
showSnabackar(android.view.View view,
java.lang.String message)
Shows a simple
Snackbar |
protected void |
showToast(int resId)
Shows a
Toast message. |
protected void |
showToast(java.lang.String message)
Shows a
Toast message with a Long life span of the Toast shown. |
protected final int mLayout
protected final int mMenu
public void onCreate(android.os.Bundle savedInstanceState)
protected void onResume()
protected void onPause()
protected void setActionBarTitle(java.lang.String title)
protected void showToast(int resId)
Toast message.resId - A message resourceprotected void showToast(java.lang.String message)
Toast message with a Long life span of the Toast shown.message - the message to be shown by the toast.protected void showSnabackar(android.view.View view,
java.lang.String message)
Snackbarview - The view to anchor the Snackbar tomessage - The message to be showedprotected void showSnabackar(android.view.View view,
int resId)
Snackbarview - The view to anchor the Snackbar toresId - The message to be showedpublic boolean onCreateOptionsMenu(android.view.Menu menu)
public boolean onOptionsItemSelected(android.view.MenuItem item)
public boolean onContextItemSelected(android.view.MenuItem item)
protected android.view.View fadeIn(android.view.View view,
boolean animate)
protected android.view.View fadeOut(android.view.View view,
boolean animate)
protected <V extends android.view.View> V setViewGone(V view)
protected <V extends android.view.View> V setViewGone(V view,
boolean gone)
protected void addFragment(int containerViewId,
Fragment fragment,
java.lang.String tag)
Fragment to this activity's layout.containerViewId - The container view where to add the fragment.fragment - The fragment to be added.tag - The tag for the fragmentprotected void addFragment(int containerViewId,
Fragment fragment)
Fragment to this activity's layout.containerViewId - The container view where to add the fragment.fragment - The fragment to be added.protected void replaceFragment(int containerViewId,
Fragment fragment,
java.lang.String tag)
Fragment in the activity.containerViewId - The container view where to add the fragment.fragment - The fragment to be added.tag - The tag for the fragmentprotected void replaceFragment(int containerViewId,
Fragment fragment)
Fragment in the activity.containerViewId - the container view where to add the fragment.fragment - the fragment to be added.public ApplicationComponent getApplicationComponent()
ApplicationComponentprotected ActivityModule getActivityModule()
ActivityModule