com.hippo.io.UniFileInputStreamPipe Java Examples
The following examples show how to use
com.hippo.io.UniFileInputStreamPipe.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpiderDen.java From MHViewer with Apache License 2.0 | 6 votes |
@Nullable public InputStreamPipe openDownloadInputStreamPipe(int index) { UniFile dir = getDownloadDir(); if (dir == null) { return null; } for (int i = 0; i < 2; i++) { UniFile file = findImageFile(dir, index); if (file != null) { return new UniFileInputStreamPipe(file); } else if (!copyFromCacheToDownloadDir(index)) { return null; } } return null; }
Example #2
Source File: HeaderImageView.java From Nimingban with Apache License 2.0 | 6 votes |
private void setImageFile(UniFile file) { if (file == null) { return; } Object object = NMBApplication.getImageWrapperHelper(getContext()) .decode(new UniFileInputStreamPipe(file)); if (object != null) { ImageWrapper imageWrapper = (ImageWrapper) object; imageWrapper.start(); Drawable drawable = new ImageDrawable(imageWrapper); removeDrawableAndHolder(); setImageDrawable(drawable); mImageFile = file; mContainer = null; } }
Example #3
Source File: SpiderDen.java From EhViewer with Apache License 2.0 | 6 votes |
@Nullable public InputStreamPipe openDownloadInputStreamPipe(int index) { UniFile dir = getDownloadDir(); if (dir == null) { return null; } for (int i = 0; i < 2; i++) { UniFile file = findImageFile(dir, index); if (file != null) { return new UniFileInputStreamPipe(file); } else if (!copyFromCacheToDownloadDir(index)) { return null; } } return null; }
Example #4
Source File: DownloadsScene.java From MHViewer with Apache License 2.0 | 5 votes |
@Override public InputStreamPipe get() { ensureFile(); if (mFile != null) { return new UniFileInputStreamPipe(mFile); } else { return null; } }
Example #5
Source File: GalleryActivity2.java From Nimingban with Apache License 2.0 | 5 votes |
@Override public void bindPagerHolder(GalleryHolder holder, int position) { Object object = NMBApplication.getImageWrapperHelper(GalleryActivity2.this) .decode(new UniFileInputStreamPipe(mImageFile)); if (object != null) { ImageWrapper imageWrapper = (ImageWrapper) object; imageWrapper.start(); Drawable drawable = new ImageDrawable(imageWrapper); holder.galleryPage.showDrawable(drawable); } else { holder.galleryPage.showFailedText(); } }
Example #6
Source File: HeaderImageView.java From Nimingban with Apache License 2.0 | 5 votes |
@Override public InputStreamPipe get() { if (mTempFile == null) { return null; } else { return new UniFileInputStreamPipe(mTempFile); } }
Example #7
Source File: DownloadsScene.java From EhViewer with Apache License 2.0 | 5 votes |
@Override public InputStreamPipe get() { ensureFile(); if (mFile != null) { return new UniFileInputStreamPipe(mFile); } else { return null; } }
Example #8
Source File: QRCodeScanActivity.java From Nimingban with Apache License 2.0 | 4 votes |
@SuppressLint("StaticFieldLeak") private void scanImage(final Uri uri) { if (progressDialog != null) return; progressDialog = new ProgressDialogBuilder(this) .setTitle(R.string.please_wait) .setMessage(R.string.qr_scan_processing) .setCancelable(false) .show(); new AsyncTask<Void, Void, String>() { @Override protected String doInBackground(Void... voids) { UniFile file = UniFile.fromUri(QRCodeScanActivity.this, uri); if (file == null) return null; // ZXing can't process large image Bitmap bitmap = BitmapUtils.decodeStream(new UniFileInputStreamPipe(file), 1024, 1024); if (bitmap == null) return null; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap.getPixels(pixels, 0, width, 0, 0, width, height); bitmap.recycle(); int[] newPixels = null; for (int i = 0; i < 4; i++) { if (i > 0) { newPixels = BitmapUtils.rotate(pixels, width, height, newPixels); int temp = width; width = height; height = temp; int[] tempPixels = pixels; pixels = newPixels; newPixels = tempPixels; } RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels); final HybridBinarizer hybBin = new HybridBinarizer(source); final BinaryBitmap bBitmap = new BinaryBitmap(hybBin); QRCodeReader reader = new QRCodeReader(); Map<DecodeHintType, Boolean> hints = new HashMap<>(); try { return reader.decode(bBitmap, hints).getText(); } catch (NotFoundException | FormatException | ChecksumException e) { // Try PURE_BARCODE hints.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE); reader.reset(); try { return reader.decode(bBitmap, hints).getText(); } catch (NotFoundException | FormatException | ChecksumException ee) { // pass } } } return null; } @Override protected void onPostExecute(String text) { if (progressDialog != null) { progressDialog.dismiss(); progressDialog = null; } if (text != null) { processCookieText(text); } else { Toast.makeText(QRCodeScanActivity.this, R.string.qr_scan_invalid, Toast.LENGTH_SHORT).show(); } } }.execute(); }