Update groups
This commit is contained in:
parent
5d412c8f94
commit
d6e5964fdd
4 changed files with 33 additions and 15 deletions
|
@ -39,7 +39,7 @@ import android.support.annotation.UiThread;
|
|||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@SuppressLint({ "NewApi", "DefaultLocale" })
|
||||
public class DownloadIndexesThread {
|
||||
private final static Log LOG = PlatformUtil.getLog(DownloadIndexesThread.class);
|
||||
private final Context ctx;
|
||||
|
@ -332,7 +332,8 @@ public class DownloadIndexesThread {
|
|||
}
|
||||
} else if (o instanceof String) {
|
||||
String message = (String) o;
|
||||
if (!message.equals("I/O error occurred : Interrupted")) {
|
||||
// ctx.getString(R.string.shared_string_io_error) +": Interrupted";
|
||||
if (!message.toLowerCase().contains("interrupted")) {
|
||||
if (uiActivity == null ||
|
||||
!message.equals(uiActivity.getString(R.string.shared_string_download_successful))) {
|
||||
AccessibleToast.makeText(ctx, message, Toast.LENGTH_LONG).show();
|
||||
|
|
|
@ -117,6 +117,14 @@ public class DownloadResourceGroup {
|
|||
Collections.sort(g.individualResources, new Comparator<IndexItem>() {
|
||||
@Override
|
||||
public int compare(IndexItem lhs, IndexItem rhs) {
|
||||
int lli = lhs.getType().getOrderIndex();
|
||||
int rri = rhs.getType().getOrderIndex();
|
||||
if(lli < rri) {
|
||||
return -1;
|
||||
} else if(lli > rri) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return collator.compare(lhs.getVisibleName(app.getApplicationContext(), osmandRegions),
|
||||
rhs.getVisibleName(app.getApplicationContext(), osmandRegions));
|
||||
}
|
||||
|
@ -180,6 +188,11 @@ public class DownloadResourceGroup {
|
|||
return getGroupById(lst, 0);
|
||||
}
|
||||
|
||||
public DownloadResourceGroup getSubGroupById(String uid) {
|
||||
String[] lst = uid.split("\\#");
|
||||
return getSubGroupById(lst, 0);
|
||||
}
|
||||
|
||||
public List<IndexItem> getIndividualResources() {
|
||||
return individualResources;
|
||||
}
|
||||
|
@ -193,12 +206,17 @@ public class DownloadResourceGroup {
|
|||
if (lst.length == subInd + 1) {
|
||||
return this;
|
||||
} else if (groups != null) {
|
||||
for (DownloadResourceGroup rg : groups) {
|
||||
DownloadResourceGroup r = rg.getGroupById(lst, subInd + 1);
|
||||
if (r != null) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
return getSubGroupById(lst, subInd + 1);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private DownloadResourceGroup getSubGroupById(String[] lst, int subInd) {
|
||||
for (DownloadResourceGroup rg : groups) {
|
||||
DownloadResourceGroup r = rg.getGroupById(lst, subInd );
|
||||
if (r != null) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -244,8 +244,7 @@ public class DownloadResources extends DownloadResourceGroup {
|
|||
DownloadResourceGroup mainGrp = new DownloadResourceGroup(parentGroup, DownloadResourceGroupType.REGION, reg.getRegionId());
|
||||
mainGrp.region = reg;
|
||||
parentGroup.addGroup(mainGrp);
|
||||
DownloadResourceGroup subRegions = new DownloadResourceGroup(mainGrp, DownloadResourceGroupType.SUBREGIONS);
|
||||
mainGrp.addGroup(subRegions);
|
||||
|
||||
List<IndexItem> list = groupByRegion.get(reg);
|
||||
if(list != null) {
|
||||
DownloadResourceGroup flatFiles = new DownloadResourceGroup(mainGrp, DownloadResourceGroupType.REGION_MAPS);
|
||||
|
@ -254,6 +253,8 @@ public class DownloadResources extends DownloadResourceGroup {
|
|||
}
|
||||
mainGrp.addGroup(flatFiles);
|
||||
}
|
||||
DownloadResourceGroup subRegions = new DownloadResourceGroup(mainGrp, DownloadResourceGroupType.SUBREGIONS);
|
||||
mainGrp.addGroup(subRegions);
|
||||
// add to processing queue
|
||||
for(WorldRegion rg : subregions) {
|
||||
queue.add(rg);
|
||||
|
|
|
@ -286,7 +286,7 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
|
|||
iconLeft = cache.getContentIcon(R.drawable.ic_world_globe_dark);
|
||||
} else {
|
||||
DownloadResourceGroup ggr = group
|
||||
.getGroupById(DownloadResourceGroupType.REGION_MAPS.getDefaultId());
|
||||
.getSubGroupById(DownloadResourceGroupType.REGION_MAPS.getDefaultId());
|
||||
iconLeft = cache.getContentIcon(R.drawable.ic_map);
|
||||
if (ggr != null && ggr.getIndividualResources() != null) {
|
||||
IndexItem item = null;
|
||||
|
@ -301,11 +301,9 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
|
|||
}
|
||||
if (item != null) {
|
||||
if (item.isOutdated()) {
|
||||
iconLeft = cache.getIcon(R.drawable.ic_map,
|
||||
ctx.getResources().getColor(R.color.color_distance));
|
||||
iconLeft = cache.getIcon(R.drawable.ic_map, R.color.color_distance);
|
||||
} else {
|
||||
iconLeft = cache.getIcon(R.drawable.ic_map,
|
||||
ctx.getResources().getColor(R.color.color_ok));
|
||||
iconLeft = cache.getIcon(R.drawable.ic_map, R.color.color_ok);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue