Skip to content

Instantly share code, notes, and snippets.

@derekcsm
Last active August 29, 2015 14:15
Show Gist options
  • Save derekcsm/4fdc212dde89fd33e020 to your computer and use it in GitHub Desktop.
Save derekcsm/4fdc212dde89fd33e020 to your computer and use it in GitHub Desktop.
ActMain
public class ActMain extends ActionBarActivity {
private Toolbar mToolbar;
private android.support.v7.app.ActionBar abMain = null;
// https://gist.github.com/castorflex/4e46a9dc2c3a4245a28e
public static CircleProgressView mProgressToolbar;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.act_main);
/*
finds the toolbar view in act_main.xml
*/
mToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
/*
this sets your toolbar to act as you would expext
your typical actionbar to work
*/
setSupportActionBar(mToolbar);
/*
I'm setting the top left icon to a drawer hamburger here
*/
mToolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
/*
If you want to reference your Toolbar as an ActionBar variable
at some point you can do this
*/
abMain = getSupportActionBar();
abMain.setHomeButtonEnabled(true);
/*
finds the CircleProgressView for use later
*/
mProgressToolbar = (CircleProgressView) findViewById(R.id.progress_spinner);
}
/*
Calling setToolbarProgress from anywhere in your app while
ActMain is visible, will cause the circular progress bar to
toggle it's visiblility within the toolbar, this acts as a
replacement to setSupportProgressBarIndeterminateVisibility(boolean);
now that the toolbar doesn't support it.
*/
public static void setToolbarProgress(boolean show) {
if (show) {
mProgressToolbar.setVisibility(View.VISIBLE);
} else {
mProgressToolbar.setVisibility(View.GONE);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment