santalu / empty-view

A view that displays state of screen like loading, error, empty
Apache License 2.0
377 stars 46 forks source link

Vector drawable's issue on Android < Lollipop #7

Closed kozinakoff closed 6 years ago

kozinakoff commented 7 years ago

There is an vector drawables issue on old Android devices. You should use AppCompatResources.getDrawable to support old Android versions.

...
mLoadingDrawableRes = a.getResourceId(R.styleable.EmptyView_loadingDrawable, -1);
...
mEmptyDrawableRes = a.getResourceId(R.styleable.EmptyView_emptyDrawable, -1);
...
mErrorDrawableRes = a.getResourceId(R.styleable.EmptyView_errorDrawable, -1);`
    private void setIcon(@DrawableRes int emptyDrawableRes, @ColorInt int tint) {
        if (emptyDrawableRes == -1) {
            mImageView.setVisibility(GONE);
        } else {
            mImageView.setVisibility(VISIBLE);
            mImageView.setImageDrawable(AppCompatResources.getDrawable(getContext(), emptyDrawableRes));
            ...
        }
    }

Thanks!

santalu commented 7 years ago

Hi, which android version are we talking about exactly?

kozinakoff commented 7 years ago

Hi! Android 4.2 for instance.