Thursday, July 14, 2011

Blackberry app for Pace Bus of Chicago - Entry 2

I wasted the whole of yesterday in watching movies, eating and sleeping and so did not work on the app at all. Today I worked some quality time on the app and overhauled the map UI interface.

I had implemented a working prototype of map feature but there were couple of problems. First thing was the Map was drawn directly from the main PaceBus screen. That was a very bad design and I thought it would be simple for now, for development sake and hence went with it. But going through that design I was having trouble bringing the route information into the Map and passing it around the timer and HTTP connection thread to fetch the route's data. So this morning the first thing I worked was to make a Map Launch Screen containing drop down box and a button to launch Map. The drop down had the routes populated from the HTTP route fetch thread.The user is required to select the route from the drop down, click on Goto Map button to open map. This way I had the selected route in the Launch screen and was able to pass it to any module as need arises.
The next problem was to handle the timer. The idea is to have a timer set up which will go off every 15 secs (say) and everytime it triggers, the timer thread would run a fetch thread to obtain the new coordinates from the PaceBus web server and pass it to map to update the locations. The change in UI helped me in this also. Previously I had problem in deciding from where to start the timer and from where to terminate it. Now it was clear that I should start the timer when user clicks on the Goto Map button. So on button click, map is invoked and timer is run.

* @see FieldChangeListener#fieldChanged
* Note: Due to the reason this is only back door, when user changes _kbUseAreaBasedProbability field the threshold will be set to default.
public void fieldChanged( Field field, int context ) {
if(field == _gotoMapButtonField)
//Map button clicked. Get the route number selected
int routeSelectedIndex = _routeNumberChoiceField.getSelectedIndex();
strRouteNo= (String) _routeNumberChoiceField.getChoice(routeSelectedIndex);
if(strRouteNo == null || PaceConstants.SELECT_ROUTE_FROM_LIST.equals(strRouteNo)){
Dialog.inform("Select a route from the list.");
//fetch the bus coordinates for that route
Thread fetchThread = new Thread(){
public void run() {
HTTPDemo.getInstance().fetchPage(PaceConstants.MAP_COORDINATES_PAGE+"?u="+strRouteNo, PaceConstants.EXTRACT_COORDINATES);
//In the meantime, run the spinner
//start a timer to timely fetch bus coordinates
timer = new Timer();
task = new TimerTask()
public void run()
//on timeout, fetch data only if Map application is running
boolean MapRunning = false;
ApplicationDescriptor descriptors[] = ApplicationManager.getApplicationManager().getVisibleApplications();
for(int i=0; i
if(descriptors[i].getName().equals("BlackBerry Maps")|| descriptors[i].getName().equals("Maps")){
Thread fetchThread = new Thread(){
public void run() {
HTTPDemo.getInstance().fetchPage(PaceConstants.MAP_COORDINATES_PAGE+"?u="+strRouteNo, PaceConstants.EXTRACT_COORDINATES);
MapRunning = true;
//cancel timer if Map application is no more running
//after a delay of 5 secs, the timer will timeout every 20 secs
timer.scheduleAtFixedRate(task, 5000, 20000);
PaceBusApp.log("MapLaunchScreen(): Goto Map button event is handled. Timer started.");


The code above describes the action taken when Goto Map button is clicked. It also contains the timer initialization code. Everytime the button is clicked a fresh timer is created. One more modification done was that the timer would fetch coordinates only when there is a Map application currently running. If there is no Map application running, then the timer will cancel itself.
The MapLaunchScreen implements GlobalEventListener so it gets a notification when the coordinate fetch is complete. In the event handler, if the data received from fetch is null that means there are no buses running at this time and this is also the place where we should stop the timer (remember the timer was started the moment Map launch button was clicked) plus we should invoke a default map which doesn't have any location info. Just a generic map. Makes sense.

public void eventOccurred(long guid, int data0, int data1, Object object0,
Object object1) {

if( guid == PaceConstants.GUID_PACE_FETCH_BUS_COORDINATES && data0 == PaceConstants.EXTRACT_COORDINATES)
PaceBusApp.log("PaceBusApp: MapLaunchScreen - eventOccured(): GUID_PACE_FETCH_BUS_COORDINATES");
//if spinner is running, close it
if(this.spinner != null){
this.spinner = null;
//save the object received
if(object0 == null){
Dialog.inform("There are no buses running this time.");
//remove timer
//show default map
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments());
CoordinatesData = (BusCoordinatesDb)object0;
//display the coordinates on map
PaceBusApp.log("PaceBusApp: MapLaunchScreen - exiting eventOccured()");

The code above is the event handler which is invoked everytime the coordinates have been fetched.
handleMap is a simple function which forms the location string from the coordinates obtained and call the Map application with that argument.

public void handleMap(){
//return if we did not receive valid coordinates
if(CoordinatesData == null)
Vector lt = CoordinatesData.getLatitude();
Vector lg = CoordinatesData.getLongitude();
//prepare the location string
stringBuffer = null;
stringBuffer = new StringBuffer("");
for (int i = 0; i
int g = (int) ((Double.parseDouble((String)lg.elementAt(i))) * 100000);
int t = (int) ((Double.parseDouble((String)lt.elementAt(i))) * 100000);
//launch the map application. If Map is already running, the locations will be updated
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments( MapsArguments.ARG_LOCATION_DOCUMENT, stringBuffer.toString()));

The map code idea is borrowed from BlackBerryMapsDemo project under the sample applications. This much should suffice for now. Next time I'll try to fix some UI related bugs in the module developed so far.


Stumble Upon Toolbar

Wednesday, July 13, 2011

Blackberry app for Pace Bus of Chicago - Entry 1

If I had the power to go back in time 4 months from now, this would be that blog entry. Today I realized I should blog about my 4 month old project i.e the Blackberry app I am developing for the Pace Bus transit system of Chicago suburban. The project is still going strong and I am very pleased with the results so far. Since I am late in blogging about it, I'll start it right away. In this blog I'll summarize the work done so far and from now on I will make sure to have one entry at-least every time I am working on the app.

I was in Chicago 4 months ago, doing my internship at Research In Motion when my colleague Anu suggested that we should develop an app as an internal project in RIM. I thought its exciting and will be a good use of my spare time so I agreed instantaneously. Then we decided to sit down every Wednesday for 2 hrs to discuss about it. The first meeting was to decide on the app we would be developing. Necessity is the mother of invention. I suggested to let us make a list of things we do from the moment we get off the bed till we go to bed and see if we can improve on something to make the job easier. To make my point clear, I gave Anu an example. Lets say you wake up in the morning on a typical day and do what, may be brush your teeths, shower, dress up, then reach the bus stop and wait for bus....wait a sec....may be we can develop an app that would let you know whens the bus coming and ...Bingo! We got our-self an app.
The agenda for next Wednesday meeting was 'Research'. We would look around for an existing app that does the same thing more or less. We could not find any, no Android or iPhone or BlackBerry app. There were apps for the Chicago subways but not for Pace Bus, the suburban bus service system. Next is feasibility study. Doing an exercise on sample BB apps and the tools, IDE etc went fine and a successful HelloWorld app was a boost for the confidence. Pace Bus has its own website of course and a little help from their web server combined with our effort could indeed produce an app.
And so we began coding. Design was simple. Ask the user about routes, directions and stop info through drop down menus and fetch the information from their web server using a background thread. The UI design is driven by how the Pace Website UI is. Anu's contribution is invaluable to the project. She is a genius in coding and makes the job so much easier for me to code thereafter. The app was now able to display the next three times at which a bus is expected at the selected stop just like website. On top of that we added 'MyFaves' wherein the user's selected stop info can be saved to be used later without going through selecting the stuff all over again. Then we added 'Rider News' to the app which will display news about any route affected because of construction, re-routing, temporary suspension of service etc.
We wanted to implement the map feature but it was close to my end of term and so we submitted the app to BB App guys for launching. Maps and other knickknacks were postponed for ver2. Then I moved to Florida to finish my last term in the University. Anu remained at RIM.
For reasons beyond significance here, the launch date of AppWorld got postponed to 3 months which is like 5 weeks from now. While in Florida and with launch delay, I got around to fix couple of things in the app. The Logo, for instance, had to be changed. We had used Pace's official logo but afraid of copyright issues, I designed a new logo for the app. Then I started working on the map feature. Anu was busy with company work and I didn't want to distract her so much but she was again very helpful in this. She sent me a list of links she visited when she was researching about the Map thing.

These were really important esp the first one which actually holds the dynamic coordinates of the bus, exactly the thing I was looking for. I have no idea how on Earth was she able to find that link. I tried real hard myself to locate one such link but failed. With these parameters available and borrowing codes from sample BBMaps codes, I made a working map feature, which is now able to display the location of buses in the map and updates them periodically.
This much information is enough for this post. In short, the app is working, with features like dynamically displaying time, MyFaves, Rider News and now Maps (partially done).
Next post onwards I'll discuss the development on a daily basis.


Stumble Upon Toolbar

Monday, March 14, 2011

confessions of a lost mind

Its been 3 days now. I have been sitting in the same place I was put 3 days ago. I should not be bothered about that because my life was like this 4 months ago. My owner lived not 100 steps away from the office so "work from home" became "work from office" and moreover he had a Dell dude to take care of his needs. I used to be left in the corner, forgotten and I never complained. But something happened 4 months ago. My ownership changed hands. I was taken in by a cute little girl since her laptop had broken down. I had doubts at first, I was little scared and fearful. But then I started to like her. She took good care of me, atleast I was in use everyday. Her little fingers running over my keyboard gave me tickles. And she would go to sleep under my watchful eyes. I would be on, the whole night and I would wake her up on gtalk pings. I would be sad when she would leave for work in the morning and like an obedient housewife I would be all ears for her footsteps in the evening. I have never felt more happy than when I would see her enter through that door and she would smile at me. In few seconds I am up and running and boy, is she leading a very complicated life or what! There would be 3-4 word documents open, 2 video files running, tons of websites (mostly shopping sites), gtalk, facebook bla bla. I never complained. This is nothing for me and I was just happy to be able to serve. We were best friends in no time. For sometime I forgot what I am and where I am. The occasional car rides, the smell of delicious dinner, were but for few days untill this "hp" dude showed up at the door one day. My whole world was upside down. I remembered her checking out that dude over internet but I never paid attention. But I accepted my fate. After all I am old now. Hp has got this fancy webcam, stylish keyboard, drop-dead looks. She decided to move on, like everyone else and here I am, back to where it all started. In few days, I'll be returned to the company from where I came and may be I'll be dismembered, disintegrated, thrown away...I don't know, but I'll always cherish my days with the girl.

Stumble Upon Toolbar

Sunday, March 6, 2011

Why do I always end up with morons as roommates

Some people could be so insensitive to others I can never imagine. I wonder if some people are left out of the evolution race.

Its 3 in the morning and I am up. Any normal person would be sleeping now and I would be sleeping now if for any other normal day. But this day isn't like any normal day. This day my bloody dumbass roommate decides to talk to his some bloody friend or family I do not care back in India. And when he is talking over phone he decides not to budge from his bed. Thats good things except that his bed is right next to mine. So he doesn't know when he is speaking, he is not only speaking to the microphone, he is yelling at my ears also. Bloody hell. My sleep is ruined. My day is starting up with I am super irritated and mighty pissed of at my roommate. He is truly a stupid guy. He is from some crappy university, which has 5 words in it and one word happens to be Purdue so he goes on telling everyone "I am from Purdue". Recently he met another proper Purdue university guy and when that guy asked which side of the university you stay, or your department etc and to which yours truly replies "Oh I am from actually so and so university" and the other guy tells him on his face "Dude, thats not Purdue".
One time he goes to the university to sort out his training thing and finish all the paper formalities and guess what he forgets to bring along to the university, his documents folder. The next morning he calls me from the university and tells me to scan his passport, I-20 and other documents. I am like what the hell man!!!! Who goes to a bar and forgets to bring along his Id (Yes, he has done that also).
Sometimes I really believe people cannot be this stupid but every time I look at my roommate and I get my proof. He is such a shame on human evolution. Moreover I am not talking about some guy from the shanties, some uneducated asshole who has not be told about manners etc because those can be stupid but if you are properly educated, had a family when growing up, were told about manners and common sense, and you applied to some US university (no matter how crappy the university is), one can atleast expect some sane thoughts and actions from you. Even after all these you still act dumb, well, you are an asshole and you rightly deserve to be someone's asshole.
At this time I remember one quote from Calvin&Hobbes because it so much suits the situation.

--The most difficult part of being a genius is that you have to put up with millions of morons around you.

Stumble Upon Toolbar

Monday, February 21, 2011

Music....simply music

I have been a big music buff but still lot less than others who are like crazy after it. I am not like many of those music fanatics who put up huge posters of their idol and revere their each voice, neither a fanatic to spend couple thousand bucks to see their idol play it live somewhere.
I am basically a traveler personality when it comes to music. Yes, I am a finder, I am an explorer. I keep looking for good music, the one that speaks to me and listening to which I feel my souls' just been touched by that voice, that music, that lyrics.
I am not aver to listening to rock, metal, or rap etc but I find that country songs are the one that I best relate to.
I am a very very big fan of bollywood music. As much as I hate Hindi movies, I love more their music. Thats the music I have grown up with. During my undergraduate days at Rourkela I came across people listening to western bands like Backstreet Boys, Jennifer Lopez etc and I liked their music also. With time I came across lot of other artists and bands. Linkin Park, Bryan Adams etc. Listening and loving the music is lot different than being lost in music. And the hindi songs are the one that have those effects on me. May be because I am better able to understand Hindi lyrics than English. It usually happens to me that while listening to English songs I couldn't make out some of their lyrics and its when I explicitly look at their lyrics I get to understand what he/she meant to say. This would take away some charm of the music experience for me.
Also when I would love some song, I would like to sing it myself more often, try to get the feel again and again inside me and I would completely fail in that respect with English songs. Its hard to remember their lyrics and add the accent to that. Its totally not the same to listen the same song in Indian accent. Ruined.

Coming to Hindi songs then. As I said I enjoy the experience of listening to hindi songs as if I am a traveler, an explorer. Moving from one song to another and trying to see how that songs speaks to me. Discard the songs that evoke a feeling of irritation, anger, disgust. And there are many of these, with crappy lyrics, mixing English, Arabic and all sorts of language with Hindi, and some songs here the lyrics is so out of rhythm, poetry, flow, some songs where music doesn't do justice to the underlying voice and lyrics and thats why remixes are totally not of my taste. They completely ruin the feeling. Although any music instrument is fine with me, violin and flute are in particular, evoke a strong urge from my inside. They are the instruments that straightaway touch the soul without even trying. So simple, so fine, so strong, speaking thousand vibes.
I am always in the hunto for good music. Thats why when I am listening on grooveshark or Youtube I jump from one to another. Sometimes I would simply discard the song and sometimes I would simply stop on something, stuck ion it forever for it seems, as if I have been to one of the wonders and I am spellbound. Thats when I feel like listening to this song for thousand times and still not feel bored. The beauty is everytime I would hear the song, it would bring out a stronger emotion. After listening to atleast 10-15 times I am like totally immersed in its effect. I feel like I am lost. I feel like I am standing in front of a vista, to which I can simply stare for my lifetime, silence, no words, so peaceful. Yes peaceful. Oly the winds blowing, water rushing through the stream, clouds covering the mountains, foliage everywhere, green, white, blue. Anybody can get lost in front of a view like this. The passion for music blends well with my traveling enthusiasm. I love to travel and I have been to many beautiful places. And I just get lost in those places, totally oblivious of the fact how much time has passed since I have been watching this view. And whenever I listen to some of my favorite songs, I could close my eyes and all those memories would come crashing in front my vision. I relive those moments all over again, and again and again and everytime I feel more and more connected, more and more close to reality, as if I can touch the snow, feel the cold wind, hear the water drops, see those mountain peaks, breathe that air.
My songs speak to me. They know what I am going through and like a faithful lover, a caressing mother, a responsible elder brother, an understanding friend they embrace me in their arms. I feel lost, lost of all thoughts, lost of worries, lost of happiness and sadness, lost of family and friends, lost of the world, lost of luxury, lost of religion, money, work, lost of myself. Sometimes I would virtually feel my soul coming out of my body, as if the music punched a hole in my chest and took out my soul. Thats the power of music I am talkig about. If a find a music that speaks to me, when listening to it, it feels like I am connected like the pieces of a jigsaw puzzle, yes, exactly like that, as if there are rows of pieces and I would just go and my body would connect with every single incomplete piece. I feel complete. The music feels complete. My body would shake automatically with every beat of that song, my lips would speak out the words with the artist, my skin hair will rise in appreciation, goosebumps all over the body, feets and head in sync with the beats.
I cannot imagine without music. They bring out so much emotions out of me that I cannot express. The lyrics make me go crazy, literally speechless. I cannot admire enough, the lyricist, the musician to be able to do justice to that, the voice blowing life into it and whoa, you got a mysterious mistress. Music is like beauty. The speechless power it contains, you would never be able to appreciate until you feel something inside thats just inexplicable.
Its incredible how much energy each song contains yet how much calmness they infuse in you. There is no better alternative when you want to remember someone, relive some moments of the past, or just to forget everything around you, than to listen to your favorite music, earphones, loud volume, laid back in the couch or bed, eyes closed. Darkness. Total darkness. Stop. Feel.


Stumble Upon Toolbar