@@ -180,64 +180,58 @@ public DeepLinkResult dispatchFrom(Activity activity, Intent sourceIntent) {
180
180
Class <?> c = matchedDeeplinkEntry .getActivityClass ();
181
181
Intent newIntent = null ;
182
182
TaskStackBuilder taskStackBuilder = null ;
183
- if (c != null ) {
184
- if (matchedDeeplinkEntry .getMethod () == null ) {
185
- newIntent = new Intent (activity , c );
186
- } else {
187
- Method method ;
188
- DeepLinkResult errorResult = new DeepLinkResult (false , uriString ,
189
- "Could not deep link to method: " + matchedDeeplinkEntry .getMethod () + " intents length == 0" ,
190
- deeplinkMatchResult , new DeepLinkMethodResult (null , taskStackBuilder ));
191
- try {
192
- method = c .getMethod (matchedDeeplinkEntry .getMethod (), Context .class );
193
- if (method .getReturnType ().equals (TaskStackBuilder .class )) {
194
- taskStackBuilder = (TaskStackBuilder ) method .invoke (c , activity );
183
+ if (matchedDeeplinkEntry .getMethod () == null ) {
184
+ newIntent = new Intent (activity , c );
185
+ } else {
186
+ Method method ;
187
+ DeepLinkResult errorResult = new DeepLinkResult (false , uriString ,
188
+ "Could not deep link to method: " + matchedDeeplinkEntry .getMethod () + " intents length == 0" ,
189
+ deeplinkMatchResult , new DeepLinkMethodResult (null , taskStackBuilder ));
190
+ try {
191
+ method = c .getMethod (matchedDeeplinkEntry .getMethod (), Context .class );
192
+ if (method .getReturnType ().equals (TaskStackBuilder .class )) {
193
+ taskStackBuilder = (TaskStackBuilder ) method .invoke (c , activity );
194
+ if (taskStackBuilder .getIntentCount () == 0 ) {
195
+ return errorResult ;
196
+ }
197
+ newIntent = taskStackBuilder .editIntentAt (taskStackBuilder .getIntentCount () - 1 );
198
+ } else if (method .getReturnType ().equals (DeepLinkMethodResult .class )) {
199
+ DeepLinkMethodResult methodResult = (DeepLinkMethodResult ) method .invoke (c , activity );
200
+ if (methodResult .getTaskStackBuilder () != null ) {
201
+ taskStackBuilder = methodResult .getTaskStackBuilder ();
195
202
if (taskStackBuilder .getIntentCount () == 0 ) {
196
203
return errorResult ;
197
204
}
198
205
newIntent = taskStackBuilder .editIntentAt (taskStackBuilder .getIntentCount () - 1 );
199
- } else if (method .getReturnType ().equals (DeepLinkMethodResult .class )) {
200
- DeepLinkMethodResult methodResult = (DeepLinkMethodResult ) method .invoke (c , activity );
201
- if (methodResult .getTaskStackBuilder () != null ) {
202
- taskStackBuilder = methodResult .getTaskStackBuilder ();
203
- if (taskStackBuilder .getIntentCount () == 0 ) {
204
- return errorResult ;
205
- }
206
- newIntent = taskStackBuilder .editIntentAt (taskStackBuilder .getIntentCount () - 1 );
207
- } else if (methodResult .getIntent () != null ) {
208
- newIntent = methodResult .getIntent ();
209
- }
210
- } else {
211
- newIntent = (Intent ) method .invoke (c , activity );
206
+ } else if (methodResult .getIntent () != null ) {
207
+ newIntent = methodResult .getIntent ();
212
208
}
213
- } catch (NoSuchMethodException exception ) {
214
- method = c .getMethod (matchedDeeplinkEntry .getMethod (), Context .class , Bundle .class );
215
- if (method .getReturnType ().equals (TaskStackBuilder .class )) {
216
- taskStackBuilder = (TaskStackBuilder ) method .invoke (c , activity , parameters );
209
+ } else {
210
+ newIntent = (Intent ) method .invoke (c , activity );
211
+ }
212
+ } catch (NoSuchMethodException exception ) {
213
+ method = c .getMethod (matchedDeeplinkEntry .getMethod (), Context .class , Bundle .class );
214
+ if (method .getReturnType ().equals (TaskStackBuilder .class )) {
215
+ taskStackBuilder = (TaskStackBuilder ) method .invoke (c , activity , parameters );
216
+ if (taskStackBuilder .getIntentCount () == 0 ) {
217
+ return errorResult ;
218
+ }
219
+ newIntent = taskStackBuilder .editIntentAt (taskStackBuilder .getIntentCount () - 1 );
220
+ } else if (method .getReturnType ().equals (DeepLinkMethodResult .class )) {
221
+ DeepLinkMethodResult methodResult = (DeepLinkMethodResult ) method .invoke (c , activity , parameters );
222
+ if (methodResult .getTaskStackBuilder () != null ) {
223
+ taskStackBuilder = methodResult .getTaskStackBuilder ();
217
224
if (taskStackBuilder .getIntentCount () == 0 ) {
218
225
return errorResult ;
219
226
}
220
227
newIntent = taskStackBuilder .editIntentAt (taskStackBuilder .getIntentCount () - 1 );
221
- } else if (method .getReturnType ().equals (DeepLinkMethodResult .class )) {
222
- DeepLinkMethodResult methodResult = (DeepLinkMethodResult ) method .invoke (c , activity , parameters );
223
- if (methodResult .getTaskStackBuilder () != null ) {
224
- taskStackBuilder = methodResult .getTaskStackBuilder ();
225
- if (taskStackBuilder .getIntentCount () == 0 ) {
226
- return errorResult ;
227
- }
228
- newIntent = taskStackBuilder .editIntentAt (taskStackBuilder .getIntentCount () - 1 );
229
- } else if (methodResult .getIntent () != null ) {
230
- newIntent = methodResult .getIntent ();
231
- }
232
- } else {
233
- newIntent = (Intent ) method .invoke (c , activity , parameters );
228
+ } else if (methodResult .getIntent () != null ) {
229
+ newIntent = methodResult .getIntent ();
234
230
}
231
+ } else {
232
+ newIntent = (Intent ) method .invoke (c , activity , parameters );
235
233
}
236
234
}
237
- } else {
238
- if (errorHandler != null ) {
239
- errorHandler .activityClassNotFound (uriString , matchedDeeplinkEntry .getClassName ());
240
- }
241
235
}
242
236
if (newIntent == null ) {
243
237
return new DeepLinkResult (false , uriString , "Destination Intent is null!" ,
@@ -268,7 +262,15 @@ public DeepLinkResult dispatchFrom(Activity activity, Intent sourceIntent) {
268
262
}
269
263
}
270
264
271
- private DeepLinkMatchResult findEntry (String uriString ) {
265
+ /**
266
+ * Returns a raw match result for the given uriString. This is null if no match is found.
267
+ * There is no general use for that during normal operation but it might be useful when writing
268
+ * tests.
269
+ *
270
+ * @param uriString Uri to be matched
271
+ * @return An instance of {@link DeepLinkMatchResult} if a match was found or null if not.
272
+ */
273
+ public @ Nullable DeepLinkMatchResult findEntry (@ NonNull String uriString ) {
272
274
DeepLinkEntry entryRegExpMatch = null ;
273
275
List <DeepLinkMatchResult > entryIdxMatches = new ArrayList <>();
274
276
DeepLinkUri uri = DeepLinkUri .parse (uriString );
0 commit comments