Merge pull request #1891 from mfietz/issue/1888-asynctask-execute

Resolve potential AsyncTask performance issue
This commit is contained in:
Tom Hennen 2016-04-25 08:17:59 -04:00
commit e73d8b32bc
2 changed files with 13 additions and 4 deletions

View File

@ -239,7 +239,11 @@ public class FeedInfoActivity extends ActionBarActivity {
}
}
};
loadTask.execute(feedId);
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
loadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, feedId);
} else {
loadTask.execute(feedId);
}
}

View File

@ -121,7 +121,7 @@ public class GpodnetAuthenticationActivity extends ActionBarActivity {
final String passwordStr = password.getText().toString();
if (BuildConfig.DEBUG) Log.d(TAG, "Checking login credentials");
new AsyncTask<GpodnetService, Void, Void>() {
AsyncTask<GpodnetService, Void, Void> authTask = new AsyncTask<GpodnetService, Void, Void>() {
volatile Exception exception;
@ -143,7 +143,7 @@ public class GpodnetAuthenticationActivity extends ActionBarActivity {
if (exception == null) {
advance();
} else {
txtvError.setText(exception.getMessage());
txtvError.setText(exception.getCause().getMessage());
txtvError.setVisibility(View.VISIBLE);
}
}
@ -160,7 +160,12 @@ public class GpodnetAuthenticationActivity extends ActionBarActivity {
}
return null;
}
}.execute(service);
};
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
authTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, service);
} else {
authTask.execute();
}
}
});
}