This commit is contained in:
GaidamakUA 2015-10-21 18:12:37 +03:00
commit e5941c29e0
4 changed files with 52 additions and 5 deletions

View file

@ -1986,4 +1986,12 @@
<string name="poi_industrial_timber">類型:木材</string>
<string name="poi_industrial_refinery">類型:煉油廠</string>
<string name="poi_industrial_warehouse">類型:倉庫</string>
<string name="poi_industrial_auto_wrecker">類型:車輛報廢廠</string>
<string name="poi_industrial_agriculture">類型:農耕</string>
<string name="poi_industrial_brewery">類型:啤酒廠</string>
<string name="poi_industrial_brickyard">類型:磚廠</string>
<string name="poi_industrial_intermodal_freight_terminal">類型:貨櫃集裝場</string>
<string name="poi_industrial_sawmill">類型:鋸木廠</string>
<string name="poi_industrial_water_purification">類型:水淨化廠</string>
<string name="poi_industrial_port">類型:港埠</string>
</resources>

View file

@ -390,6 +390,7 @@ public class DownloadIndexesThread {
List<File> filesToReindex = new ArrayList<File>();
boolean forceWifi = downloadFileHelper.isWifiConnected();
Set<IndexItem> currentDownloads = new HashSet<IndexItem>();
String warn = "";
try {
downloadCycle: while (!indexItemDownloading.isEmpty()) {
IndexItem item = indexItemDownloading.poll();
@ -419,14 +420,24 @@ public class DownloadIndexesThread {
}
// trackEvent(entry);
publishProgress(item);
String wn = reindexFiles(filesToReindex);
if(!Algorithms.isEmpty(wn)) {
warn += " " + wn;
}
filesToReindex.clear();
// slow down but let update all button work properly
indexes.updateFilesToUpdate();;
}
}
} finally {
currentDownloadingItem = null;
currentDownloadingItemProgress = 0;
}
String warn = reindexFiles(filesToReindex);
return warn;
//String warn = reindexFiles(filesToReindex);
if(warn.trim().length() == 0) {
return null;
}
return warn.trim();
} catch (InterruptedException e) {
LOG.info("Download Interrupted");
// do not dismiss dialog

View file

@ -124,6 +124,10 @@ public class DownloadResources extends DownloadResourceGroup {
protected void updateFilesToUpdate() {
initAlreadyLoadedFiles();
recalculateFilesToUpdate();
}
private void recalculateFilesToUpdate() {
List<IndexItem> stillUpdate = new ArrayList<IndexItem>();
for (IndexItem item : itemsToUpdate) {
String sfName = item.getTargetFileName();

View file

@ -34,7 +34,6 @@ import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
@ -68,6 +67,8 @@ import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
@ -79,6 +80,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
private static final Log LOG = PlatformUtil.getLog(LocalIndexesFragment.class);
private LoadLocalIndexTask asyncLoader;
private Map<String, IndexItem> filesToUpdate = new HashMap<String, IndexItem>();
private LocalIndexesAdapter listAdapter;
private AsyncTask<LocalIndexInfo, ?, ?> operationTask;
@ -161,6 +163,11 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
}
public void reloadData() {
List<IndexItem> itemsToUpdate = getDownloadActivity().getDownloadThread().getIndexes().getItemsToUpdate();
filesToUpdate.clear();
for(IndexItem ii : itemsToUpdate) {
filesToUpdate.put(ii.getTargetFileName(), ii);
}
LoadLocalIndexTask current = asyncLoader;
if(current == null || current.getStatus() == AsyncTask.Status.FINISHED ||
current.isCancelled() || current.getResult() != null) {
@ -1032,7 +1039,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
if (child.isBackupedData()) {
icon.setImageDrawable(backup);
} 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));
@ -1097,6 +1105,10 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
private Drawable getContentIcon(DownloadActivity context, int 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;
}
});
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)
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_delete_dark));
@ -1138,7 +1162,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
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")
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_refresh_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {