Latest updates

Yesterday I wrote about a problem I had in figuring out how to add images to the app in a certain way.

Today I found the solution. My attempt yesterday was to put the images in the drawable folder, I needed to get bitmaps of these images in order to copy them to a new folder. This took about 10 seconds. Today I’ve put the images in the assets folder, and now I can use a different method to copy the files to a local folder.

This link helped me out:

Yay, problem solved. So now I thought I would do some extra tests and put the app live.

Emulate Nexus 10

I have a Nexus 7, and it makes sense to test the app on a bigger tablet. So I use the emulator for that. The emulator crashed a couple of times, but once I figured out I needed to restrict the amount of RAM the emulator could use I was good to go.

So I open the app, click on my book, and I get my first crash. The error points to a place that I was afraid it would. First I need to explain something that the Android team forgot to build.

The goal: Add a button above a grid of book covers. If the user scrolls the grid, the button must scroll with it out of screen. Once the user clicks a cover, it must open the correct book. If the user does a long press, the user can select view/edit/delete book. 

Grid, button on topIf I would like to do this for a list. The code would be quite simple. With the key piece of code looking like this:<em><span class="pln"> MyLayoutView.</span><span class="pln">addHeaderView</span><span class="pun">(</span><span class="pln">header</span></em><span class="pun"><em>)</em>.</span>

For a grid, there is no ‘addHeaderView’ method. The people at Google must have found this annoying when they created their Google Photos app back in 2013, so they made some custom code to fix the problem for their own app. Then they shared this piece of code, as you can read in this stack overflow post.

There also is a popular library shared by Etsy. But it doesn’t include the long press functionality.

First a little rant: I can’t get my head around that there where developers at Google working on their photos app and noticed that a piece of basic android code was missing for the gridview and then only fixed it for themselves. By only sharing the code, without documentation, it becomes clear that they don’t care that beginning developers might find a subclassed gridview implementation an extra hurdle to take.

Besides that it’s stupid that it’s not part of core Android to add an header to a gridview, the solution created by Google appears to be broken. When I click a cover, it refers to the wrong book. After some testing, it became clear that the number of columns was effecting what ID I was sending when I clicked a cover. Part of the ‘fun’ of having to implement the a subclassed gridview, is that the counting of columns methods was no longer working. I needed the number of columns to be able to get the correct ID to refer to the correct book.

I ended up with measuring the width of the screen, and using the width of the column to count the number of columns by hand. Not super elegant, but it works. Or, as I should say now, it worked.

Apparently something is different in Nexus 10, so it doesn’t work anymore.

Here are my options:

** This would probably work, but it’s not clear to me yet how I would deal with different screen sizes (landscape / portrait). It’s probably quite some work for me. * Try to find a different library that can add a header

I might try this, but I don&#8217;t expect to find something that is tested on a lot of devices and use cases.

** I know it works on this device, because I have one. The upside is that I get to launch the app and will be able to get feedback on it. I can then update the app and include more devices later on.**

** * Do more testing on the emulator to try to better understand what is going on for the Nexus 10

I&#8217;m trying to do this, but my computer is having major problems with running the emulator, my browser and Android Studio. It works, but it takes me about 10 minutes to see an update to the app and being able to test it. Also Android Studio is becoming slower and slower. To make it more fun, logcat (the way you get feedback on crashes) is no longer filtering for my app, so I need scroll through a whole bunch of not relevant logs to find out what&#8217;s going on.

So why am I sharing all this?

  1. I want to give a full picture of what it takes to create these apps. I wrote about the concept, the UX, the analytics, marketing, graphics, but I haven’t written a lot about the coding part yet.
  2. I’m hoping that in writing down what my problem is, it will become clearer to myself how to find a solution.
  3. I’m a bit frustrated and felt the need for a little ranting. I’m so close to launching the app..

Yep, now it’s time to go to sleep.

Update 19 nov

I fixed it, at least for the Nexus 7 and the emulator for Nexus 10. The next day I had a computer restart, and with a more responsive computer I was able to do some testing on the emulator. My ‘counting by hand’ of the columns was not working correctly because I was taking a too small measurement of the column.

All updates