From e3e202815323350bfb700016707ad18433667cf6 Mon Sep 17 00:00:00 2001 From: Stypox Date: Thu, 2 Apr 2020 08:25:47 +0200 Subject: [PATCH] Use AppCompatResources instead of ContextCompat --- .../newpipe/fragments/detail/VideoDetailFragment.java | 9 ++++++--- .../java/org/schabi/newpipe/player/VideoPlayer.java | 4 ++-- .../schabi/newpipe/settings/SelectKioskFragment.java | 11 +++-------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 93ae5d5b8..317f30a48 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -35,6 +36,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.content.res.AppCompatResources; import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.viewpager.widget.ViewPager; @@ -1076,7 +1078,7 @@ public class VideoDetailFragment extends BaseStateFragment return; } - thumbnailImageView.setImageDrawable(ContextCompat.getDrawable(activity, imageResource)); + thumbnailImageView.setImageDrawable(AppCompatResources.getDrawable(requireContext(), imageResource)); animateView(thumbnailImageView, false, 0, 0, () -> animateView(thumbnailImageView, true, 500)); } @@ -1168,8 +1170,9 @@ public class VideoDetailFragment extends BaseStateFragment uploaderThumb.setVisibility(View.GONE); } - subChannelThumb.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.buddy)); - uploaderThumb.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.buddy)); + Drawable buddyDrawable = AppCompatResources.getDrawable(activity, R.drawable.buddy); + subChannelThumb.setImageDrawable(buddyDrawable); + uploaderThumb.setImageDrawable(buddyDrawable); if (info.getViewCount() >= 0) { if (info.getStreamType().equals(StreamType.AUDIO_LIVE_STREAM)) { diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java index 8812a867c..576d42a00 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java @@ -46,7 +46,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.core.content.ContextCompat; +import androidx.appcompat.content.res.AppCompatResources; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.PlaybackParameters; @@ -956,7 +956,7 @@ public abstract class VideoPlayer extends BasePlayer controlAnimationView.setVisibility(View.VISIBLE); - controlAnimationView.setImageDrawable(ContextCompat.getDrawable(context, drawableId)); + controlAnimationView.setImageDrawable(AppCompatResources.getDrawable(context, drawableId)); controlViewAnimator.start(); } diff --git a/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java b/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java index f5c8b07a9..98f133a7c 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java @@ -10,7 +10,7 @@ import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.Nullable; -import androidx.core.content.ContextCompat; +import androidx.appcompat.content.res.AppCompatResources; import androidx.fragment.app.DialogFragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -160,13 +160,8 @@ public class SelectKioskFragment extends DialogFragment { final Entry entry = kioskList.get(position); holder.titleView.setText(entry.kioskName); holder.thumbnailView - .setImageDrawable(ContextCompat.getDrawable(getContext(), entry.icon)); - holder.view.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(final View view) { - clickedItem(entry); - } - }); + .setImageDrawable(AppCompatResources.getDrawable(requireContext(), entry.icon)); + holder.view.setOnClickListener(view -> clickedItem(entry)); } class Entry {