Created
October 29, 2018 19:14
-
-
Save Zoomelectrico/b33bf0bf67df3e4e02a1f9b9361df138 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.tracker.tracker.tareas; | |
import android.graphics.Bitmap; | |
import android.graphics.BitmapFactory; | |
import android.os.AsyncTask; | |
import android.support.annotation.Nullable; | |
import android.util.Log; | |
import android.widget.ImageView; | |
import java.io.InputStream; | |
public class ProfilePicture extends AsyncTask <String, Void, Bitmap> { | |
private ImageView profilePic; | |
public ProfilePicture(ImageView img) { | |
this.profilePic = img; | |
} | |
@Nullable | |
@Override | |
protected Bitmap doInBackground(String... urls) { | |
String url = urls[0]; | |
Bitmap bitmap = null; | |
try { | |
InputStream in = new java.net.URL(url).openStream(); | |
bitmap = BitmapFactory.decodeStream(in); | |
} catch (Exception e) { | |
Log.e("Error", e.getMessage()); | |
e.printStackTrace(); | |
} | |
return bitmap; | |
} | |
protected void onPostExecute(Bitmap result) { | |
this.profilePic.setImageBitmap(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment