a MVP library for Android favoring a stateful Presenter
Changelog:
Changelog
06.06.19
Same as 0.9.5
but with an fix that TiCoroutineScope.launchUntilViewDetaches
crashes when using in in TiPresenter.onAttachView
.
TiCoroutineScope.launchUntilViewDetaches
#192 (Thanks @Syex!)https://github.com/grandcentrix/ThirtyInch/compare/v0.9.5...v0.9.6
03.06.19
New lint module to detect issues early.
For instance we detect that you have missed to implement the TiView
in your Activity
or Fragment
.
Use:
No action required. We bundle the lint registry together with the main thirtyinch
module.
This new kotlin module which makes the usage of Kotlin coroutines super easy with ThirtyInch.
The Jobs
you will start with the TiCoroutineScope
will be automatically canceled when either the View
disappeared or the Presenter
got destroyed.
Use:
implementation "net.grandcentrix.thirtyinch:thirtyinch-kotlin-coroutines:0.9.5"
You can also checkout our README#coroutines.
This module was removed because CompositeAndroid isn't maintained anymore.
lint
module #158kotlin-coroutines
support #182https://github.com/grandcentrix/ThirtyInch/compare/v0.9.0...v0.9.5
31.7.18
sendToView
-> deliverToView
for kotlin usersNew kotlin module which makes the usage of sendToView
easier. If you have more ideas open a issue or PR.
When using sendToView
, repeating it.*
inside the lambda is quite annoying.
It's clear that the methods are called on the view.
With the kotlin extension deliverToView
the TiView
will be give over to the lambda as this
.
// normal java API
sendToView {
it.showText("Hello World")
}
// kotlin extension
deliverToView {
showText("Hello World")
}
Back in the Java days we had to use it
inside the sendToView
-lambda.
Use:
implementation "net.grandcentrix.thirtyinch:thirtyinch-kotlin:$thirtyinchVersion"
Starting with Android Studio 3.2 you can migrate to AndroidX and ThirtyInch is ready.
kotlin
module with TiPresenter#deliverToView(block: View.() -> Unit)
which can be used as a replacement for sendToView
#150api
, was compileOnly
)Rx2TiPresenterUtils#deliverLatestToView
#137 (thx @GrahamBorland)TiPresenter#sendToView
is now public
(was protected
) which allows a kotlin extension function #142https://github.com/grandcentrix/ThirtyInch/compare/v0.8.5...v0.9.0
14.10.17
Mostly a maintenance release improving documentation, adding tests and cleaning up the repository.
Highlight: The test
package is now deprecated and all functionality was moved into the thirtyinch
artifact.
Thanks for external contributors: @baltuky @vpondala
TiPresenter#test()
returns a TiTestPresenter
with helper methods for unit testing. Replaces TiPresenterInstructor
and deprecates the test
artifact.TiPresenter#test()
documentation, thx @baltukyRELEASE.md
instructionsDelegatedTiActivity#isActivityChangingConfigurations
which turned out as not required to handle config changes correctly. Simplifies internal logicOneTimeRemovable
PresenterScope
testsHamcrest
assertions with AssertJ
, thx @vpondalaTiTestPresenter
https://github.com/grandcentrix/ThirtyInch/compare/v0.8.0...v0.8.5
04.05.17
Version 0.8.0 is a big step forward towards 1.0.0. The biggest problem, a memory leak when using Fragments could be resolved. This bugfix was only possible after introducing tons of tests.
API enhancements of TiPresenter
make MVP even easier and removes common pitfalls
Increased code coverage from below 20% to 67% (646/951 lines)
Thanks for external contributors: @remcomokveld, @vRallev, @jonathan-caryl, @k0shk0sh
TiPresenter
onAttachView(TiView)
replaces onWakeUp()
which is now deprecatedonDetachView()
replaces onSleep()
which is now deprecatedgetView()
is now annotated with @Nullable
getViewOrThrow()
for cases where the view logically can't be null
sendToView(ViewAction<TiView>)
to postpone code execution until the view is attachedrunOnUiThread(Runnable)
executes code on the view Ui Thread.sendToView(view -> { })
automatically executes the action on the Ui ThreadTiFragment
FragmentManager
anymoresetRetainInstanceState(false)
. Setting TiFragment#setRetainInstanceState(true)
will throwTiActivity
PresenterSavior
singleton, drop support for NonConfigurationInstance
Other
TiLog
is used for logging. Listener to see a log output@DistinctUntilChanged
supports multiple comparators. (EqualsComparator
, WeakEqualsComparator
, HashComparator
(default))provided
dependency instead of compile
TiDialogFragment
@CallSuper
where a super call is required.TiActivity
, TiFragment
... API for subclasses.TiPresenter
gets destroyed when TiFragment
gets removed from the FragmentManagerProguard
rules included in the libraryTiConfiguration#setUseStaticSaviorToRetain(Boolean)
is now deprecated. The PresenterSavior
singleton is always used to retain presenters when TiConfiguration#setRetainPresenterEnabled(true)
.null
before unsubscribing from Subscriptionsmanage\[View\]Subscriptions(Subscription...)
manageViewSubscription(Subscription)
will now throw when the view isn't attachedRxTiPresenterUtils#isViewReady()
now emits the ready event after onAttachView(TiView)
was called.manage\[View\]Subscription
will now return Subscription
New module for RxJava2 analog to rx module
RxTiPresenterDisposableHandler#manageDisposable
and RxTiPresenterDisposableHandler#manageViewDisposable
TiFragmentPlugin
TiPresenterInstructor
automatically sets an Executor
for runOnUiThread
and sendToView
actionsLoggingInterceptor
https://github.com/grandcentrix/ThirtyInch/compare/v0.7.1...v0.8.0
2017-04-25
Most likely the last RC before releasing 0.8.0 🎉
TiPresenter
gets destroyed when TiFragment
gets removed from the FragmentManager #78 #33 #83 #68TiFragment
supports the backstack #78TiActivity
, TiFragment
... API for subclasses. #79@CallSuper
where a super call is required. #79TiConfiguration#setUseStaticSaviorToRetain(Boolean)
is now deprecated. The Savior
singleton is always used to retain presenters when TiConfiguration#setRetainPresenterEnabled(true)
. This also means that TiActivity
dropped support for the NonConfigurationInstance
API #78TiFragment
was initially using setRetainInstanceState(true)
. TiFragment
uses now the default: setRetainInstanceState(false)
. When you try to set TiFragment#setRetainInstanceState(true)
it will throw. #78 #67TiPresenter
works now with the Activity
API only. #78manage*Subscription
will now return Subscription
#73manage*Subscription(Subscription...)
is now manage*Subscriptions(Subscription...)
(note the S here), was introduced in an earlier RC and is no breaking change. #73manage* Disposable
will not return Disposable
#73manage* Disposable(Disposable...)
is now manage* Disposables(Disposable...)
(note the S here 😉), was introduced in an earlier RC and is no breaking change. #73ViewPager
#84LoggingInterceptor
logs all method calls to the TiView
interface to TiLog
for debugging. Don't forget to enable TiLog
or pass a custom Logger
to the LoggingInterceptor
constructor. #85compile "net.grandcentrix.thirtyinch:thirtyinch-logginginterceptor:$thirtyinchVersion"
// register TiLog in your Application
if (BuildConfig.DEBUG) {
TiLog.setLogger(TiLog.LOGCAT);
}
public class MyActivity extends TiActivity<MyPresenter, MyView> implements MyView {
public MyActivity() {
// log by default to TiLog
addBindViewInterceptor(new LoggingInterceptor());
// log to logcat for debug builds
addBindViewInterceptor(new LoggingInterceptor(BuildConfig.DEBUG ? TiLog.LOGCAT : null));
}
}
https://github.com/grandcentrix/ThirtyInch/compare/v0.8.0-rc3...v0.8.0-rc4
2017-02-10
TiPresenter#runOnUiThread(Runnable)
executes code on the view Ui Thread. #65sendToView(view -> { })
automatically executes the action on the Ui Thread #65sendToView(action)
actions will be executed after #onAttachView(view)
, and after all LifecycleObserver
received their events. 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. #65LifecycleObserver
s get called in order they are added for constructive events (VIEW_ATTACHED
) and in reversed order for destructive events (VIEW_DETACHED
, DESTROYED
). First in, last out. #65TiFragmentPlugin
#49manageViewSubscription(Subscription)
will now throw when the view isn't attached #58, #61TiLifecycleObserver#onChange(state, beforeLifecycleEvent)
to TiLifecycleObserver#onChange(state, hasLifecycleMethodBeenCalled)
, also adjusted the documentation #61RxTiPresenterUtils#isViewReady()
to emit the ready event after onAttachView(TiView)
was called.rx2
module compile "net.grandcentrix.thirtyinch:thirtyinch-rx2:$thirtyinchVersion"
#54Disposable
with RxTiPresenterDisposableHandler#manageDisposable
and RxTiPresenterDisposableHandler#manageViewDisposable
#54, #64RxTiPresenterUtils#isViewReady(): Observable<Boolean>
emits the view attached stateTiPresenterInstructor
automatically sets an Executor
for runOnUiThread
and sendToView
actions. It's even more recommended to use it instead of calling the lifecycle methods manually0.8.0-rc2
TiDialogFragment
#42 with TiDialogFragmentDelegate
under the hood #47 (thanks @vRallev)@DistinctUntilChanged
uses now hashcode()
instead of equals()
by default (again) for comparison. Revert of change introduced in 0.8.0-rc1
#46