Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
4ed0ec4fda
4 changed files with 57 additions and 63 deletions
|
@ -42,6 +42,8 @@ public class WorldRegion {
|
|||
private boolean purchased;
|
||||
private boolean isInPurchasedArea;
|
||||
|
||||
private MapState mapState = MapState.NOT_DOWNLOADED;
|
||||
|
||||
public String getRegionId() {
|
||||
return regionId;
|
||||
}
|
||||
|
@ -82,6 +84,26 @@ public class WorldRegion {
|
|||
return isInPurchasedArea;
|
||||
}
|
||||
|
||||
public MapState getMapState() {
|
||||
return mapState;
|
||||
}
|
||||
|
||||
public void processNewMapState(MapState mapState) {
|
||||
LOG.debug("old state=" + this.mapState);
|
||||
switch (this.mapState) {
|
||||
case NOT_DOWNLOADED:
|
||||
this.mapState = mapState;
|
||||
break;
|
||||
case DOWNLOADED:
|
||||
if (mapState == MapState.OUTDATED)
|
||||
this.mapState = mapState;
|
||||
break;
|
||||
case OUTDATED:
|
||||
break;
|
||||
}
|
||||
LOG.debug("new state=" + this.mapState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -294,4 +316,10 @@ public class WorldRegion {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public enum MapState {
|
||||
NOT_DOWNLOADED,
|
||||
DOWNLOADED,
|
||||
OUTDATED
|
||||
}
|
||||
}
|
|
@ -238,6 +238,15 @@ public class DownloadIndexesThread {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (resource.type == DownloadActivityType.NORMAL_FILE
|
||||
|| resource.type == DownloadActivityType.ROADS_FILE) {
|
||||
if (resource.isAlreadyDownloaded(indexFileNames)) {
|
||||
region.processNewMapState(checkIfItemOutdated(resource)
|
||||
? WorldRegion.MapState.OUTDATED : WorldRegion.MapState.DOWNLOADED);
|
||||
} else {
|
||||
region.processNewMapState(WorldRegion.MapState.NOT_DOWNLOADED);
|
||||
}
|
||||
}
|
||||
typesSet.add(resource.getType());
|
||||
regionResources.put(resource.getSimplifiedFileName(), resource);
|
||||
}
|
||||
|
@ -529,6 +538,8 @@ public class DownloadIndexesThread {
|
|||
protected IndexFileList doInBackground(Void... params) {
|
||||
IndexFileList indexFileList = DownloadOsmandIndexesHelper.getIndexesList(ctx);
|
||||
if (indexFileList != null) {
|
||||
updateLoadedFiles();
|
||||
prepareFilesToUpdate();
|
||||
prepareData(indexFileList.getIndexFiles());
|
||||
}
|
||||
return indexFileList;
|
||||
|
@ -538,7 +549,6 @@ public class DownloadIndexesThread {
|
|||
indexFiles = result;
|
||||
if (indexFiles != null && uiActivity != null) {
|
||||
dataPrepared = resourcesByRegions.size() > 0;
|
||||
prepareFilesToUpdate();
|
||||
boolean basemapExists = uiActivity.getMyApplication().getResourceManager().containsBasemap();
|
||||
IndexItem basemap = indexFiles.getBasemap();
|
||||
if (basemap != null) {
|
||||
|
@ -565,7 +575,6 @@ public class DownloadIndexesThread {
|
|||
if (uiActivity != null) {
|
||||
uiActivity.updateProgress(false);
|
||||
runCategorization(uiActivity.getDownloadType());
|
||||
runCategorization(); // for new implementation
|
||||
uiActivity.onCategorizationFinished();
|
||||
}
|
||||
}
|
||||
|
@ -647,8 +656,6 @@ public class DownloadIndexesThread {
|
|||
return filtered;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
public List<IndexItem> getFilteredByType() {
|
||||
final List<IndexItem> filtered = new ArrayList<IndexItem>();
|
||||
List<IndexItem> cachedIndexFiles = getCachedIndexFiles();
|
||||
|
@ -685,58 +692,6 @@ public class DownloadIndexesThread {
|
|||
execute(inst);
|
||||
}
|
||||
|
||||
public void runCategorization() {
|
||||
final BasicProgressAsyncTask<Void, Void, List<IndexItem>> inst
|
||||
= new BasicProgressAsyncTask<Void, Void, List<IndexItem>>(ctx) {
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
currentRunningTask.add(this);
|
||||
this.message = ctx.getString(R.string.downloading_list_indexes);
|
||||
if (uiActivity != null) {
|
||||
uiActivity.updateProgress(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<IndexItem> doInBackground(Void... params) {
|
||||
final List<IndexItem> filtered = getFilteredByType();
|
||||
updateLoadedFiles();
|
||||
return filtered;
|
||||
}
|
||||
|
||||
public List<IndexItem> getFilteredByType() {
|
||||
final List<IndexItem> filtered = new ArrayList<IndexItem>();
|
||||
List<IndexItem> cachedIndexFiles = getCachedIndexFiles();
|
||||
if (cachedIndexFiles != null) {
|
||||
for (IndexItem file : cachedIndexFiles) {
|
||||
filtered.add(file);
|
||||
}
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(List<IndexItem> filtered) {
|
||||
prepareFilesToUpdate();
|
||||
currentRunningTask.remove(this);
|
||||
if (uiActivity != null) {
|
||||
uiActivity.updateProgress(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateProgress(boolean updateOnlyProgress) {
|
||||
if (uiActivity != null) {
|
||||
uiActivity.updateProgress(updateOnlyProgress);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
execute(inst);
|
||||
}
|
||||
|
||||
private void prepareFilesToUpdate() {
|
||||
List<IndexItem> filtered = getCachedIndexFiles();
|
||||
if (filtered != null) {
|
||||
|
|
|
@ -12,7 +12,6 @@ import android.widget.ProgressBar;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -27,8 +26,6 @@ import java.text.DateFormat;
|
|||
import java.util.Map;
|
||||
|
||||
public class ItemViewHolder {
|
||||
private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(WorldItemsFragment.class);
|
||||
|
||||
private final TextView nameTextView;
|
||||
private final TextView descrTextView;
|
||||
private final ImageView leftImageView;
|
||||
|
@ -222,7 +219,21 @@ public class ItemViewHolder {
|
|||
descrTextView.setVisibility(View.GONE);
|
||||
mapDateTextView.setVisibility(View.GONE);
|
||||
|
||||
leftImageView.setImageDrawable(getContextIcon(context, R.drawable.ic_map));
|
||||
Drawable leftImageDrawable = null;
|
||||
switch (region.getMapState()) {
|
||||
case NOT_DOWNLOADED:
|
||||
leftImageDrawable = getContextIcon(context, R.drawable.ic_map);
|
||||
break;
|
||||
case DOWNLOADED:
|
||||
leftImageDrawable = getContextIcon(context, R.drawable.ic_map,
|
||||
context.getResources().getColor(R.color.color_ok));
|
||||
break;
|
||||
case OUTDATED:
|
||||
leftImageDrawable = getContextIcon(context, R.drawable.ic_map,
|
||||
context.getResources().getColor(R.color.color_distance));
|
||||
break;
|
||||
}
|
||||
leftImageView.setImageDrawable(leftImageDrawable);
|
||||
rightImageButton.setVisibility(View.GONE);
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
|
@ -186,8 +186,8 @@ public class VoiceItemsFragment extends OsmandExpandableListFragment {
|
|||
.inflate(R.layout.two_line_with_images_list_item, parent, false);
|
||||
viewHolder = new ItemViewHolder(convertView,
|
||||
getMyApplication().getResourceManager().getDateFormat(),
|
||||
getMyActivity().getIndexActivatedFileNames(),
|
||||
getMyActivity().getIndexFileNames());
|
||||
getMyActivity().getIndexFileNames(),
|
||||
getMyActivity().getIndexActivatedFileNames());
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ItemViewHolder) convertView.getTag();
|
||||
|
|
Loading…
Reference in a new issue