当前位置: 首页>>代码示例>>Java>>正文


Java NSNotification类代码示例

本文整理汇总了Java中org.robovm.apple.foundation.NSNotification的典型用法代码示例。如果您正苦于以下问题:Java NSNotification类的具体用法?Java NSNotification怎么用?Java NSNotification使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NSNotification类属于org.robovm.apple.foundation包,在下文中一共展示了NSNotification类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: IOSProductsList

import org.robovm.apple.foundation.NSNotification; //导入依赖的package包/类
public IOSProductsList() {
    // Register for StoreManager's notifications
    NSNotificationCenter.getDefaultCenter().addObserver(StoreManager.IAPProductRequestNotification,
            StoreManager.getInstance(), NSOperationQueue.getMainQueue(), new VoidBlock1<NSNotification>() {
                @Override
                public void invoke(NSNotification a) {
                    handleProductRequestNotification(a);
                }
            });

    // The tableview is organized into 2 sections: AVAILABLE PRODUCTS and
    // INVALID PRODUCT IDS
    products.add(new MyModel("AVAILABLE PRODUCTS"));
    products.add(new MyModel("INVALID PRODUCT IDS"));

    fetchProductInformation();

    getTableView().registerReusableCellClass(UITableViewCell.class, "availableProductID");
    getTableView().registerReusableCellClass(UITableViewCell.class, "invalidIdentifierID");
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:21,代码来源:IOSProductsList.java

示例2: viewDidLoad

import org.robovm.apple.foundation.NSNotification; //导入依赖的package包/类
@Override
public void viewDidLoad() {
    getTableView().setSeparatorStyle(UITableViewCellSeparatorStyle.SingleLine);

    super.viewDidLoad();

    UIView texturedBackgroundView = new UIView(getView().getBounds());
    texturedBackgroundView.setBackgroundColor(UIColor.black());
    getTableView().setBackgroundView(texturedBackgroundView);

    getNavigationItem().setTitleView(new UIImageView(UIImage.getImage("LogoNavigationBar")));

    // Add Settings button
    getNavigationItem().setRightBarButtonItem(new PAPSettingsButtonItem(settingsButtonAction));

    applicationDidReceiveRemoteNotification = PAPNotificationManager.addObserver(
            PAPNotification.DID_RECEIVE_REMOTE_NOTIFICATION, new VoidBlock1<NSNotification>() {
                @Override
                public void invoke(NSNotification notification) {
                    loadObjects();
                }
            });

    blankTimelineView = new UIView(getTableView().getBounds());

    UIButton button = new UIButton(UIButtonType.Custom);
    button.setBackgroundImage(UIImage.getImage("ActivityFeedBlank"), UIControlState.Normal);
    button.setFrame(new CGRect(24, 113, 271, 140));
    button.addOnTouchUpInsideListener(inviteFriendsButtonAction);
    blankTimelineView.addSubview(button);

    lastRefresh = PAPCache.getSharedCache().getLastActivityFeedRefresh();
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:34,代码来源:PAPActivityFeedViewController.java

示例3: handleProductRequestNotification

import org.robovm.apple.foundation.NSNotification; //导入依赖的package包/类
/**
 * Update the UI according to the notification result
 * 
 * @param notification
 */
private void handleProductRequestNotification(NSNotification notification) {
    MyModel model = null;
    StoreManager productRequestNotification = (StoreManager) notification.getObject();
    IAPProductRequestStatus result = productRequestNotification.getStatus();

    sectionNames.clear();

    switch (result) {
    // The App Store has recognized some identifiers and returned their
    // matching products.
    case ProductsFound:
        model = products.get(0);
        model.setElements(productRequestNotification.getAvailableProducts());
        // Keep track of the position of the AVAILABLE PRODUCTS section
        sectionNames.add("AVAILABLE PRODUCTS");
        break;
    // Some product identifiers were not recognized by the App Store
    case IdentifiersNotFound:
        model = products.get(1);
        model.setElements(productRequestNotification.getInvalidProductIds());
        // Keep track of the position of the INVALID PRODUCT IDS section
        sectionNames.add("INVALID PRODUCT IDS");
        break;
    default:
        break;
    }
    // Reload the tableview to update it
    if (model != null) {
        getTableView().reloadData();
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:37,代码来源:IOSProductsList.java

示例4: didReceiveMemoryWarning

import org.robovm.apple.foundation.NSNotification; //导入依赖的package包/类
@Method(selector = "didReceiveMemoryWarning:")
private void didReceiveMemoryWarning(NSNotification nsNotification) {
    this.scaledImageCache = null;
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:5,代码来源:BitmapDrawable.java

示例5: addObserver

import org.robovm.apple.foundation.NSNotification; //导入依赖的package包/类
public static NSObject addObserver(PAPNotification notification, VoidBlock1<NSNotification> callback) {
    return NSNotificationCenter.getDefaultCenter().addObserver(notification.getName(), null,
            NSOperationQueue.getMainQueue(), callback);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:5,代码来源:PAPNotificationManager.java

示例6: ParentViewController

import org.robovm.apple.foundation.NSNotification; //导入依赖的package包/类
public ParentViewController() {
    NSNotificationCenter.getDefaultCenter().addObserver(StoreObserver.IAPPurchaseNotification,
            StoreObserver.getInstance(),
            NSOperationQueue.getMainQueue(), new VoidBlock1<NSNotification>() {
                @Override
                public void invoke(NSNotification a) {
                    handlePurchasesNotification(a);
                }
            });

    segmentedControl = new UISegmentedControl(NSArray.fromStrings("Products", "Purchases"));
    segmentedControl.setSelectedSegment(0);
    segmentedControl.addOnValueChangedListener(new UIControl.OnValueChangedListener() {
        @Override
        public void onValueChanged(UIControl control) {
            segmentValueChanged(control);
        }
    });
    getNavigationItem().setTitleView(segmentedControl);

    getNavigationItem().setRightBarButtonItem(
            new UIBarButtonItem("Restore", UIBarButtonItemStyle.Done, new UIBarButtonItem.OnClickListener() {
                @Override
                public void onClick(UIBarButtonItem barButtonItem) {
                    restore();
                }
            }));

    UIView view = getView();
    view.setBackgroundColor(UIColor.white());

    statusMessage = new UILabel(new CGRect(0, 64, 320, 44));
    statusMessage.setTextAlignment(NSTextAlignment.Center);
    statusMessage.setFont(UIFont.getSystemFont(14));

    containerView = new UIView(UIScreen.getMainScreen().getApplicationFrame());
    view.addSubview(containerView);

    productsList = new IOSProductsList();
    purchasesList = new IOSPurchasesList();

    // Add iOSProductsList and iOSPurchasesList as child view controllers
    addChildViewController(productsList);
    productsList.didMoveToParentViewController(this);
    addChildViewController(purchasesList);
    purchasesList.didMoveToParentViewController(this);

    // iOSProductsList is the default child view controller
    cycleViewControllers(null, productsList);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:51,代码来源:ParentViewController.java

示例7: handlePurchasesNotification

import org.robovm.apple.foundation.NSNotification; //导入依赖的package包/类
/**
 * Update the UI according to the notification result
 * 
 * @param notification
 */
private void handlePurchasesNotification(NSNotification notification) {
    StoreObserver purchasesNotification = (StoreObserver) notification.getObject();
    IAPPurchaseNotificationStatus status = purchasesNotification.getStatus();

    switch (status) {
    case PurchaseSucceeded:
        String title = StoreManager.getInstance().getTitleForId(purchasesNotification.getPurchasedID());

        // Display the product's title associated with the payment's product
        // identifier if it exists or the product
        // identifier, otherwise.
        String displayedTitle = title != null ? title : purchasesNotification.getPurchasedID();
        alert("Purchase Status", displayedTitle + " was successfully purchased.");
        break;
    case PurchaseFailed:
        alert("Purchase Status", purchasesNotification.getMessage());
        break;
    // Switch to the iOSPurchasesList view controller when receiving a
    // successful restore notification
    case RestoredSucceeded:
        // Get the view controller currently displayed
        UIViewController selectedController = getViewControllerForSelectedIndex((int) segmentedControl
                .getSelectedSegment());
        segmentedControl.setSelectedSegment(1);
        cycleViewControllers(selectedController, purchasesList);
        break;
    case RestoredFailed:
        alert("Purchase Status", purchasesNotification.getMessage());
        break;
    // Notify the user that downloading is about to start when receiving a
    // download started notification
    case DownloadStarted:
        hasDownloadContent = true;
        getView().addSubview(statusMessage);
        break;
    // Display a status message showing the download progress
    case DownloadInProgress:
        hasDownloadContent = true;
        title = StoreManager.getInstance().getTitleForId(purchasesNotification.getPurchasedID());
        displayedTitle = title.length() > 0 ? title : purchasesNotification.getPurchasedID();
        statusMessage.setText(String.format("Downloading %s %.2f%%", displayedTitle,
                purchasesNotification.getDownloadProgress()));
        break;
    // Downloading is done, remove the status message
    case DownloadSucceeded:
        hasDownloadContent = false;
        statusMessage.setText("Download complete: 100%");

        // Remove the message after 2 seconds
        DispatchQueue.getMainQueue().after(2, TimeUnit.SECONDS, new Runnable() {
            @Override
            public void run() {
                hideStatusMessage();
            }
        });
        break;
    default:
        break;
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:66,代码来源:ParentViewController.java


注:本文中的org.robovm.apple.foundation.NSNotification类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。