Last active
August 29, 2015 14:22
-
-
Save AraujoJordan/8602699d887936b42ffe to your computer and use it in GitHub Desktop.
LoadProfileImage.java
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
/** | |
* Get the user profile picture from Google Plus account | |
* | |
* USAGE: new LoadProfileImage(imageView).execute(urlToTheImage); | |
*/ | |
private class LoadProfileImage extends AsyncTask<String, Void, Bitmap> { | |
ImageView bmImage; | |
//CONSTRUCTOR | |
public LoadProfileImage(ImageView bmImage) { | |
this.bmImage = bmImage; | |
} | |
protected Bitmap doInBackground(String... urls) { | |
String urldisplay = urls[0]; | |
urldisplay = urldisplay.split("sz=50")[0] + "sz=500"; //get 500x500 user picture (50x50 is too small) | |
Bitmap mIcon11 = null; | |
try { | |
InputStream in = new java.net.URL(urldisplay).openStream(); | |
mIcon11 = BitmapFactory.decodeStream(in); | |
} catch (Exception e) { | |
Log.e("Error", e.getMessage()); | |
e.printStackTrace(); | |
} | |
return mIcon11; | |
} | |
protected void onPostExecute(Bitmap result) { | |
bmImage.setImageBitmap(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment