Showing posts with label android iphone sqlite table view. Show all posts
Showing posts with label android iphone sqlite table view. Show all posts

Thursday, March 7, 2013

What I installed on my Mac at new job

Boy it has been a long and winding road to get the new MacBook Pro into a useful state. I realize Macs are meant to be super easy to use but that gets in the way of power users.

I have learned a lot of new terminal commands, where files reside on a Mac, naming conventions when reading Mac web pages and what not. I will try to share what I can before I forget it all and move on to the next thing.

I wanted to see hidden files. Executing this in terminal allows for that:

defaults write com.apple.finder AppleShowAllFiles TRUE

Change the TRUE to a FALSE to reverse the change.

~/ means your home directory when you are on a web site.

See the first five lines of the clipboard

pbpaste | head -n 5

Terminal is OK but I wanted a tabbed support as I use Console 2 on the PC. I installed iTerm to handle that situation. I also like a semi-transparent background on the terminal as I am generally monitoring things behind it too.

Finder is really not my cup of tea but I was able to get around most of my issues using xtraFinder. While this program is still in beta it fixes the major issues I have with Finder and it is free.

1) Tabs to open multiple directories instead of having multiple windows open on screen
2) Grouping folders first then files. Never understood why Finder does not have this option. Most of the time I am looking for a folder first then a file within second, I don't want to scroll way the heck down to find my Folder. I know I can sort by Kind to get them in group but that still puts them randomly somewhere grouped in a list.

I copied in my music files from a USB key from my Windows box. There was a stupid desktop.ini file left in each album directory. I wanted to delete all of them which on Windows is:

del desktop.ini /s

For the Mac I needed:

find . -name 'desktop.ini' -print -exec rm -fr {} \;

I realize this is a more powerful command but this is a simple thing I need to do a lot and what I had to type to make it happen was not straight forward. I will have that command in my pocket from now on though.

I had to tweak my security settings to allow me to install things not from the Mac Store. Good to stop a normal user from doing this and it was a one time change to make me happy.

Mac Ports seems to be the way to go to install 3rd party products. You need to know the name of what you are installing. You get to type your password a lot as you are using SUDO commands left and right to accomplish this. It works and the web sites are really good at listing the port name you need to use for the install.

Just found you need to do this after installing Xcode and the Xcode command line tools:

sudo xcodebuild -license

If you don't then you will get errors when attempting to install programs.

The company uses VMware Fusion so I had a license. I was able to quickly install Win 7 professional from DVD. Some of the production apps are written in C# thus the need for a VM to run them.

iTunes does not support common audio file formats so I used Adapter to convert music to MP3 so I can listen to it on my Sennheiser wireless headphones. I have had them for a couple of years now and still on first set of rechargeable batteries. While not perfect, an occasional hiccup due to interference, they have served me well.

At the prodding of the other developer who started on the same day as I did I installed Evernote. Nice app to type in random thoughts and to do lists as they hit my brain. I can see all that stuff on my Note II which makes it very easy to remember the crazy list of items I still need to bring in. 

I use Sublime 2 as my text editor. I like it that I have the same editor on my PC at home as on the Mac. Some of the keystrokes are a bit different but I am getting used to that too.

All the other set up was configuring SQL settings, other environment variables, VPN, tweaks to various programs so they operate to my liking and doing web research on my first project and on tools they use here that I am not deeply familiar with yet.

I also need to find out coding style. Seems to be opposite of the last job no matter where I go. I am used to braces on same line but it appears that they are on separate line here. No big deal to me, configure Eclipse to do it that way and get on with life. 

Do wish I had a docking station for the MacBook, unplugging everything to take it home for the night is a bit silly. Was so easy to undock the Lenovo laptop at old job and put it in bag with extra power supply. Not enough USB ports and they seem to trickle charge my phone. I have the external keyboard in one port and my phone in the other leaving zero for anything else.

Friday, July 29, 2011

Android vs iPhone - SQLite and Table Views

I am still in the process of converting my iPhone project to Android. Main goal is to allow doctors to create cases out in the field and submit them to the back office for case workers to finish up and send off to insurance companies to get paid. All the rest of the software is written in Java and Ruby and has been operational for a number of years.

There are currently 24 of tables involved in the process with some containing over 17,000 records. I am storing as much of the data on the device as possible but some of it needs to be requested per login session as it can change on the back end - facilities, referring physicians, providers, etc.

The basics of getting the table data in XML format, converting it via SAX parsing to table rows and executing inserts to populate the tables is very similar between the platforms. Where the fun begins is displaying the data to the user.

The iPhone has a standard Table View but it is up to you to do all the work. You have to build out the rows, you have to get them displayed, you have to deal with rows that have different amounts of data. You have to convert clicks back into rows of your table. It appears one developer did the SQLite side and another did the Table View side but neither talked to each other. Doing all the work yourself is not fun. I have hundreds of lines of code to handle what I am doing trying to be generic as possible. Even showing a simple string when you have an empty table is a pain. Finally you have the fun of performing the SQL queries in a simulated background thread. You are responsible for disabling the UI, showing the busy spinner, positioning the busy spinner and if you feel really adventurous showing some status text.

Moving over to the Android has been a pleasure. Sure, I have the whole database schema in place giving me a big head start but that is not what is making it so easy. The Android team decided to do a lot of the hard work for me and provided a SimpleCursorAdapter. I can query the table, get a cursor back and pass it to this adapter and my table automatically populates. In a ton less code I actually have better functionality. The rows automatically size to the strings I provide. If my cursor has no rows a simple addition to the XML file shows the "No matches found" message. Background activities automatically take care of disabling the UI and I get to show status strings with ease.

Things are falling into place so quickly on the Android side I am able to add extra features as I go. This equals some pain as I will get to back port those to the iPhone before shipping.

This is not the only area where I have found Android to have a more complete API. I can quickly create two views, one for landscape, one for portrait and have them appear without any special code. Doing that on the iPhone is a major hassle. You can either shuffle the controls around in code, which is what I have done, or you can attempt to have to XIB files and do double control hookups which seems like a massive waste.

The code base I am generating on the Android side is massively smaller than on the iPhone. Pretty much anything I do takes less lines and much shorter lines of code to accomplish. Objective C is not a terse language. The less I have to type the faster I can get code done even with auto-complete available on both platforms. I also don't mind refactoring code in Eclipse where it is s crap shoot in Xcode. If I have to do anything massive I do it in AppCode which helps a lot. Not having two files for every class is also nice, cuts the size of the code tree in half.

It is going to be interesting to see what the doctors think. Many have iPhones but are thinking of getting Android tablets to do their case work. Why an Android tablet? Because you can get it in a 7" form factor and that size fits in a lab coat pocket where the 10" iPad does not. My job is to be cross platform and as feature equal as possible. This gives them a wide variety of device choice between iOS and Android.

Beta testing will be straight forward on the Android. I can send them the file and have them install it or they can stop by my cube, plug in the device to my USB cable and I can copy it right over after I kick the device into debug mode. iPhone, well buddy you better tell Apple about the device, wait for it to get provisioned, build the code with the provision in place then copy it on to the device. If you want them to install it they have to play funky monkey with iTunes. Can't go over a 100 device limit either without buying a second license.

The other area of fun will be release time. The initial version of the app just handled appointments and not completing the case. I was able to release the Android Market in 10 minutes. It took a full week for Apple to approve my app and have it hit the iPhone App Store. If I want to fix a bug on the Android I fix it and release it on my own. I have to restart the process on the iPhone side. With the current, very simple app, out there I have not had to do a bug release. The new version is much more complicated which increase the odds of nasty bugs.

If we update our back end we can easily sync that with an Android release. With the iPhone we are in the total dark even if I am really sure I have not used anything in the code that Apple with frown upon. It could take weeks to get something accepted. Can't even do a proper marketing campaign when you can't give a real release date. Apple is not really enterprise friendly and they are not really all that developer friendly either.

I am pretty happy with what I have been able to pull off on the iPhone. It looks good and according to QA is working nicely.  I am very interested to see how the Android side turns out. So far it is matching the iPhone punch for punch and coming out better in a number of areas. Any time I have less code to write I know I will have less bugs and thus happier customers.