-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d7445e
commit 2fd7b55
Showing
7 changed files
with
64 additions
and
79 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
36 changes: 2 additions & 34 deletions
36
conductor/src/main/java/com/bluelinelabs/conductor/ControllerFactory.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,10 @@ | ||
package com.bluelinelabs.conductor; | ||
|
||
import android.os.Bundle; | ||
|
||
import com.bluelinelabs.conductor.internal.ClassUtils; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
import static com.bluelinelabs.conductor.Controller.KEY_ARGS; | ||
import static com.bluelinelabs.conductor.Controller.KEY_CLASS_NAME; | ||
|
||
public abstract class ControllerFactory { | ||
|
||
@NonNull final Controller create(@NonNull Bundle bundle) { | ||
final String className = bundle.getString(KEY_CLASS_NAME); | ||
//noinspection ConstantConditions | ||
Class cls = ClassUtils.classForName(className, false); | ||
Bundle args = bundle.getBundle(KEY_ARGS); | ||
if (args != null) { | ||
args.setClassLoader(cls.getClassLoader()); | ||
} | ||
|
||
final Controller result = create(className, args); | ||
if (result == null) { | ||
return Controller.newInstance(bundle); | ||
} else { | ||
return result; | ||
} | ||
} | ||
|
||
public interface ControllerFactory { | ||
@Nullable | ||
public abstract Controller create(@NonNull String controllerName, @NonNull Bundle args); | ||
|
||
static final class DefaultControllerFactory extends ControllerFactory { | ||
@Nullable | ||
@Override | ||
public Controller create(@NonNull String controllerName, @NonNull Bundle args) { | ||
return null; | ||
} | ||
} | ||
Controller create(@NonNull String controllerName, @Nullable Bundle args); | ||
} |
16 changes: 16 additions & 0 deletions
16
conductor/src/main/java/com/bluelinelabs/conductor/DefaultControllerFactory.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,16 @@ | ||
package com.bluelinelabs.conductor; | ||
|
||
import android.os.Bundle; | ||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
final class DefaultControllerFactory implements ControllerFactory { | ||
|
||
static final DefaultControllerFactory INSTANCE = new DefaultControllerFactory(); | ||
|
||
@Nullable | ||
@Override | ||
public final Controller create(@NonNull String controllerName, @Nullable Bundle args) { | ||
return null; | ||
} | ||
} |
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