1 min read

Tags

I just spent an hour debugging an issue that should have been a non-issue at all.

A thing about working on a huge product like Domain with such a small team is that there are some bits that tend to get left behind. Lately I have been playing with a bunch of libraries to find out how the modern ones do image pan and zoom. This is important for us because those crazy expensive houses have pretty high-res photos.

Look at this!

One of the libraries I was looking at was Subsampling Scale Image View. I have heard good things about it, but was too lazy to figure it out. Today will be the day, I said. Today I will stop being lazy and figure it out.

After about an hour of furious Googling, I ended up finding a bunch of code that I managed to cobble together that theoretically should work. Maybe at this point I should mention that images and graphics are not my strong suit. There’s too much stuff going on and my I can’t wrap my head around it.

Anyway, I need to get the Bitmap from a file downloaded by Glide. Someone on the internet said this should work:

BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeFile(downloadedFile.getAbsolutePath(), opts);

I fired up my app and nothing is loading. All the pages in the whole of my image gallery are empty. Maybe I’m using the library wrong? Maybe this is not how I should apply BitmapRegionDecoder? Maybe it’s not actually downloading the file?

I ended putting breakpoints all over the place:

And it’s still not working. It’s not crashing.. so at least I got that going for me.

I was getting frustrated, so I was like, “What does BitmapFactory.decodeFile and the options do anyway??” I looked for the JavaDoc.

inJustDecodeBounds

boolean inJustDecodeBounds If set to true, the decoder will return null (no bitmap), but the out… fields will still be set, allowing the caller to query the bitmap without having to allocate the memory for its pixels.

Ah. FML.

What have we learned today? Read the docs, kids.