Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
c304b405f2
2 changed files with 38 additions and 5 deletions
|
@ -390,6 +390,7 @@ public class DownloadIndexesThread {
|
||||||
List<File> filesToReindex = new ArrayList<File>();
|
List<File> filesToReindex = new ArrayList<File>();
|
||||||
boolean forceWifi = downloadFileHelper.isWifiConnected();
|
boolean forceWifi = downloadFileHelper.isWifiConnected();
|
||||||
Set<IndexItem> currentDownloads = new HashSet<IndexItem>();
|
Set<IndexItem> currentDownloads = new HashSet<IndexItem>();
|
||||||
|
String warn = "";
|
||||||
try {
|
try {
|
||||||
downloadCycle: while (!indexItemDownloading.isEmpty()) {
|
downloadCycle: while (!indexItemDownloading.isEmpty()) {
|
||||||
IndexItem item = indexItemDownloading.poll();
|
IndexItem item = indexItemDownloading.poll();
|
||||||
|
@ -419,14 +420,22 @@ public class DownloadIndexesThread {
|
||||||
}
|
}
|
||||||
// trackEvent(entry);
|
// trackEvent(entry);
|
||||||
publishProgress(item);
|
publishProgress(item);
|
||||||
|
String wn = reindexFiles(filesToReindex);
|
||||||
|
if(!Algorithms.isEmpty(wn)) {
|
||||||
|
warn += " " + wn;
|
||||||
|
}
|
||||||
|
filesToReindex.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
currentDownloadingItem = null;
|
currentDownloadingItem = null;
|
||||||
currentDownloadingItemProgress = 0;
|
currentDownloadingItemProgress = 0;
|
||||||
}
|
}
|
||||||
String warn = reindexFiles(filesToReindex);
|
//String warn = reindexFiles(filesToReindex);
|
||||||
return warn;
|
if(warn.trim().length() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return warn.trim();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
LOG.info("Download Interrupted");
|
LOG.info("Download Interrupted");
|
||||||
// do not dismiss dialog
|
// do not dismiss dialog
|
||||||
|
|
|
@ -34,7 +34,6 @@ import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.IProgress;
|
import net.osmand.IProgress;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
|
@ -68,6 +67,8 @@ import java.text.Collator;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -79,6 +80,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
|
|
||||||
private static final Log LOG = PlatformUtil.getLog(LocalIndexesFragment.class);
|
private static final Log LOG = PlatformUtil.getLog(LocalIndexesFragment.class);
|
||||||
private LoadLocalIndexTask asyncLoader;
|
private LoadLocalIndexTask asyncLoader;
|
||||||
|
private Map<String, IndexItem> filesToUpdate = new HashMap<String, IndexItem>();
|
||||||
private LocalIndexesAdapter listAdapter;
|
private LocalIndexesAdapter listAdapter;
|
||||||
private AsyncTask<LocalIndexInfo, ?, ?> operationTask;
|
private AsyncTask<LocalIndexInfo, ?, ?> operationTask;
|
||||||
|
|
||||||
|
@ -161,6 +163,11 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadData() {
|
public void reloadData() {
|
||||||
|
List<IndexItem> itemsToUpdate = getDownloadActivity().getDownloadThread().getIndexes().getItemsToUpdate();
|
||||||
|
filesToUpdate.clear();
|
||||||
|
for(IndexItem ii : itemsToUpdate) {
|
||||||
|
filesToUpdate.put(ii.getTargetFileName(), ii);
|
||||||
|
}
|
||||||
LoadLocalIndexTask current = asyncLoader;
|
LoadLocalIndexTask current = asyncLoader;
|
||||||
if(current == null || current.getStatus() == AsyncTask.Status.FINISHED ||
|
if(current == null || current.getStatus() == AsyncTask.Status.FINISHED ||
|
||||||
current.isCancelled() || current.getResult() != null) {
|
current.isCancelled() || current.getResult() != null) {
|
||||||
|
@ -1032,7 +1039,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
if (child.isBackupedData()) {
|
if (child.isBackupedData()) {
|
||||||
icon.setImageDrawable(backup);
|
icon.setImageDrawable(backup);
|
||||||
} else {
|
} else {
|
||||||
icon.setImageDrawable(getContentIcon(ctx, child.getType().getIconResource()));
|
int colorId = filesToUpdate.containsKey(child.getFileName()) ? R.color.color_distance : R.color.color_ok;
|
||||||
|
icon.setImageDrawable(getContentIcon(ctx, child.getType().getIconResource(), colorId));
|
||||||
}
|
}
|
||||||
|
|
||||||
nameTextView.setText(getNameToDisplay(child));
|
nameTextView.setText(getNameToDisplay(child));
|
||||||
|
@ -1097,6 +1105,10 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
private Drawable getContentIcon(DownloadActivity context, int resourceId) {
|
private Drawable getContentIcon(DownloadActivity context, int resourceId) {
|
||||||
return context.getMyApplication().getIconsCache().getContentIcon(resourceId);
|
return context.getMyApplication().getIconsCache().getContentIcon(resourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Drawable getContentIcon(DownloadActivity context, int resourceId, int colorId) {
|
||||||
|
return context.getMyApplication().getIconsCache().getIcon(resourceId, colorId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1128,6 +1140,18 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
final IndexItem update = filesToUpdate.get(info.getFileName());
|
||||||
|
if (update != null) {
|
||||||
|
item = optionsMenu.getMenu().add(R.string.shared_string_download)
|
||||||
|
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_import));
|
||||||
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
getDownloadActivity().startDownload(update);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
item = optionsMenu.getMenu().add(R.string.shared_string_delete)
|
item = optionsMenu.getMenu().add(R.string.shared_string_delete)
|
||||||
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_delete_dark));
|
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_delete_dark));
|
||||||
|
@ -1138,7 +1162,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (getMyApplication().getSettings().BETA_TESTING_LIVE_UPDATES.get()) {
|
if (info.getType() == LocalIndexType.MAP_DATA && getMyApplication().getSettings().BETA_TESTING_LIVE_UPDATES.get()) {
|
||||||
item = optionsMenu.getMenu().add("Live updates")
|
item = optionsMenu.getMenu().add("Live updates")
|
||||||
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_refresh_dark));
|
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_refresh_dark));
|
||||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
|
|
Loading…
Reference in a new issue