List of usage examples for org.apache.cordova FileUtils stripFileProtocol
private String stripFileProtocol(String filePath)
From source file:com.phonegap.plugins.wsiCameraLauncher.WsiCameraLauncher.java
License:Apache License
/** * In the special case where the default width, height and quality are * unchanged we just write the file out to disk saving the expensive * Bitmap.compress function./*from www . j ava2 s. com*/ * * @param uri * @throws FileNotFoundException * @throws IOException */ private void writeUncompressedImage(Uri uri) throws FileNotFoundException, IOException { FileInputStream fis = new FileInputStream(FileUtils.stripFileProtocol(imageUri.toString())); OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri); byte[] buffer = new byte[4096]; int len; while ((len = fis.read(buffer)) != -1) { os.write(buffer, 0, len); } os.flush(); os.close(); fis.close(); }
From source file:com.phonegap.plugins.wsiCameraLauncher.WsiCameraLauncher.java
License:Apache License
/** * Cleans up after picture taking. Checking for duplicates and that kind of * stuff./* www.ja v a2 s.c om*/ * * @param newImage */ private void cleanup(int imageType, Uri oldImage, Uri newImage, Bitmap bitmap) { if (bitmap != null) { bitmap.recycle(); } // Clean up initial camera-written image file. (new File(FileUtils.stripFileProtocol(oldImage.toString()))).delete(); checkForDuplicateImage(imageType); // Scan for the gallery to update pic refs in gallery if (this.saveToPhotoAlbum && newImage != null) { this.scanForGallery(newImage); } System.gc(); }
From source file:com.phonegap.plugins.wsiCapture.WsiCapture.java
License:Apache License
/** * Get the Image specific attributes/*from w w w . ja v a 2s. c o m*/ * * @param filePath * path to the file * @param obj * represents the Media File Data * @return a JSONObject that represents the Media File Data * @throws JSONException */ private JSONObject getImageData(String filePath, JSONObject obj) throws JSONException { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(FileUtils.stripFileProtocol(filePath), options); obj.put("height", options.outHeight); obj.put("width", options.outWidth); return obj; }