use of carbon.widget.Toolbar in project Carbon by ZieIony.
the class Samples method initToolbar.
public static void initToolbar(final Activity activity, String title) {
final DebugOverlay overlay = new DebugOverlay(activity);
Toolbar toolbar = (Toolbar) activity.findViewById(R.id.toolbar);
toolbar.setTitle(title);
final ImageView debug = (ImageView) activity.findViewById(R.id.debug);
if (debug != null) {
debug.setTint(Carbon.getThemeColor(activity, R.attr.carbon_colorDisabled));
debug.setOnClickListener(new View.OnClickListener() {
boolean debugEnabled = false;
@Override
public void onClick(View view) {
if (!debugEnabled) {
debug.setTint(Carbon.getThemeColor(activity, R.attr.carbon_iconColor));
overlay.show();
debugEnabled = true;
} else {
debug.setTint(Carbon.getThemeColor(activity, R.attr.carbon_colorDisabled));
overlay.dismiss();
debugEnabled = false;
}
}
});
}
CheckBox checkBox = (CheckBox) activity.findViewById(R.id.enabled);
if (checkBox != null)
checkBox.setOnCheckedChangeListener((compoundButton, checked) -> {
List<View> views = findViewsWithTag((ViewGroup) activity.getWindow().getDecorView().getRootView(), "enable");
for (View v : views) v.setEnabled(checked);
});
}
use of carbon.widget.Toolbar in project Carbon by ZieIony.
the class ToolbarActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_toolbar);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setIconVisible(true);
setSupportActionBar(toolbar);
setTitle("Toolbar");
}
use of carbon.widget.Toolbar in project Carbon by ZieIony.
the class CollapsingLayout method onNestedScrollByY.
@Override
public int onNestedScrollByY(int dy) {
DependencyLayout.LayoutParams layoutParams = (DependencyLayout.LayoutParams) getLayoutParams();
int newHeight = MathUtils.constrain(layoutParams.height - dy, getMinimumHeight(), getMaximumHeight());
setElevation(MathUtils.map(getMaximumHeight(), getMinimumHeight(), 0, getResources().getDimension(carbon.R.dimen.carbon_elevationToolbar), newHeight));
int usedDy = layoutParams.height - newHeight;
layoutParams.height = newHeight;
setLayoutParams(layoutParams);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
ImageView iconView = (ImageView) toolbar.getIconView();
TextView titleView = toolbar.getTitleView();
{
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) iconView.getLayoutParams();
params.gravity = Gravity.TOP;
iconView.setLayoutParams(params);
}
{
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) titleView.getLayoutParams();
params.gravity = Gravity.TOP;
titleView.setLayoutParams(params);
}
if (getHeight() == getMinimumHeight() && iconView.getVisibility() != VISIBLE && iconView.getAnimator() == null) {
iconView.setVisibility(VISIBLE);
} else if (getHeight() != getMinimumHeight() && iconView.getVisibility() == VISIBLE && iconView.getAnimator() == null) {
iconView.setVisibility(INVISIBLE);
}
titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, MathUtils.map(getMaximumHeight(), getMinimumHeight(), getResources().getDimension(R.dimen.carbon_textSizeHeadline), getResources().getDimension(carbon.R.dimen.carbon_textSizeTitle), newHeight));
return usedDy;
}
use of carbon.widget.Toolbar in project Carbon by ZieIony.
the class ButtonsUsageActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_buttonsusage);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setIconVisible(true);
ProgressBar progress = (ProgressBar) findViewById(R.id.progress);
progress.setProgress(0.8f);
}
use of carbon.widget.Toolbar in project Carbon by ZieIony.
the class SearchToolbarActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
List<DefaultAvatarTextItem> items = generateItems();
RowListAdapter<DefaultAvatarTextItem> adapter = new RowListAdapter<>(items, AvatarTextRow::new);
RecyclerView recyclerView = findViewById(R.id.recycler);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(adapter);
searchEditText = findViewById(R.id.searchEditText);
searchEditText.setDataProvider(new ListSearchAdapter<DefaultAvatarTextItem>(items) {
@NotNull
@Override
public String[] getItemWords(DefaultAvatarTextItem item) {
return new String[] { item.getText() };
}
});
searchEditText.setOnFilterListener((SearchEditText.OnFilterListener<DefaultAvatarTextItem>) filterResults -> {
if (filterResults == null) {
adapter.setItems(items);
} else if (filterResults.size() == 2) {
adapter.setItems(new ArrayList<>());
} else {
adapter.setItems(filterResults);
}
});
findViewById(R.id.clear).setOnClickListener(v -> searchEditText.setText(""));
searchBar = findViewById(R.id.searchbar);
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setOnMenuItemClicked((view, item, position) -> openSearch(view));
closeButton = findViewById(R.id.close);
closeButton.setOnClickListener(v -> closeSearch());
}
Aggregations