Tag Archives: eventqueue

Fight with threads (I won)

4 May

Today I made some major improvements on Twitthere. In short, I completed the OAuth authorisation cycle including serializing the user credentials and token data to a local file. This may seem simple but it is hard to get it right and to keep it that way. I must confess, I haven’t caught all exceptions sufficiently but I was so happy it all worked I’m taking the rest of the evening off 😉 Those exceptions will stay there and wait for me to solve them.

Anyway, it took me a lot of puzzling to get it all right. I’ve been working non-stop from 2 o’clock today until now (half past 10 in the evening) to get it to work. The thing that bugged me most was the loading screen I came up with to keep the user attracted to the program. The API calls to get tokens and swap the request token for an access token take some time, and the GUI would freeze while doing that. Everyone knows that’s a pain in the ass for the user, who has to stare at a frozen GUI for a couple of seconds. So, I threaded the API calls to keep the GUI interactive during the requests and at first it wouldn’t work. Finally, after some thorough puzzling and a lot of trial-and-error, it worked. The loading screen now shows a small animation with ticking dots (like ‘Loading…’, and the amount of dots changes) and it has an animated GIF showing a ‘loading’ animation. You can’t imagine how glad I was I came to the last panel, the ConfirmPanel, which shows that the user can finally start using Twitthere (so weird to put so much effort in the code to just let the user open their profile). For a small development peek, to see how and in what IDE I work, check the images below.

Of course I also updated the javadoc, so have a look at my new panels!

— Léon