Meetup.com: Android for Java Refugees

Nice Dutch meetup organized by my employer. The Android version of my current project will also receive some attention during this meetup.. :)

Thursday, November 29, 2012
6:00 PM To 9:00 PM

Xebia
Utrechtseweg 49, Hilversum

More info here.

Ben jij een ervaren Java ontwikkelaar? En ben je geïnteresseerd in mobile development? Kom dan naar de Android for Java Refugees Meetup op 29 november aanstaande. Onze mobile developers zullen tijdens deze Meetup hun praktijkervaringen met Android delen. We behandelen de basis en laten ook zien wat we hebben geleerd bij het ontwikkelen van high profile Enterprise Android apps. Het programma bestaat uit ontvangst met eten, twee presentaties en een uitgebreide Q&A.

Android for Java Refugees: Getting Started

De titel van deze presentatie spreekt voor zich!
Andrew Snare, Senior Consultant Mobile Development bij Xebia, bespreekt onder andere:

  • Project layout & source control
  • Maven integration
  • Comparison with Java
  • Tools: Emulator & Testing
  • Designing your application flow: understanding platform conventions.
  • Activities, Intents & Services

ING Mobiel Bankieren: van telefoon naar tablet

Ronald Warners, Senior Consultant Android Development bij Xebia, laat tijdens deze presentatie aan de hand van voorbeelden uit de ING Mobiel Bankieren App zien wat de ervaringen zijn bij het optimaliseren van de Android App voor tablets. Hoe houden we de code schoon? Hoe hergebruiken we zoveel mogelijk? En hoe hebben we toch andere lay- outs en flows op verschillende devices? Is fragmentatie van Android devices daarbij een probleem? De volgende onderwerpen worden onder andere besproken:

  • Compatibility
  • Fragments & Loaders
  • Selectors
  • Examples from ING mobiel bankieren
  • Lessons learned

Jouw vraag?

Tweet jouw specifieke vraag voor deze Meetup naar @Xebia Onze Experts zullen de vragen verwerken in hun verhalen en beantwoorden tijdens de Q&A.

iOS – Just a quick way to create a shadow on any view

This post is a reposting of a blog post I did for my employer.

Sometimes you would want a shadow on a view.

Easiest and quickest way is to just add it on the view’s layer:

-(void)loadView {
    CGRect frame = [[UIScreen mainScreen] applicationFrame];
     
    self.view = [[UIView alloc] initWithFrame:frame];
    self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    self.view.backgroundColor = [UIColor blackColor];
     
    UIView *glowView = [[UIView alloc] initWithFrame:CGRectMake(frame.size.width /2 -10, frame.size.height /2 -30, 20, 60)];
    glowView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | 
                                    UIViewAutoresizingFlexibleTopMargin |
                                    UIViewAutoresizingFlexibleLeftMargin |
                                    UIViewAutoresizingFlexibleRightMargin;
     
    glowView.backgroundColor = [UIColor whiteColor];
     
    [self.view addSubview:glowView];
     
    //Setup the shadow on the view's CALayer.
    CALayer *viewLayer = glowView.layer;
    viewLayer.shadowOffset = CGSizeMake(0, 0);
    viewLayer.shadowColor = [[UIColor yellowColor] CGColor];
    viewLayer.shadowPath = [UIBezierPath bezierPathWithRect:glowView.bounds].CGPath;
    viewLayer.shadowRadius = 10.0f;
    viewLayer.shadowOpacity = 1.0f;
  
    //Let's animate it while we're at it.
    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"];
    animation.duration = 0.5f;
    animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
    animation.fromValue = [NSNumber numberWithFloat:1.0];
    animation.toValue = [NSNumber numberWithFloat:0.0];
    animation.autoreverses = YES;
    animation.repeatCount = HUGE_VALF;
    [viewLayer addAnimation:animation forKey:@"shadowOpacity"];
}

I must admit, this is kind of basic stuff. But it seems a lot of people actually forget about the fact that all UIView subclasses are based on Core Animation CALayers.

See the source code https://github.com/xebia/ios-DemoForBlog and try the example, the interesting bits about this example are all contained within the fourth tab of the application, it’s the XSDFourthViewController in the code.

iOS – Voiceover and view picking

This is a reposting of a blog post I did on my employers blog.

Something that might interest the developers out there working with accessibility on iOS.

If you have strange behavior, as in, being unable to (partially) pick an accessibility frame by just dragging your finger over the screen, I might be able to answer just why.

As it turns out. VoiceOver and sub views being out of bounds of their parent’s view bounds don’t really mix.

Continue reading

iOS – Animation glitch example

This is a reposting of a blog post I did on my employers blog.

A short while ago we were running into an interesting animation glitch. The actual solution is quite simple.

Here’s what the glitch was about. A table view could be toggled into an edit mode. On performing this toggle a label would be animated out of the view and hidden. The strange thing was, that this label was resizing it’s font size right the second before the actual animation started.

Fortunately we were able to fix this problem.

Continue reading

Xebia, 6 months in…

6 months ago i started at Xebia. It’s been a fun ride so far. Started working on a super cool mobile project with a user base soon to pass a million users.

Right now I’m enjoying a few weeks off. And I’m looking at where I’m at now and where I would like to go. Things have been very interesting the last 6 months.

And the most important news is, I’ll working on my Open University education again. For my work I get to stay in hotels a lot and to keep my mind occupied on those evenings I think a few self study courses will do nicely.

Beware though… This is the most important news for now…

Xebia, two weeks in…

Two weeks ago I started at my new employer. Xebia. I’ve been busy, but soon, I will be super busy. If all goes well I’ll be doing some very cool work in the near future. For now, I’m helping out colleagues where I can. Trying to make a name for myself and stake my claim within the Mobile group of Xebia.

Suffice to say, let’s make things ripple this year. :) I took the plunge and sofar, the water has been very comfy.

Also, Happy valentine’s day to everyone and one person in particular. :)
IMG 0684

Unresolved dependencies

A while ago I created this picture:

unresolved_dependencies.jpg

For some reason I was watching my older pictures and this one struck a chord with me today. Since my last blog post a lot of things have happened. One of those things is that after nine years I will be leaving my current employer Info Support.

Also I’ve been doing a lot of soul searching and I have come to some conclusions.

There is a person I care about fighting as I write this to get well again. I sure hope that person will find the strength and will to press on and fight for all the good things this person still wants to do.

Suffice to say there are many other things as well… All coming down to the line clearly readable on this picture.

“Unresolved dependencies”

Enabling HTTP request response logging on JBoss 4.2

Today I had a bit of a fiddle with JBoss 4.2 due to IE7/IE8 compatibility differences.

When opening or downloading a file in IE7 over an SSL connection (HTTPS), IE7 requires a bit of HTTP header-fu to allow you to actually perform that action.

It’s simple really. Just add “Pragma: public” and “Cache-Control: maxage=3600″ to your HTTP headers and you’re good to go.

In Java code:

response.setHeader("Pragma", "public");
response.setHeader("Cache-Control", "maxage=3600");

To check if it’s working was a different matter. How to check the HTTP header content when things get sent over an HTTPS connection… FireBug doesn’t work, and so doesn’t any other developer tooling in any browser. Tracing the network traffic is pretty useless too, it’s encrypted. Last option, trace it on the server. Simply enabling network tracing on the Java VM didn’t work. For some reason JBoss doesn’t pick up this Java VM setting, probably because they are using a NIO based stack or something. I really don’t know.

JBoss does use Catalina for it’s HTTP/HTTPS/Web container handling. Catalina is another name for Tomcat. Tomcat has this valve thing which allows you to plug into the processing pipe. Good thing there are standard Valve implementations available that do just what I needed.

Just drop the next snippet somewhere appropriate:

<!-- Enable http request/response logging.-->
<Valve className=org.apache.catalina.valves.RequestDumperValve
           prefix=localhost_access_log. suffix=.log
           pattern=common directory=${jboss.server.home.dir}/log
           resolveHosts=false />

Appropriate in my case was in the file “[JBOSS-HOME]/server/default/deploy/jboss-web.deployer/server.xml”.

And lo and behold it logged:

11:46:44,262 INFO  [[localhost]]           authType=BASIC
11:46:44,262 INFO  [[localhost]]      contentLength=48189
11:46:44,262 INFO  [[localhost]]        contentType=application/pdf
11:46:44,262 INFO  [[localhost]]             header=Pragma=public
11:46:44,262 INFO  [[localhost]]             header=Cache-Control=maxage=3600
11:46:44,262 INFO  [[localhost]]             header=Expires=Thu, 01 Jan 1970 01:00:00 CET
11:46:44,262 INFO  [[localhost]]             header=X-Powered-By=Servlet 2.4; JBoss-4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)/JBossWeb-2.0
11:46:44,332 INFO  [[localhost]]             header=X-Powered-By=JSF/1.2
11:46:44,332 INFO  [[localhost]]             header=X-Powered-By=Servlet 2.4; JBoss-4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)/JBossWeb-2.0
11:46:44,332 INFO  [[localhost]]             header=X-Powered-By=JSF/1.2
11:46:44,332 INFO  [[localhost]]             header=Content-Type=application/pdf
11:46:44,332 INFO  [[localhost]]             header=Content-Length=48189
11:46:44,332 INFO  [[localhost]]             header=Date=Thu, 26 Aug 2010 09:46:44 GMT
11:46:44,332 INFO  [[localhost]]            message=null
11:46:44,332 INFO  [[localhost]]         remoteUser=admin
11:46:44,332 INFO  [[localhost]]             status=200

-XX:-DontCompileHugeMethods

Read some stuff today about huge methods and the JVM’s JIT Compiler.

The JIT proces detects hotspots in code. If a hotspot is detected (usually 1000 to 1500 hits depending on your platform and JVM version) the JIT process marks a method for compilation to machine instructions. After compilation, method invocations are generally crazy fast on a method since the JIT process had like a thousand times to see what generally happens during the execution of a method and can optimise accordingly. (So never ever use the Xcomp option on the JVM, it forces compilation from the start, but this is generally slower, because the compilation will not be optimized in any way.)

The thing is, when performing this operation of marking methods for compilation there’s a catch. An 8k byte code instructions catch to be exact. If a method in byte code contains more then 8000 byte code instructions it will never ever be marked for compilation, period. About 2500 lines of Java code should do the trick. But believe me, I’ve seen crazy fools create monsters methods of that magnitude.

It gets even better though. When looking for methods to mark for compilation, the JIT process uses a call graph when doing it’s magic work of granting methods the privilege of optimized compilation. And here comes the catch in that, if a big fat honking pile of 8k byte code is encountered in a method while walking the call graph, JIT says: “I aint touching that!”. Thus any method called from that pile of poop not reachable in any other way through the call graph, will never ever feel the warm love of JIT optimized compilation.

Now you could use the lovely “-XX:-DontCompileHugeMethods” argument when invoking the JVM. But from what I’ve understand it’s a bad thing to do, because amongst others it forces the JVM to go digging through those 8k wonders of human creativity.

Other option is to just use your sane mind and round up and terminate the morons in your project creating these 8k monsters. It’s good practice anyway to keep your methods small and task focussed in any object oriented language.

The gist is, don’t use “-XX:-DontCompileHugeMethods”. Go bananas during a code review whenever you find any method which is too big for comfort. Let’s just say that the default statement count suggested by checkstyle is a good one. So any method or constructor above 30 statements in length should be cause for investigation during a code review.