Skip to content

Commit

Permalink
Merge pull request #250 from frankFic/master
Browse files Browse the repository at this point in the history
Changed the execute to executeOnExecutor to fix #246
  • Loading branch information
martykan authored Dec 29, 2017
2 parents 6d726e8 + c2a62a1 commit 27bc9f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions app/src/main/java/cz/martykan/forecastie/AlarmReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ private void getWeather() {
if (isUpdateLocation()) {
new GetLocationAndWeatherTask().execute(); // This method calls the two methods below once it has determined a location
} else {
new GetWeatherTask().execute();
new GetLongTermWeatherTask().execute();
new GetWeatherTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new GetLongTermWeatherTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
} else {
failed = true;
Expand Down Expand Up @@ -227,8 +227,8 @@ protected void onPostExecute(Void aVoid) {
new GetCityNameTask().execute(String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude()));
} else {
Log.e(TAG, "Couldn't determine location. Using last known location.");
new GetWeatherTask().execute();
new GetLongTermWeatherTask().execute();
new GetWeatherTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new GetLongTermWeatherTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
try {
locationManager.removeUpdates(locationListener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.Settings;
Expand Down Expand Up @@ -201,11 +202,11 @@ private void preloadWeather() {

String lastToday = sp.getString("lastToday", "");
if (!lastToday.isEmpty()) {
new TodayWeatherTask(this, this, progressDialog).execute("cachedResponse", lastToday);
new TodayWeatherTask(this, this, progressDialog).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "cachedResponse", lastToday);
}
String lastLongterm = sp.getString("lastLongterm", "");
if (!lastLongterm.isEmpty()) {
new LongTermWeatherTask(this, this, progressDialog).execute("cachedResponse", lastLongterm);
new LongTermWeatherTask(this, this, progressDialog).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "cachedResponse", lastLongterm);
}
}

Expand Down

0 comments on commit 27bc9f9

Please sign in to comment.