use of carbon.drawable.VectorDrawable in project Carbon by ZieIony.
the class CarbonResources method getDrawable.
public Drawable getDrawable(int resId) {
if (resId != 0 && getResourceTypeName(resId).equals("raw")) {
return new VectorDrawable(this, resId);
} else {
TypedValue value = new TypedValue();
getValue(resId, value, true);
return loadDrawable(value, null);
}
}
use of carbon.drawable.VectorDrawable in project Carbon by ZieIony.
the class CarbonResources method getDrawable.
public Drawable getDrawable(int resId, Resources.Theme theme) {
if (resId != 0 && getResourceTypeName(resId).equals("raw")) {
return new VectorDrawable(this, resId);
} else {
TypedValue value = new TypedValue();
getValue(resId, value, true);
return loadDrawable(value, theme);
}
}
use of carbon.drawable.VectorDrawable in project Carbon by ZieIony.
the class DropDown method initSpinner.
private void initSpinner(Context context, AttributeSet attrs, int defStyleAttr) {
VectorDrawable drawable = new VectorDrawable(getResources(), R.raw.carbon_dropdown);
int size = (int) (Carbon.getDip(getContext()) * 24);
drawable.setBounds(0, 0, size, size);
setCompoundDrawables(null, null, drawable, null);
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.DropDown, defStyleAttr, R.style.carbon_DropDown);
int theme = a.getResourceId(R.styleable.DropDown_carbon_popupTheme, -1);
defaultAdapter = new Adapter();
dropDownMenu = new DropDownMenu(new ContextThemeWrapper(context, theme));
dropDownMenu.setAdapter(defaultAdapter);
dropDownMenu.setOnItemClickedListener(onItemClickedListener);
dropDownMenu.setOnDismissListener(() -> isShowingPopup = false);
dropDownMenu.setMode(Mode.values()[a.getInt(R.styleable.DropDown_carbon_mode, Mode.Over.ordinal())]);
setOnClickListener(view -> {
dropDownMenu.show(DropDown.this);
isShowingPopup = true;
});
a.recycle();
}
use of carbon.drawable.VectorDrawable in project Carbon by ZieIony.
the class EditText method initSelectionHandle.
private void initSelectionHandle() {
if (android.os.Build.VERSION.SDK_INT >= 11) {
try {
final Field fEditor = android.widget.TextView.class.getDeclaredField("mEditor");
fEditor.setAccessible(true);
editor = fEditor.get(this);
mIgnoreActionUpEventField = editor.getClass().getDeclaredField("mIgnoreActionUpEvent");
mIgnoreActionUpEventField.setAccessible(true);
final Field fSelectHandleLeft = editor.getClass().getDeclaredField("mSelectHandleLeft");
final Field fSelectHandleRight = editor.getClass().getDeclaredField("mSelectHandleRight");
final Field fSelectHandleCenter = editor.getClass().getDeclaredField("mSelectHandleCenter");
fSelectHandleLeft.setAccessible(true);
fSelectHandleRight.setAccessible(true);
fSelectHandleCenter.setAccessible(true);
VectorDrawable leftHandle = new VectorDrawable(getResources(), R.raw.carbon_selecthandle_left);
leftHandle.setTint(Carbon.getThemeColor(getContext(), R.attr.colorAccent));
fSelectHandleLeft.set(editor, leftHandle);
VectorDrawable rightHandle = new VectorDrawable(getResources(), R.raw.carbon_selecthandle_right);
rightHandle.setTint(Carbon.getThemeColor(getContext(), R.attr.colorAccent));
fSelectHandleRight.set(editor, rightHandle);
VectorDrawable middleHandle = new VectorDrawable(getResources(), R.raw.carbon_selecthandle_middle);
middleHandle.setTint(Carbon.getThemeColor(getContext(), R.attr.colorAccent));
fSelectHandleCenter.set(editor, middleHandle);
} catch (final Exception ignored) {
}
} else {
try {
final Field fSelectHandleLeft = android.widget.TextView.class.getDeclaredField("mSelectHandleLeft");
final Field fSelectHandleRight = android.widget.TextView.class.getDeclaredField("mSelectHandleRight");
final Field fSelectHandleCenter = android.widget.TextView.class.getDeclaredField("mSelectHandleCenter");
fSelectHandleLeft.setAccessible(true);
fSelectHandleRight.setAccessible(true);
fSelectHandleCenter.setAccessible(true);
VectorDrawable leftHandle = new VectorDrawable(getResources(), R.raw.carbon_selecthandle_left);
leftHandle.setTint(Carbon.getThemeColor(getContext(), R.attr.colorAccent));
fSelectHandleLeft.set(this, leftHandle);
VectorDrawable rightHandle = new VectorDrawable(getResources(), R.raw.carbon_selecthandle_right);
rightHandle.setTint(Carbon.getThemeColor(getContext(), R.attr.colorAccent));
fSelectHandleRight.set(this, rightHandle);
VectorDrawable middleHandle = new VectorDrawable(getResources(), R.raw.carbon_selecthandle_middle);
middleHandle.setTint(Carbon.getThemeColor(getContext(), R.attr.colorAccent));
fSelectHandleCenter.set(this, middleHandle);
} catch (final Exception ignored) {
}
}
}
use of carbon.drawable.VectorDrawable in project Carbon by ZieIony.
the class IconTextListItemActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listcomponent);
Samples.initToolbar(this, getString(R.string.iconTextListItemActivity_title));
RecyclerView recycler = (RecyclerView) findViewById(R.id.recycler);
recycler.setLayoutManager(new LinearLayoutManager(this));
RowListAdapter adapter = new RowListAdapter<>(DefaultIconTextItem.class, IconTextRow::new);
adapter.addFactory(DefaultIconSearchItem.class, parent -> new IconSearchRow(parent, new ArraySearchDataProvider(new String[] {}), filterResults -> {
}));
recycler.setAdapter(adapter);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(new ColorDrawable(Carbon.getThemeColor(this, R.attr.carbon_dividerColor)), getResources().getDimensionPixelSize(R.dimen.carbon_1dip));
dividerItemDecoration.setDrawRules(position -> position == 0);
recycler.addItemDecoration(dividerItemDecoration);
VectorDrawable drawable = new VectorDrawable(getResources(), R.raw.ic_face_24px);
adapter.setItems(Arrays.asList(new DefaultIconSearchItem(this), new DefaultIconTextItem(drawable, "text"), new DefaultIconTextItem(drawable, "text"), new DefaultIconTextItem(drawable, "text"), new DefaultIconTextItem(drawable, "text")));
}
Aggregations