time checks

This commit is contained in:
simon 2020-09-10 16:54:38 +03:00
parent d62a92b5e8
commit 1d3849ef4d
4 changed files with 12 additions and 4 deletions

View file

@ -5,7 +5,9 @@
android:orientation="vertical" android:orientation="vertical"
android:padding="32dp" android:padding="32dp"
android:gravity="center" android:gravity="center"
android:background="@color/color_black"> android:clickable="true"
android:background="@color/color_black"
android:focusable="true">
<TextView <TextView
android:id="@+id/server_status_textview" android:id="@+id/server_status_textview"

View file

@ -34,8 +34,8 @@ public class ServerFragment extends BaseOsmAndFragment {
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
enableStrictMode(); enableStrictMode();
super.onCreate(savedInstanceState);
} }
@Override @Override
@ -72,6 +72,8 @@ public class ServerFragment extends BaseOsmAndFragment {
.detectDiskReads() .detectDiskReads()
.detectDiskWrites() .detectDiskWrites()
.detectNetwork() .detectNetwork()
.permitDiskReads()
.permitDiskWrites()
.penaltyLog() .penaltyLog()
.build()); .build());
StrictMode.setVmPolicy( StrictMode.setVmPolicy(

View file

@ -24,6 +24,7 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint {
private static final Log LOG = PlatformUtil.getLog(TileEndpoint.class); private static final Log LOG = PlatformUtil.getLog(TileEndpoint.class);
private final MapActivity mapActivity; private final MapActivity mapActivity;
private final MetaTileFileSystemCache cache; private final MetaTileFileSystemCache cache;
//TODO restore mapState on Exit
private final RotatedTileBox mapTileBoxCopy; private final RotatedTileBox mapTileBoxCopy;
public TileEndpoint(MapActivity mapActivity) { public TileEndpoint(MapActivity mapActivity) {
@ -31,12 +32,13 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint {
this.cache = new MetaTileFileSystemCache(mapActivity.getMyApplication()); this.cache = new MetaTileFileSystemCache(mapActivity.getMyApplication());
this.mapTileBoxCopy = mapActivity.getMapView().getCurrentRotatedTileBox().copy(); this.mapTileBoxCopy = mapActivity.getMapView().getCurrentRotatedTileBox().copy();
//for debug //for debug
//this.cache.clearCache(); this.cache.clearCache();
} }
@Override @Override
public NanoHTTPD.Response process(NanoHTTPD.IHTTPSession session, String url) { public NanoHTTPD.Response process(NanoHTTPD.IHTTPSession session, String url) {
// https://tile.osmand.net/hd/6/55/25.png // https://tile.osmand.net/hd/6/55/25.png
LOG.debug("SERVER: STARTED REQUEST");
int extInd = url.indexOf('.'); int extInd = url.indexOf('.');
if (extInd >= 0) { if (extInd >= 0) {
url = url.substring(0, extInd); url = url.substring(0, extInd);
@ -75,6 +77,7 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint {
} }
private synchronized MetaTileFileSystemCache.MetaTileCache requestMetatile(int x, int y, int zoom) { private synchronized MetaTileFileSystemCache.MetaTileCache requestMetatile(int x, int y, int zoom) {
long time2 = System.currentTimeMillis();
MetaTileFileSystemCache.MetaTileCache cacheTile = this.cache.get(zoom, x, y); MetaTileFileSystemCache.MetaTileCache cacheTile = this.cache.get(zoom, x, y);
if (cacheTile != null) { if (cacheTile != null) {
return cacheTile; return cacheTile;
@ -102,6 +105,7 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint {
} }
res.bmp = tempBmp.copy(tempBmp.getConfig(), true); res.bmp = tempBmp.copy(tempBmp.getConfig(), true);
this.cache.put(res); this.cache.put(res);
LOG.debug("SERVER: TIME TO REQUEST TILE: " + (System.currentTimeMillis() - time2));
return res; return res;
} catch (InterruptedException e) { } catch (InterruptedException e) {
LOG.error(e); LOG.error(e);

View file

@ -830,7 +830,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
// this method could be called in non UI thread // this method could be called in non UI thread
public void refreshMap(final boolean updateVectorRendering) { public void refreshMap(final boolean updateVectorRendering) {
if (view != null && view.isShown()) { if ((view != null && view.isShown()) || isScreenViewDetached) {
boolean nightMode = application.getDaynightHelper().isNightMode(); boolean nightMode = application.getDaynightHelper().isNightMode();
Boolean currentNightMode = this.nightMode; Boolean currentNightMode = this.nightMode;
boolean forceUpdateVectorDrawing = currentNightMode != null && currentNightMode != nightMode; boolean forceUpdateVectorDrawing = currentNightMode != null && currentNightMode != nightMode;