Fixed issue with maps not being downloaded after tour download
This commit is contained in:
parent
5e9a232a05
commit
74d4fef91e
4 changed files with 56 additions and 58 deletions
|
@ -19,6 +19,7 @@ import net.osmand.access.AccessibleAlertBuilder;
|
|||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.plus.access.AccessibilityMode;
|
||||
import net.osmand.plus.activities.*;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadIndexFragment;
|
||||
import net.osmand.plus.api.SQLiteAPI;
|
||||
import net.osmand.plus.api.SQLiteAPIImpl;
|
||||
|
@ -111,7 +112,7 @@ public class OsmandApplication extends Application {
|
|||
BRouterServiceConnection bRouterServiceConnection;
|
||||
|
||||
MapActivity mapActivity;
|
||||
DownloadIndexFragment downloadActivity;
|
||||
DownloadActivity downloadActivity;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
|
@ -879,11 +880,11 @@ public class OsmandApplication extends Application {
|
|||
this.mapActivity = mapActivity;
|
||||
}
|
||||
|
||||
public void setDownloadActivity(DownloadIndexFragment downloadActivity) {
|
||||
public void setDownloadActivity(DownloadActivity downloadActivity) {
|
||||
this.downloadActivity = downloadActivity;
|
||||
}
|
||||
|
||||
public DownloadIndexFragment getDownloadActivity() {
|
||||
public DownloadActivity getDownloadActivity() {
|
||||
return downloadActivity;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,10 +30,7 @@ import net.osmand.plus.voice.TTSCommandPlayerImpl;
|
|||
|
||||
import java.io.File;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by Denis on 08.09.2014.
|
||||
|
@ -202,6 +199,7 @@ public class DownloadActivity extends SherlockFragmentActivity {
|
|||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
getMyApplication().setDownloadActivity(this);
|
||||
BasicProgressAsyncTask<?, ?, ?> t = downloadListIndexThread.getCurrentRunningTask();
|
||||
}
|
||||
|
||||
|
@ -476,4 +474,53 @@ public class DownloadActivity extends SherlockFragmentActivity {
|
|||
task.execute();
|
||||
}
|
||||
|
||||
public void showDialogToDownloadMaps(Collection<String> maps) {
|
||||
int count = 0;
|
||||
int sz = 0;
|
||||
String s = "";
|
||||
for (IndexItem i : DownloadActivity.downloadListIndexThread.getCachedIndexFiles()) {
|
||||
for (String map : maps) {
|
||||
if ((i.getFileName().equals(map + ".obf.zip") || i.getFileName().equals(map + "_" + IndexConstants.BINARY_MAP_VERSION + ".obf.zip"))
|
||||
&& i.getType() == DownloadActivityType.NORMAL_FILE) {
|
||||
final List<DownloadEntry> de = i.createDownloadEntry(getMyApplication(), i.getType(), new ArrayList<DownloadEntry>(1));
|
||||
for(DownloadEntry d : de ) {
|
||||
count++;
|
||||
sz += d.sizeMB;
|
||||
}
|
||||
if(s.length() > 0) {
|
||||
s +=", ";
|
||||
}
|
||||
s += i.getVisibleName(getMyApplication(), getMyApplication().getResourceManager().getOsmandRegions());
|
||||
getEntriesToDownload().put(i, de);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(count > 0){
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setMessage(getString(R.string.download_additional_maps, s, sz));
|
||||
builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
downloadFilesCheckInternet();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.default_buttons_no, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
getEntriesToDownload().clear();
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
getEntriesToDownload().clear();
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -110,7 +110,6 @@ public class DownloadIndexFragment extends OsmandExpandableListFragment {
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getMyApplication().setDownloadActivity(this);
|
||||
getDownloadActivity().updateProgress(false);
|
||||
BasicProgressAsyncTask<?, ?, ?> t = DownloadActivity.downloadListIndexThread.getCurrentRunningTask();
|
||||
if(t instanceof DownloadIndexesThread.DownloadIndexesAsyncTask) {
|
||||
|
@ -121,55 +120,6 @@ public class DownloadIndexFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
}
|
||||
|
||||
public void showDialogToDownloadMaps(Collection<String> maps) {
|
||||
int count = 0;
|
||||
int sz = 0;
|
||||
String s = "";
|
||||
for (IndexItem i : DownloadActivity.downloadListIndexThread.getCachedIndexFiles()) {
|
||||
for (String map : maps) {
|
||||
if (i.getFileName().equals(map + ".obf.zip") && i.getType() == DownloadActivityType.NORMAL_FILE) {
|
||||
final List<DownloadEntry> de = i.createDownloadEntry(getMyApplication(), i.getType(), new ArrayList<DownloadEntry>(1));
|
||||
for(DownloadEntry d : de ) {
|
||||
count++;
|
||||
sz += d.sizeMB;
|
||||
}
|
||||
if(s.length() > 0) {
|
||||
s +=", ";
|
||||
}
|
||||
s += i.getVisibleName(getMyApplication(), getMyApplication().getResourceManager().getOsmandRegions());
|
||||
getDownloadActivity().getEntriesToDownload().put(i, de);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(count > 0){
|
||||
Builder builder = new AlertDialog.Builder(getDownloadActivity());
|
||||
builder.setMessage(getString(R.string.download_additional_maps, s, sz));
|
||||
builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
getDownloadActivity().downloadFilesCheckInternet();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.default_buttons_no, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
getDownloadActivity().getEntriesToDownload().clear();
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
getDownloadActivity().getEntriesToDownload().clear();
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == RELOAD_ID) {
|
||||
|
|
|
@ -229,7 +229,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
|
|||
}
|
||||
this.tourPresent = tourPresent;
|
||||
if(!suggestToDownloadMap.isEmpty()) {
|
||||
final DownloadIndexFragment da = app.getDownloadActivity();
|
||||
final DownloadActivity da = app.getDownloadActivity();
|
||||
if (da != null) {
|
||||
app.runInUIThread(new Runnable() {
|
||||
|
||||
|
|
Loading…
Reference in a new issue