forked from Arello-Mobile/Moxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to run feature modules independent from main applicatio…
…n module. This allows Instant App support (Arello-Mobile#209), running unit-tests for feature modules (Arello-Mobile#223) and other issues Arello-Mobile#224. Here, Moxy always references to MoxyReflector by com.arellomobile.mvp package and generates MoxyReflectorDelegate for each module. In order to use Moxy, there is no need to follow instructions described on this page https://github.com/Arello-Mobile/Moxy/wiki/Multiple-modules Now it is only required to add 1 line of code to BaseActivity.onCreate of each module : MoxyReflector.registerDelegate(MoxyReflectorDelegate.INSTANCE);
- Loading branch information
1 parent
a7271af
commit 3b01fca
Showing
8 changed files
with
140 additions
and
145 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
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
66 changes: 66 additions & 0 deletions
66
moxy/src/main/java/com/arellomobile/mvp/reflector/MoxyReflector.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,66 @@ | ||
package com.arellomobile.mvp.reflector; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
* Date: 07.12.2016 | ||
* Time: 16:39 | ||
* | ||
* @author Yuri Shmakov | ||
*/ | ||
public final class MoxyReflector { | ||
|
||
private static final Collection<ReflectorDelegate> sReflectorDelegates = new HashSet<>(); | ||
|
||
public static void registerDelegate(final ReflectorDelegate reflectorDelegate) { | ||
sReflectorDelegates.add(reflectorDelegate); | ||
} | ||
|
||
public static Object getViewState(final Class<?> presenterClass) { | ||
|
||
for (final ReflectorDelegate delegate: sReflectorDelegates) { | ||
|
||
final Object viewState = delegate.getViewState(presenterClass); | ||
|
||
if (viewState != null) { | ||
|
||
return viewState; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public static List<Object> getPresenterBinders(final Class<?> delegated) { | ||
for (final ReflectorDelegate delegate: sReflectorDelegates) { | ||
|
||
final List<Object> binders = delegate.getPresenterBinders(delegated); | ||
|
||
if (binders != null) { | ||
|
||
return binders; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public static Object getStrategy(final Class strategyClass) { | ||
|
||
for (final ReflectorDelegate delegate: sReflectorDelegates) { | ||
|
||
final Object strategy = delegate.getStrategy(strategyClass); | ||
|
||
if (strategy != null) { | ||
|
||
return strategy; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
moxy/src/main/java/com/arellomobile/mvp/reflector/ReflectorDelegate.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,9 @@ | ||
package com.arellomobile.mvp.reflector; | ||
|
||
import java.util.List; | ||
|
||
public interface ReflectorDelegate { | ||
Object getViewState(Class<?> presenterClass); | ||
List<Object> getPresenterBinders(Class<?> delegated); | ||
Object getStrategy(Class<?> strategyClass); | ||
} |
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
Oops, something went wrong.