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


Java VoidBlock2类代码示例

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


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

示例1: logIn

import org.robovm.objc.block.VoidBlock2; //导入依赖的package包/类
public void logIn(final List<String> readPermissions, final LoginListener listener) {
    log("Trying to login with read permissions (%s)...", readPermissions);
    loginManager.logInWithReadPermissions(readPermissions,
            new VoidBlock2<FBSDKLoginManagerLoginResult, NSError>() {
                @Override
                public void invoke(FBSDKLoginManagerLoginResult result, NSError error) {
                    if (error != null) {
                        log("Failed to login: %s", error.getLocalizedDescription());
                        listener.onError("An unknown error happened!");
                    } else if (result.isCancelled()) {
                        log("Cancelled login!");
                        listener.onCancel();
                    } else {
                        if (!result.getGrantedPermissions().containsAll(readPermissions)) {
                            log("Failed to login: Permissions declined (%s)", result.getDeclinedPermissions());
                            listener.onError("The following permissions have been declined: "
                                    + result.getDeclinedPermissions().toString());
                        } else {
                            log("Successfully logged in!");
                            listener.onSuccess();
                        }
                    }
                }
            });
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:26,代码来源:FacebookHandler.java

示例2: requestPublishPermissions

import org.robovm.objc.block.VoidBlock2; //导入依赖的package包/类
public void requestPublishPermissions(final List<String> publishPermissions, final LoginListener listener) {
    log("Requesting publish permissions (%s)...", publishPermissions);
    loginManager.logInWithPublishPermissions(publishPermissions,
            new VoidBlock2<FBSDKLoginManagerLoginResult, NSError>() {
                @Override
                public void invoke(FBSDKLoginManagerLoginResult result, NSError error) {
                    if (error != null) {
                        log("Failed to request publish permissions: %s", error);
                        listener.onError("An unknown error happened!");
                    } else if (result.isCancelled()) {
                        log("Cancelled request for publish permissions!");
                        listener.onCancel();
                    } else {
                        if (!result.getGrantedPermissions().containsAll(publishPermissions)) {
                            log("Failed to request publish permissions: Permissions declined (%s)",
                                    result.getDeclinedPermissions());
                            listener.onError("The following permissions have been declined: "
                                    + result.getDeclinedPermissions().toString());
                        } else {
                            log("Successfully requested publish permissions");
                            listener.onSuccess();
                        }
                    }
                }
            });
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:27,代码来源:FacebookHandler.java

示例3: getCellForItem

import org.robovm.objc.block.VoidBlock2; //导入依赖的package包/类
@Override
public UICollectionViewCell getCellForItem(UICollectionView collectionView, NSIndexPath indexPath) {
    final AAPLGridViewCell cell = (AAPLGridViewCell) collectionView.dequeueReusableCell(CellReuseIdentifier,
            indexPath);

    // Increment the cell's tag
    final long currentTag = cell.getTag() + 1;
    cell.setTag(currentTag);

    PHAsset asset = assetsFetchResults.get(indexPath.getItem());
    imageManager.requestImageForAsset(asset, assetGridThumbnailSize, PHImageContentMode.AspectFill, null,
            new VoidBlock2<UIImage, PHImageRequestResult>() {
                @Override
                public void invoke(UIImage result, PHImageRequestResult b) {
                    // Only update the thumbnail if the cell tag hasn't
                    // changed. Otherwise, the cell has been re-used.
                    if (cell.getTag() == currentTag) {
                        cell.setThumbnailImage(result);
                    }
                }
            });
    return cell;
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:24,代码来源:AAPLAssetGridViewController.java

示例4: updateSubtitleIfNeeded

import org.robovm.objc.block.VoidBlock2; //导入依赖的package包/类
public void updateSubtitleIfNeeded() {
    if (subtitle == null) {
        // for the subtitle, we reverse geocode the lat/long for a proper
        // location string name
        CLLocation location = new CLLocation(coordinate.getLatitude(), coordinate.getLongitude());
        CLGeocoder geocoder = new CLGeocoder();
        geocoder.reverseGeocodeLocation(location, new VoidBlock2<NSArray<CLPlacemark>, NSError>() {
            @Override
            public void invoke(NSArray<CLPlacemark> placemarks, NSError error) {
                if (placemarks.size() > 0) {
                    CLPlacemark placemark = placemarks.get(0);
                    subtitle = String.format("Near %s", getStringForPlacemark(placemark));
                }
            }
        });
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:18,代码来源:PhotoAnnotation.java

示例5: didSelectRow

import org.robovm.objc.block.VoidBlock2; //导入依赖的package包/类
/**
 * Loads and launches a store product view controller with a selected
 * product
 * 
 * @param tableView
 * @param indexPath
 */
@Override
public void didSelectRow(UITableView tableView, NSIndexPath indexPath) {
    Product item = myProducts.get(indexPath.getSection());

    // Create a product dictionary using the selected product's iTunes
    // identifer
    SKStoreProductParameters parameters = new SKStoreProductParameters().setITunesItemIdentifier(item
            .getProductID());

    // Attempt to load the selected product from the App Store, display the
    // store product view controller if success
    // and print an error message, otherwise.
    storeProductViewController.loadProduct(parameters, new VoidBlock2<Boolean, NSError>() {
        @Override
        public void invoke(Boolean result, NSError error) {
            if (result) {
                presentViewController(storeProductViewController, true, null);
            } else {
                System.err.println("Error message: " + error.getLocalizedDescription());
            }
        }
    });
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:31,代码来源:IAPStoreProductViewController.java

示例6: updateImage

import org.robovm.objc.block.VoidBlock2; //导入依赖的package包/类
private void updateImage() {
    lastImageViewSize = imageView.getBounds().getSize();

    double scale = UIScreen.getMainScreen().getScale();
    CGSize targetSize = new CGSize(imageView.getBounds().getWidth() * scale, imageView.getBounds().getHeight()
            * scale);

    PHImageRequestOptions options = new PHImageRequestOptions();

    // Download from cloud if necessary
    options.setNetworkAccessAllowed(true);
    options.setProgressHandler(new VoidBlock4<Double, NSError, BooleanPtr, NSDictionary<?, ?>>() {
        @Override
        public void invoke(final Double progress, NSError error, BooleanPtr c, NSDictionary<?, ?> d) {
            DispatchQueue.getMainQueue().async(new Runnable() {
                @Override
                public void run() {
                    progressView.setProgress(progress.floatValue());
                    progressView.setHidden(progress <= 0 || progress >= 1);
                };
            });
        }
    });
    PHImageManager.getDefaultManager().requestImageForAsset(asset, targetSize, PHImageContentMode.AspectFill,
            options,
            new VoidBlock2<UIImage, PHImageRequestResult>() {
                @Override
                public void invoke(final UIImage result, PHImageRequestResult info) {
                    if (result != null) {
                        imageView.setImage(result);
                    }
                }
            });
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:35,代码来源:AAPLAssetViewController.java

示例7: handleTrashButtonItem

import org.robovm.objc.block.VoidBlock2; //导入依赖的package包/类
@IBAction
private void handleTrashButtonItem(NSObject sender) {
    VoidBlock2<Boolean, NSError> completionHandler = new VoidBlock2<Boolean, NSError>() {
        @Override
        public void invoke(Boolean success, NSError error) {
            if (success) {
                DispatchQueue.getMainQueue().async(new Runnable() {
                    @Override
                    public void run() {
                        getNavigationController().popViewController(true);
                    }
                });
            } else {
                System.err.println("Error: " + error);
            }
        }
    };
    if (assetCollection != null) {
        // Remove asset from album
        PHPhotoLibrary.getSharedPhotoLibrary().performChanges(new Runnable() {
            @Override
            public void run() {
                PHAssetCollectionChangeRequest changeRequest = new PHAssetCollectionChangeRequest(assetCollection);
                changeRequest.removeAssets(new NSArray<PHAsset>(asset));
            }
        }, completionHandler);
    } else {
        // Delete asset from library
        PHPhotoLibrary.getSharedPhotoLibrary().performChanges(new Runnable() {
            @Override
            public void run() {
                PHAssetChangeRequest.deleteAssets(new NSArray<PHAsset>(asset));
            }
        }, completionHandler);
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:37,代码来源:AAPLAssetViewController.java

示例8: handleAddButtonItem

import org.robovm.objc.block.VoidBlock2; //导入依赖的package包/类
@IBAction
private void handleAddButtonItem(NSObject sender) {
    // Create a random dummy image.
    CGRect rect = Math.random() % 2 == 0 ? new CGRect(0, 0, 400, 300) : new CGRect(0, 0, 300, 400);
    UIGraphics.beginImageContext(rect.getSize(), false, 1.0);
    UIColor.fromHSBA(Math.random() % 100 / 100, 1, 1, 1).setFill();
    UIGraphics.rectFill(rect, CGBlendMode.Normal);
    final UIImage image = UIGraphics.getImageFromCurrentImageContext();
    UIGraphics.endImageContext();

    // Add it to the photo library
    PHPhotoLibrary.getSharedPhotoLibrary().performChanges(new Runnable() {
        @Override
        public void run() {
            PHAssetChangeRequest assetChangeRequest = PHAssetChangeRequest.createImageAssetCreationRequest(image);

            if (assetCollection != null) {
                PHAssetCollectionChangeRequest assetCollectionChangeRequest = new PHAssetCollectionChangeRequest(
                        assetCollection);
                assetCollectionChangeRequest.addAssets(new NSArray<>(assetChangeRequest
                        .getPlaceholderForCreatedAsset()));
            }
        }
    }, new VoidBlock2<Boolean, NSError>() {
        @Override
        public void invoke(Boolean success, NSError error) {
            if (!success) {
                System.err.println("Error creating asset: " + error);
            }
        }
    });
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:33,代码来源:AAPLAssetGridViewController.java

示例9: getIndexPathsFromIndexesWithSection

import org.robovm.objc.block.VoidBlock2; //导入依赖的package包/类
private NSArray<NSIndexPath> getIndexPathsFromIndexesWithSection(NSIndexSet indexSet, final long section) {
    final NSArray<NSIndexPath> indexPaths = new NSMutableArray<>(indexSet.size());
    indexSet.enumerateIndexes(new VoidBlock2<Long, BooleanPtr>() {
        @Override
        public void invoke(Long idx, BooleanPtr stop) {
            indexPaths.add(NSIndexPath.item(idx, section));
        }
    });
    return indexPaths;
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:11,代码来源:AAPLAssetGridViewController.java

示例10: startGUISignIn

import org.robovm.objc.block.VoidBlock2; //导入依赖的package包/类
@Override
protected void startGUISignIn() {
    Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Starting GUI sign in.");

    VoidBlock2<FBSDKLoginManagerLoginResult, NSError> result = new VoidBlock2<FBSDKLoginManagerLoginResult, NSError>() {

        @Override
        public void invoke(FBSDKLoginManagerLoginResult loginResult, NSError nsError) {
            if (nsError != null) {
                signOut();
                Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Error while trying to sign in: " + nsError.getLocalizedDescription());
                callback.onError(new GDXFacebookError(nsError.getLocalizedDescription()));
            } else if (loginResult.isCancelled()) {
                Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Sign fail by user.");
                signOut();
                callback.onCancel();
            } else {
                accessToken = new GDXFacebookAccessToken(FBSDKAccessToken.getCurrentAccessToken().getTokenString(), FBSDKAccessToken.getCurrentAccessToken().getExpirationDate().toDate().getTime());
                storeNewToken(accessToken);
                Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Sign successful. User token: " + accessToken.getToken());
                callback.onSuccess(new SignInResult(accessToken, "Sign in successful."));
            }

        }

    };

    List<String> listPermissions = new ArrayList<String>();

    for (int i = 0; i < permissions.size; i++) {
        listPermissions.add(permissions.get(i));
    }

    if (this.signInMode == SignInMode.PUBLISH) {
        loginManager.logInWithPublishPermissions(listPermissions, result);
    } else {
        loginManager.logInWithReadPermissions(listPermissions, result);
    }


}
 
开发者ID:TomGrill,项目名称:gdx-facebook,代码行数:42,代码来源:IOSGDXFacebook.java

示例11: createImagePicker

import org.robovm.objc.block.VoidBlock2; //导入依赖的package包/类
private void createImagePicker() {
    imagePicker = new UIImagePickerController();
    imagePicker.setSourceType(UIImagePickerControllerSourceType.Camera);

    imagePicker.setMediaTypes(Arrays.asList("public.movie"));
    imagePicker.setCameraCaptureMode(UIImagePickerControllerCameraCaptureMode.Video);

    imagePicker.setAllowsEditing(false);
    imagePicker.setShowsCameraControls(false);
    imagePicker.setCameraViewTransform(CGAffineTransform.Identity());

    // not all devices have two cameras or a flash so just check here
    if (UIImagePickerController.isCameraDeviceAvailable(UIImagePickerControllerCameraDevice.Rear)) {
        imagePicker.setCameraDevice(UIImagePickerControllerCameraDevice.Rear);
        if (UIImagePickerController.isCameraDeviceAvailable(UIImagePickerControllerCameraDevice.Front)) {
            cameraSelectionButton.setAlpha(1);
            showCameraSelection = true;
        }
    } else {
        imagePicker.setCameraDevice(UIImagePickerControllerCameraDevice.Front);
    }

    if (UIImagePickerController.isFlashAvailableForCameraDevice(imagePicker.getCameraDevice())) {
        imagePicker.setCameraFlashMode(UIImagePickerControllerCameraFlashMode.Off);
        flashModeButton.setAlpha(1);
        showFlashMode = true;
    }

    imagePicker.setVideoQuality(UIImagePickerControllerQualityType._640x480);

    imagePicker.setDelegate(new UIImagePickerControllerDelegateAdapter() {
        @Override
        public void didFinishPickingMedia(UIImagePickerController picker, UIImagePickerControllerEditingInfo info) {
            NSURL videoURL = info.getMediaURL();

            boolean okToSaveVideo = UIVideo.isCompatibleWithSavedPhotosAlbum(new File(videoURL.getPath()));
            if (okToSaveVideo) {
                UIVideo.saveToPhotosAlbum(new File(videoURL.getPath()), new VoidBlock2<String, NSError>() {
                    @Override
                    public void invoke(String a, NSError b) {
                        showControls();
                    }
                });
            } else {
                showControls();
            }

        }
    });
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:51,代码来源:RootViewController.java


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