Trying to load a image from a website and crop the center of that particular image into a circle. I currently am trying to us the below code. There are two things wrong with the code... One is I cannot use net functions in my main method. And two I am cropping it correctly?
private Drawable getAvatar(String link) {
RoundedBitmapDrawable drw = null;
try {
URL url = new URL(link);
Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
drw = RoundedBitmapDrawableFactory.create(Resources.getSystem(), bmp);
drw.setCornerRadius(Math.max(bmp.getWidth(), bmp.getHeight()) / 2.0f);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
return drw;
}
I think my options are to either make a new class that is a thread and load all images there... I need these images to be updated into another activity.
AsyncTask is causing skipping in frames I need a real thread but still need to update UI