How to control MultiThreading in MVP pattern for Android development? -


recently, try use mvp pattern in android project.

i know can't bussiness logic job in view layer. view must deliver works presenter layer wait result presenter.

view should in ui thread. presenter may in sub-thread.

how control multithreading in view layout , preseneter layer?

any highly appreciated.

you have 2 directions need communicate:

a) non-ui ui thread

and

b) ui thread non-ui thread.

for first case, popular way these days use runonuithread()

here's nice survey of technique , other popular options:

http://www.intertech.com/blog/android-non-ui-to-ui-thread-communications-part-1-of-5/

as other direction, not typically necessary unless have slow blocking operations. more question of clean organization of source code. modern technique sending results view presenter using custom interfaces in fragments in "communicating activity" section:

http://developer.android.com/guide/components/fragments.html

note should not put long running operations on ui thread because make app feel sluggish. try run them on different thread if take more 50 milliseconds or so.


Comments