I'm adding multiple TileOverlays to a Google map from cache. When trying to animate them using a handler by changing their visibility there is a flickering of the overlays on the map during the first play through.
Any other way with which I can achieve this?
public class LocalTileProvider implements TileProvider {
private String url;
DatabaseHelper db;
String type;
// private Paint opacityPaint = new Paint();
String newurl= PathFinder.rainradar_HDBaseurl;
String uid;
public LocalTileProvider(String uid,DatabaseHelper cache,String type){
this.uid=uid;
this.db=cache;
this.type=type;
}
//taking the tile from SQLITEDATABASE
@Override
public Tile getTile(int x, int y, int zoom){
Tile tile = null;
if(db.ispresent(uid, zoom,x , y,type)){
byte[] b=db.gettiles(uid, zoom,x , y,type);
tile = new Tile(256, 256, b);
return tile;
}
return NO_TILE;
}
}
The following is code for adding those tiles to the Google map
LocalTileProvider provider1 = new LocalTileProvider(uidList.get(0), db, TAG);
TileOverlayOptions top1 = new TileOverlayOptions().tileProvider(provider1).visible(true);
tileoverlay_1 = googleMap.addTileOverlay(top1);
After adding them I'm playing the animation with the handler by toggling the tile's visibility
public void start() {
btn_play.setEnabled(true);
tileoverlay_default.setVisible(false);
runnable_animation = new Runnable() {
@Override
public void run() {
//tileoverlay_default.setVisible(false);
isDownloading = false;
// stop_download=true;
isRunning = true;
btn_play.setBackgroundResource(R.drawable.player_pause_2x);
setVisibility(global);
if (global == 11) {
global = 0;
} else {
global = global + 1;
}
mHandler_animation.postDelayed(this, 1000);
}
};
mHandler_animation.post(runnable_animation);
}