I am trying to play a video like animation in the google maps - marker's infoWindow. Following are the things that work perfectly :
- Able to show Image slide show (stored in the res/drawable folder) inside the markers infoWindow using a handler that updates the UI image view inside the Marker's infoWindow
- I also got the video server up and running that serves the Image Bitmaps as Streams when requested
- I also developed a mobile client that fetches the video(series of images) from the server and play that as a video.
Now, from the APPLICATION [1] i developed, Instead of the stored images, I am trying to Fetch series of images(that belongs to the video) from SERVER [2] and set the received images in the imageView.
The problem I am facing is I am getting new images and I am calling the imageView.setImageBitmap(bt); but the imageView is not getting refreshed until I force the view to be updated (via touch events)
Below is my code :
class RefreshHandler extends Handler {
@Override
public void handleMessage(Message msg) {
BasicMapActivity.this.updateUI();
}
public void sleep(long delayMillis) {
this.removeMessages(0);
sendMessageDelayed(obtainMessage(0), delayMillis);
}
};
public void updateUI() {
refreshHandler.sleep(200); // Handler type object which makes this function to call as if its on a different thread
Log.d("Update UI - in RUN", "liveOffset : " + liveOffset);
StreamElement se = getNextLiveView();
if (se != null) {
Bitmap bmp = BitmapFactory.decodeByteArray(se.getData(), 0, se.getData().length);
Bitmap bt=Bitmap.createScaledBitmap(bmp, 150, 150, false);
Log.d("Actual Refresh ", "liveOffset : " + liveOffset); // updates inside the above getNextLiveView function that fetches the new image
imageViewK = (ImageView) kv.findViewById(R.id.imageView1);
imageViewK.setImageBitmap(bt); // Received new image is set every time on the imageView
//imageViewK.postInvalidate();
} else{
Bitmap bMap = BitmapFactory.decodeResource(getResources(),
imgidK[1]);
Bitmap bt = Bitmap.createScaledBitmap(bMap, 75, 75, false);
imageViewK.setImageBitmap(bt);
}
}
I have commented the above code to explain my situation. This is getting logged every time (Log.d("Actual Refresh ", "liveOffset : " + liveOffset) with updated liveOffset value) -> That means, I am able to reach the imageView setting line every time in the thread loop execution. As you can see I have also tried using imageView.postInvalidate() as I imagine this method is running on a non-UI thread, but still the imageView is not getting updated automatically. What am i doing wrong here?