use of carbon.widget.LinearLayout in project Carbon by ZieIony.
the class ShareToolbarActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initToolbar();
final LinearLayout shareToolbar = findViewById(R.id.shareToolbar);
final View root = shareToolbar.getRootView();
findViewById(R.id.shareIcon).setOnClickListener(view -> {
view.setVisibility(View.GONE);
final ValueAnimator animator = ValueAnimator.ofFloat(0, 1);
animator.setInterpolator(new AccelerateDecelerateInterpolator());
animator.addUpdateListener(animation -> {
float frac = animator.getAnimatedFraction();
float cornerRadius = MathUtils.lerp(shareToolbar.getHeight() / 2.0f, 0, frac);
shareToolbar.setCornerRadius((int) cornerRadius);
float left = MathUtils.lerp(root.getWidth() - shareToolbar.getHeight() - getResources().getDimension(R.dimen.carbon_padding), 0, frac);
float right = MathUtils.lerp(root.getWidth() - getResources().getDimension(R.dimen.carbon_padding), root.getWidth(), frac);
shareToolbar.layout((int) left, shareToolbar.getTop(), (int) right, shareToolbar.getBottom());
shareToolbar.setElevation(frac);
int inColor = Carbon.getThemeColor(this, R.attr.colorSecondary);
int outColor = Carbon.getThemeColor(this, R.attr.colorSurface);
shareToolbar.setBackgroundColor(AnimUtils.lerpColor(frac, inColor, outColor));
});
animator.setDuration(300);
view.setOnClickListener(null);
animator.start();
final List<View> viewsWithTag = shareToolbar.findViewsWithTag("animate");
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 * 40);
}
}, 200);
});
}
use of carbon.widget.LinearLayout in project Carbon by ZieIony.
the class EditTextMenu method dismiss.
@Override
public void dismiss() {
LinearLayout content = getContentView().findViewById(R.id.carbon_menuContainer);
content.setVisibility(View.INVISIBLE);
content.getAnimator().addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
EditTextMenu.super.dismiss();
}
});
}
use of carbon.widget.LinearLayout in project Carbon by ZieIony.
the class EditTextMenu method showImmediate.
public boolean showImmediate(EditText anchor) {
editText = anchor;
super.showAtLocation(anchor, Gravity.START | Gravity.TOP, 0, 0);
update();
LinearLayout content = getContentView().findViewById(R.id.carbon_menuContainer);
content.setVisibility(View.VISIBLE);
return true;
}
use of carbon.widget.LinearLayout in project Carbon by ZieIony.
the class EditTextMenu method update.
public void update() {
if (editText == null)
return;
final Resources res = getContentView().getContext().getResources();
int margin = (int) res.getDimension(R.dimen.carbon_padding);
int itemHeight = (int) res.getDimension(R.dimen.carbon_menuHeight);
Rect windowRect = new Rect();
editText.getWindowVisibleDisplayFrame(windowRect);
int[] location = new int[2];
editText.getLocationInWindow(location);
LinearLayout content = getContentView().findViewById(R.id.carbon_menuContent);
content.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(itemHeight, View.MeasureSpec.EXACTLY));
int popupX = location[0] - margin;
int popupY = location[1] - margin * 2 - content.getMeasuredHeight();
update(popupX, popupY, content.getMeasuredWidth() + margin * 2, content.getMeasuredHeight() + margin * 2);
super.update();
}
use of carbon.widget.LinearLayout in project Carbon by ZieIony.
the class PathAnimationActivity method onCreate.
@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initToolbar();
ImageView imageView = findViewById(R.id.image);
imageView.setImageDrawable(new DrawableImageGenerator(this).next());
LinearLayout card = findViewById(R.id.card);
View layout = findViewById(R.id.layout);
layout.setOnTouchListener((v, event) -> {
if (event.getAction() == MotionEvent.ACTION_UP) {
NURBS nurbs = new NURBS();
nurbs.addPoint(new PointF(card.getX() + card.getWidth() / 2, card.getY() + card.getHeight() / 2));
nurbs.addPoint(new PointF(event.getX(), card.getY() + card.getHeight() / 2));
nurbs.addPoint(new PointF(event.getX(), event.getY()));
nurbs.init();
ValueAnimator animator = ValueAnimator.ofFloat(0, 1);
float srcWidth = card.getWidth();
float srcHeight = card.getHeight();
float destWidth = expanded ? getResources().getDimension(R.dimen.carbon_contentSpace) : layout.getWidth();
float destHeight = destWidth * 9.0f / 16;
animator.setDuration(500);
animator.setInterpolator(new FastOutSlowInInterpolator());
animator.addUpdateListener(animation -> {
PointF point = nurbs.getPoint((Float) animation.getAnimatedValue());
int w = (int) MathUtils.lerp(srcWidth, destWidth, (Float) animation.getAnimatedValue());
int h = (int) MathUtils.lerp(srcHeight, destHeight, (Float) animation.getAnimatedValue());
int x = (int) point.x - w / 2;
int y = (int) point.y - h / 2;
card.setBounds(x, y, w, h);
});
animator.start();
expanded = !expanded;
}
return true;
});
}
Aggregations