use of carbon.widget.ImageView 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.ImageView 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.ImageView in project Carbon by ZieIony.
the class PowerMenuActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_powermenu);
powerMenu = findViewById(R.id.powerMenu);
final FrameLayout transitionLayout = (FrameLayout) findViewById(R.id.transition);
findViewById(R.id.button).setOnClickListener(view -> {
if (powerMenu.getVisibility() == View.VISIBLE)
return;
for (int i = 0; i < transitionLayout.getChildCount(); i++) transitionLayout.getChildAt(i).setVisibility(i == 0 ? View.VISIBLE : View.GONE);
final List<View> viewsWithTag = ((LinearLayout) transitionLayout.getChildAt(0)).findViewsWithTag("animate");
Stream.of(viewsWithTag).forEach(v -> v.setVisibility(View.INVISIBLE));
powerMenu.setVisibility(View.VISIBLE);
view.getHandler().postDelayed(() -> {
Stream.of(viewsWithTag).forEach(v -> {
v.getHandler().postDelayed(() -> {
v.setVisibility(View.VISIBLE);
}, viewsWithTag.indexOf(v) * 40);
});
}, 200);
});
findViewById(R.id.powerOff).setOnClickListener(view -> {
final List<View> viewsWithTag = ((FrameLayout) transitionLayout.getChildAt(1)).findViewsWithTag("animate");
for (int i = 0; i < viewsWithTag.size(); i++) viewsWithTag.get(i).setVisibility(View.INVISIBLE);
view.getHandler().postDelayed(() -> {
for (int i = 0; i < viewsWithTag.size(); i++) {
final int finalI = i;
view.getHandler().postDelayed(() -> viewsWithTag.get(finalI).setVisibility(View.VISIBLE), i * 20);
}
}, 400);
view.getHandler().postDelayed(() -> powerMenu.setVisibility(View.INVISIBLE), 3000);
});
findViewById(R.id.reboot).setOnClickListener(view -> {
final List<View> viewsWithTag = ((FrameLayout) transitionLayout.getChildAt(2)).findViewsWithTag("animate");
for (int i = 0; i < viewsWithTag.size(); i++) viewsWithTag.get(i).setVisibility(View.INVISIBLE);
view.getHandler().postDelayed(() -> {
for (int i = 0; i < viewsWithTag.size(); i++) {
final int finalI = i;
view.getHandler().postDelayed(() -> viewsWithTag.get(finalI).setVisibility(View.VISIBLE), i * 20);
}
}, 400);
view.getHandler().postDelayed(() -> powerMenu.setVisibility(View.INVISIBLE), 3000);
});
findViewById(R.id.airplaneMode).setOnClickListener(view -> {
final List<View> viewsWithTag = ((FrameLayout) transitionLayout.getChildAt(3)).findViewsWithTag("animate");
for (int i = 0; i < viewsWithTag.size(); i++) viewsWithTag.get(i).setVisibility(View.INVISIBLE);
view.getHandler().postDelayed(() -> {
for (int i = 0; i < viewsWithTag.size(); i++) {
final int finalI = i;
view.getHandler().postDelayed(() -> viewsWithTag.get(finalI).setVisibility(View.VISIBLE), i * 20);
}
}, 400);
view.getHandler().postDelayed(() -> {
airplaneMode = !airplaneMode;
TextView amStatus = (TextView) findViewById(R.id.airplaneModeStatus);
amStatus.setText("Airplane Mode is " + (airplaneMode ? "on" : "off"));
ImageView airplaneModeIcon = (ImageView) view.findViewById(R.id.airplaneModeIcon);
airplaneModeIcon.setImageResource(airplaneMode ? R.raw.ic_airplanemode_on_24px : R.raw.ic_airplanemode_off_24px);
}, 3000);
});
findViewById(R.id.vibration).setOnClickListener(view -> {
if (vibration) {
vibration = false;
view.setBackgroundColor(0xffffffff);
((ImageView) view).setTint(getResources().getColor(R.color.carbon_black_54));
} else {
vibration = true;
view.setBackgroundColor(0xff00695D);
((ImageView) view).setTint(0xffffffff);
Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(500);
}
powerMenu.postInvalidate();
});
findViewById(R.id.volume).setOnClickListener(view -> {
if (volume) {
volume = false;
view.setBackgroundColor(0xffffffff);
((ImageView) view).setTint(getResources().getColor(R.color.carbon_black_54));
} else {
volume = true;
view.setBackgroundColor(0xff00695D);
((ImageView) view).setTint(0xffffffff);
view.playSoundEffect(SoundEffectConstants.CLICK);
}
powerMenu.postInvalidate();
});
}
Aggregations