Files
android/proprietary/samplePlayer/src/com/widevine/demo/ImageHandler.java
Jeff Tinker 9f735d298a Rework WidevineSamplePlayer to use fragments
Previously it used TabActivity which has been deprecated
and no longer works.

bug: 29045104

Change-Id: I207f0208b6dba47adfa0ffe7485800d1561af617
2016-06-13 11:27:03 -07:00

57 lines
1.3 KiB
Java

/*
* (c)Copyright 2011 Google, Inc
*/
package com.widevine.demo;
import java.io.IOException;
import java.net.MalformedURLException;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
public class ImageHandler extends Thread {
private boolean scale;
private String imageUrl;
private Bitmap clipImage = null;
public ImageHandler(String imageUrl) {
this.imageUrl = imageUrl;
this.clipImage = null;
}
public void setScale(boolean scale) {
this.scale = scale;
}
public void run() {
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet request = new HttpGet(imageUrl);
HttpResponse response = httpClient.execute(request);
this.clipImage = BitmapFactory.decodeStream(response.getEntity().getContent());
if (scale) {
this.clipImage = Bitmap.createScaledBitmap(this.clipImage, 150, 200, false);
}
} catch (MalformedURLException e) {
this.clipImage = null;
} catch (IOException e) {
this.clipImage = null;
}
}
public Bitmap getBitmap() {
return this.clipImage;
}
}