Merge pull request #4648 from osmandapp/async_task_fix

Fix async task
This commit is contained in:
Alexey 2017-10-26 13:56:05 +03:00 committed by GitHub
commit f7893d6b42
4 changed files with 18 additions and 4 deletions

View file

@ -25,6 +25,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class CurrentPositionHelper {
@ -36,6 +38,7 @@ public class CurrentPositionHelper {
private ApplicationMode am;
private List<BinaryMapReaderResource> usedReaders = new ArrayList<>();
private static final org.apache.commons.logging.Log log = PlatformUtil.getLog(CurrentPositionHelper.class);
private ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
public CurrentPositionHelper(OsmandApplication app) {
this.app = app;
@ -99,7 +102,7 @@ public class CurrentPositionHelper {
}
return null;
}
}.execute((Void) null);
}.executeOnExecutor(singleThreadExecutor, (Void) null);
res = true;
}
return res;

View file

@ -136,6 +136,8 @@ import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -200,6 +202,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
private InAppHelper inAppHelper;
private Timer splashScreenTimer;
private ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
@Override
public void onCreate(Bundle savedInstanceState) {
setRequestedOrientation(AndroidUiHelper.getScreenOrientation(this));
@ -1234,7 +1238,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
protected void onPostExecute(Void result) {
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
}.executeOnExecutor(singleThreadExecutor, (Void) null);
}

View file

@ -78,6 +78,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static net.osmand.plus.OsmandApplication.SHOW_PLUS_VERSION_INAPP_PARAM;
@ -125,6 +127,8 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
private boolean nauticalPluginDisabled;
private boolean freeVersion;
private ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
@Override
protected void onCreate(Bundle savedInstanceState) {
getMyApplication().applyTheme(this);
@ -784,7 +788,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
newDownloadIndexes();
}
};
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
task.executeOnExecutor(singleThreadExecutor);
}

View file

@ -23,6 +23,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class CurrentPositionHelper {
@ -33,6 +35,7 @@ public class CurrentPositionHelper {
private List<BinaryMapIndexReader> readers = new ArrayList<>();
private List<BinaryMapIndexReader> usedReaders = new ArrayList<>();
private static final org.apache.commons.logging.Log log = PlatformUtil.getLog(CurrentPositionHelper.class);
private ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
public CurrentPositionHelper(SampleApplication app) {
this.app = app;
@ -103,7 +106,7 @@ public class CurrentPositionHelper {
}
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
}.executeOnExecutor(singleThreadExecutor, (Void) null);
res = true;
}
return res;