Continue refactoring

This commit is contained in:
Victor Shcherb 2015-10-18 17:13:21 +02:00
parent e5b451193a
commit 266e62c459
8 changed files with 154 additions and 165 deletions

View file

@ -80,8 +80,6 @@ public class BaseDownloadActivity extends ActionBarProgressActivity {
public void downloadedIndexes() { public void downloadedIndexes() {
} }
public void updateFragments() {
}
public void downloadListUpdated() { public void downloadListUpdated() {
} }
@ -155,7 +153,7 @@ public class BaseDownloadActivity extends ActionBarProgressActivity {
private void downloadFileCheck_Final_Run(IndexItem[] items) { private void downloadFileCheck_Final_Run(IndexItem[] items) {
downloadListIndexThread.runDownloadFiles(items); downloadListIndexThread.runDownloadFiles(items);
updateFragments(); updateProgress(false);
} }

View file

@ -119,7 +119,7 @@ public class DownloadActivity extends BaseDownloadActivity implements DialogDism
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
getMyApplication().getAppCustomization().resumeActivity(DownloadActivity.class, this); getMyApplication().getAppCustomization().resumeActivity(DownloadActivity.class, this);
updateFragments(); updateProgress(false);
} }
@ -157,8 +157,22 @@ public class DownloadActivity extends BaseDownloadActivity implements DialogDism
final int countedDownloads = downloadListIndexThread.getCountedDownloads(); final int countedDownloads = downloadListIndexThread.getCountedDownloads();
visibleBanner.updateProgress(countedDownloads, basicProgressAsyncTask); visibleBanner.updateProgress(countedDownloads, basicProgressAsyncTask);
} }
if (!updateOnlyProgress) { if(activeDownloads != null) {
updateFragments(); if(updateOnlyProgress) {
activeDownloads.notifyDataSetChanged();
} else {
activeDownloads.notifyDataSetInvalidated();
}
}
// FIXME
//((DownloadActivity) getActivity()).updateDescriptionTextWithSize(getView());
for (WeakReference<Fragment> ref : fragSet) {
Fragment f = ref.get();
notifyUpdateDataSetChanged(f);
if(f instanceof RegionItemsFragment) {
Fragment innerFragment = ((RegionItemsFragment)f).getChildFragmentManager().findFragmentById(R.id.fragmentContainer);
notifyUpdateDataSetChanged(innerFragment);
}
} }
} }
@ -209,22 +223,6 @@ public class DownloadActivity extends BaseDownloadActivity implements DialogDism
this.activeDownloads = activeDownloads; this.activeDownloads = activeDownloads;
} }
@Override
public void updateFragments() {
if(activeDownloads != null) {
activeDownloads.refresh();
}
// FIXME
//((DownloadActivity) getActivity()).updateDescriptionTextWithSize(getView());
for (WeakReference<Fragment> ref : fragSet) {
Fragment f = ref.get();
notifyUpdateDataSetChanged(f);
if(f instanceof RegionItemsFragment) {
Fragment innerFragment = ((RegionItemsFragment)f).getChildFragmentManager().findFragmentById(R.id.fragmentContainer);
notifyUpdateDataSetChanged(innerFragment);
}
}
}
private void notifyUpdateDataSetChanged(Fragment f) { private void notifyUpdateDataSetChanged(Fragment f) {

View file

@ -1,31 +0,0 @@
package net.osmand.plus.download;
import java.io.File;
public class DownloadEntry {
public long dateModified;
public double sizeMB;
public File targetFile;
public boolean zipStream;
public boolean unzipFolder;
public File fileToDownload;
public String baseName;
public String urlToDownload;
public boolean isAsset;
public String assetName;
public DownloadActivityType type;
public DownloadEntry() {
}
public DownloadEntry(String assetName, String fileName, long dateModified) {
this.dateModified = dateModified;
targetFile = new File(fileName);
this.assetName = assetName;
isAsset = true;
}
}

View file

@ -200,7 +200,7 @@ public class DownloadFileHelper {
return ctx.getSettings().isWifiConnected(); return ctx.getSettings().isWifiConnected();
} }
public boolean downloadFile(DownloadEntry de, IProgress progress, public boolean downloadFile(IndexItem.DownloadEntry de, IProgress progress,
List<File> toReIndex, DownloadFileShowWarning showWarningCallback, boolean forceWifi) throws InterruptedException { List<File> toReIndex, DownloadFileShowWarning showWarningCallback, boolean forceWifi) throws InterruptedException {
try { try {
final List<InputStream> downloadInputStreams = new ArrayList<InputStream>(); final List<InputStream> downloadInputStreams = new ArrayList<InputStream>();
@ -235,7 +235,7 @@ public class DownloadFileHelper {
} }
} }
private void copyVoiceConfig(DownloadEntry de) { private void copyVoiceConfig(IndexItem.DownloadEntry de) {
File f = ctx.getAppPath("/voice/" + de.baseName + "/_config.p"); File f = ctx.getAppPath("/voice/" + de.baseName + "/_config.p");
if (f.exists()) try { if (f.exists()) try {
InputStream is = ctx.getAssets().open("voice/" + de.baseName + "/config.p"); InputStream is = ctx.getAssets().open("voice/" + de.baseName + "/config.p");
@ -252,7 +252,7 @@ public class DownloadFileHelper {
} }
} }
private void unzipFile(DownloadEntry de, IProgress progress, List<InputStream> is) throws IOException { private void unzipFile(IndexItem.DownloadEntry de, IProgress progress, List<InputStream> is) throws IOException {
CountingMultiInputStream fin = new CountingMultiInputStream(is); CountingMultiInputStream fin = new CountingMultiInputStream(is);
int len = (int) fin.available(); int len = (int) fin.available();
int mb = (int) (len / (1024f*1024f)); int mb = (int) (len / (1024f*1024f));
@ -308,7 +308,7 @@ public class DownloadFileHelper {
fin.close(); fin.close();
} }
private void copyFile(DownloadEntry de, IProgress progress, private void copyFile(IndexItem.DownloadEntry de, IProgress progress,
CountingMultiInputStream countIS, int length, InputStream toRead, File targetFile) CountingMultiInputStream countIS, int length, InputStream toRead, File targetFile)
throws IOException { throws IOException {
targetFile.getParentFile().mkdirs(); targetFile.getParentFile().mkdirs();

View file

@ -65,8 +65,8 @@ public class DownloadIndexesThread {
private ConcurrentLinkedQueue<IndexItem> indexItemDownloading = new ConcurrentLinkedQueue<IndexItem>(); private ConcurrentLinkedQueue<IndexItem> indexItemDownloading = new ConcurrentLinkedQueue<IndexItem>();
private IndexItem currentDownloadingItem = null; private IndexItem currentDownloadingItem = null;
private int currentDownloadingItemProgress = 0; private int currentDownloadingItemProgress = 0;
private DownloadIndexes indexes = new DownloadIndexes(); private DownloadIndexes indexes = new DownloadIndexes();
public static class DownloadIndexes { public static class DownloadIndexes {
Map<WorldRegion, Map<String, IndexItem>> resourcesByRegions = new HashMap<>(); Map<WorldRegion, Map<String, IndexItem>> resourcesByRegions = new HashMap<>();
@ -77,8 +77,8 @@ public class DownloadIndexesThread {
private Map<String, String> indexFileNames = new LinkedHashMap<>(); private Map<String, String> indexFileNames = new LinkedHashMap<>();
private Map<String, String> indexActivatedFileNames = new LinkedHashMap<>(); private Map<String, String> indexActivatedFileNames = new LinkedHashMap<>();
private List<IndexItem> itemsToUpdate = new ArrayList<>(); private List<IndexItem> itemsToUpdate = new ArrayList<>();
public DownloadIndexesThread(Context ctx) { public DownloadIndexesThread(Context ctx) {
this.ctx = ctx; this.ctx = ctx;
@ -89,10 +89,44 @@ public class DownloadIndexesThread {
} }
/// UI notifications methods
public void setUiActivity(BaseDownloadActivity uiActivity) { public void setUiActivity(BaseDownloadActivity uiActivity) {
this.uiActivity = uiActivity; this.uiActivity = uiActivity;
} }
@UiThread
private void updateProgressUI(boolean onlyProgress) {
if (uiActivity != null) {
uiActivity.updateProgress(onlyProgress);
}
}
@UiThread
private void onCategorizationFinished() {
if (uiActivity != null) {
uiActivity.onCategorizationFinished();
}
}
@UiThread
private void updateDownloadList() {
if (uiActivity != null) {
uiActivity.updateDownloadList();
}
}
@UiThread
private void notifyFilesToUpdateChanged() {
List<IndexItem> filtered = getCachedIndexFiles();
if (filtered != null) {
updateDownloadList();
}
}
// PUBLIC API
public List<IndexItem> getCurrentDownloadingItems() { public List<IndexItem> getCurrentDownloadingItems() {
List<IndexItem> res = new ArrayList<IndexItem>(); List<IndexItem> res = new ArrayList<IndexItem>();
IndexItem ii = currentDownloadingItem; IndexItem ii = currentDownloadingItem;
@ -102,7 +136,7 @@ public class DownloadIndexesThread {
res.addAll(indexItemDownloading); res.addAll(indexItemDownloading);
return res; return res;
} }
public boolean isDownloading(IndexItem item) { public boolean isDownloading(IndexItem item) {
if(item == currentDownloadingItem) { if(item == currentDownloadingItem) {
return true; return true;
@ -114,7 +148,7 @@ public class DownloadIndexesThread {
} }
return false; return false;
} }
public int getCountedDownloads() { public int getCountedDownloads() {
int i = 0; int i = 0;
if(currentDownloadingItem != null && DownloadActivityType.isCountedInDownloads(currentDownloadingItem)) { if(currentDownloadingItem != null && DownloadActivityType.isCountedInDownloads(currentDownloadingItem)) {
@ -127,18 +161,18 @@ public class DownloadIndexesThread {
} }
return i; return i;
} }
// FIXME // FIXME
public List<IndexItem> getCachedIndexFiles() { public List<IndexItem> getCachedIndexFiles() {
return indexes.indexFiles != null ? indexes.indexFiles.getIndexFiles() : null; return indexes.indexFiles != null ? indexes.indexFiles.getIndexFiles() : null;
} }
// FIXME // FIXME
public Map<String, String> getIndexFileNames() { public Map<String, String> getIndexFileNames() {
return indexFileNames; return indexFileNames;
} }
// FIXME // FIXME
public Map<String, String> getIndexActivatedFileNames() { public Map<String, String> getIndexActivatedFileNames() {
return indexActivatedFileNames; return indexActivatedFileNames;
@ -185,8 +219,8 @@ public class DownloadIndexesThread {
} }
private boolean prepareData(List<IndexItem> resources, private boolean prepareData(List<IndexItem> resources,
Map<WorldRegion, Map<String, IndexItem>> resourcesByRegions, Map<WorldRegion, Map<String, IndexItem>> resourcesByRegions,
List<IndexItem> voiceRecItems, List<IndexItem> voiceTTSItems) { List<IndexItem> voiceRecItems, List<IndexItem> voiceTTSItems) {
List<IndexItem> resourcesInRepository; List<IndexItem> resourcesInRepository;
if (resources != null) { if (resources != null) {
resourcesInRepository = resources; resourcesInRepository = resources;
@ -227,8 +261,8 @@ public class DownloadIndexesThread {
// FIXME argument list // FIXME argument list
private void processRegion(List<IndexItem> resourcesInRepository, Map<WorldRegion, private void processRegion(List<IndexItem> resourcesInRepository, Map<WorldRegion,
Map<String, IndexItem>> resourcesByRegions, Map<String, IndexItem>> resourcesByRegions,
List<IndexItem> voiceRecItems, List<IndexItem> voiceTTSItems, List<IndexItem> voiceRecItems, List<IndexItem> voiceTTSItems,
boolean processVoiceFiles, WorldRegion region) { boolean processVoiceFiles, WorldRegion region) {
String downloadsIdPrefix = region.getDownloadsIdPrefix(); String downloadsIdPrefix = region.getDownloadsIdPrefix();
Map<String, IndexItem> regionResources = new HashMap<>(); Map<String, IndexItem> regionResources = new HashMap<>();
Set<DownloadActivityType> typesSet = new TreeSet<>(new Comparator<DownloadActivityType>() { Set<DownloadActivityType> typesSet = new TreeSet<>(new Comparator<DownloadActivityType>() {
@ -275,7 +309,7 @@ public class DownloadIndexesThread {
region.setResourceTypes(typesSet); region.setResourceTypes(typesSet);
resourcesByRegions.put(region, regionResources); resourcesByRegions.put(region, regionResources);
} }
private boolean checkRunning() { private boolean checkRunning() {
if (getCurrentRunningTask() != null) { if (getCurrentRunningTask() != null) {
@ -305,13 +339,13 @@ public class DownloadIndexesThread {
execute(new DownloadIndexesAsyncTask(ctx)); execute(new DownloadIndexesAsyncTask(ctx));
} }
} }
public void cancelDownload(IndexItem item) { public void cancelDownload(IndexItem item) {
if(currentDownloadingItem == item) { if(currentDownloadingItem == item) {
downloadFileHelper.setInterruptDownloading(true);; downloadFileHelper.setInterruptDownloading(true);;
} else {
indexItemDownloading.remove(item);
} }
// TODO Auto-generated method stub
} }
private <P> void execute(BasicProgressAsyncTask<?, P, ?, ?> task, P... indexItems) { private <P> void execute(BasicProgressAsyncTask<?, P, ?, ?> task, P... indexItems) {
@ -336,15 +370,6 @@ public class DownloadIndexesThread {
} }
} }
@UiThread
private void notifyFilesToUpdateChanged() {
List<IndexItem> filtered = getCachedIndexFiles();
if (filtered != null) {
if (uiActivity != null) {
uiActivity.updateDownloadList();
}
}
}
public boolean checkIfItemOutdated(IndexItem item) { public boolean checkIfItemOutdated(IndexItem item) {
boolean outdated = false; boolean outdated = false;
@ -385,8 +410,6 @@ public class DownloadIndexesThread {
} else { } else {
oldItemSize = app.getAppPath(item.getTargetFileName()).length(); oldItemSize = app.getAppPath(item.getTargetFileName()).length();
} }
if (itemSize != oldItemSize) { if (itemSize != oldItemSize) {
outdated = true; outdated = true;
} }
@ -395,47 +418,14 @@ public class DownloadIndexesThread {
return outdated; return outdated;
} }
private void updateFilesToUpdate() {
List<IndexItem> stillUpdate = new ArrayList<IndexItem>();
for (IndexItem item : itemsToUpdate) {
String sfName = item.getTargetFileName();
java.text.DateFormat format = app.getResourceManager().getDateFormat();
String date = item.getDate(format);
String indexactivateddate = indexActivatedFileNames.get(sfName);
String indexfilesdate = indexFileNames.get(sfName);
if (date != null &&
!date.equals(indexactivateddate) &&
!date.equals(indexfilesdate) &&
indexActivatedFileNames.containsKey(sfName)) {
stillUpdate.add(item);
}
}
itemsToUpdate = stillUpdate;
if (uiActivity != null) {
uiActivity.updateDownloadList();
}
}
public boolean isDownloadRunning() {
for (int i = 0; i < currentRunningTask.size(); i++) {
if (currentRunningTask.get(i) instanceof DownloadIndexesAsyncTask) {
return true;
}
}
return false;
}
public IndexItem getCurrentDownloadingItem() { public IndexItem getCurrentDownloadingItem() {
return currentDownloadingItem; return currentDownloadingItem;
} }
public int getCurrentDownloadingItemProgress() { public int getCurrentDownloadingItemProgress() {
return currentDownloadingItemProgress; return currentDownloadingItemProgress;
} }
// FIXME deprecated
public BasicProgressAsyncTask<?, ?, ?, ?> getCurrentRunningTask() { public BasicProgressAsyncTask<?, ?, ?, ?> getCurrentRunningTask() {
for (int i = 0; i < currentRunningTask.size(); ) { for (int i = 0; i < currentRunningTask.size(); ) {
if (currentRunningTask.get(i).getStatus() == Status.FINISHED) { if (currentRunningTask.get(i).getStatus() == Status.FINISHED) {
@ -459,7 +449,7 @@ public class DownloadIndexesThread {
} }
return asz; return asz;
} }
public Map<String, String> listWithAlternatives(final java.text.DateFormat dateFormat, File file, final String ext, public Map<String, String> listWithAlternatives(final java.text.DateFormat dateFormat, File file, final String ext,
final Map<String, String> files) { final Map<String, String> files) {
@ -524,7 +514,6 @@ public class DownloadIndexesThread {
protected void onPostExecute(DownloadIndexes result) { protected void onPostExecute(DownloadIndexes result) {
indexes = result; indexes = result;
notifyFilesToUpdateChanged();
if (result.indexFiles != null) { if (result.indexFiles != null) {
if (result.indexFiles.isIncreasedMapVersion()) { if (result.indexFiles.isIncreasedMapVersion()) {
showWarnDialog(); showWarnDialog();
@ -533,10 +522,9 @@ public class DownloadIndexesThread {
AccessibleToast.makeText(ctx, R.string.list_index_files_was_not_loaded, Toast.LENGTH_LONG).show(); AccessibleToast.makeText(ctx, R.string.list_index_files_was_not_loaded, Toast.LENGTH_LONG).show();
} }
currentRunningTask.remove(this); currentRunningTask.remove(this);
if (uiActivity != null) { notifyFilesToUpdateChanged();
uiActivity.updateProgress(false); updateProgressUI(false);
uiActivity.onCategorizationFinished(); onCategorizationFinished();
}
} }
private void showWarnDialog() { private void showWarnDialog() {
@ -564,18 +552,34 @@ public class DownloadIndexesThread {
@Override @Override
protected void updateProgress(boolean updateOnlyProgress, Void tag) { protected void updateProgress(boolean updateOnlyProgress, Void tag) {
if (uiActivity != null) { updateProgressUI(true);
uiActivity.updateProgress(updateOnlyProgress);
}
} }
} }
//FIXME
private void updateFilesToUpdate() {
List<IndexItem> stillUpdate = new ArrayList<IndexItem>();
for (IndexItem item : itemsToUpdate) {
String sfName = item.getTargetFileName();
java.text.DateFormat format = app.getResourceManager().getDateFormat();
String date = item.getDate(format);
String indexactivateddate = indexActivatedFileNames.get(sfName);
String indexfilesdate = indexFileNames.get(sfName);
if (date != null &&
!date.equals(indexactivateddate) &&
!date.equals(indexfilesdate) &&
indexActivatedFileNames.containsKey(sfName)) {
stillUpdate.add(item);
}
}
itemsToUpdate = stillUpdate;
}
public class DownloadIndexesAsyncTask extends BasicProgressAsyncTask<IndexItem, IndexItem, Object, String> implements DownloadFileShowWarning { public class DownloadIndexesAsyncTask extends BasicProgressAsyncTask<IndexItem, IndexItem, Object, String> implements DownloadFileShowWarning {
private OsmandPreference<Integer> downloads; private OsmandPreference<Integer> downloads;
public DownloadIndexesAsyncTask(Context ctx) { public DownloadIndexesAsyncTask(Context ctx) {
super(ctx); super(ctx);
@ -594,17 +598,15 @@ public class DownloadIndexesThread {
protected void onProgressUpdate(Object... values) { protected void onProgressUpdate(Object... values) {
for (Object o : values) { for (Object o : values) {
if (o instanceof IndexItem) { if (o instanceof IndexItem) {
if (uiActivity != null) { updateProgressUI(false);
uiActivity.updateFragments(); IndexItem item = (IndexItem) o;
IndexItem item = (IndexItem) o; String name = item.getBasename();
String name = item.getBasename(); long count = dbHelper.getCount(name, DatabaseHelper.DOWNLOAD_ENTRY) + 1;
long count = dbHelper.getCount(name, DatabaseHelper.DOWNLOAD_ENTRY) + 1; DatabaseHelper.HistoryDownloadEntry entry = new DatabaseHelper.HistoryDownloadEntry(name, count);
DatabaseHelper.HistoryDownloadEntry entry = new DatabaseHelper.HistoryDownloadEntry(name, count); if (count == 1) {
if (count == 1) { dbHelper.add(entry, DatabaseHelper.DOWNLOAD_ENTRY);
dbHelper.add(entry, DatabaseHelper.DOWNLOAD_ENTRY); } else {
} else { dbHelper.update(entry, DatabaseHelper.DOWNLOAD_ENTRY);
dbHelper.update(entry, DatabaseHelper.DOWNLOAD_ENTRY);
}
} }
} else if (o instanceof String) { } else if (o instanceof String) {
String message = (String) o; String message = (String) o;
@ -613,11 +615,8 @@ public class DownloadIndexesThread {
!message.equals(uiActivity.getString(R.string.shared_string_download_successful))) { !message.equals(uiActivity.getString(R.string.shared_string_download_successful))) {
AccessibleToast.makeText(ctx, message, Toast.LENGTH_LONG).show(); AccessibleToast.makeText(ctx, message, Toast.LENGTH_LONG).show();
} }
} else {
if (uiActivity != null) {
uiActivity.updateProgress(true);
}
} }
updateProgressUI(false);
} }
} }
super.onProgressUpdate(values); super.onProgressUpdate(values);
@ -647,15 +646,15 @@ public class DownloadIndexesThread {
if (mainView != null) { if (mainView != null) {
mainView.setKeepScreenOn(false); mainView.setKeepScreenOn(false);
} }
uiActivity.downloadedIndexes();
} }
currentRunningTask.remove(this); currentRunningTask.remove(this);
if (uiActivity != null) { notifyFilesToUpdateChanged();
uiActivity.updateProgress(false);
}
updateFilesToUpdate(); updateFilesToUpdate();
updateProgressUI(false);
} }
@Override @Override
protected String doInBackground(IndexItem... filesToDownload) { protected String doInBackground(IndexItem... filesToDownload) {
@ -777,7 +776,7 @@ public class DownloadIndexesThread {
public boolean downloadFile(IndexItem item, List<File> filesToReindex, boolean forceWifi) public boolean downloadFile(IndexItem item, List<File> filesToReindex, boolean forceWifi)
throws InterruptedException { throws InterruptedException {
downloadFileHelper.setInterruptDownloading(false); downloadFileHelper.setInterruptDownloading(false);
DownloadEntry de = item.createDownloadEntry(app); IndexItem.DownloadEntry de = item.createDownloadEntry(app);
boolean res = false; boolean res = false;
if(de == null) { if(de == null) {
return res; return res;
@ -804,7 +803,7 @@ public class DownloadIndexesThread {
@Override @Override
protected void updateProgress(boolean updateOnlyProgress, IndexItem tag) { protected void updateProgress(boolean updateOnlyProgress, IndexItem tag) {
currentDownloadingItemProgress = getProgressPercentage(); currentDownloadingItemProgress = getProgressPercentage();
uiActivity.updateProgress(true); updateProgressUI(true);
} }
} }

View file

@ -161,6 +161,34 @@ public class IndexItem implements Comparable<IndexItem>/*, Parcelable*/ {
public String getDate(java.text.DateFormat format) { public String getDate(java.text.DateFormat format) {
return format.format(new Date(timestamp)); return format.format(new Date(timestamp));
} }
public static class DownloadEntry {
public long dateModified;
public double sizeMB;
public File targetFile;
public boolean zipStream;
public boolean unzipFolder;
public File fileToDownload;
public String baseName;
public String urlToDownload;
public boolean isAsset;
public String assetName;
public DownloadActivityType type;
public DownloadEntry() {
}
public DownloadEntry(String assetName, String fileName, long dateModified) {
this.dateModified = dateModified;
targetFile = new File(fileName);
this.assetName = assetName;
isAsset = true;
}
}
// @Override // @Override

View file

@ -34,8 +34,12 @@ public class ActiveDownloadsDialogFragment extends DialogFragment {
return builder.create(); return builder.create();
} }
public void refresh() { public void notifyDataSetInvalidated() {
adapter.updateData(); adapter.refreshAllData();
}
public void notifyDataSetChanged() {
adapter.notifyDataSetChanged();
} }
public void onDetach() { public void onDetach() {
@ -59,10 +63,10 @@ public class ActiveDownloadsDialogFragment extends DialogFragment {
deleteDrawable = context.getMyApplication().getIconsCache() deleteDrawable = context.getMyApplication().getIconsCache()
.getPaintedContentIcon(R.drawable.ic_action_remove_dark, .getPaintedContentIcon(R.drawable.ic_action_remove_dark,
context.getResources().getColor(R.color.dash_search_icon_dark)); context.getResources().getColor(R.color.dash_search_icon_dark));
updateData(); refreshAllData();
} }
public void updateData() { public void refreshAllData() {
clear(); clear();
addAll(context.getDownloadThread().getCurrentDownloadingItems()); addAll(context.getDownloadThread().getCurrentDownloadingItems());
} }
@ -127,7 +131,7 @@ public class ActiveDownloadsDialogFragment extends DialogFragment {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
context.getDownloadThread().cancelDownload(item); context.getDownloadThread().cancelDownload(item);
adapter.updateData(); adapter.refreshAllData();
} }
}); });
progressBar.setIndeterminate(isIndeterminate); progressBar.setIndeterminate(isIndeterminate);

View file

@ -6,24 +6,17 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.WorldRegion; import net.osmand.plus.WorldRegion;
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
import net.osmand.plus.activities.OsmandExpandableListFragment; import net.osmand.plus.activities.OsmandExpandableListFragment;
import net.osmand.plus.base.BasicProgressAsyncTask;
import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.download.DownloadEntry;
import net.osmand.plus.download.IndexItem; import net.osmand.plus.download.IndexItem;
import org.apache.commons.logging.Log;
import android.app.Dialog; import android.app.Dialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;