I have created an app that implements a MapsView. And when i click the marker, it will show me the info window where the data is retrieved from the database by using picasso. It works fine, but the problem is that the image in the info window not shows me the image that i needed, it still shows me the placeholder image. But when i click the map and click again to the marker, it will shows me the image that i needed. But if i'm not clicking on the map (still clicking the marker), it still always shows me the placeholder marker. How do I display the image that i needed (the placeholder image will replace with the image that i needed) with a time?
Here's my code
public void plotMarkers(ArrayList<MyMarker> markers) {
if(markers.size() > 0) {
for (MyMarker myMarker : markers)
{
dest = new LatLng(myMarker.getmLatitude(), myMarker.getmLongitude());
markerOption = new MarkerOptions().position(dest);
location_marker = mMap.addMarker(markerOption);
Target target = new PicassoMarker(location_marker);
targets.add(target);
ImageView image = new ImageView(this);
image.setImageResource(R.mipmap.marker);
int width = image.getDrawable().getIntrinsicWidth();
int height = image.getDrawable().getIntrinsicHeight();
Picasso.with(MapsActivity.this).load(myMarker.getmIcon()).resize(width, height).onlyScaleDown().into(target);
mMarkersHashMap.put(location_marker, myMarker);
i = getIntent();
if(i.getBooleanExtra("maps", true)) {
location_marker.setTitle(i.getStringExtra("nama"));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(dest, 16));
}
else {
mMap.setInfoWindowAdapter(new MarkerInfoWindowAdapter());
}
}
}
}
public class MarkerInfoWindowAdapter implements GoogleMap.InfoWindowAdapter
{
@Override
public View getInfoWindow(Marker marker) {
return null;
}
@Override
public View getInfoContents(Marker marker) {
View v = getLayoutInflater().inflate(R.layout.info_windowlayout, null);
MyMarker myMarker = mMarkersHashMap.get(marker);
TextView markerLabel = (TextView) v.findViewById(R.id.marker_label);
markerLabel.setText(myMarker.getmLabel());
ImageView foto = (ImageView) v.findViewById(R.id.foto);
Picasso.with(getApplicationContext()).load(myMarker.getmImage()).placeholder(R.layout.progress).error(R.mipmap.error).into(foto);
TextView anotherLabel = (TextView) v.findViewById(R.id.another_label);
anotherLabel.setText("Baca selengkapnya...");
return v;
}
}