예제 #1
0
 /** @since Available in iOS 9.0 and later. */
 public static NSObject observeAccountChanged(final Runnable block) {
   return NSNotificationCenter.getDefaultCenter()
       .addObserver(
           AccountChangedNotification(),
           null,
           NSOperationQueue.getMainQueue(),
           new VoidBlock1<NSNotification>() {
             @Override
             public void invoke(NSNotification a) {
               block.run();
             }
           });
 }
예제 #2
0
파일: NSPort.java 프로젝트: wynney/robovm
 public static NSObject observeDidBecomeInvalid(NSPort object, final VoidBlock1<NSPort> block) {
   return NSNotificationCenter.getDefaultCenter()
       .addObserver(
           DidBecomeInvalidNotification(),
           object,
           NSOperationQueue.getMainQueue(),
           new VoidBlock1<NSNotification>() {
             @Override
             public void invoke(NSNotification a) {
               block.invoke((NSPort) a.getObject());
             }
           });
 }
예제 #3
0
 public static NSObject observeWillExit(NSThread object, final VoidBlock1<NSThread> block) {
   return NSNotificationCenter.getDefaultCenter()
       .addObserver(
           WillExitNotification(),
           object,
           NSOperationQueue.getMainQueue(),
           new VoidBlock1<NSNotification>() {
             @Override
             public void invoke(NSNotification a) {
               block.invoke((NSThread) a.getObject());
             }
           });
 }
예제 #4
0
 public static NSObject observeDidResignKey(final VoidBlock1<UIWindow> block) {
   return NSNotificationCenter.getDefaultCenter()
       .addObserver(
           DidResignKeyNotification(),
           null,
           NSOperationQueue.getMainQueue(),
           new VoidBlock1<NSNotification>() {
             @Override
             public void invoke(NSNotification a) {
               block.invoke((UIWindow) a.getObject());
             }
           });
 }
예제 #5
0
 public static NSObject observeKeyboardDidHide(final VoidBlock1<UIKeyboardAnimation> block) {
   return NSNotificationCenter.getDefaultCenter()
       .addObserver(
           KeyboardDidHideNotification(),
           null,
           NSOperationQueue.getMainQueue(),
           new VoidBlock1<NSNotification>() {
             @Override
             public void invoke(NSNotification a) {
               block.invoke(new UIKeyboardAnimation(a.getUserInfo()));
             }
           });
 }
예제 #6
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());
             }
           });
 }
예제 #7
0
 public static NSObject observeChanged(
     NSURLCredentialStorage object, final VoidBlock1<NSURLCredentialStorage> block) {
   return NSNotificationCenter.getDefaultCenter()
       .addObserver(
           ChangedNotification(),
           object,
           NSOperationQueue.getMainQueue(),
           new VoidBlock1<NSNotification>() {
             @Override
             public void invoke(NSNotification a) {
               block.invoke((NSURLCredentialStorage) a.getObject());
             }
           });
 }
예제 #8
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);
             }
           });
 }