2010
07.01

Working NumberPicker and Android

For the last few weeks, I’ve been working on and off on a small android project. For number selection, I wanted to use something similar to what’s in the Alarm Clock that ships with most Android phones… a simple control made out of 3 elements, a text field, an “increase” button and a “decrease” button. I was really surprised to see that this is not part of the SDK. After checking on the net, I found this site:

http://www.quietlycoding.com/?p=5

It seemed to work well most of the time, but I had a strange behavior that I thought was coming from my side… After displaying the NumberPicker in a Dialog, I was using an OnClick on some button in this dialog, and sometimes the number I was getting from the picker didn’t correspond to what was on screen. Also, after seeing the application running on my phone, I decided to show it to my fiancée, and her first try at it broke the NumberPicker! If you hold one of the buttons, the picker will loop infinitely increasing or decreasing the value.

There might be other issues but here’s my fix to the two of them:

First, the infinitely increasing value problem, it appears that the code that’s constantly run does not have exit conditions, here’s how I fixed it:


private final Runnable mRunnable = new Runnable() {
	public void run() {
		boolean repost = false;
		if (mIncrement) {
			changeCurrent(mCurrent + 1);
			if(mIncrementButton.isPressed())
			{
				repost = true;
			}
		} else if (mDecrement) {
			changeCurrent(mCurrent - 1);
			if(mDecrementButton.isPressed())
			{
				repost = true;
			}
		}
		if(repost)
		{
			mHandler.postDelayed(this, mSpeed);
		}
	}
};

I simply check if the button is still pressed before reposting the “increase” callback.

As for the value, if the text edit was currently being edited and the value was fetched before it lost focus, it was still returning the old value… the fix is quite simple:


public int getCurrent() {
	validateInput(mText);
	return mCurrent;
}

Here’s the modified NumberPicker.java to be used with QuietlyCoding’s package, feel free to comment if you have any questions!

Thanks

2010
04.08

If you’ve happened to use a lib with debug information, chances are that you’ve tried to step into a function and was greeted with a pop up similar to (I’ve compiled real quick FreeImage, which is an awesome library available here, to have a lib with debug information, then moved the source elsewhere because the pdb contains the original path the source was built from):

If at this point, you press “Cancel”, you’ll be prompted with a pop up saying:

Sure, no problem.

The thing is that once this is done, anytime you’ll try to step into a function coming from the same cpp file you just canceled the look up, you’ll be prompted with the message without being able to select the file.

This is really easy to fix actually.  This setting is stored in the Solution, under the Debug Source Files panel:

Simply removing the file from the “Do not look for these source files” will re enable the file selection dialog.

2010
04.08

A while ago I received the visit of two programmers from a middleware company at work.  They were showing me how to properly use their software, so they had to integrate it in our solution.  The more senior one was typing while the junior was learning from him.  I saw him use something I’ve never seen before so I guess I learned something too!

He used “>” followed by “of” in the search tab, and as he typed, the drop down menu was populated by files matching his filter… hum!  I didn’t know Visual Studio had this built in, I thought you had to use Workspace Whiz or Visual Assist!

Here’s an example:

(screenshot taken using the BWAPI solution)

The prefix > tells Visual Studio to interpret the rest as a command.  The actual Command Window is accessible using Ctrl-Alt-A (default binding) for those who don’t want to use the mouse  to select the “Quick Find” text box.  You can either use an Alias (such as of for Open File) or the actual command (such as File.Open).

Microsoft lists some commands and aliases available here but using >Alias will list all the set aliases.

http://msdn.microsoft.com/en-us/library/c3a0kd3x.aspx

You can create aliases and remove aliases using the alias command:

http://msdn.microsoft.com/en-us/library/xasxzd71.aspx

Given that most people don’t use them at all, it is pretty standard across all PCs, so if you have to work on other people’s PCs, you should be able to use aliases instead of relying on an installed plug in!

2009
12.13

Sunday evening project

Since my fiancee is studying hard for her finals, I decided to spend the evening building my Ice Tube Clock from Ada Fruit Industries.

At first I wanted to take step by step pictures while assembling it, but there’s many steps and they’re all well documented on Limor Fried’s website so I didn’t bother.

Here’s what it looked like after unboxing:

Now what it looked like after unpacking:

And here’s the finished product:

Overall I’m pretty satisfied with it.  I’ve built it while watching Blade and Iron Man, taking a break to eat… so that’s maybe 2h30 to solder it and assemble the case?

As a newbie I found the kit pretty straight forward to assemble.  The final product while being a clock, as promised, feels a bit cheap though.  I’m not sure what I was expecting to be honest.

I’d give it a B+/A-… kind of makes me regret buying it when I see this kit: Bulbdial Clock Kit from Evil Mad Scientist.

2009
12.02

Starcraft AI Competition

I can’t recall how many hours I played StarCraft… it must be in the thousands….

That’s why I was appealed by this new competition:

http://eis.ucsc.edu/StarCraftAICompetition

With my interest for StarCraft and my AI background, I wanted to participate… but knowing how much spare time I have, I decided against it :(   However, I started committing code for the Brood War API (http://code.google.com/p/bwapi/) which is used for the competition and I’m having quite some fun.  Taking small issues and fixing them, I can spend as little time as I want and I don’t have to commit to release an AI in a few months!

If you’re in the Montreal area and would like some help with your bot, feel free to ask, I’d be glad to participate, as long as I don’t have too much to do, cause I don’t have much time to spend on such project!  I have quite a few ideas of neat things to implement, but on my own I simply won’t have time to achieve awesome results.

2009
11.05

Visual Studio Plugins

There’s a new programmer on my team and today I was reviewing his code.  He had this weird scrollbar in Visual Studio which displayed a preview of the code with an highlighted “window” of what was on the screen.

For those who’d be interested in checking it out:

RockScroll

Also, the only other plugin I use is Visual Assist X, you can get it here (not free though, but totally worth it!):

Visual Assist X

2009
10.25

Sidebar Gadgets

I’ve been using the Vista Sidebar on my laptop for a while now, because it has a widescreen and I couldn’t care less about the width of the screen! I’m more interested in the number of lines of code I can cram in one view… so instead of wasting the space with “whitespace”, I decided to actually use the Sidebar to display useful things.  I’ve installed a while ago the pretty good looking All CPU Meter from the folks at Add Gadget and I really liked it, though I was bummed that it didn’t have support for Battery Life and Signal Strength display.  Since I’m using it on a laptop, these are values I’m very interested in.

For a while I searched the net for good Gadgets that could display what I wanted, but they all either had a bad UI or had too much information in them.

Tonight, I decided to take a look at what a “Gadget” is… actually, it’s a simple HMTL app, with CSS and JS files.  It turned out that I could easily set the values for two bars / graphs I wasn’t using (my laptop only has 2 cores) and I hooked them to my battery life and signal strength.  5 minutes later, I had the Gadget I always wanted!

Tadam!

gadget

Thanks to the guys at Add Gadget!

PS.: I won’t be releasing the source code as the original work is copyrighted, but I’ll try to see with them if it could be possible to add the options to the original gadget!

2009
10.21

Presentation

My presentation @Ubisoft Campus is today.  I don’t think I’ll be putting up the slides as they’re in French and pretty incomplete without me talking.  At first I was preparing a big Word document, but that didn’t really fit the format of the presentation so I dropped it for a few slides.  If anyone is interested in having them, feel free to contact me!

Now, it’s time to spend some time designing an entry for the Arduino Contest at Instructables!

Visit Instructables for more info!

2009
09.30

AI – navigation and planning

I’m currently working on a presentation for the Ubisoft Campus in roughly 3 weeks, which explains why my post on “Components” is dragging…

I will most likely post the document and sample code I’ll be writing for the Campus in a new section.  The presentation is how graphs can be used for navigation and planification purposes, using the same algorithms, with different node structures.  Chances are the document will be in French, but I’ll try to translate it if people seem interested!

2009
09.23

FTDI Bitbang Mode

This seems pretty interesting:

http://hackaday.com/2009/09/22/introduction-to-ftdi-bitbang-mode/

It would be rather easy using this technique to have software running on the PC report to a device (leds, LCD, piezo buzzer, etc…) system status and/or notifications!