Search in sources :

Example 1 with VectorDrawable

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);
    }
}
Also used : VectorDrawable(carbon.drawable.VectorDrawable) TypedValue(android.util.TypedValue)

Example 2 with VectorDrawable

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);
    }
}
Also used : VectorDrawable(carbon.drawable.VectorDrawable) TypedValue(android.util.TypedValue)

Example 3 with VectorDrawable

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();
}
Also used : ContextThemeWrapper(android.view.ContextThemeWrapper) TypedArray(android.content.res.TypedArray) DropDownMenu(carbon.internal.DropDownMenu) ArrayAdapter(carbon.recycler.ArrayAdapter) VectorDrawable(carbon.drawable.VectorDrawable)

Example 4 with VectorDrawable

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) {
        }
    }
}
Also used : Field(java.lang.reflect.Field) VectorDrawable(carbon.drawable.VectorDrawable)

Example 5 with VectorDrawable

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")));
}
Also used : Arrays(java.util.Arrays) Bundle(android.os.Bundle) IconSearchRow(carbon.component.IconSearchRow) DividerItemDecoration(carbon.recycler.DividerItemDecoration) IconTextRow(carbon.component.IconTextRow) ColorDrawable(android.graphics.drawable.ColorDrawable) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DefaultIconTextItem(carbon.component.DefaultIconTextItem) DefaultIconSearchItem(carbon.component.DefaultIconSearchItem) Carbon(carbon.Carbon) RecyclerView(carbon.widget.RecyclerView) SamplesActivity(tk.zielony.carbonsamples.SamplesActivity) VectorDrawable(carbon.drawable.VectorDrawable) R(tk.zielony.carbonsamples.R) RowListAdapter(carbon.recycler.RowListAdapter) Nullable(android.support.annotation.Nullable) ArraySearchDataProvider(carbon.widget.ArraySearchDataProvider) Samples(tk.zielony.carbonsamples.Samples) DefaultIconSearchItem(carbon.component.DefaultIconSearchItem) ColorDrawable(android.graphics.drawable.ColorDrawable) IconTextRow(carbon.component.IconTextRow) RowListAdapter(carbon.recycler.RowListAdapter) RecyclerView(carbon.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(carbon.recycler.DividerItemDecoration) DefaultIconTextItem(carbon.component.DefaultIconTextItem) IconSearchRow(carbon.component.IconSearchRow) VectorDrawable(carbon.drawable.VectorDrawable) ArraySearchDataProvider(carbon.widget.ArraySearchDataProvider)

Aggregations

VectorDrawable (carbon.drawable.VectorDrawable)7 TypedValue (android.util.TypedValue)2 RowListAdapter (carbon.recycler.RowListAdapter)2 RecyclerView (carbon.widget.RecyclerView)2 TypedArray (android.content.res.TypedArray)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Bundle (android.os.Bundle)1 Nullable (android.support.annotation.Nullable)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 ContextThemeWrapper (android.view.ContextThemeWrapper)1 Carbon (carbon.Carbon)1 DefaultIconDropDownItem (carbon.component.DefaultIconDropDownItem)1 DefaultIconEditTextItem (carbon.component.DefaultIconEditTextItem)1 DefaultIconPasswordItem (carbon.component.DefaultIconPasswordItem)1 DefaultIconSearchItem (carbon.component.DefaultIconSearchItem)1 DefaultIconTextItem (carbon.component.DefaultIconTextItem)1 IconSearchRow (carbon.component.IconSearchRow)1 IconTextRow (carbon.component.IconTextRow)1 DropDownMenu (carbon.internal.DropDownMenu)1 ArrayAdapter (carbon.recycler.ArrayAdapter)1