Example #1
0
 public static NSObject observeAuthenticationDidChange(
     GKLocalPlayer object, final VoidBlock1<GKLocalPlayer> block) {
   return NSNotificationCenter.getDefaultCenter()
       .addObserver(
           AuthenticationDidChangeNotification(),
           object,
           NSOperationQueue.getMainQueue(),
           new VoidBlock1<NSNotification>() {
             @Override
             public void invoke(NSNotification a) {
               block.invoke((GKLocalPlayer) a.getObject());
             }
           });
 }
Example #2
0
 /** @since Available in iOS 8.0 and later. */
 public static NSObject observeFailedToDecode(
     AVSampleBufferDisplayLayer object,
     final VoidBlock2<AVSampleBufferDisplayLayer, NSError> block) {
   return NSNotificationCenter.getDefaultCenter()
       .addObserver(
           FailedToDecodeNotification(),
           object,
           NSOperationQueue.getMainQueue(),
           new VoidBlock1<NSNotification>() {
             @Override
             public void invoke(NSNotification a) {
               NSDictionary<?, ?> data = a.getUserInfo();
               NSError error = null;
               if (data.containsKey(FailedToDecodeNotificationErrorKey())) {
                 error = (NSError) data.get(FailedToDecodeNotificationErrorKey());
               }
               block.invoke((AVSampleBufferDisplayLayer) a.getObject(), error);
             }
           });
 }