czyrux / mvploadersample Goto Github PK
View Code? Open in Web Editor NEWSample project to showcase how to use Android Loaders with MVP to preserve Presenter across orientation changes
Sample project to showcase how to use Android Loaders with MVP to preserve Presenter across orientation changes
In the BasePresenterActivity you call the initLoader()
on the onCreate()
method.
When the onLoadFinished
of that given loader is called you set the presenter
field with the loaded presenter.
However, you reference the presenter on the onStart()
method but is there any guarantee that the onLoadFinished
callback has been executed prior to the onStart()
method (i.e. do we know for sure that we have a presenter by the time onStart()
executes)? Thanks!
Edit: On the documentation of the Loader, startLoading states that
This function will normally be called for you automatically by LoaderManager when the associated fragment/activity is being started.
I didn't assume that the state of "being started" corresponded to the onStart() method or equivalent thus my question. And as it is documented it seems that may not always happen. Closing the issue. Thanks!
Update to support Library 24.x.x to fix issue with Loader result deliver twice after rotation
Issue: stackoverflow
This update also fix: #3
In onLoadFinished() of the BasePresenterFragment you call:
onPresenterPrepared(presenter);
before presenter.onViewAttached(getPresenterView());
I would think this might potentially cause an issue if you call the presenter in the onPresenterPrepared method of the fragment before the view is attached.
Hello All !
I just started MVP in android.
I want to create adapter from cursor so How to get cursor from onLoadFinished(Loader
loader, P presenter) ?
Thanks,
Kaushlendra.
Hey,
I ve implemented your simple in to an app, when launching the app I am getting this error :
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'presenter.BasePresenter presenter.loader.PresenterFactory.create()' on a null object reference`
at presenter.loader.PresenterLoader.onForceLoad(PresenterLoader.java:39)
at android.support.v4.content.Loader.forceLoad(Loader.java:329)
in this line in particular
mPresenter = mPresenterFactory.create();
I am using dagger 2 to inject the presenter factory inside the presenter
Add Javadoc in order to clarify methods in Base Activity and Fragment
Steps to reproduce:
having an Activity with Presenter-Loader. Loader behaves correctly on orientation change. But:
having the Activity in Portrait, calling/starting another Activity that is forced to landscape and the returning back from this activity lets the Loadermanager reset the loader and the Presenter does not survive.
Has anybody else experienced that issue?
When i set "Don't keep activities", The loader will be null when presenter-activity is in background!
Hello Guys,
I need help,
I have use isplayer.js file is when maximize isplayer cant work on print-screen disable functionality
how to disable in full screen mode printscreen key using javascript.
Regards,
Vikash Das
When devices rotates presenter gets destroyed can you help me with this error please
Thanks for the Help
In BasePresenterFragment you do:
@Override
public void onStop() {
presenter.onViewDetached();
super.onStop();
Log.i(TAG, "onPause-" + tag());
}
But what about attaching the view back in onStart() method?
I think it should be like that:
@Override
public void onStop() {
if(presenter != null){
presenter.onViewDetached();
}
super.onStop();
Log.i(TAG, "onStop-" + tag());
}
@Override
public void onStart() {
super.onStart();
if(presenter != null){
presenter.onViewAttached(getPresenterView());
}
Log.i(TAG, "onStart-" + tag());
}
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.