clojure-android / lein-droid

A Leiningen plugin for building Clojure/Android projects
Eclipse Public License 1.0
645 stars 56 forks source link

Delay finish until MainActivity has been loaded #62

Closed ghost closed 10 years ago

ghost commented 10 years ago

When the MainActivity loads a lot of application namespaces, the time difference between the call to .finish() in the SplashActivity and the MainActivity actually showing up, is quite significant, sometimes even causing the dreaded "Activity is not responding" warning.

By loading the MainActivity class in the background, it can be ensured that the transition will be (almost...) immediate.

alexander-yakushev commented 10 years ago

Hey Volker,

I understood the problem, but don't quite get why the class loading should be run in separate AsyncTask. Also, you call finish() right after executing that AsyncTask, wouldn't it be called immediately just the same?

I updated splash in sample to do this simpler https://github.com/clojure-android/lein-droid/blob/master/sample/src/java/test/leindroid/sample/SplashActivity.java . Can you try this approach with your code and see if it works? Thank you!

ghost commented 10 years ago

Hi Alex,

Your solution is fine... I used an AsyncTask in my own initial solution for a Splash and was somewhat fixated on the concept, plus it was a known-good solution to my problem with the load delay.

As for the call to finish() in proceed()... You're correct and the patch is wrong. ;-)

alexander-yakushev commented 10 years ago

All right! Hope I did it right with this commit. Thanks for reporting!