Comments (11)
I think that Presenter should not tell view to show something. Presenter in not controller. MVC does not work on Android, see "best practices" section.
I don't know what your Settings object is doing, but it seems to me that you can put all this code into your activity.
from nucleus.
Yes, you can use onTakeView to push data from presenter to view if that data is needed every time a view is attached.
from nucleus.
I would think this pattern becomes a little weird. Because this means you should at some cases couple activities with presenters and some not. Else you'll leave empty presenters around for no reason.
Imagine you have an application that has a simple wizard. The only thing that activity should do is present static views and during the wizard maybe write settings that will be saved in your application.
If code such the one above is supposed to be placed in the activity it means i should decouple the presenter for that specific activity, which would break the mvp-pattern.
Does not the mvp-pattern say you should couple: model->presenter->view to display something and the other way around view->presenter->model to store something?
You probably know more than me, but I know this for sure, there will be cases when the presenters will not be used for anything, which strikes me as odd :)
from nucleus.
Reading preferences is not a task that deserves presenter. This is a one-line main thread action. Keep it stupid simple!
Yes, I use presenter only if I have background tasks to handle or if my database should be split off view. Overengineering is a real problem on big projects, this is why not every view should have them.
from nucleus.
I'll try stick with that reference :)
from nucleus.
You can create an observable from preferences if you wish and use deliver() to send data to view.
from nucleus.
If one is to be able to make a project-specific baseactivity that makes easy interaction with both activities not using presenters and activities using presenters, I think a new annotation would have to be added in that case :)
if RequiresPresenter-annotation is used to tell that an activitiy needs a presenter, then it should be possible to also tell with an annotation that it does not need it, else you'll have to use two baseactivities for your activities, one that uses nucleusActivity and one that does not :)
from nucleus.
If you make a project-specific base activity then just don't say that it requires a presenter. :-D
from nucleus.
Then how will I make an activity than needs to be extended from that baseactivity that DOES require a presenter? :D
I tried the following
public class BaseActivity<PresenterType extends nucleus.presenter.Presenter> extends NucleusActionBarActivity<PresenterType> {
}
But if you remove the RequiresPresenter-annotation from the activities extending from it, and I just got an error that I needed to declare a Presenter for the activites using that baseactivity :)
So that didnt seem to work
It does seem like an issue
from nucleus.
Ok, I will check this. Thank you for the report.
from nucleus.
Done! :) 1.1.0
from nucleus.
Related Issues (20)
- Best practice for normal case. (get support.) HOT 3
- Wondering about multiple Presenter endpoint calls (Question) HOT 2
- How to get onComplete using restartable methods? HOT 1
- How could i force restartableFirst.onError with mockito? HOT 1
- RxJava latest version not used. HOT 1
- Console error saving file HOT 1
- Activity method called every time HOT 2
- (Question) Don't keep activieties option HOT 1
- Confusion about restartables and the Activity lifecycle HOT 3
- Does Nucleus support native Fragments? HOT 2
- Throwing VerifyError in < API 21 HOT 1
- Question regarding getView() and reference the View in the presenter. HOT 11
- Nucleus with Dagger 2 HOT 3
- NucleusActionBarActivity with support library 26 HOT 13
- Help with injecting Presenter when using AndroidInjector HOT 3
- Calling setPresenter in OnCreate HOT 2
- clear the delivery cache
- Crashes when starting a new activity using kotlin
- upgrade a new version for androidx, please
- getView() deprecated
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nucleus.