-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: sample-recyclerview/src/main/java/com/mateuszkoslacz/moviper/recyclerviewsample/viper/view/adapter/ProductAdapter.java
- Loading branch information
Showing
173 changed files
with
1,232 additions
and
2,394 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
13 changes: 0 additions & 13 deletions
13
moviper/src/androidTest/java/com/mateuszkoslacz/moviper/ApplicationTest.java
This file was deleted.
Oops, something went wrong.
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
21 changes: 12 additions & 9 deletions
21
...n/java/com/mateuszkoslacz/moviper/base/exception/PresenterAlreadyRegisteredException.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,20 +1,23 @@ | ||
package com.mateuszkoslacz.moviper.base.exception; | ||
|
||
import com.mateuszkoslacz.moviper.iface.presenter.MoviperPresenter; | ||
import com.mateuszkoslacz.moviper.iface.presenter.ViperPresenter; | ||
|
||
/** | ||
* Created by mateuszkoslacz on 24.10.2016. | ||
*/ | ||
|
||
public class PresenterAlreadyRegisteredException extends RuntimeException { | ||
|
||
public PresenterAlreadyRegisteredException(MoviperPresenter presenter) { | ||
super(String.format("Presenter %1$s named %1$s is already registered! You enabled presenter instances" + | ||
"access and tried to register two or more presenters of the same class and name." + | ||
"Override getName() method in your %1$s presenter in way that will provide unique name" + | ||
"for each instance or disable presenter instances access using " + | ||
"Moviper.getInstance().setConfig(new Config.Builder()...) and setting " + | ||
"withInstancePresentersEnabled(true) in config builder.", | ||
presenter.getClass().getName(), presenter.getName())); | ||
public PresenterAlreadyRegisteredException(ViperPresenter presenter) { | ||
super(String.format( | ||
"Presenter %1$s named %2$s is already registered! You enabled presenter " + | ||
"instances access and tried to register two or more presenters of the " + | ||
"same class and name. Override getName() method in your %1$s presenter " + | ||
"in way that will provide unique name for each instance or disable " + | ||
"presenter instances access using " + | ||
"Moviper.getInstance().setConfig(new Config.Builder()...) and setting " + | ||
"withInstancePresentersEnabled(true) in config builder.", | ||
presenter.getClass().getName(), | ||
presenter.getName())); | ||
} | ||
} |
2 changes: 0 additions & 2 deletions
2
...in/java/com/mateuszkoslacz/moviper/base/exception/PresenterInstancesAccessNotEnabled.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
2 changes: 0 additions & 2 deletions
2
...c/main/java/com/mateuszkoslacz/moviper/base/exception/PresentersAccessUtilNotEnabled.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
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
18 changes: 8 additions & 10 deletions
18
moviper/src/main/java/com/mateuszkoslacz/moviper/base/interactor/BaseRxInteractor.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,27 +1,25 @@ | ||
package com.mateuszkoslacz.moviper.base.interactor; | ||
|
||
|
||
import com.mateuszkoslacz.moviper.iface.interactor.MoviperInteractor; | ||
import com.mateuszkoslacz.moviper.iface.interactor.MoviperRxInteractor; | ||
import com.mateuszkoslacz.moviper.iface.interactor.ViperInteractor; | ||
import com.mateuszkoslacz.moviper.iface.interactor.ViperRxInteractor; | ||
|
||
/** | ||
* Created by lucas.urbas on 29/08/15. | ||
* <p> | ||
* Adapted and modified by mateuszkoslacz on 21.10.2016. | ||
* <p> | ||
* Base Interactor class. (see {@link MoviperInteractor}) | ||
* Base Interactor class. (see {@link ViperInteractor}) | ||
*/ | ||
public abstract class BaseRxInteractor implements MoviperRxInteractor { | ||
public abstract class BaseRxInteractor implements ViperRxInteractor { | ||
|
||
@Override | ||
public void onPresenterDetached(boolean retainInstance) { | ||
onPresenterDetached(); | ||
// stub | ||
public void attach() { | ||
|
||
} | ||
|
||
@Override | ||
@Deprecated | ||
public void onPresenterDetached(){ | ||
// stub | ||
public void detach(boolean retainInstance) { | ||
|
||
} | ||
} |
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
99 changes: 99 additions & 0 deletions
99
moviper/src/main/java/com/mateuszkoslacz/moviper/base/presenter/BaseRxPresenter.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,99 @@ | ||
package com.mateuszkoslacz.moviper.base.presenter; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.NonNull; | ||
|
||
import com.hannesdorfmann.mosby.mvp.MvpBasePresenter; | ||
import com.hannesdorfmann.mosby.mvp.MvpView; | ||
import com.mateuszkoslacz.moviper.iface.interactor.ViperRxInteractor; | ||
import com.mateuszkoslacz.moviper.iface.presenter.ViperPresenter; | ||
import com.mateuszkoslacz.moviper.iface.presenter.interactor.ViperPresenterForInteractor; | ||
import com.mateuszkoslacz.moviper.iface.presenter.routing.ViperPresenterForRouting; | ||
import com.mateuszkoslacz.moviper.iface.routing.ViperRxRouting; | ||
import com.mateuszkoslacz.moviper.iface.view.ViperView; | ||
import com.mateuszkoslacz.moviper.presenterbus.Moviper; | ||
|
||
import rx.Subscription; | ||
import rx.subscriptions.CompositeSubscription; | ||
|
||
/** | ||
* Created by mateuszkoslacz on 08.08.2016. | ||
* <p> | ||
* Viper - View, Interactor, Presenter, Entities, Routing | ||
* <p> | ||
* This is a Activity version of base presenter class for mentioned set of concepts. | ||
* (see {@link MvpBasePresenter}) | ||
* <p> | ||
* You can use any Mosby Activity View with this class | ||
* ({@link com.hannesdorfmann.mosby.mvp.MvpActivity}, | ||
* {@link com.hannesdorfmann.mosby.mvp.lce.MvpLceActivity}, | ||
* {@link com.hannesdorfmann.mosby.mvp.viewstate.MvpViewStateActivity}, | ||
* {@link com.hannesdorfmann.mosby.mvp.viewstate.lce.MvpLceViewStateActivity}) | ||
*/ | ||
//TODO migrate to MvpNullObjectPresenter base class? | ||
public abstract class BaseRxPresenter | ||
<ViewType extends MvpView, // I prefer readability rather than conventions | ||
InteractorType extends ViperRxInteractor, | ||
RoutingType extends ViperRxRouting> | ||
extends CommonBasePresenter<ViewType> | ||
implements ViperPresenter<ViewType>, | ||
ViperPresenterForInteractor<InteractorType>, | ||
ViperPresenterForRouting<RoutingType> { | ||
|
||
@NonNull | ||
private RoutingType routing; | ||
|
||
@NonNull | ||
private InteractorType interactor; | ||
|
||
|
||
private CompositeSubscription compositeSubscription; | ||
|
||
public BaseRxPresenter() { | ||
this(null); | ||
} | ||
|
||
public BaseRxPresenter(Bundle args) { | ||
super(args); | ||
this.compositeSubscription = new CompositeSubscription(); | ||
this.routing = createRouting(); | ||
this.interactor = createInteractor(); | ||
} | ||
|
||
@Override | ||
public void attachView(ViewType view) { | ||
super.attachView(view); | ||
Moviper.getInstance().register(this); | ||
routing.attach((ViperView) view); | ||
interactor.attach(); | ||
} | ||
|
||
@Override | ||
public void detachView(boolean retainInstance) { | ||
super.detachView(retainInstance); | ||
if (!retainInstance) unsubscribe(); | ||
Moviper.getInstance().unregister(this); | ||
routing.detach(retainInstance); | ||
interactor.detach(retainInstance); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public RoutingType getRouting() { | ||
return routing; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public InteractorType getInteractor() { | ||
return interactor; | ||
} | ||
|
||
protected void addSubscription(Subscription subscription) { | ||
if (compositeSubscription != null) compositeSubscription.add(subscription); | ||
} | ||
|
||
private void unsubscribe() { | ||
if (compositeSubscription != null) compositeSubscription.clear(); | ||
} | ||
} |
Oops, something went wrong.