Skip to content

Commit

Permalink
Fixed loading vector icons in API19
Browse files Browse the repository at this point in the history
  • Loading branch information
arok committed Oct 3, 2016
1 parent 1ee05b4 commit 04f48ef
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v4.view.ViewCompat;
import android.support.v7.content.res.AppCompatResources;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
Expand Down Expand Up @@ -180,9 +181,20 @@ private void init(Context context, AttributeSet attrs) {
mSubmitText = a.getText(R.styleable.EasyVideoPlayer_evp_submitText);
mBottomLabelText = a.getText(R.styleable.EasyVideoPlayer_evp_bottomText);

mRestartDrawable = a.getDrawable(R.styleable.EasyVideoPlayer_evp_restartDrawable);
mPlayDrawable = a.getDrawable(R.styleable.EasyVideoPlayer_evp_playDrawable);
mPauseDrawable = a.getDrawable(R.styleable.EasyVideoPlayer_evp_pauseDrawable);

int restartDrawableResId = a.getResourceId(R.styleable.EasyVideoPlayer_evp_restartDrawable, -1);
int playDrawableResId = a.getResourceId(R.styleable.EasyVideoPlayer_evp_playDrawable, -1);
int pauseDrawableResId = a.getResourceId(R.styleable.EasyVideoPlayer_evp_pauseDrawable, -1);

if (restartDrawableResId != -1) {
mRestartDrawable = AppCompatResources.getDrawable(context, restartDrawableResId);
}
if (playDrawableResId != -1) {
mPlayDrawable = AppCompatResources.getDrawable(context, playDrawableResId);
}
if (pauseDrawableResId != -1) {
mPauseDrawable = AppCompatResources.getDrawable(context, pauseDrawableResId);
}

mHideControlsOnPlay = a.getBoolean(R.styleable.EasyVideoPlayer_evp_hideControlsOnPlay, true);
mAutoPlay = a.getBoolean(R.styleable.EasyVideoPlayer_evp_autoPlay, false);
Expand Down Expand Up @@ -211,11 +223,11 @@ private void init(Context context, AttributeSet attrs) {
mSubmitText = context.getResources().getText(R.string.evp_submit);

if (mRestartDrawable == null)
mRestartDrawable = ContextCompat.getDrawable(context, R.drawable.evp_action_restart);
mRestartDrawable = AppCompatResources.getDrawable(context, R.drawable.evp_action_restart);
if (mPlayDrawable == null)
mPlayDrawable = ContextCompat.getDrawable(context, R.drawable.evp_action_play);
mPlayDrawable = AppCompatResources.getDrawable(context, R.drawable.evp_action_play);
if (mPauseDrawable == null)
mPauseDrawable = ContextCompat.getDrawable(context, R.drawable.evp_action_pause);
mPauseDrawable = AppCompatResources.getDrawable(context, R.drawable.evp_action_pause);
}

@Override
Expand Down Expand Up @@ -306,7 +318,7 @@ public void setRestartDrawable(@NonNull Drawable drawable) {

@Override
public void setRestartDrawableRes(@DrawableRes int res) {
setRestartDrawable(ContextCompat.getDrawable(getContext(), res));
setRestartDrawable(AppCompatResources.getDrawable(getContext(), res));
}

@Override
Expand All @@ -317,7 +329,7 @@ public void setPlayDrawable(@NonNull Drawable drawable) {

@Override
public void setPlayDrawableRes(@DrawableRes int res) {
setPlayDrawable(ContextCompat.getDrawable(getContext(), res));
setPlayDrawable(AppCompatResources.getDrawable(getContext(), res));
}

@Override
Expand All @@ -328,7 +340,7 @@ public void setPauseDrawable(@NonNull Drawable drawable) {

@Override
public void setPauseDrawableRes(@DrawableRes int res) {
setPauseDrawable(ContextCompat.getDrawable(getContext(), res));
setPauseDrawable(AppCompatResources.getDrawable(getContext(), res));
}

@Override
Expand Down
5 changes: 3 additions & 2 deletions library/src/main/res/layout/evp_include_controls.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -53,7 +54,7 @@
android:background="?selectableItemBackground"
android:paddingLeft="@dimen/evp_button_size"
android:paddingRight="@dimen/evp_button_size"
android:src="@drawable/evp_action_restart"
app:srcCompat="@drawable/evp_action_restart"
tools:ignore="ContentDescription" />

<TextView
Expand Down Expand Up @@ -81,7 +82,7 @@
android:layout_below="@+id/position"
android:layout_centerHorizontal="true"
android:background="?selectableItemBackground"
android:src="@drawable/evp_action_play"
app:srcCompat="@drawable/evp_action_play"
tools:ignore="ContentDescription" />

<TextView
Expand Down

0 comments on commit 04f48ef

Please sign in to comment.