GCX-HCI / ThirtyInch

a MVP library for Android favoring a stateful Presenter
Apache License 2.0
1.03k stars 101 forks source link

TiPresenter#runOnUiThread(Runnable) #65

Closed passsy closed 7 years ago

passsy commented 7 years ago

Allows code to run on the UI thread within the TiPresenter. This is most likely not a method for users of Ti but for extensions using the LifecycleObserver-API (another PR will follow).

public API changes

The action of TiPresenter#sendToView(Runnable action) will be now be called on the UI thread. Furthermore will those actions be executed after onAttachView(TiView) and after all lifecycle observers have been called. This allows preparing the view in onAttachView(TiView) for those actions. That way the view should be in a "running" state as if the view was never gone. For very rare and special cases TiPresenter#getQueuedViewActions() can be used to manually execute queued actions. People are creative.

Another change has been made to RxTiPresenterUtils#isViewReady() which was firing the ready event before onAttachView(TiView) was called. The ready event is now fired after onAttachView(TiView)

The execution order of lifecycle obersvers when receiving teardown events has been reversed; following "first in, last out"

internal changes

The method in DelegatedTiActivity#postToMessageQueue(Runnable runnable) has been replaced with DelegatedTiActivity#Executor getUiThreadExecutor();, same for the Fragment interface. All classes have been adjusted.


I think the API changes are not critical and could also be bug fixes preventing rare race conditions.

passsy commented 7 years ago

@StefMa Ready. I already tested the sample and a real project and everything works fine