use of android.graphics.drawable.Drawable in project Carbon by ZieIony.
the class Button method updateBackgroundTint.
private void updateBackgroundTint() {
Drawable background = getBackground();
if (background instanceof RippleDrawable)
background = ((RippleDrawable) background).getBackground();
if (background == null)
return;
if (backgroundTint != null && backgroundTintMode != null) {
int color = backgroundTint.getColorForState(getDrawableState(), backgroundTint.getDefaultColor());
background.setColorFilter(new PorterDuffColorFilter(color, backgroundTintMode));
} else {
background.setColorFilter(null);
}
}
use of android.graphics.drawable.Drawable in project Carbon by ZieIony.
the class CheckedTextView method onDraw.
@Override
protected void onDraw(Canvas canvas) {
final Drawable buttonDrawable = drawable;
if (buttonDrawable != null) {
final int verticalGravity = getGravity() & Gravity.VERTICAL_GRAVITY_MASK;
final int drawableHeight = buttonDrawable.getIntrinsicHeight();
final int drawableWidth = buttonDrawable.getIntrinsicWidth();
final int top;
switch(verticalGravity) {
case Gravity.BOTTOM:
top = getHeight() - drawableHeight;
break;
case Gravity.CENTER_VERTICAL:
top = (getHeight() - drawableHeight) / 2;
break;
default:
top = 0;
}
final int bottom = top + drawableHeight;
final int left = isLayoutRtl() ? getPaddingLeft() : getWidth() - drawableWidth - getPaddingRight();
final int right = isLayoutRtl() ? drawableWidth + getPaddingLeft() : getWidth() - getPaddingRight();
buttonDrawable.setBounds(left, top, right, bottom);
final Drawable background = getBackground();
if (background != null && background instanceof RippleDrawable) {
//TODO: hotspotBounds
// ((RippleDrawable)background).setHotspotBounds(left, top, right, bottom);
}
}
super.onDraw(canvas);
if (buttonDrawable != null) {
final int scrollX = getScrollX();
final int scrollY = getScrollY();
if (scrollX == 0 && scrollY == 0) {
buttonDrawable.draw(canvas);
} else {
canvas.translate(scrollX, scrollY);
buttonDrawable.draw(canvas);
canvas.translate(-scrollX, -scrollY);
}
}
}
use of android.graphics.drawable.Drawable in project Carbon by ZieIony.
the class ExpandableRecyclerView method initRecycler.
private void initRecycler(AttributeSet attrs, int defStyleAttr) {
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.RecyclerView, defStyleAttr, R.style.carbon_RecyclerView);
for (int i = 0; i < a.getIndexCount(); i++) {
int attr = a.getIndex(i);
if (attr == R.styleable.RecyclerView_carbon_overScroll) {
setOverScrollMode(a.getInt(attr, ViewCompat.OVER_SCROLL_ALWAYS));
} else if (attr == R.styleable.RecyclerView_carbon_headerTint) {
setHeaderTint(a.getColor(attr, 0));
} else if (attr == R.styleable.RecyclerView_carbon_headerMinHeight) {
setHeaderMinHeight((int) a.getDimension(attr, 0.0f));
} else if (attr == R.styleable.RecyclerView_carbon_headerParallax) {
setHeaderParallax(a.getFloat(attr, 0.0f));
} else if (attr == R.styleable.RecyclerView_android_divider) {
Drawable drawable = a.getDrawable(attr);
float height = a.getDimension(R.styleable.RecyclerView_android_dividerHeight, 0);
if (drawable != null && height > 0)
setDivider(drawable, (int) height);
}
}
Carbon.initTint(this, a, tintIds);
a.recycle();
setClipToPadding(false);
setItemAnimator(new DefaultItemAnimator());
setWillNotDraw(false);
}
use of android.graphics.drawable.Drawable in project Carbon by ZieIony.
the class AvatarTextListItemActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listcomponent);
Samples.initToolbar(this, getString(R.string.avatarTextListItemActivity_title));
RecyclerView recycler = (RecyclerView) findViewById(R.id.recycler);
RowListAdapter adapter = new RowListAdapter<>(DefaultAvatarTextItem.class, AvatarTextRow.FACTORY);
adapter.addFactory(DividerItem.class, DividerRow.FACTORY);
recycler.setAdapter(adapter);
Drawable avatar = getResources().getDrawable(R.drawable.iceland);
adapter.setItems(Arrays.asList(new DefaultAvatarTextItem(avatar, "text"), new DefaultAvatarTextItem(avatar, "text"), new DividerItem(), new DefaultAvatarTextItem(avatar, "text"), new DefaultAvatarTextItem(avatar, "text")));
}
use of android.graphics.drawable.Drawable in project Carbon by ZieIony.
the class ImageTextSubtextDateListItemActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listcomponent);
Samples.initToolbar(this, getString(R.string.imageTextSubtextDateListItemActivity_title));
RecyclerView recycler = (RecyclerView) findViewById(R.id.recycler);
recycler.setLayoutManager(new LinearLayoutManager(this));
RowListAdapter adapter = new RowListAdapter<>(DefaultImageTextSubtextDateItem.class, ImageTextSubtextDateRow::new);
adapter.addFactory(DefaultHeaderItem.class, PaddedHeaderRow.FACTORY);
recycler.setAdapter(adapter);
Drawable drawable = getResources().getDrawable(R.drawable.watermelon);
String date = format.format(new Date().getTime());
adapter.setItems(Arrays.asList(new DefaultHeaderItem("Header"), new DefaultImageTextSubtextDateItem(drawable, "text", "subtext", date), new DefaultImageTextSubtextDateItem(drawable, "text", "subtext", date), new DefaultHeaderItem("Header"), new DefaultImageTextSubtextDateItem(drawable, "text", "subtext", date), new DefaultImageTextSubtextDateItem(drawable, "text", "subtext", date)));
}
Aggregations