Hahaha well thought it was over hey, well guess what the next step also caused more errors.
So this started with trying to get the ID from the database of the item that the user clicked on the list. Now i thought this would be simple, get the item clicked, its position and then get its ID. Well that was silly, the ID was the ID which represented where it was in the list. What a doughnut, ey? Well I soon learnt and grabbed it from actual array list that was holding its details and then by using the position on the list, I grab the ID that belongs to the selected item. Not that tricky but soon learnt.
Next issue was the filtering down of the bars shown on the map after the user had chosen a town, this I thought was easy, save the chosen location ID and compare it to all the LocationID’s that the bars belong to and then only show them. However this became a bit of an issue because without realizing it I was comparing it to the bars actual ID and not the LocationID in which it was associated to, simple mistake but one that was quickly fixed.
Next step was filtering down the list when a user types in the searchview so that its easier for them to find, which came with it’s own set off problems, main one being that ultimate question of of the hell do I do that? Well he’s a good (but long winded) answer. First my initial problem was that in other parts of the code I has made a “searchItem” variable of the MenuItem class which works well for the ‘setOnActionExpandListener’ which is needed for expanding and closing the search widget in the action bar. So with this in mid I searched through all the different features that the MenuItem class could do in hope to do some kind of filter. That didn’t work and then I searched gogle for it and amongst a few searches I realized that the issue was the MenuItem is generic and isn’t just for the search widget (yes I should have guessed from the start…but…well I didn’t and I soon did). Therefore to fix this I create a new variable called ‘searchView’ of (you guessed it) the SearchView kind and found the ‘setOnQueryTextListener’ and my day was saved. By then filtering the adapter to the text in the searchview I got it fully working.
The issue I have found now though is that when I refresh the map with the chosen location it still loads where the user is and they have to zoom out to find the city and bars aware abouts. Therefore my next plan is to do a check on whether this load is with no location chosen or with and if there isn’t one I’ll load it normally, however if there is, then I’ll load it in the area requested.
This can wait til next time however as I feel a nice little break is required 😛