Skip to content

Commit

Permalink
Added missing files from e7c195d
Browse files Browse the repository at this point in the history
  • Loading branch information
EricKuck committed Dec 16, 2016
1 parent 44ed198 commit d15f2b6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public abstract class ControllerChangeHandler {
private static final Map<String, ControllerChangeHandler> inProgressPushHandlers = new HashMap<>();

private boolean forceRemoveViewOnPush;

boolean hasBeenUsed;
private boolean hasBeenUsed;

/**
* Responsible for swapping Views from one Controller to another.
Expand Down Expand Up @@ -85,6 +84,16 @@ public ControllerChangeHandler copy() {
return fromBundle(toBundle());
}

/**
* Returns whether or not this is a reusable ControllerChangeHandler. Defaults to false and should
* ONLY be overridden if there are absolutely no side effects to using this handler more than once.
* In the case that a handler is not reusable, it will be copied using the {@link #copy()} method
* prior to use.
*/
public boolean isReusable() {
return false;
}

@NonNull
final Bundle toBundle() {
Bundle bundle = new Bundle();
Expand Down Expand Up @@ -145,7 +154,7 @@ public static void executeChange(@Nullable final Controller to, @Nullable final
final ControllerChangeHandler handler;
if (inHandler == null) {
handler = new SimpleSwapChangeHandler();
} else if (inHandler.hasBeenUsed) {
} else if (inHandler.hasBeenUsed && !inHandler.isReusable()) {
handler = inHandler.copy();
} else {
handler = inHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,8 @@ public ControllerChangeHandler copy() {
return new SimpleSwapChangeHandler(removesFromViewOnPush());
}

@Override
public boolean isReusable() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ public void performChange(@NonNull ViewGroup container, @Nullable View from, @Nu
public ControllerChangeHandler copy() {
return new NoOpControllerChangeHandler();
}

@Override
public boolean isReusable() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.bluelinelabs.conductor;


import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
Expand Down Expand Up @@ -82,4 +81,15 @@ public void restoreFromBundle(@NonNull Bundle bundle) {
super.restoreFromBundle(bundle);
removesFromViewOnPush = bundle.getBoolean(KEY_REMOVES_FROM_VIEW_ON_PUSH);
}

@NonNull
@Override
public ControllerChangeHandler copy() {
return new MockChangeHandler(removesFromViewOnPush, listener);
}

@Override
public boolean isReusable() {
return true;
}
}

0 comments on commit d15f2b6

Please sign in to comment.