- Improve loading speed by caching the KML folder.

This commit is contained in:
dgis 2019-11-03 23:09:06 +01:00
parent 1065c26765
commit 79cc5b22d6
3 changed files with 27 additions and 13 deletions

View file

@ -54,12 +54,13 @@ NOT WORKING YET
CHANGES
Version 1.7 (2019-11-29)
Version 1.7beta2 (2019-11-03)
- Updated source code from Eric Rechlin's Emu48 version 1.61+ that was merged from Christoph Gießelink's Emu48 version 1.62.
- Allow to take a screenshot of the fullscreen including the skin.
- Add the KML Icon if present in the navigation menu header (only support PNG or 32bits BMP in the ICO file).
- Add an optional overlapping LCD part stuck to the screen when swiping the 2 calc parts (Experimental).
- Improve loading speed by caching the KML folder.
Version 1.6 (2019-07-15)

View file

@ -54,12 +54,13 @@ NOT WORKING YET
CHANGES
Version 1.7 (2019-11-29)
Version 1.7beta2 (2019-11-03)
- Updated source code from Eric Rechlin's Emu48 version 1.61+ that was merged from Christoph Gießelink's Emu48 version 1.62.
- Allow to take a screenshot of the fullscreen including the skin.
- Add the KML Icon if present in the navigation menu header (only support PNG or 32bits BMP in the ICO file).
- Add an optional overlapping LCD part stuck to the screen when swiping the 2 calc parts (Experimental).
- Improve loading speed by caching the KML folder.
Version 1.6 (2019-07-15)

View file

@ -81,6 +81,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
@ -289,6 +290,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
if(lcdOverlappingView != null)
lcdOverlappingView.saveViewLayout();
clearFolderCache();
super.onStop();
}
@ -1290,20 +1293,29 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
return fd;
}
String folderURLCached = null;
HashMap<String, String> folderCache = new HashMap<>();
public void clearFolderCache() {
folderURLCached = null;
folderCache.clear();
}
@SuppressWarnings("unused")
public int openFileInFolderFromContentResolver(String filename, String folderURL, int writeAccess) {
Uri folderURI = Uri.parse(folderURL);
DocumentFile folderDocumentFile = DocumentFile.fromTreeUri(this, folderURI);
if(folderDocumentFile != null) {
for (DocumentFile file : folderDocumentFile.listFiles()) {
String url = file.getUri().toString();
String name = file.getName();
//Log.d(TAG, "url: " + url + ", name: " + name);
if (filename.equals(name)) {
return openFileFromContentResolver(url, writeAccess);
}
}
if(folderURLCached == null || !folderURLCached.equals(folderURL)) {
folderURLCached = folderURL;
folderCache.clear();
Uri folderURI = Uri.parse(folderURL);
DocumentFile folderDocumentFile = DocumentFile.fromTreeUri(this, folderURI);
if (folderDocumentFile != null)
for (DocumentFile file : folderDocumentFile.listFiles())
folderCache.put(file.getName(), file.getUri().toString());
}
String filenameUrl = folderCache.get(filename);
if(filenameUrl != null)
return openFileFromContentResolver(filenameUrl, writeAccess);
return -1;
}