Questions tagged [android-mvp]

On Android, MVP is a way to separate background tasks from activities/views/fragments to make them independent of most lifecycle-related events. This way an application becomes simpler and code maintainability becomes better. Use this tag if your question is specifically about using MVP in Android.

On Android, MVP is a way to separate background tasks from activities/views/fragments to make them independent of most lifecycle-related events. This way an application becomes simpler and code maintainability becomes better. Use this tag if your question is specifically about using MVP in Android.

The tag should be used along with

278 questions
5
votes
1 answer

Android ViewModel responsibility is only hold data or hold data + controller for view?

From official we know The ViewModel class is designed to store and manage UI-related data in a lifecycle conscious way But i think lot of developers use ViewModel as both data store and controller(like calling repository, network client for…
5
votes
0 answers

MVP - Presenter comparision: view injected in constructor vs takeView(View v) / dropView()

I've seen two approaches to MVP pattern in Android. Both are used in Android Architecture Blueprints: public interface Contract { interface View { void showData(String data); } interface StartVersionPresenter { void…
AppiDevo
  • 3,195
  • 3
  • 33
  • 51
5
votes
1 answer

error: [Dagger/MissingBinding] [dagger.android.AndroidInjector.inject(T)] Dagger

I wanna to make a simple project with one main activity and multiple fragments. here I have two fragments at one activity and I want to inject presenter to login fragment but it doesn't work. where is my mistake? MainApplication.java public class…
Omid Erfanmanesh
  • 547
  • 1
  • 7
  • 29
5
votes
2 answers

Is a bad practice passing references of a View to a Presenter in MVP Pattern?

I have a big project for Android with Kotlin using the MVP pattern, and I'm starting to struggle to do Unit Tests (testing the presenters mocking the view interfaces). The reason is I'm passing view references to my functions in the presenters and…
Rafael Ruiz Muñoz
  • 5,333
  • 6
  • 46
  • 92
5
votes
1 answer

Where should I do activity navigation in MVP architecture?

I have an Android project which was built using the MVP architecture. One thing that I'm not quite sure of is that when I want to navigate to another activity after clicking on a button for example, should I place startActivity(intent) inside the…
rookiedev
  • 1,057
  • 2
  • 9
  • 21
5
votes
2 answers

Prevent Dagger2 component from recreating on screen rotation

I'm new to Dagger2 dependency injection. I have some difficulties to retain the same component when screen is rotated. @Inject MainActivityPresenterImpl presenter; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { …
Alexander
  • 333
  • 3
  • 17
5
votes
2 answers

Implementing MVP on a single activity with two (or multiple) fragments

I'm developing a small application that shows a list, and when an item is clicked it opens a secondary screen with the item details. I want to implement MVP as my architecture for this app, and i have been struggling figuring out how to do that when…
mgR
  • 195
  • 1
  • 4
  • 11
4
votes
1 answer

MVP vs MVVM: how to manage alert dialogs in MVVM and improve testability

I'm MVP lover but at the same time I'm open minded and I'm trying to improve my knowledge about MVVM and databinding: I have forked here https://github.com/jpgpuyo/MVPvsMVVM the original repo https://github.com/florina-muntenescu/MVPvsMVVM from…
jpgpuyo
  • 99
  • 7
4
votes
2 answers

MVP design pattern issue in Android

I was doing R&D on MVP and I am thinking to use this design pattern for my next project. But I am facing a problem with this design pattern. Please have a look at below java code. I have a BaseActivity class public class BaseActivity extends…
Ankit Saini
  • 374
  • 5
  • 15
4
votes
1 answer

Using Dagger and Robolectric with test application

I am using MVP pattern with a Fragment(GalleryFragment), where Application class(MainApplication) sources MainActivityRepository and GalleryFragmentPresenter(grouped as DIModules) which are provided to Fragment through field injection. To test…
4
votes
0 answers

ViewPager, Dagger injection, MVP design

It came up to me when I was designing my app structure. Basically, the app has a tab layout and some fragments associated with it (let's say 2). My goal is to have presenter being injected into activity or fragment(view). However, the presenter is…
4
votes
1 answer

Mockito Error : However, there was exactly 1 interaction with this mock

Hello i try to use mockito, to verify user password if invalid i want to verify it show error message. But i got this following error : Wanted but not invoked: loginView.showPasswordError(); -> at…
fanjavaid
  • 1,676
  • 8
  • 34
  • 65
4
votes
2 answers

Using clean MVP on android with RxJava: How can you keep the presenter free of any android knowledge while still observing on the UI thread?

In an effort to implement 'clean' architecture on android with the mvp pattern it is advised to treat the android framework as a plugin and not leak any android aware dependencies into the presenter layer. Using rxjava, if I have a presenter that is…
JohnRock
  • 6,795
  • 15
  • 52
  • 61
4
votes
1 answer

MVP Interactors and Use cases relationship

I've been recently trying to understand from an architecture point of view the relationship between the interactors and the use cases in an MVP architecture. My doubt is regarding communication in between parts and what conforms to the MVP…
mradzinski
  • 614
  • 1
  • 8
  • 21
4
votes
1 answer

java.lang.StackOverflowError in gson

While structuring my app in MVP Structure I had faced one problem, when I call the web services using Retrofit in response on success I pass the whole data into the json String so it will provoked me to do this. My Log Cat: FATAL EXCEPTION: main…
1
2
3
18 19