Outreachy Week #8

So, hey, there was actually a fairly simple solution to last week’s problem that I couldn’t see, as I was unaware of how anonymous inner classes worked in Java. Thank goodness for mentors who nudge you in the right direction!

The code in CategorizationFragment.java that was released in v1.8 of the app:


    private void requestSearchResults() {

        final CountDownLatch latch = new CountDownLatch(1);

        prefixUpdaterSub = new PrefixUpdater(this) {
            @Override
            protected ArrayList<String> doInBackground(Void... voids) {
                ArrayList<String> result = new ArrayList<String>();
                try {
                    result = super.doInBackground();
                    latch.await();
                }
                catch (InterruptedException e) {
                    Log.w(TAG, e);
                    //Thread.currentThread().interrupt();
                }
                return result;
            }

            @Override
            protected void onPostExecute(ArrayList<String> result) {
                super.onPostExecute(result);

                results.addAll(result);
                Log.d(TAG, "Prefix result: " + result);

                String filter = categoriesFilter.getText().toString();
                ArrayList<String> resultsList = new ArrayList<String>(results);
                categoriesCache.put(filter, resultsList);
                Log.d(TAG, "Final results List: " + resultsList);

                categoriesAdapter.notifyDataSetChanged();
                setCatsAfterAsync(resultsList, filter);
            }
        };

        methodAUpdaterSub = new MethodAUpdater(this) {
            @Override
            protected void onPostExecute(ArrayList<String> result) {
                results.clear();
                super.onPostExecute(result);

                results.addAll(result);
                Log.d(TAG, "Method A result: " + result);
                categoriesAdapter.notifyDataSetChanged();

                latch.countDown();
            }
        };
        Utils.executeAsyncTask(prefixUpdaterSub);
        Utils.executeAsyncTask(methodAUpdaterSub);
    }

Basically, I could separate most of the preexisting AsyncTask code into the MethodAUpdater.java and PrefixUpdater.java classes (that extend AsyncTask), and then override the methods that I need via anonymous inner classes. This allows me to add the results of the API queries to the ‘results’ member variable of the outer class, in order to aggregate the results in a LinkedHashSet before displaying them to the user.

I’ve released v1.8 to Google Play, here’s to hoping the flexible category suggestions work better for users! 🙂

Outreachy Week #8

Outreachy Week #7

Made it through Phase 1 and the mid-term evaluation! 🙂 We’re deep into Phase 2 now, which involves improving the as-you-type category search. The existing codebase uses a prefix search for these category suggestions, which means that if you don’t know exactly what your category name starts with, you won’t get any pertinent suggestions. E.g. searching for ‘latte’ when you really mean ‘iced latte’ will not get you anywhere.

With the API query that we plan to use, you absolutely will get ‘iced latte’ – as the second category suggested, in fact. 🙂 The aim is for us to run that query (dubbed Method A) in parallel alongside the existing prefix search, and display the Method A results above the prefix results.

This is easily the most complicated code I’ve worked on so far, I think, since it ties heavily into the existing structure of the as-you-type queries. Phase 1 did involve writing many lines of code, but my feature could be added in a more modular (that’s the right word I think?) fashion, without really needing to alter the existing code much. Phase 2 is quite different from Phase 1 in this regard.

Will update soon!

Outreachy Week #7

Outreachy Week #6

Our first big release is out! 😀 Version 1.6, which ACTUALLY displays nearby categories when a user uploads a photo, hit the app store this week. Ohohoho. *happy dance*

On a rather more serious note, I realized that launching a major update is not anywhere near as simple as I thought it would be. The first release last week (v1.5) was supposed to work, but in actual fact worked for almost nobody (which is why I didn’t count it). Because I stupidly hadn’t tested the app on my real device, assuming that it would work the same as on the emulator. But it did not – my URI to filepath converter was not robust enough to handle a wide variety of picture storage locations (local, external, sd card, etc) and did not account for changes in KitKat that mandated a different method. Fortunately, with the help of the aFileChooser open source library, we managed to get it working.

Today, thanks to a crash report uploaded by a Marshmallow user, I found out that the permissions system had changed in API 23 and runtime permissions are now required. Which means that we need to fix this ASAP, otherwise nobody on Marshmallow can upload anything. Ooof. (Edit: Fixed it! v1.7 released, hopefully that’ll sort it out…)

Still, I’m psyched to be reaching the end of Phase 1, and we’ll be moving on to Phase 2 (more flexible category suggestions) as soon as we can, while awaiting more feedback.

 

Outreachy Week #6

Outreachy Week #5

This week was a good one. 🙂 We found out that the MediaWiki API actually returns the n closest results when geosearch is used, so there is no need for the successive calls to the API that we’d planned – we just need to specify a large radius and the API will do the rest. Simplifies things greatly.

I also managed to get the caching of area -> categories done, using the varunpant/QuadTree library that my mentor suggested. Going to promote this library a little – it’s pretty awesome, even though there don’t appear to be many people using it. Lightweight and does what we need it to do, AND the code is very well documented! The latter is such a rarity in obscure GitHub projects that I heaved a huge sigh of relief when I saw this one. Made it so much easier to learn to use it. There was an issue with the lack of namespace when we were trying to create a JAR and import it, but that aside I loved this library.

Also pushed version 1.5 to Google Play – yay! Download it and let me know what you think, guys. Every additional install is an encouragement. 🙂 Edit: Whoops, don’t do that yet. Have an issue with app running on my real device… 😦

And….

I was raving about the joys of working remotely in my last post, but I also realized recently that it’s a double-edged sword for me. There isn’t really any predetermined ‘off’ time, and initially I didn’t enforce one. I kept pushing myself to do ‘just a little more’ every day, working more than 5 days every week, dealing with an email or post as soon as I saw it. To be clear this was entirely my own fault/issue, as neither my mentors nor org admins have ever complained about me ‘not responding quickly enough’ or ‘not doing enough work’. I just felt compelled to, and wasn’t allowing myself any proper downtime each day or week, except for the vacation I took for traveling early last week.

The net result is, I came close to burning out near the start of this week. I felt overwhelmed and exhausted and like I just couldn’t be arsed anymore. But then I realized it was my own doing – of course I’m burned out when I’m not allocating any proper time for relaxation. In fact the lack of downtime was probably making me less productive in the long run.

So what I’ve been trying to do is to enforce a downtime. I’ll work hard for 40 hours a week (not necessarily 9-5, I’ve never liked 9-5, but 40 cumulative hours), and the rest of the time I’m going to just allow myself to plug off and do something else. Hopefully that works out!

Outreachy Week #5

Outreachy Week #4

Oof, what a tumultuous week! During the last week, I:

  1. Released a Google Play update for the app with GPS category suggestions displayed – yay!
  2. Prepared for what I thought was the next task (caching) and found out after a conversation with my mentor that getting the area and categories cached would be a rather more complicated task than expected, requiring the use of a third party library
  3. Also found out that I needed to get the recursive calls to the API with widening search radius done before doing #2
  4. Went on a short trip to the city for NYE – yay, pretty fireworks!
  5. Came back and tried to get the recursive calls working.
  6. Encountered a whole litany of problems and eventually needed to refactor the entire thing.
  7. Still trying to squish a bug. I’ll feel really silly when it (probably) turns out to be a small and simple thing that I missed.

I guess ups and downs are a pretty normal thing to face as a developer. Sometimes you breeze through a task that you thought would take much longer, and sometimes something that you thought would be easy ends up causing you no end of headaches. Sometimes everything goes smoothly, and sometimes plans change and you have to adapt.

On the bright side, I’ve found that I REALLY enjoy working remotely. Really, really, really do. It reminds me of how different we all are, when I read blog posts by folks who realize that working remotely isn’t for them. To me, it’s the bees’ knees! I have the freedom to work whenever I feel most productive instead of needing to pigeonhole myself into a 9-5 schedule, I can get to work with a 10 metre “commute”, I can work in PJs, get up and take a walk around the neighbourhood whenever I want to, do grocery shopping during off-peak times… I could go on, but you get the point :). The biggest complaint I’ve heard about working remotely is the loneliness, but honestly I haven’t really felt that way. Communication with mentors and other Wikimedians(?) via IRC and Hangouts is fine, and there’s family, partner, and friends for the rest of the day. I guess being strongly introverted ‘helps’ in that regard.

Onwards to Week #5, hopefully I manage to squish that pesky bug!

 

(I also realize I should probably change this blog’s theme since Christmas is well over, heh. I’ll get to it…)

 

Outreachy Week #4