nikitakozlov / retainpresenter Goto Github PK
View Code? Open in Web Editor NEWLibrary for retaining Presenter on configuration change with minimal overhead.
Library for retaining Presenter on configuration change with minimal overhead.
FragmentManager is an optional dependency (here), but afterwards you do rely that it will be there.
This may occurs when someone use this Fragment in an Activity which does not inherit from PresenterActivity
PresenterFragment is constantly adding new items to PresenterManager on every start when attachViewToPresenter() is called
You can probably change attachViewToPresenter(); to look like this:
private void attachViewToPresenter() {
P presenter = getPresenter();
if (presenter == null) {
presenter = onCreatePresenter();
if (mPresenterManager != null) {
mPresenterUUID = mPresenterManager.addPresenter(presenter);
}
}
final V view = getPresenterView();
if (presenter != null && view != null) {
presenter.onAttachView(view);
} else if (presenter == null && view != null) {
throw new IllegalStateException("You provided a view, but didn't create presenter");
} else if (presenter != null) {
throw new IllegalStateException("You created a presenter, but didn't provide a " +
"view for it");
}
}
Have you considered to apply this methodology on Custom Views?
Hi! I am trying out your approach for retaining presenters instances, and I came across with an odd issue.
Im any fragment, when I rotate the screen and call getPresenter() I am getting a null pointer exception because the presenterManager is null at the time.
I tried to debug this issue but until this moment I have no clue what this issue could be. The strange thing is that I don't know when the presenterManager looses its instance because I can state that in onResume() the presenterManager has its instance.
Are you aware of this problem?
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.