Android – Recycler View Sample

There are quite a few samples of the new Recycler list component kicking around on the net. The problem is most of them are a bit too simple. Anyway, I have written a nice example which has most of the features you might want.


The code is up on github here.


LibGDX: Demos on Github

I have made a start on fully Mavenizing my LibGDX demos and placed them up on Github.

The good news is that the core netthreads-libgdx library and the demos have been converted to use the latest version of LibGDX (0.9.9 at the time of writing). Taking the latest build from the LibGDX repo should mean that it will be easier to keep these up to date with changes to Scene2d etc.

I used the LibGDX archetype so you should have no problems building these once you have jumped through a few (minor I hope) hoops to install some dependencies on non-maven-available jar files like the tween-engine and fixtureatlas. There are detailed instructions. If you are having problems make a comment/email me or raise an issue on the issues list.

The core library is here. You will need this for the demos.

The demos up so far are:

Simple Shooter

This is the same simple shmup as before but with a lot of code tidied up. It is here.


Simple Shooter


Simple Shooter


A straightforward Box2d demo with a central rotating fixture, falling objects and nice fading labels. It is here.



Bumper walls, anti-gravity, tumbling blocks and flashing psychedelics..what’s not to like? Shows how to detect collisions between box2d elements and how to handle them.


Putting these all the once place I have discovered a ton of bugs which I have had a chance to go through and fix. Later demos fixed stuff which I never went back and applied to the earlier ones like SimpleShooter so this has been a great exercise. It’s even given me a bit of a kick to write some more.

NOTE: All the LibGDX demos linked on this blog go to GitHub now. It is easier to manage them all in the one place. The new demos have a bunch of new concepts in them like the removal of the old Singleton patterns with Google Guice managing this stuff instead. Also it’s Maven from here on. If you are familiar with the old code and build mechanism then you’ll just have to come along for the ride. I promise you’ll learn stuff that will benefit you.

Java OSC: Midi Definitions

I thought I would put up an example of my OSC java library sending messages to the pure data instance but I discovered a problem. If you send lots of OSC messages to pure data without a decent interval pure data crashes. Not good. So I have reluctantly started what I didn’t want to do which is to write my own decoder. I imagine this to be a bit like Osculator. Believe me this is pain in the backside as I know nothing about java GUI. I saw a funny comment recently which stated that Swing is ‘distilled mediocrity’ which is just about sums up my feelings about it.

Don’t get me started on oscVstBridge which I couldn’t get to work despite downloading the core java VST client and a major amount of faffing about.

Here is some definitions which I had to hunt down and build myself as I couldn’t find any code which would suffice. Each note in NOTE_NAMES has a corresponding value in NOTE_VALUES.

	 * All MIDI note names.
	public static final String[] NOTE_NAMES =
	        "C-1", "C#-1", "D-1", "D#-1", "E-1 ", "F-1 ", "F#-1", "G-1 ", "G#-1", "A-1 ", "A#-1", "B-1 ", "C0", "C#0", "D0", "D#0", "E0", "F0", "F#0", "G0", "B8", "G#0", "A0", "A#0", "B0", "C1", "C#1", "D1", "D#1", "E1", "F1", "F#1", "G1", "G#1", "A1", "A#1", "B1", "C2", "C#2", "D2", "D#2", "E2", "F2", "F#2", "G2", "G#2", "A2", "A#2", "B2", "C3", "C#3", "D3", "D#3", "E3", "F3", "F#3", "G3", "G#3", "A3", "A#3", "B3", "C4", "C#4", "D4", "D#4", "E4", "F4", "F#4", "G4", "G#4", "A4", "A#4", "B4", "C5", "C#5",
	        "D5", "D#5", "E5", "F5", "F#5", "G5", "G#5", "A5", "A#5", "B5", "C6", "C#6", "D6", "D#6", "E6", "F6", "F#6", "G6", "G#6", "A6", "A#6", "B6", "C7", "C#7", "D7", "D#7", "E7", "F7", "F#7", "G7", "G#7", "A7", "A#7", "B7", "C8", "C#89", "D8", "D#8", "E8", "F8", "F#8", "G8", "G#8", "A8", "A#8", "C9", "C#91", "D9", "D#9", "E9", "F9", "F#9", "G9"
	 * All MIDI note values.
	public static final int[] NOTE_VALUES =
	        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 120, 121,
	        122, 123, 124, 125, 126, 127

This is all the MIDI note definitions and corresponding values in some handy Java. I was using this to send each note in turn as a test. Feel free to convert this to your language of choice. You can’t stick a license on a list of numbers or can you.

General: This site is moving

The long and short of it.

WebOS: No Debugger Under Eclipse

Palm Pre developers can spin this any way they want but it’s currently not possible to set breakpoints using Eclipse, break on a line, inspect the variables or anything else debug-wise from within the IDE. It seems you have to use a command-line debugger.

I know it’s not like it’s _impossible_ to use but are we really expected to enter the full path to a line in the code to set a break point e.g.


I’m not sure what to say about this? My expectations were somewhat higher.

WebOS: newsReader SDK Sample

I have been playing around with the Palm Pre WebOS SDK. Compared to my efforts to get J2ME stuff to work (ages ago) I have to commend both Android and now Palm in making these phone SDK’s so easy to get up and running. For both Android and Palm it’s a painless task from download to seeing applications running on the bundled emulator.

Although tempting it’s too early to make a comparison between WebOS and Android as I have yet to embark on writing anything for it.

Anyway, the SDK comes with a number of samples one which is a pretty full featured RSS reader. There is a problem though. The project can be imported into Eclipse (after installing the appropriate plugin) but does not appear as a Mojo project. The reason for this is that the ‘nature’ in the project file is set to what appears to be the old name for the SDK. In order to get this to work properly in Eclipse you will have to edit the project file.

< ?xml version="1.0" encoding="UTF-8"?>

The secret is to change the content of the ‘natures’ value to the one above. Now when you import the project into Eclipse it will appear as a proper Mojo app.

The news reader is a great demo as it has a little bit of everything you will be required to know to put together an app which talks to the internet. Interesting features:

Plus lots of other stuff under the hood which I don’t understand yet.

Android: gTraffic UK

I recently got an email from Google stating that the UK market for apps has opened. I figured that there might be some UK traffic applications and I was right. My application isn’t ready quite yet. I reckon by Sunday night I will be able to publish it. I am kind-of on target. The map element isn’t very good yet but I am working on it.

You will see I have added a timeline element to the list view. The duration is displayed with a red line to indicate _now_. I might change this to ‘time left’ but I am not sure how to make that obvious. The Timebar (as I call it) is a custom control. I put this together with help from the developer group and Retio Meier’s excellent book on Android programming.

Here is the loading screen for Strathclyde. The whole of the UK is available through the BBC feed which as far as I know is a mix of Highways Agency and TrafficLink so it’s really the best source you can get.


The main list view with timeline element.


I have redone the icons using InkScape so that they are a ‘bit’ better. Not much since I am no graphic artist. I am really starting to get into InkScape though. An amazing application especially for icons and stuff if you’ve got the patience.

I think this is going to be a free application. That was how I had visualised it. The BBC data comes with some heavy duty conditions which the iPhone developer of a similar application got around (I presume) by making people add the xml feed URL themselves. I am undecided. I feel that using the data in that way was a but underhand. I believe in free data for this stuff.

Android: Traffic UK Map

Here is the map view. I just got this working so I am pretty chuffed. I calculate the bounds for each region when I load the data. These value are stored in the database against the region name and then when the map is created it sets itself to the bounds of the displayed data.


That’s all the main views in now so I need to go back through the whole thing and tidy up a few funnies.

I reckon there is a weeks work left and this will be publishable.

General: Progress

I was hoping to get the Android weather app ‘simple weather’ into some sort of semblance of working order before the end of the year but it doesn’t look likely now. I ran up against a problem which showed itself when the phone orientation was flipped repeatedly. Basically my worker thread was holding onto the SQLLite cursor somehow so that when the view adapter went to requery it there was an issue getting hold of it (at least I think that what was causing it).

This problem got me started on examining the class which is bundled into some of the examples at apps-for-android. This is an interesting class and is worth some study. Basically it lets you spawn a background thread to perform some task which will take some initial parameters and return a stated type.

I wasn’t happy with my understanding of what was going on inside this so I set out to write an Android version of the CommandProcessor design pattern.

I think I have it working and what I think I’ll do is forget about the weather application just now and try and write a demo app which will show off what I have discovered when dissecting

gwt-jsviz #2

The 0.0.1 gwt-jsviz codebase has been moved into the ‘tags’ svn directory. You can still access it under tags.01.

This has been done to make way for the 0.0.2 version code which is now in the main source trunk. The has the JSViz widget converted to a panel and the demos have been updated accordingly.

There is a rudimentary tabbed demo in the source tree which will crash your browser if you are using Firefox so avoid that for now.

Next Page →