Closed chrisjenx closed 11 years ago
Which version of RoboSpice are you using. The stack trace doesn't match actual code state.
Version 1.4.0
You'r right, I took the wrong class. Bug is being investigating. Supporting null listener was not part of the specs of the RequestProcessor
. But after all, it should be possible as well.
Nevertheless, would you have a test for the bug to appear using cancel ?
Because I'm struggling to create a mock version of the SpiceManager I have no test case to send you otherwise I would.
This is a work around for a ExecutorService:
private void requestImage(final UserPhoto photo, final boolean fullSize, OnPhotoLoadListener listener)
{
final String key = fullSize ? photo.getDisplayImageKey() : photo.getThumbnailImageKey(UserPhoto.MINI_THUMBNAIL_SIZE);
final BizzbyApplication app = BizzbyApplication.get();
final BitmapLruCache cache = app.getImageCache();
final CacheableBitmapDrawable cached = cache.get(key);
if (null != cached && cached.hasValidBitmap())
{
QLog.d("Got Bitmap: Size: [" + cached.getBitmap().getWidth() + "," + cached.getBitmap().getHeight() + "]");
setImageDrawable(cached);
if (null != listener)
listener.onPhotoLoadFinished(cached.getBitmap());
}
else
{
// Means we have an object with an invalid bitmap so remove it
if (null != cached)
cache.remove(key);
mCurrentRequest = new PhotoLoadExecutor(this, photo, cache, fullSize);
if (listener == null)
listener = new OnPhotoLoadListener()
{
@Override
public void onPhotoLoadFinished(final Bitmap bitmap)
{
}
};
app.getExecutorManager().execute(mCurrentRequest, listener);
}
}
Note the if(listener == null)
if you pass through null at this point it will FC when trying to deliver the result.
I agree Result listener wont be null in most cases, but here where I am offloading image resizing. Sometimes the result is set inline and there is no need for a listener.
Bug has been solved and a new test has been added. It is available on master branch and has been cherry picked to release branch for next release.
Thx for your help. Let's investigate the mocking problem now ;)
Nice, cheers Stephan. On 16 Feb 2013 20:47, "stephanenicolas" notifications@github.com wrote:
Bug has been solved and a new test has been added. It is available on master branch and has been cherry picked to release branch for next release.
Thx for your help. Let's investigate the mocking problem now ;)
— Reply to this email directly or view it on GitHubhttps://github.com/octo-online/robospice/issues/48#issuecomment-13674419.
Kills the app when trying to or after cancelling the request. sometimes. Or if passing a null listener through to the execute command.
Stack: