<commit_before>package com.nostra13.universalimageloader.imageloader;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.util.Log;

/**
 * Decodes image from URL (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png") into {@link Bitmap}
 * 
 * @author <NAME> (nostra13[at]gmail[dot]com)
 */
final class ImageDecoder {

	private static final String TAG = ImageDecoder.class.getSimpleName();

	private ImageDecoder() {
	}

	/**
	 * Decodes image to {@link Bitmap}. Image is scaled close to incoming {@link ImageSize image size} during decoding.
	 * Initial image size is reduced by the power of 2 (according Android recommendations)
	 * 
	 * @param imageUrl
	 *            Image URL
	 * @param targetImageSize
	 *            Image size to scale to during decoding
	 * @return Decoded bitmap
	 * @throws IOException
	 */
	public static Bitmap decodeFile(URL imageUrl, ImageSize targetImageSize) throws IOException {
		InputStream is = imageUrl.openStream();
		Options decodeOptions = getBitmapOptionsForImageDecoding(is, targetImageSize);
		is.close();

		is = imageUrl.openStream();
		Bitmap result = decodeImageStream(is, decodeOptions);
		is.close();

		return result;
	}

	private static Options getBitmapOptionsForImageDecoding(InputStream imageStream, ImageSize targetImageSize) {
		Options options = new Options();
		options.inSampleSize = computeImageScale(imageStream, targetImageSize);
		return options;
	}

	private static int computeImageScale(InputStream imageStream, ImageSize targetImageSize) {
		int width = targetImageSize.width;<commit_msg>Java docs fix<commit_after>package com.nostra13.universalimageloader.imageloader;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.util.Log;

/**
 * Decodes images to {@link Bitmap}
 * 
 * @author <NAME> (nostra13[at]gmail[dot]com)
 */
final class ImageDecoder {

	private static final String TAG = ImageDecoder.class.getSimpleName();

	private ImageDecoder() {
	}

	/**
	 * Decodes image from URL into {@link Bitmap}. Image is scaled close to incoming {@link ImageSize image size} during
	 * decoding. Initial image size is reduced by the power of 2 (according Android recommendations)
	 * 
	 * @param imageUrl
	 *            Image URL (<b>i.e.:</b> "http://site.com/image.png", "file:///mnt/sdcard/image.png")
	 * @param targetImageSize
	 *            Image size to scale to during decoding
	 * @return Decoded bitmap
	 * @throws IOException
	 */
	public static Bitmap decodeFile(URL imageUrl, ImageSize targetImageSize) throws IOException {
		InputStream is = imageUrl.openStream();
		Options decodeOptions = getBitmapOptionsForImageDecoding(is, targetImageSize);
		is.close();

		is = imageUrl.openStream();
		Bitmap result = decodeImageStream(is, decodeOptions);
		is.close();

		return result;
	}

	private static Options getBitmapOptionsForImageDecoding(InputStream imageStream, ImageSize targetImageSize) {
		Options options = new Options();
		options.inSampleSize = computeImageScale(imageStream, targetImageSize);
		return options;
	}

	private static int computeImageScale(InputStream imageStream, ImageSize targetImageSize) {
		int width = targetImageSize.width;
{'fraction_non_alphanumeric': 0.09812409812409813, 'fraction_numerical': 0.002886002886002886, 'mean_word_length': 4.644951140065147, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1797771', 'n_tokens_mistral': 1026, 'n_tokens_neox': 938, 'n_words': 281}