Can we keep all functions in the same class for android studio?

Viewed 268

Does having all your functions in the Main class affect loading times and responsiveness of the app?

I have an app where this is the case and it's a tad bit slow on a cold start but when you're inside the app and transitioning between activities , it's pretty fast. I changed the app's theme on startup and initially thought that might be the reason but even without that the initial start is a bit slow.

All my database calls are being done on a different thread so that might not be the reason. Can anyone help me out?

Also It works better on my phone that has greater ram but when i tested it on another phone , It shows this :

I/Choreographer: Skipped 33 frames!  The application may be doing too much work on its main thread.

I/OpenGLRenderer: Davey! duration=821ms; Flags=0, IntendedVsync=332847372155437, Vsync=332847922155415, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=332847929514414, AnimationStart=332847929615248, PerformTraversalsStart=332847929720039, DrawStart=332847952286865, SyncQueued=332847973509315, SyncStart=332847973692596, IssueDrawCommandsStart=332847974113638, SwapBuffers=332848190805638, FrameCompleted=332848193504701, DequeueBufferDuration=4169000, QueueBufferDuration=472000, 

So might this be because of the large amount of functions in the MainClass ? As I don't think There's a lot of work being done on the main thread (i.e the onCreate method)

1 Answers

f your App is more complex it would be better if you split the functions in many Scripts, because as you found out, it makes the start of the app really slow. Because it must read every line and maybe every if-statement. So just split the code and only use it, if needed and you should be fine.

Related