We are a GIS platform-as-a-service company, connecting people, their location, their need at a particular time. We believe in developing rock solid, highly performing, scalable and stable platform for our customers.

There are 2 challenges here,
1) Fitting them so they look all made to fit
2) Using less memory as we do bitmap stuff

Bitmaps can bring challenges when you need to work with them across screens. Keeping the code neat and clear is also very important, for this you want to keep the layouts and fitting stuff in the xml, and the bitmap resizing, fitting, reading and memory handling in the code. Less code is good right ?

So I use a GridView and a layout to define the cell contents.

GridView will use attributes numColumns, gravity (once they fit, play with padding, margins, horizontalspacing and verticalspacing).

For the cell contents I use RelativeLayout (height = 0, weight = 1). ImageView within it uses scaleType=fitXY (play with the others once you have them all fitting) and layout_centerInParent.

In your getView of your GridAdapter, you need to set the width of your image at runtime. For this you need to get the screen width, and set the width of your image.

Self Advertisement
—–Start of Advertisement——-
BUILD CAR POOL SOLUTIONS ON ANY DEVICE TO RUN ANYWHERE (www.mcruiseon.com). Introducing mCruiseOn, the java library /json api’s that you can use to build a car pool solution. Be the next avego.com, carpooling.com, zimride.com. mCruiseOn is your one stop API on EC2.
——End of Advertisement——-

I just enabled log4j, and stopped printing stacktrace on exceptions. So the errors I started to get were very cryptic. Printing stacktrace is important even after you have log4j consuming the exception object.
Once I uncommented e.printStackTrace(), I got more meaningful exception stacktraces which helped identify the root cause.
In my case
– Did not have the setMethod for a new primary key defined, in the class refered by the hbm file.
– Had java.util.Integer instead of java.lang.Integer
– for a variable acPreference I had getACPreference, instead I should have had getAcPreference

Well, like any programmer, I started with System.out.println’s for my logging and debugging needs. But only after I wrote myself a set of test cases. As you assumed right I ran out of thought process to organize my log’s very soon. As I was debugging stuff, I realized that my logs not only need to be categorized they need to be “intended”. When I “intended” I meant that sometime in future I want to be able to say something like “show me logs of all threading happening on my server”. So I know who is using my threads, when and is some client eating up my threadpool ? I also want to be able to drive down to the client level to figure out who exactly is eating it up.

The that is “important” for me, not urgent as yet. As any good time management advice will tell you, to focus on your urgent and important. So currently I need to be able to just organize my logs into the regular 4 levels, fatal, error, info and debug. So here goes. I choose Log4j for many reasons
– Tried and tested
– A lot of help on the net for log4j
– Best Practices are already identified, documented and followed (http://juliusdavies.ca/logging.html)
/**
* Logger Design
* Should be greppable
* Separate files for separate areas of interest
* Device/Connection/StreamManager threads
* Stream Management
* Request Issues
* Database Issues
* Memcached Issues
* TimeStamps with timezones from server and client and down to nanoseconds (yyyy-MM-dd/HH:mm:ss.SSS/zzz) Java does not support nanoseconds
* Identity (who tried to do what)
* Single Line (no multiple line’s. Except, exceptions
* When did user last login ?
* Error reported to user “must” be logged (exact Error)
* Every Class to have
* public static final Logger log = Logger.getLogger(MyClass.class) ;
*/

I did encounter some trouble starting up. So this blog will help those who want to startup too. The the above advice, I also did the following
– In my main method I did
PropertyConfigurator.configure(“log4j.properties”);
– Added log.properties under the same level as src directory on my eclipse project
Project
src
….
log4j.properties
– My log4j.properties contents are
log4j.rootLogger=DEBUG, CA
log4j.appender.CA=org.apache.log4j.ConsoleAppender
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
log4j.appender.CA.layout.ConversionPattern=%-4r [%t] %-5p %c %x – %m%n

I started to get a weird exception
java.io.InvalidClassException: package.com.something.Some_Hibernate_Table; no valid constructor
at java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:730)
.
.
.
Some_Hibernate_Table

The stack trace was very weird, it hinted at a launch stack, and a exception from a table other than what I was sending data to. Infact after doing some debugging, step by step, this exception happened on a get on a SomeOther_Hibernate_Table.