Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[sample] Mask RejectedExecutionException. This is only the sample so …

…fixing this isn't high on my priority list.
  • Loading branch information...
commit ffef32129e0bfe883de19725595ae39157d7cf48 1 parent 2a3ab09
@chrisbanes authored
View
16 sample/src/uk/co/senab/bitmapcache/samples/NetworkedCacheableImageView.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
+
package uk.co.senab.bitmapcache.samples;
import android.content.Context;
@@ -31,6 +32,7 @@
import java.lang.ref.WeakReference;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.util.concurrent.RejectedExecutionException;
import uk.co.senab.bitmapcache.BitmapLruCache;
import uk.co.senab.bitmapcache.CacheableBitmapDrawable;
@@ -130,7 +132,7 @@ public NetworkedCacheableImageView(Context context, AttributeSet attrs) {
public boolean loadImage(String url, final boolean fullSize) {
// First check whether there's already a task running, if so cancel it
if (null != mCurrentTask) {
- mCurrentTask.cancel(false);
+ mCurrentTask.cancel(true);
}
// Check to see if the memory cache already has the bitmap. We can
@@ -155,10 +157,14 @@ public boolean loadImage(String url, final boolean fullSize) {
mCurrentTask = new ImageUrlAsyncTask(this, mCache, decodeOpts);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
- SDK11.executeOnThreadPool(mCurrentTask, url);
- } else {
- mCurrentTask.execute(url);
+ try {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+ SDK11.executeOnThreadPool(mCurrentTask, url);
+ } else {
+ mCurrentTask.execute(url);
+ }
+ } catch (RejectedExecutionException e) {
+ // This shouldn't happen, but might.
}
return false;
Please sign in to comment.
Something went wrong with that request. Please try again.