DrawerActivity

public class DrawerActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener

Superclass for all Activities that have a navigation drawer

Fields

currentUser

protected long currentUser

ID of the current User

frameLayout

protected FrameLayout frameLayout

Parent for the drawer activity

fullLayout

protected DrawerLayout fullLayout

The inflated user interface for the activity with the drawer

mDrawerLayout

protected DrawerLayout mDrawerLayout

User interface for the drawer itself

mDrawerToggle

protected ActionBarDrawerToggle mDrawerToggle

Toggles whether the drawer is visible

mToolbar

protected Toolbar mToolbar

queue

RequestQueue queue

Queue for asynchronous tasks

subscribedNetworkIds

protected Set<Long> subscribedNetworkIds

IDs of the Networks the current User is subscribed to

subscribedNetworks

protected SparseArray<Network> subscribedNetworks

The User’s current Networks

thisActivity

Activity thisActivity

Reference to the current activity

Methods

onConfigurationChanged

public void onConfigurationChanged(Configuration newConfig)

{@inheritDoc} Also updates the configuration of the drawer toggle by calling DrawerActivity.mDrawerToggle.onConfigurationChanged(Configuration) with the provided parameter.

Parameters:

onNavigationItemSelected

public boolean onNavigationItemSelected(MenuItem item)

Handle navigation items the user selects. If they select a Network, they are sent to TimelineActivity after the selected network is set as their chosen one. Otherwise, the appropriate activity is launched based on the option they select.

Parameters:
  • item – Item the user selected.
Returns:

Always returns true

onPostCreate

protected void onPostCreate(Bundle savedInstanceState)

{@inheritDoc} Also syncs the state of DrawerActivity.mDrawerToggle

Parameters:

onStop

public void onStop()

This ensures that we are canceling all network requests if the user is leaving this activity. We use a RequestFilter that accepts all requests (meaning it cancels all requests)

setContentView

public void setContentView(int layoutResID)

Create the drawer from R.layout.activity_drawer, which has parent with ID R.id.drawer_frame. Populate the drawer with data from the current User and their Networks.

Parameters:
  • layoutResID – ID for the layout file to inflate