Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-04-06 20:40:37 +02:00
commit 6d890873cc
2 changed files with 29 additions and 21 deletions

View file

@ -1,6 +1,5 @@
package net.osmand.plus.dashboard; package net.osmand.plus.dashboard;
import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -53,15 +52,9 @@ public class DashRecentsFragment extends DashLocationFragment {
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() { (view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Activity activity = getActivity();
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
final Intent search = new Intent(activity, appCustomization.getSearchActivity());
// search.putExtra(SearchActivity.SHOW_ONLY_ONE_TAB, true);
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.HISTORY_TAB_INDEX);
activity.startActivity(search);
closeDashboard(); closeDashboard();
MapActivity activity = (MapActivity) getActivity();
activity.showQuickSearch(MapActivity.ShowQuickSearchMode.NEW, false);
} }
}); });
return view; return view;

View file

@ -394,18 +394,9 @@ public class DownloadResources extends DownloadResourceGroup {
} }
} }
WorldRegion downloadRegion = regions.getRegionData(regions.getFullName(o)); WorldRegion downloadRegion = regions.getRegionData(regions.getFullName(o));
if (downloadRegion == null || !isRegion || !regions.contain(o, point31x, point31y)) { if (downloadRegion != null && isRegion && regions.contain(o, point31x, point31y)) {
it.remove(); if (!isIndexItemDownloaded(downloadThread, type, downloadRegion, res)) {
} addIndexItem(downloadThread, type, downloadRegion, res);
List<IndexItem> otherIndexItems = new ArrayList<>(downloadThread.getIndexes().getIndexItems(downloadRegion));
for (IndexItem indexItem : otherIndexItems) {
if (indexItem.getType() == type
&& !res.contains(indexItem)) {
if (indexItem.isDownloaded()) {
res.clear();
return res;
}
res.add(indexItem);
} }
} }
} }
@ -413,4 +404,28 @@ public class DownloadResources extends DownloadResourceGroup {
} }
return res; return res;
} }
private static boolean isIndexItemDownloaded(DownloadIndexesThread downloadThread, DownloadActivityType type, WorldRegion downloadRegion, List<IndexItem> res) {
List<IndexItem> otherIndexItems = new ArrayList<>(downloadThread.getIndexes().getIndexItems(downloadRegion));
for (IndexItem indexItem : otherIndexItems) {
if (indexItem.getType() == type && indexItem.isDownloaded()) {
return true;
}
}
return downloadRegion.getSuperregion() != null
&& isIndexItemDownloaded(downloadThread, type, downloadRegion.getSuperregion(), res);
}
private static boolean addIndexItem(DownloadIndexesThread downloadThread, DownloadActivityType type, WorldRegion downloadRegion, List<IndexItem> res) {
List<IndexItem> otherIndexItems = new ArrayList<>(downloadThread.getIndexes().getIndexItems(downloadRegion));
for (IndexItem indexItem : otherIndexItems) {
if (indexItem.getType() == type
&& !res.contains(indexItem)) {
res.add(indexItem);
return true;
}
}
return downloadRegion.getSuperregion() != null
&& addIndexItem(downloadThread, type, downloadRegion.getSuperregion(), res);
}
} }