-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/#8-implement-malaria-profile-pag…
…e' into #20-implement-malaria-follo-up-visit # Conflicts: # opensrp-chw-malaria/src/main/java/org/smartregister/chw/malaria/activity/BaseMalariaProfileActivity.java # opensrp-chw-malaria/src/main/java/org/smartregister/chw/malaria/domain/MemberObject.java
- Loading branch information
Showing
5 changed files
with
71 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 1 addition & 12 deletions
13
...-malaria/src/main/java/org/smartregister/chw/malaria/contract/MalariaProfileContract.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,7 @@ | ||
package org.smartregister.chw.malaria.contract; | ||
|
||
import android.content.Context; | ||
import org.smartregister.view.contract.BaseProfileContract; | ||
|
||
public interface MalariaProfileContract { | ||
interface View { | ||
Context getContext(); | ||
|
||
MalariaProfileContract.View getView(); | ||
|
||
MalariaProfileContract.Presenter presenter(); | ||
|
||
} | ||
|
||
interface Presenter extends BaseProfileContract.Presenter { | ||
void setProfileViewWithData(); | ||
} | ||
} |
40 changes: 16 additions & 24 deletions
40
...ia/src/main/java/org/smartregister/chw/malaria/presenter/BaseMalariaProfilePresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,34 @@ | ||
package org.smartregister.chw.malaria.presenter; | ||
|
||
import android.content.Context; | ||
|
||
import org.smartregister.chw.malaria.contract.MalariaProfileContract; | ||
import org.smartregister.chw.malaria.domain.MemberObject; | ||
|
||
import java.lang.ref.WeakReference; | ||
|
||
public class BaseMalariaProfilePresenter implements MalariaProfileContract.Presenter, MalariaProfileContract.View { | ||
protected WeakReference<MalariaProfileContract.View> view; | ||
protected MemberObject memberObject; | ||
public class BaseMalariaProfilePresenter { | ||
protected MalariaProfileContract.View view; | ||
private MemberObject memberObject; | ||
protected Context context; | ||
|
||
|
||
public BaseMalariaProfilePresenter(MalariaProfileContract.View contractView, MemberObject memberObject) { | ||
this.view = new WeakReference<>(contractView); | ||
public BaseMalariaProfilePresenter(MalariaProfileContract.View view, MemberObject memberObject) { | ||
this.view = view; | ||
this.memberObject = memberObject; | ||
|
||
} | ||
|
||
@Override | ||
public Context getContext() { | ||
return null; | ||
public void attachView(MalariaProfileContract.View view) { | ||
this.view = view; | ||
} | ||
|
||
@Override | ||
public MalariaProfileContract.View getView() { | ||
if(view != null) { | ||
return view.get(); | ||
} | ||
return null; | ||
public void detachView() { | ||
this.view = null; | ||
} | ||
|
||
@Override | ||
public MalariaProfileContract.Presenter presenter() { | ||
return null; | ||
} | ||
|
||
|
||
@Override | ||
public void onDestroy(boolean b) { | ||
//destroy | ||
public void fillProfileData(MemberObject memberObject) { | ||
if (memberObject != null) { | ||
view.setProfileViewWithData(); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...hw-malaria/src/test/java/org/smartregister/presenter/BaseMalariaProfilePresenterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.smartregister.presenter; | ||
|
||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.smartregister.chw.malaria.contract.MalariaProfileContract; | ||
import org.smartregister.chw.malaria.domain.MemberObject; | ||
import org.smartregister.chw.malaria.presenter.BaseMalariaProfilePresenter; | ||
|
||
import static org.mockito.Mockito.never; | ||
import static org.mockito.Mockito.verify; | ||
|
||
public class BaseMalariaProfilePresenterTest { | ||
@Mock | ||
private MalariaProfileContract.View view = Mockito.mock(MalariaProfileContract.View.class); | ||
@Mock | ||
BaseMalariaProfilePresenter profilePresenter = Mockito.mock(BaseMalariaProfilePresenter.class); | ||
|
||
@Mock | ||
MemberObject memberObject = Mockito.mock(MemberObject.class); | ||
|
||
@Test | ||
public void fillProfileData_doesntCallsSetProfileViewWithDataIfMemberObjectEmpty() { | ||
profilePresenter.fillProfileData(memberObject); | ||
verify(view, never()).setProfileViewWithData(); | ||
} | ||
} |