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


Java NSBundle类代码示例

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


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

示例1: fetchProductInformation

import org.robovm.apple.foundation.NSBundle; //导入依赖的package包/类
/** Retrieve product information from the App Store */
@SuppressWarnings("unchecked")
private void fetchProductInformation() {
    // Query the App Store for product information if the user is is allowed
    // to make purchases.
    // Display an alert, otherwise.
    if (SKPaymentQueue.canMakePayments()) {
        // Load the product identifiers fron ProductIds.plist
        String filePath = NSBundle.getMainBundle().findResourcePath("ProductIds", "plist");
        NSArray<NSString> productIds = (NSArray<NSString>) NSArray.read(new File(filePath));

        StoreManager.getInstance().fetchProductInformationForIds(productIds.asStringList());
    } else {
        // Warn the user that they are not allowed to make purchases.
        alert("Warning", "Purchases are disabled on this device.");
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:18,代码来源:IOSProductsList.java

示例2: displayMailComposerSheet

import org.robovm.apple.foundation.NSBundle; //导入依赖的package包/类
/**
 * Displays an email composition interface inside the application. Populates
 * all the Mail fields.
 */
private void displayMailComposerSheet() {
    MFMailComposeViewController picker = new MFMailComposeViewController();
    picker.setMailComposeDelegate(this);
    picker.setSubject("Hello from California!");

    // Set up recipients
    picker.setToRecipients(Arrays.asList("[email protected]"));
    picker.setCcRecipients(Arrays.asList("[email protected]", "[email protected]"));
    picker.setBccRecipients(Arrays.asList("[email protected]"));

    // Attach an image to the email
    String path = NSBundle.getMainBundle().findResourcePath("rainy", "jpg");
    NSData myData = NSData.read(new File(path));
    picker.addAttachmentData(myData, "image/jpeg", "rainy");

    // Fill out the email body text
    String emailBody = "It is raining in sunny California!";
    picker.setMessageBody(emailBody, false);

    presentViewController(picker, true, null);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:26,代码来源:MessageComposerViewController.java

示例3: populateRegistrationDomain

import org.robovm.apple.foundation.NSBundle; //导入依赖的package包/类
/**
 * Locates the file representing the root page of the settings for this app,
 * invokes loadDefaults:fromSettingsPage:inSettingsBundleAtURL: on it, and
 * registers the loaded values as the app's defaults.
 */
private void populateRegistrationDomain() {
    NSURL settingsBundleURL = NSBundle.getMainBundle().findResourceURL("Settings", "bundle");

    /*
     * Invoke loadDefaults() on the property list file for the root settings
     * page (always named Root.plist).
     */
    NSDictionary<NSString, ?> appDefaults = loadDefaults("Root.plist", settingsBundleURL);

    /*
     * appDefaults is now populated with the preferences and their default
     * values. Add these to the registration domain.
     */
    NSUserDefaults.getStandardUserDefaults().registerDefaults(appDefaults);
    NSUserDefaults.getStandardUserDefaults().synchronize();
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:22,代码来源:AppPrefs.java

示例4: viewDidLoad

import org.robovm.apple.foundation.NSBundle; //导入依赖的package包/类
@Override
public void viewDidLoad() {
    super.viewDidLoad();

    try {
        // Load the display strings.
        String resourcePath = NSBundle.getMainBundle().findResourcePath("DisplayStrings", "txt");
        String string = NSString.readFile(resourcePath, NSStringEncoding.UTF16BigEndian);

        if (string != null) {
            String[] displayStrings = string.split("\\r?\\n");
            moveMeView.setDisplayStrings(displayStrings);
            moveMeView.setupNextDisplayString();
        }
    } catch (NSErrorException e) {
        throw new Error(e);
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:19,代码来源:APLViewController.java

示例5: createApplication

import org.robovm.apple.foundation.NSBundle; //导入依赖的package包/类
@Override
protected IOSApplication createApplication()
{
    IOSApplicationConfiguration config = new IOSApplicationConfiguration();
    final String version = NSBundle.getMainBundle().getInfoDictionaryObject("CFBundleShortVersionString").toString();
    return new IOSApplication(new PixelDungeon(new PDPlatformSupport(version, null, new IOSInputProcessor())), config);
}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:8,代码来源:IOSLauncher.java

示例6: LayoutViewController

import org.robovm.apple.foundation.NSBundle; //导入依赖的package包/类
public LayoutViewController(String layoutName, NSBundle layoutBundle) {
    super(null, null);

    if(layoutBundle == null) {
        layoutBundle = NSBundle.getMainBundle();
    }
    if(layoutName != null) {
        this.layoutUrl = layoutBundle.findResourceURL(layoutName, "xml");
    }
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:11,代码来源:LayoutViewController.java

示例7: testInflateURL

import org.robovm.apple.foundation.NSBundle; //导入依赖的package包/类
@Test
public void testInflateURL() throws Exception {
    NSURL url = NSBundle.getMainBundle().findResourceURL("test/testLayout1", "xml");
    LayoutInflater inflater = new LayoutInflater();

    LayoutBridge rootView = new LayoutBridge(new CGRect(0, 0, 100, 100));
    UIView view = inflater.inflate(url, rootView, false);

    Assert.assertNotNull("Inflater returned null when inflating simple view", view);
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:11,代码来源:LayoutInflaterTest.java

示例8: testInflateAttachToRootTrue

import org.robovm.apple.foundation.NSBundle; //导入依赖的package包/类
@Test
public void testInflateAttachToRootTrue() throws Exception {
    NSURL url = NSBundle.getMainBundle().findResourceURL("test/testLayout1", "xml");
    LayoutInflater inflater = new LayoutInflater();

    LayoutBridge rootView = new LayoutBridge(new CGRect(0, 0, 100, 100));
    UIView view = inflater.inflate(url, rootView, true);

    Assert.assertEquals("Inflater did not return rootView", view, rootView);
    Assert.assertEquals("Inflater did not attach inflated view to rootView", 1, rootView.getSubviews().size());
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:12,代码来源:LayoutInflaterTest.java

示例9: testInflateAttachToRootFalse

import org.robovm.apple.foundation.NSBundle; //导入依赖的package包/类
@Test
public void testInflateAttachToRootFalse() throws Exception {
    NSURL url = NSBundle.getMainBundle().findResourceURL("test/testLayout1", "xml");
    LayoutInflater inflater = new LayoutInflater();

    LayoutBridge rootView = new LayoutBridge(new CGRect(0, 0, 100, 100));
    UIView view = inflater.inflate(url, rootView, false);

    Assert.assertNull("Inflater attached inflated view to rootView", view.getSuperview());
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:11,代码来源:LayoutInflaterTest.java

示例10: testInflateCustomView

import org.robovm.apple.foundation.NSBundle; //导入依赖的package包/类
@Test
public void testInflateCustomView() throws Exception {
    NSURL url = NSBundle.getMainBundle().findResourceURL("test/testLayout2", "xml");
    LayoutInflater inflater = new LayoutInflater();

    LayoutBridge rootView = new LayoutBridge(new CGRect(0, 0, 100, 100));
    UIView view = inflater.inflate(url, rootView, false);

    Assert.assertEquals("Inflater inflated the wrong view type", view.getClass(), CustomTestView.class);
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:11,代码来源:LayoutInflaterTest.java

示例11: testInflatePrefixedViews

import org.robovm.apple.foundation.NSBundle; //导入依赖的package包/类
@Test
public void testInflatePrefixedViews() throws Exception {
    NSURL url = NSBundle.getMainBundle().findResourceURL("test/testLayout3", "xml");
    LayoutInflater inflater = new LayoutInflater();

    LayoutBridge rootView = new LayoutBridge(new CGRect(0, 0, 100, 100));
    UIView view = inflater.inflate(url, rootView, false);

    Assert.assertEquals("Inflater didn't resolve the non-prefixed view name to a prefixed class name", view.getClass(), CustomTestView.class);
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:11,代码来源:LayoutInflaterTest.java

示例12: testInflateSubviews

import org.robovm.apple.foundation.NSBundle; //导入依赖的package包/类
@Test
public void testInflateSubviews() throws Exception {
    NSURL url = NSBundle.getMainBundle().findResourceURL("test/testLayout4", "xml");
    LayoutInflater inflater = new LayoutInflater();

    LayoutBridge rootView = new LayoutBridge(new CGRect(0, 0, 100, 100));
    UIView view = inflater.inflate(url, rootView, false);

    Assert.assertEquals("Inflater did not inflate the LinearLayout root view", view.getClass(), LinearLayout.class);
    Assert.assertEquals("Inflater inflated the wrong number of subviews", 2, view.getSubviews().size());
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:12,代码来源:LayoutInflaterTest.java

示例13: crateStatsRequestVO

import org.robovm.apple.foundation.NSBundle; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected StatsRequestVO crateStatsRequestVO() throws IllegalAccessException, InstantiationException {
    U statsReporterVO = (U) requestType.newInstance();
    statsReporterVO.udid = UIDevice.getCurrentDevice().getIdentifierForVendor().asString();
    statsReporterVO.model = UIDevice.getCurrentDevice().getModel();
    statsReporterVO.version = String.valueOf(NSBundle.getMainBundle().getInfoDictionary().asStringMap().get("CFBundleVersion"));
    //System.out.println(statsReporterVO);
    return statsReporterVO;
}
 
开发者ID:UnderwaterApps,项目名称:submarine,代码行数:11,代码来源:IOSStatsReporter.java

示例14: viewDidLoad

import org.robovm.apple.foundation.NSBundle; //导入依赖的package包/类
@Override
public void viewDidLoad() {
    super.viewDidLoad();

    result.setText("Enter 2 numbers");

    // this just demonstrates how to load a resources
    // from a framework. The storyboard is not really used.
    NSBundle bundle = NSBundle.getBundle("org.robovm.MySwiftFramework");
    UIStoryboard storyboard = new UIStoryboard("Storyboard", bundle);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:12,代码来源:MyViewController.java

示例15: getImageData

import org.robovm.apple.foundation.NSBundle; //导入依赖的package包/类
private static NSArray<?> getImageData() {
    if (imageData == null) {
        String path = NSBundle.getMainBundle().findResourcePath("ImageData", "plist");
        NSData plistData = NSData.read(new File(path));
        try {
            imageData = (NSArray<?>) NSPropertyListSerialization.getPropertyListFromData(plistData,
                    NSPropertyListMutabilityOptions.None);
        } catch (NSErrorException e) {
            System.err.println("Unable to read image data: " + e.getError());
        }
    }
    return imageData;
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:14,代码来源:ImageScrollView.java


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