Skip to content
This repository has been archived by the owner on Aug 9, 2020. It is now read-only.

Commit

Permalink
Removed mismatch exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor committed Mar 19, 2016
1 parent 3fea534 commit 57b159e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)";
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
}
};
}
Expand Down

0 comments on commit 57b159e

Please sign in to comment.