Example #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();
             }
           });
 }
Example #2
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()));
             }
           });
 }
Example #3
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());
             }
           });
 }
  private void loadImages(Runnable completed) {
    new Thread(
            () -> {
              List<UIImage> images = new ArrayList<>();

              for (String url : imageUrls) {
                File path = ImageCache.getInstance().downloadImage(url);
                if (path != null) {
                  images.add(new UIImage(path));
                }
              }
              NSOperationQueue.getMainQueue()
                  .addOperation(
                      () -> {
                        imageView.setImages(images);
                        completed.run();
                      });
            })
        .start();
  }