use of android.widget.Toolbar in project plaid by nickbutcher.
the class DesignerNewsStory method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_designer_news_story);
ButterKnife.bind(this);
story = getIntent().getParcelableExtra(EXTRA_STORY);
fab.setOnClickListener(fabClick);
chromeFader = new ElasticDragDismissFrameLayout.SystemChromeFader(this);
markdown = new Bypass(this, new Bypass.Options().setBlockQuoteLineColor(ContextCompat.getColor(this, R.color.designer_news_quote_line)).setBlockQuoteLineWidth(// dps
2).setBlockQuoteLineIndent(// dps
8).setPreImageLinebreakHeight(//dps
4).setBlockQuoteIndentSize(TypedValue.COMPLEX_UNIT_DIP, 2f).setBlockQuoteTextColor(ContextCompat.getColor(this, R.color.designer_news_quote)));
circleTransform = new CircleTransform(this);
designerNewsPrefs = DesignerNewsPrefs.get(this);
layoutManager = new LinearLayoutManager(this);
commentsList.setLayoutManager(layoutManager);
commentsList.setItemAnimator(new CommentAnimator(getResources().getInteger(R.integer.comment_expand_collapse_duration)));
header = getLayoutInflater().inflate(R.layout.designer_news_story_description, commentsList, false);
bindDescription();
// setup title/toolbar
if (collapsingToolbar != null) {
// narrow device: collapsing toolbar
collapsingToolbar.addOnLayoutChangeListener(titlebarLayout);
collapsingToolbar.setTitle(story.title);
final Toolbar toolbar = (Toolbar) findViewById(R.id.story_toolbar);
toolbar.setNavigationOnClickListener(backClick);
commentsList.addOnScrollListener(headerScrollListener);
setEnterSharedElementCallback(new SharedElementCallback() {
@Override
public void onSharedElementStart(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
ReflowText.setupReflow(getIntent(), collapsingToolbar);
}
@Override
public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
ReflowText.setupReflow(collapsingToolbar);
}
});
} else {
// w600dp configuration: content card scrolls over title bar
final TextView title = (TextView) findViewById(R.id.story_title);
title.setText(story.title);
findViewById(R.id.back).setOnClickListener(backClick);
}
final View enterCommentView = setupCommentField();
if (story.comment_count > 0) {
// flatten the comments from a nested structure {@see Comment#comments} to a
// list appropriate for our adapter (using the depth attribute).
List<Comment> flattened = new ArrayList<>(story.comment_count);
unnestComments(story.comments, flattened);
commentsAdapter = new DesignerNewsCommentsAdapter(header, flattened, enterCommentView);
commentsList.setAdapter(commentsAdapter);
} else {
commentsAdapter = new DesignerNewsCommentsAdapter(header, new ArrayList<Comment>(0), enterCommentView);
commentsList.setAdapter(commentsAdapter);
}
customTab = new CustomTabActivityHelper();
customTab.setConnectionCallback(customTabConnect);
}
use of android.widget.Toolbar in project platform_frameworks_base by android.
the class SettingsDrawerActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
long startTime = System.currentTimeMillis();
TypedArray theme = getTheme().obtainStyledAttributes(android.R.styleable.Theme);
if (!theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
getWindow().addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
super.setContentView(R.layout.settings_with_drawer);
mContentHeaderContainer = (FrameLayout) findViewById(R.id.content_header_container);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
if (mDrawerLayout == null) {
return;
}
Toolbar toolbar = (Toolbar) findViewById(R.id.action_bar);
if (theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
toolbar.setVisibility(View.GONE);
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
mDrawerLayout = null;
return;
}
getDashboardCategories();
setActionBar(toolbar);
mDrawerAdapter = new SettingsDrawerAdapter(this);
ListView listView = (ListView) findViewById(R.id.left_drawer);
listView.setAdapter(mDrawerAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(android.widget.AdapterView<?> parent, View view, int position, long id) {
onTileClicked(mDrawerAdapter.getTile(position));
}
});
mUserManager = UserManager.get(this);
if (DEBUG_TIMING)
Log.d(TAG, "onCreate took " + (System.currentTimeMillis() - startTime) + " ms");
}
use of android.widget.Toolbar in project android_frameworks_base by DirtyUnicorns.
the class SettingsDrawerActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
long startTime = System.currentTimeMillis();
TypedArray theme = getTheme().obtainStyledAttributes(android.R.styleable.Theme);
if (!theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
getWindow().addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
super.setContentView(R.layout.settings_with_drawer);
mContentHeaderContainer = (FrameLayout) findViewById(R.id.content_header_container);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
if (mDrawerLayout == null) {
return;
}
Toolbar toolbar = (Toolbar) findViewById(R.id.action_bar);
if (theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
toolbar.setVisibility(View.GONE);
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
mDrawerLayout = null;
return;
}
getDashboardCategories();
setActionBar(toolbar);
mDrawerAdapter = new SettingsDrawerAdapter(this);
ListView listView = (ListView) findViewById(R.id.left_drawer);
View header = getLayoutInflater().inflate(R.layout.header, null);
listView.addHeaderView(header, null, false);
listView.setAdapter(mDrawerAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(android.widget.AdapterView<?> parent, View view, int position, long id) {
position = position - 1;
mOpenTileFromLeftDrawer = true;
onTileClicked(mDrawerAdapter.getTile(position));
}
});
mUserManager = UserManager.get(this);
if (DEBUG_TIMING)
Log.d(TAG, "onCreate took " + (System.currentTimeMillis() - startTime) + " ms");
}
use of android.widget.Toolbar in project android_frameworks_base by AOSPA.
the class DrawerController method create.
/**
* Returns a controller suitable for {@code Layout}.
*/
static DrawerController create(Activity activity) {
DrawerLayout layout = (DrawerLayout) activity.findViewById(R.id.drawer_layout);
if (layout == null) {
return new DummyDrawerController();
}
View drawer = activity.findViewById(R.id.drawer_roots);
Toolbar toolbar = (Toolbar) activity.findViewById(R.id.roots_toolbar);
drawer.getLayoutParams().width = calculateDrawerWidth(activity);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(activity, layout, R.drawable.ic_hamburger, R.string.drawer_open, R.string.drawer_close);
return new RuntimeDrawerController(layout, drawer, toggle, toolbar);
}
use of android.widget.Toolbar in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothSettings method resetBarSize.
private void resetBarSize(float titleTextSize, int actionBarHeight, int switchBarHeight) {
Activity activity = getActivity();
DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();
int titleId = Resources.getSystem().getIdentifier("action_bar", "id", "android");
Toolbar toolbar = (Toolbar) activity.getWindow().findViewById(titleId);
TextView title = null;
if (toolbar != null) {
LayoutParams layoutParams = toolbar.getLayoutParams();
layoutParams.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, actionBarHeight, displayMetrics);
for (int i = 0; i < toolbar.getChildCount(); ++i) {
if (toolbar.getChildAt(i) instanceof TextView) {
title = (TextView) toolbar.getChildAt(i);
}
Toolbar.LayoutParams childLayoutParams = (Toolbar.LayoutParams) toolbar.getChildAt(i).getLayoutParams();
childLayoutParams.gravity = Gravity.CENTER_VERTICAL;
}
}
if (title != null)
title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, titleTextSize);
if (mSwitchBar != null) {
LayoutParams layoutParams = mSwitchBar.getLayoutParams();
layoutParams.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, switchBarHeight, displayMetrics);
}
}
Aggregations