本文整理汇总了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.");
}
}
示例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);
}
示例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();
}
示例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);
}
}
示例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);
}
示例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");
}
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
示例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);
}
示例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());
}
示例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;
}
示例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);
}
示例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;
}