I have a navigation drawer in my app. I am making an HTTP request to load in friends and group names along with the pics. I want my pics to resize so they can adjust in. This is what i have
This is what i want
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
int k=0;
for(String n : friends){
String words[] = n.split(":");
menu.findItem(R.id.friends).getSubMenu().add(R.id.friends, Integer.parseInt(words[1]),k,words[0]);
MenuItem myMenuItem = menu.findItem(R.id.friends).getSubMenu().findItem(Integer.parseInt(words[1]));
DownloadImageTask dn = new DownloadImageTask(myMenuItem);
dn.execute(AppConfig.IMAGESURL + words[2]);
}
}
public class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
private final WeakReference<MenuItem> menuItemReference;
public DownloadImageTask(MenuItem menuItem) {
menuItemReference = new WeakReference<>(menuItem);
}
protected Bitmap doInBackground(String... urls) {
String urldisplay = urls[0];
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 bitmap) {
if (isCancelled()) {
bitmap = null;
}
if (menuItemReference != null) {
MenuItem menuitem = menuItemReference.get();
if (menuitem != null) {
if (bitmap != null) {
Drawable r = new BitmapDrawable(getResources(),bitmap);
menuitem.setIcon(r);
} else {
// Drawable placeholder = imageView.getContext().getResources().getDrawable(R.drawable.placeholder);
// imageView.setImageDrawable(placeholder);
}
}
}
}
}