Where should I start activity in MVP pattern?

Asked 2 years ago, Updated 2 years ago, 29 views

Hello, everyone I am studying the mvp pattern while developing Android.

During the development process, we need to call the start activity function to display the new activity Where should I enter this code?

Well, it's the processing of the view, so I think it's right to go into the view It's something that's being handled, so it's kind of like being done at Presenter...

Is there any need to turn it over to the Presenter? I want to, but In Activity, if you need to hand over the data to Intent, Anyway, I have to get the data again through the presenter...

If you think about it, it could be a coding style that depends on the person developing itten thousand For those who have developed many MVPs, post a question about where to put them!

If you don't mind, the reason...Please!

android

2022-09-21 23:10

1 Answers

Personally, in the case of startActivity(), I think putting it in V is more suitable for MVP. (Considering the process of floating fragments or dialogs) And I don't think it'll be a problem because the data to be used as an Intent Parimeter can be transferred from P to V.

If you value testability in implementing MVP, you can either make the Presenter layer completely separate from the Android framework or not. So depending on what perspective you have and what perspective you have, you can actually be a kebake. Just by looking at the examples below, you can see that there are various ways to use them. I think it would be meaningful to put it in here and there in the code you're writing and judge for yourself which one is better.

For todo-mvp, run startActivity immediately in activity

For MvpCleanArchitecture, run startAcitivty in activities immediately and execute fragment transactions

Run in Presenter for u2020-mvp, delegate to ScreenSwitcher

For android-mvp, run in Presenter


2022-09-21 23:10

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.