@@ -193,21 +193,18 @@ public static boolean permissionPermanentlyDenied(Object object, String deniedPe
193
193
* {@link android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback#onRequestPermissionsResult(int, String[], int[])}
194
194
* method.
195
195
* <p>
196
- * If any permissions were granted or denied, the Activity will receive the appropriate
196
+ * If any permissions were granted or denied, the {@code object} will receive the appropriate
197
197
* callbacks through {@link PermissionCallbacks} and methods annotated with
198
198
* {@link AfterPermissionGranted} will be run if appropriate.
199
199
*
200
200
* @param requestCode requestCode argument to permission result callback.
201
201
* @param permissions permissions argument to permission result callback.
202
202
* @param grantResults grantResults argument to permission result callback.
203
- * @param object the calling Activity or Fragment.
204
- * @throws IllegalArgumentException if the calling Activity does not implement
205
- * {@link PermissionCallbacks}.
203
+ * @param receivers an array of objects that have a method annotated with {@link AfterPermissionGranted}
204
+ * or implement {@link PermissionCallbacks}.
206
205
*/
207
206
public static void onRequestPermissionsResult (int requestCode , String [] permissions ,
208
- int [] grantResults , Object object ) {
209
-
210
- checkCallingObjectSuitability (object );
207
+ int [] grantResults , Object ... receivers ) {
211
208
212
209
// Make a collection of granted and denied permissions from the request.
213
210
ArrayList <String > granted = new ArrayList <>();
@@ -221,25 +218,28 @@ public static void onRequestPermissionsResult(int requestCode, String[] permissi
221
218
}
222
219
}
223
220
224
- // Report granted permissions, if any.
225
- if (!granted .isEmpty ()) {
226
- // Notify callbacks
227
- if (object instanceof PermissionCallbacks ) {
228
- ((PermissionCallbacks ) object ).onPermissionsGranted (requestCode , granted );
221
+ // iterate through all receivers
222
+ for (Object object : receivers ) {
223
+ // Report granted permissions, if any.
224
+ if (!granted .isEmpty ()) {
225
+ if (object instanceof PermissionCallbacks ) {
226
+ ((PermissionCallbacks ) object ).onPermissionsGranted (requestCode , granted );
227
+ }
229
228
}
230
- }
231
229
232
- // Report denied permissions, if any.
233
- if (!denied .isEmpty ()) {
234
- if (object instanceof PermissionCallbacks ) {
235
- ((PermissionCallbacks ) object ).onPermissionsDenied (requestCode , denied );
230
+ // Report denied permissions, if any.
231
+ if (!denied .isEmpty ()) {
232
+ if (object instanceof PermissionCallbacks ) {
233
+ ((PermissionCallbacks ) object ).onPermissionsDenied (requestCode , denied );
234
+ }
236
235
}
237
- }
238
236
239
- // If 100% successful, call annotated methods
240
- if (!granted .isEmpty () && denied .isEmpty ()) {
241
- runAnnotatedMethods (object , requestCode );
237
+ // If 100% successful, call annotated methods
238
+ if (!granted .isEmpty () && denied .isEmpty ()) {
239
+ runAnnotatedMethods (object , requestCode );
240
+ }
242
241
}
242
+
243
243
}
244
244
245
245
@ TargetApi (23 )
0 commit comments