private class setProfileData extends AsyncTask<Void, Void, Bitmap> {
@Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
progressDialog = new ProgressDialog(getActivity());
progressDialog.setMessage("Loading ..");
progressDialog.setCancelable(true);
progressDialog.show();
}
@Override
protected Bitmap doInBackground(Void... arg0) {
try {
String imgurl = imageURL.replace(" ", "%20");
Log.e("Profile pic path ----------->>>>>", imgurl);
ProfilePicBitmap = null;
// URL url = new URL(imgurl);
try {
Bitmap ProfilePicBitmap = null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 8;
try {
ProfilePicBitmap = BitmapFactory.decodeStream(
(InputStream) new URL(imgurl).getContent(), null, options);
} catch (Exception e) {
e.printStackTrace();
try {
ProfilePicBitmap = BitmapFactory.decodeStream((InputStream) new URL(imgurl)
.getContent());
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
ProfilePicBitmap = BitmapFactory.decodeResource(
getResources(), R.drawable.ic_launcher);
}
} catch (Exception e) {
e.printStackTrace();
}
return ProfilePicBitmap;
}
@Override
protected void onPostExecute(Bitmap result) {
super.onPostExecute(result);
// Dismiss the progress dialog
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
try {
if (ProfilePicBitmap != null) {
ImageView.setImageBitmap(ProfilePicBitmap);
} else {
ImageView.setImageBitmap(BitmapFactory
.decodeResource(getResources(),
R.drawable.ic_launcher));
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onCancelled() {
super.onCancelled();
progressDialog.dismiss();
}
}