Fix screen hang during calculation bug (add a timer)
Fix UI refreshing stop after screen flipping bug
This commit is contained in:
parent
425535c6c0
commit
7a52d04245
2 changed files with 17 additions and 5 deletions
|
@ -324,6 +324,7 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
|
||||||
if (calculateTilesMemoryTask != null) {
|
if (calculateTilesMemoryTask != null) {
|
||||||
calculateTilesMemoryTask.cancel(true);
|
calculateTilesMemoryTask.cancel(true);
|
||||||
}
|
}
|
||||||
|
setRetainInstance(false);
|
||||||
}
|
}
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
@ -450,6 +451,7 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshDataInfo() {
|
private void refreshDataInfo() {
|
||||||
|
setRetainInstance(true);
|
||||||
calculateTilesBtnPressed = false;
|
calculateTilesBtnPressed = false;
|
||||||
itemsHolder = DataStorageHelper.refreshInfo(app);
|
itemsHolder = DataStorageHelper.refreshInfo(app);
|
||||||
calculateMemoryTask = itemsHolder.calculateMemoryUsedInfo(this);
|
calculateMemoryTask = itemsHolder.calculateMemoryUsedInfo(this);
|
||||||
|
@ -483,9 +485,16 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
|
||||||
@Override
|
@Override
|
||||||
public void onMemoryInfoUpdate() {
|
public void onMemoryInfoUpdate() {
|
||||||
updateAllSettings();
|
updateAllSettings();
|
||||||
app.getSettings().OSMAND_USAGE_SPACE.set(itemsHolder.getTotalUsedBytes());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFinishUpdating(String taskKey) {
|
||||||
|
updateAllSettings();
|
||||||
|
if (taskKey != null && taskKey.equals(TILES_MEMORY)) {
|
||||||
|
app.getSettings().OSMAND_USAGE_SPACE.set(itemsHolder.getTotalUsedBytes());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class MoveFilesToDifferentDirectory extends AsyncTask<Void, Void, Boolean> {
|
public static class MoveFilesToDifferentDirectory extends AsyncTask<Void, Void, Boolean> {
|
||||||
|
|
||||||
protected WeakReference<OsmandActionBarActivity> activity;
|
protected WeakReference<OsmandActionBarActivity> activity;
|
||||||
|
|
|
@ -274,14 +274,14 @@ public class DataStorageHelper implements Parcelable {
|
||||||
|
|
||||||
public RefreshMemoryUsedInfo calculateMemoryUsedInfo(UpdateMemoryInfoUIAdapter listener) {
|
public RefreshMemoryUsedInfo calculateMemoryUsedInfo(UpdateMemoryInfoUIAdapter listener) {
|
||||||
File rootDir = new File(currentStoragePath);
|
File rootDir = new File(currentStoragePath);
|
||||||
RefreshMemoryUsedInfo task = new RefreshMemoryUsedInfo(listener, otherMemory, rootDir, null, null);
|
RefreshMemoryUsedInfo task = new RefreshMemoryUsedInfo(listener, otherMemory, rootDir, null, null, OTHER_MEMORY);
|
||||||
task.execute(mapsMemory, srtmAndHillshadeMemory, tracksMemory, notesMemory);
|
task.execute(mapsMemory, srtmAndHillshadeMemory, tracksMemory, notesMemory);
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RefreshMemoryUsedInfo calculateTilesMemoryUsed(UpdateMemoryInfoUIAdapter listener) {
|
public RefreshMemoryUsedInfo calculateTilesMemoryUsed(UpdateMemoryInfoUIAdapter listener) {
|
||||||
File rootDir = new File(tilesMemory.getDirectories()[0].getAbsolutePath());
|
File rootDir = new File(tilesMemory.getDirectories()[0].getAbsolutePath());
|
||||||
RefreshMemoryUsedInfo task = new RefreshMemoryUsedInfo(listener, otherMemory, rootDir, null, srtmAndHillshadeMemory.getPrefixes());
|
RefreshMemoryUsedInfo task = new RefreshMemoryUsedInfo(listener, otherMemory, rootDir, null, srtmAndHillshadeMemory.getPrefixes(), TILES_MEMORY);
|
||||||
task.execute(tilesMemory);
|
task.execute(tilesMemory);
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
@ -293,12 +293,13 @@ public class DataStorageHelper implements Parcelable {
|
||||||
private String[] directoriesToAvoid;
|
private String[] directoriesToAvoid;
|
||||||
private String[] prefixesToAvoid;
|
private String[] prefixesToAvoid;
|
||||||
|
|
||||||
public RefreshMemoryUsedInfo(UpdateMemoryInfoUIAdapter listener, DataStorageMemoryItem otherMemory, File rootDir, String[] directoriesToAvoid, String[] prefixesToAvoid) {
|
public RefreshMemoryUsedInfo(UpdateMemoryInfoUIAdapter listener, DataStorageMemoryItem otherMemory, File rootDir, String[] directoriesToAvoid, String[] prefixesToAvoid, String taskKey) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.otherMemory = otherMemory;
|
this.otherMemory = otherMemory;
|
||||||
this.rootDir = rootDir;
|
this.rootDir = rootDir;
|
||||||
this.directoriesToAvoid = directoriesToAvoid;
|
this.directoriesToAvoid = directoriesToAvoid;
|
||||||
this.prefixesToAvoid = prefixesToAvoid;
|
this.prefixesToAvoid = prefixesToAvoid;
|
||||||
|
this.taskKey = taskKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -437,7 +438,7 @@ public class DataStorageHelper implements Parcelable {
|
||||||
protected void onPostExecute(Void aVoid) {
|
protected void onPostExecute(Void aVoid) {
|
||||||
super.onPostExecute(aVoid);
|
super.onPostExecute(aVoid);
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onMemoryInfoUpdate();
|
listener.onFinishUpdating(taskKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -467,6 +468,8 @@ public class DataStorageHelper implements Parcelable {
|
||||||
public interface UpdateMemoryInfoUIAdapter {
|
public interface UpdateMemoryInfoUIAdapter {
|
||||||
|
|
||||||
void onMemoryInfoUpdate();
|
void onMemoryInfoUpdate();
|
||||||
|
|
||||||
|
void onFinishUpdating(String taskKey);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue