• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NSData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: execute

import org.robovm.apple.foundation.NSData; //导入依赖的package包/类
@Override protected RFuture<Response> execute(Builder req) {
  RPromise<Response> result = plat.exec().deferredPromise();

  NSMutableURLRequest mreq = new NSMutableURLRequest();
  mreq.setURL(new NSURL(req.url));
  for (Header header : req.headers) {
    mreq.setHTTPHeaderField(header.name, header.value);
  }
  mreq.setHTTPMethod(req.method());
  if (req.isPost()) {
    mreq.setHTTPHeaderField("Content-type", req.contentType());
    if (req.payloadString != null) {
      try {
        mreq.setHTTPBody(new NSData(req.payloadString.getBytes("UTF-8")));
      } catch (UnsupportedEncodingException uee) {
        throw new RuntimeException(uee);
      }
    } else {
      mreq.setHTTPBody(new NSData(req.payloadBytes));
    }
  }
  sendRequest(mreq, result);
  return result;
}
 
开发者ID:playn,项目名称:playn,代码行数:25,代码来源:RoboNet.java


示例2: getRemoteImage

import org.robovm.apple.foundation.NSData; //导入依赖的package包/类
@Override public Image getRemoteImage(final String url, int width, int height) {
  final ImageImpl image = createImage(true, width, height, url);
  plat.net().req(url).execute().
    onSuccess(new Slot<Net.Response>() {
      public void onEmit (Net.Response rsp) {
        try {
          image.succeed(toData(Scale.ONE, new UIImage(new NSData(rsp.payload()))));
        } catch (Throwable t) {
          plat.log().warn("Failed to decode remote image [url=" + url + "]", t);
          image.fail(t);
        }
      }
    }).
    onFailure(new Slot<Throwable>() {
      public void onEmit (Throwable cause) { image.fail(cause); }
    });
  return image;
}
 
开发者ID:playn,项目名称:playn,代码行数:19,代码来源:RoboAssets.java


示例3: create

import org.robovm.apple.foundation.NSData; //导入依赖的package包/类
public static Drawable create(NSData data) {
    Drawable drawable = null;

    if(data == null)
        return null;

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

    byte[] bytes = data.getBytes();
    if(bytes != null) {
        ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);

        try {
            DocumentBuilder db = factory.newDocumentBuilder();
            InputSource inputSource = new InputSource(inputStream);
            Document document = db.parse(inputSource);

            drawable = create(document.getDocumentElement());
        } catch (ParserConfigurationException | SAXException | IOException e) {
            e.printStackTrace();
        }
    }
    return drawable;
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:25,代码来源:Drawable.java


示例4: create

import org.robovm.apple.foundation.NSData; //导入依赖的package包/类
public static ResourceStateList create(NSData data, ResourceStateList resourceStateList) {
    if(data == null)
        return null;

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

    byte[] bytes = data.getBytes();
    if(bytes != null) {
        ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);

        try {
            DocumentBuilder db = factory.newDocumentBuilder();
            InputSource inputSource = new InputSource(inputStream);
            Document document = db.parse(inputSource);

            resourceStateList = inflateDocument(document, resourceStateList);
        } catch (ParserConfigurationException | SAXException | IOException e) {
            e.printStackTrace();
        }
    }
    return resourceStateList;
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:23,代码来源:ResourceStateList.java


示例5: getXML

import org.robovm.apple.foundation.NSData; //导入依赖的package包/类
public static Document getXML(NSData nsData) {
    Document document = null;
    DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();

    byte[] bytes = nsData.getBytes();
    if(bytes != null) {
        ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);

        try {
            DocumentBuilder db = dfactory.newDocumentBuilder();
            InputSource inputSource = new InputSource(inputStream);
            document = db.parse(inputSource);
        } catch (SAXException | ParserConfigurationException | IOException e) {
            e.printStackTrace();
        }
    }
    return document;
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:19,代码来源:XMLUtil.java


示例6: setContentOfCell

import org.robovm.apple.foundation.NSData; //导入依赖的package包/类
public static UITableViewCell setContentOfCell(String name, NSURL url, String adresse, String email) {
	UITableViewCell cell = new UITableViewCell(new CGRect(0, 0, 300, 60));
	UIImageView img = new UIImageView(new CGRect(20, 10, 70, 70));
	NSData data = (NSData)NSData.read(url);
	img.setImage(new UIImage(data));		
	cell.getContentView().addSubview(img);
	
	UILabel label1 = new UILabel(new CGRect(100, 10, cell.getContentView().getFrame().getWidth(), 20));
	label1.setText(name);
	label1.setTextColor(UIColor.colorBrown());
	cell.getContentView().addSubview(label1);
	
	UILabel label2 = new UILabel(new CGRect(100, 35, cell.getContentView().getFrame().getWidth(), 20));
	label2.setText(adresse);
	cell.getContentView().addSubview(label2);
	
	UILabel label3 = new UILabel(new CGRect(100, 55, cell.getContentView().getFrame().getWidth(), 20));
	label3.setText(email);
	cell.getContentView().addSubview(label3);
	return cell;
}
 
开发者ID:Kourtessia,项目名称:RoboVM-for-iOS,代码行数:22,代码来源:AddressbookUtils.java


示例7: didReceiveDeepLink

import org.robovm.apple.foundation.NSData; //导入依赖的package包/类
@Override
public void didReceiveDeepLink(GPPDeepLink deepLink) {
    String deepLinkID = deepLink.getDeepLinkID();
    NSData decodedData = GTLBase64.decodeWebSafe(deepLinkID);
    if (decodedData == null)
        return;

    try {
        deepLinkParams = (NSDictionary<?, ?>) NSJSONSerialization.createJSONObject(decodedData,
                NSJSONReadingOptions.None);
        Log.d("Deep link ID is %s", deepLinkID);
        Log.d("This is my dictionary %s", deepLinkParams);
    } catch (NSErrorException e) {
        e.printStackTrace();
    }

    if (challengeReceivedHandler != null) {
        challengeReceivedHandler.run();
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:21,代码来源:TypeNumberApp.java


示例8: setFile

import org.robovm.apple.foundation.NSData; //导入依赖的package包/类
public void setFile(PFFile file) {
    final String requestURL = file.getUrl(); // Save copy of url locally
    url = file.getUrl(); // Save copy of url on the instance

    file.getDataInBackground(new PFGetDataCallback() {
        @Override
        public void done(NSData data, NSError error) {
            if (error == null) {
                UIImage image = new UIImage(data);
                if (requestURL.equals(url)) {
                    setImage(image);
                    setNeedsDisplay();
                }
            } else {
                Log.e("Error on fetching file: %s", error);
            }
        }
    });
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:20,代码来源:PAPImageView.java


示例9: onClick

import org.robovm.apple.foundation.NSData; //导入依赖的package包/类
@Override
        public void onClick(UIBarButtonItem barButtonItem) {
            if (photo.getPicture().isDataAvailable()) {
                showShareSheet();
            } else {
//        [MBProgressHUD showHUDAddedTo:self.view animated:YES]; TODO
                photo.getPicture().getDataInBackground(new PFGetDataCallback() {
                    @Override
                    public void done(NSData data, NSError error) {
//            [MBProgressHUD hideHUDForView:self.view animated:YES]; TODO
                        if (error == null) {
                            showShareSheet();
                        }
                    }
                });
            }
        }
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:18,代码来源:PAPPhotoDetailsViewController.java


示例10: didRegisterForRemoteNotifications

import org.robovm.apple.foundation.NSData; //导入依赖的package包/类
/**
 * Will be called when the user accepted remote notifications and whenever
 * the device token changes.
 * 
 * @param application
 * @param deviceToken will be used to identify this device from remote push
 *            notification servers.
 */
@Override
public void didRegisterForRemoteNotifications(UIApplication application, NSData deviceToken) {
    if (deviceToken != null) {
        /*
         * **IMPORTANT** Normally you would send the deviceToken to a push
         * notification server to be able to send push notifications to this
         * device.
         */

        // Let's store the device token in the app preferences.
        NSUserDefaults.getStandardUserDefaults().put(DEVICE_TOKEN_USER_PREF, deviceToken);
        NSUserDefaults.getStandardUserDefaults().synchronize();
    }

    // Call the success callback.
    if (notificationRegistrationListener != null) {
        notificationRegistrationListener.onSuccess();
        notificationRegistrationListener = null;
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:29,代码来源:AppDelegate.java


示例11: displayMailComposerSheet

import org.robovm.apple.foundation.NSData; //导入依赖的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


示例12: load

import org.robovm.apple.foundation.NSData; //导入依赖的package包/类
public static void load(File path, int bufferId) {
  NSData data = null;
  try {
    // mmap (if possible) the audio file for efficient reading/uploading
    data = NSData.read(path, RoboAssets.READ_OPTS);
    load(data.asByteBuffer(), path.getName(), bufferId);
  } catch (NSErrorException e) {
    throw new RuntimeException(e.toString());
  } finally {
    // now dispose the mmap'd file to free up resources
    if (data != null) {
      data.dispose();
    }
  }
}
 
开发者ID:playn,项目名称:playn,代码行数:16,代码来源:CAFLoader.java


示例13: getBytesSync

import org.robovm.apple.foundation.NSData; //导入依赖的package包/类
@Override
public ByteBuffer getBytesSync(String path) throws Exception {
  File fullPath = resolvePath(path);
  plat.log().debug("Loading bytes " + fullPath);
  // this NSData will release resources when garbage collected
  return NSData.read(fullPath, READ_OPTS).asByteBuffer();
}
 
开发者ID:playn,项目名称:playn,代码行数:8,代码来源:RoboAssets.java


示例14: getXML

import org.robovm.apple.foundation.NSData; //导入依赖的package包/类
public Document getXML(NSURL url) throws IOException {
    Document document = null;

    NSData nsData = (NSData) cache.get(url.getAbsoluteString());

    try {
        if(nsData == null) { // trying to fetch (does not exist in cache)
            nsData = NSData.read(url);

            if(nsData == null) {
                if(url.isFileURL())
                    throw new FileNotFoundException(url.getAbsoluteString());
            } else {
                cache.put(url.getAbsoluteString(), nsData);
            }
        }

        if(nsData != null) {
            DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();

            byte[] bytes = nsData.getBytes();
            if(bytes != null) {
                ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);

                DocumentBuilder db = dfactory.newDocumentBuilder();
                InputSource inputSource = new InputSource(inputStream);
                document = db.parse(inputSource);
            }
        }
    } catch (SAXException | ParserConfigurationException e) {
        e.printStackTrace();
    }

    return document;
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:36,代码来源:XMLCache.java


示例15: setContentOfCell

import org.robovm.apple.foundation.NSData; //导入依赖的package包/类
public void setContentOfCell(UITableViewCell cell, String txt, NSURL url) {
	UIImageView img = new UIImageView(new CGRect(25, 5, 80, 80));
   	NSData data = (NSData) NSData.read(url);
	img.setImage(new UIImage(data));
	cell.getContentView().addSubview(img);

	UILabel label = new UILabel(new CGRect(120, 30, cell.getContentView()
			.getFrame().getWidth(), 20));
	label.setText(txt);
	cell.getContentView().addSubview(label);
}
 
开发者ID:Kourtessia,项目名称:RoboVM-for-iOS,代码行数:12,代码来源:GenderListTableViewController.java


示例16: showShareSheet

import org.robovm.apple.foundation.NSData; //导入依赖的package包/类
private void showShareSheet() {
    photo.getPicture().getDataInBackground(new PFGetDataCallback() {
        @Override
        public void done(NSData data, NSError error) {
            if (error == null) {
                List<Object> activityItems = new ArrayList<>(3);

                NSArray<PAPActivity> activities = getObjects();

                // Prefill caption if this is the original poster of the
                // photo, and then only if they added a caption initially.
                if (PAPUser.getCurrentUser().getObjectId().equals(photo.getUser().getObjectId())
                        && activities.size() > 0) {
                    PAPActivity firstActivity = activities.first();
                    if (firstActivity.getFromUser().getObjectId().equals(photo.getUser().getObjectId())) {
                        String commentString = firstActivity.getContent();
                        activityItems.add(commentString);
                    }
                }

                activityItems.add(new UIImage(data));
                activityItems.add(new NSURL(String.format("https://anypic.org/#pic/%s", photo.getObjectId())));

                UIActivityViewController activityViewController = new UIActivityViewController(activityItems, null);
                getNavigationController().presentViewController(activityViewController, true, null);
            }
        }
    });
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:30,代码来源:PAPPhotoDetailsViewController.java


示例17: didRegisterForRemoteNotifications

import org.robovm.apple.foundation.NSData; //导入依赖的package包/类
@Override
public void didRegisterForRemoteNotifications(UIApplication application, NSData deviceToken) {
    if (application.getApplicationIconBadgeNumber() != 0) {
        application.setApplicationIconBadgeNumber(0);
    }

    PFInstallation currentInstallation = PFInstallation.getCurrentInstallation();
    currentInstallation.setDeviceToken(deviceToken);
    currentInstallation.saveInBackground();
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:11,代码来源:AnyPicApp.java


示例18: getImageData

import org.robovm.apple.foundation.NSData; //导入依赖的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


示例19: getJPEGRepresentationWithCompressionQuality

import org.robovm.apple.foundation.NSData; //导入依赖的package包/类
private NSData getJPEGRepresentationWithCompressionQuality(CIImage image, double compressionQuality) {
    EAGLContext eaglContext = new EAGLContext(EAGLRenderingAPI.OpenGLES2);
    CIContext ciContext = new CIContext(eaglContext);
    CGImage outputImage = ciContext.createCGImage(image, image.getExtent());
    UIImage uiImage = new UIImage(outputImage, 1.0, UIImageOrientation.Up);
    NSData jpegRepresentation = uiImage.toJPEGData(compressionQuality);
    return jpegRepresentation;
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:9,代码来源:AAPLAssetViewController.java


示例20: didReceiveData

import org.robovm.apple.foundation.NSData; //导入依赖的package包/类
@Override
public void didReceiveData(NSURLConnection connection, NSData data) {
    try {
        audioFileStream.parseBytes(data.getBytes(), AudioFileStreamParseFlags.None);
    } catch (OSStatusException e) {
        throw new Error(e);
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:9,代码来源:WebRadioPlayer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GOTO类代码示例发布时间:2022-05-23
下一篇:
Java SwiftProtocolConstants类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap