From 57b159ec6f9786e826ff0afbea38ab1b8ac5c126 Mon Sep 17 00:00:00 2001 From: Victor Date: Sat, 19 Mar 2016 02:05:34 +0100 Subject: [PATCH] Removed mismatch exceptions. --- .../src/main/java/rx_activity_result/Locale.java | 2 -- .../src/main/java/rx_activity_result/RxActivityResult.java | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/rx_activity_result/src/main/java/rx_activity_result/Locale.java b/rx_activity_result/src/main/java/rx_activity_result/Locale.java index 64cf203..cab487f 100644 --- a/rx_activity_result/src/main/java/rx_activity_result/Locale.java +++ b/rx_activity_result/src/main/java/rx_activity_result/Locale.java @@ -5,6 +5,4 @@ */ public interface Locale { String RX_ACTIVITY_RESULT_NOT_REGISTER = "You must call RxActivityResult.register(application) before attempting to use startIntent"; - String ACTIVITY_MISMATCH_TARGET_UI = "Mismatch target ui: the current Activity is not the same class type as the one provided when calling RxActivityResult.on(this)"; - String FRAGMENT_MISMATCH_TARGET_UI = "Mismatch target ui: not found any active Fragment whose class matches with the one provided when calling RxActivityResult.on(this)"; } diff --git a/rx_activity_result/src/main/java/rx_activity_result/RxActivityResult.java b/rx_activity_result/src/main/java/rx_activity_result/RxActivityResult.java index 565b865..e40903d 100644 --- a/rx_activity_result/src/main/java/rx_activity_result/RxActivityResult.java +++ b/rx_activity_result/src/main/java/rx_activity_result/RxActivityResult.java @@ -78,8 +78,10 @@ private OnResult onResultActivity() { @Override public void response(int resultCode, Intent data) { if (activitiesLifecycle.getLiveActivity() == null) return; + //If true it means some other activity has been stacked as a secondary process. + //Wait until the current activity be the target activity if (activitiesLifecycle.getLiveActivity().getClass() != clazz) { - throw new IllegalStateException(Locale.ACTIVITY_MISMATCH_TARGET_UI); + return; } T activity = (T) activitiesLifecycle.getLiveActivity(); @@ -111,7 +113,8 @@ private OnResult onResultFragment() { } } - throw new IllegalStateException(Locale.FRAGMENT_MISMATCH_TARGET_UI); + //If code reaches this point it means some other activity has been stacked as a secondary process. + //Wait until the current activity be the target activity to get the associated fragment } }; }