Skip to content

Commit

Permalink
Fix a deprecation warning in DataUriTest.
Browse files Browse the repository at this point in the history
  • Loading branch information
sjudd committed Feb 9, 2018
1 parent 10e2266 commit 41f7400
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
import android.net.Uri;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.support.v4.content.ContextCompat;
import android.util.Base64;
import com.bumptech.glide.test.ConcurrencyHelper;
import com.bumptech.glide.test.ResourceIds;
import com.bumptech.glide.test.TearDownGlide;
import com.bumptech.glide.util.Preconditions;
import java.io.ByteArrayOutputStream;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -96,7 +98,8 @@ private String getDataUriString(CompressFormat format) {

private String getBase64BitmapBytes(CompressFormat format) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Drawable drawable = context.getResources().getDrawable(ResourceIds.raw.canonical);
Drawable drawable =
Preconditions.checkNotNull(ContextCompat.getDrawable(context, ResourceIds.raw.canonical));
Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
bitmap.compress(format, 100, bos);
byte[] data = bos.toByteArray();
Expand Down

0 comments on commit 41f7400

Please sign in to comment.