<commit_before>package kr.co.namsang.mb.barista.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Collections;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import kr.co.namsang.mb.barista.io.FileCache;
import kr.co.namsang.mb.barista.io.MemoryCache;
import kr.co.namsang.mb.barista.util.IOUtils;
import kr.co.namsang.mb.barista.util.LogUtils;
import kr.co.namsang.mb.barista.util.UiUtils;

import kr.co.namsang.mb.barista.R;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.ImageView;

public class ImageLoader 
{    
    MemoryCache memoryCache = new MemoryCache();
    FileCache fileCache;
    private Map<ImageView, String> imageViews = Collections.synchronizedMap(new WeakHashMap<ImageView, String>());
    ExecutorService executorService; 
    
    private boolean bHideStub = false;
    
    public static void displayImage(Context context, String url, ImageView imageView) {
    	ImageLoader imageLoader = new ImageLoader(context);
    	imageLoader.displayImage(url,  imageView);
    }
    
    public ImageLoader(Context context) {
        fileCache = new FileCache(context);
        executorService = Executors.newFixedThreadPool(5);
    }
    
    public static void setStubId(int stubId) {
    	stub_id = stubId;
    }
    
    public void setStubEnable(boolean enable) {
    	bHideStub = !enable;
    }
    
    public static int stub_id = R.drawable.stub;
    public void displayImage(String url, ImageView imageView) {
        imageViews.put(imageView, url);
        Bitmap bitmap = memoryCache.get(url);
        if (bitmap != null) {
            imageView.setImageBitmap(bitmap);
        }
        else {
            queuePhoto(url, imageView);
            if (!bHideStub)
            	imageView.setImageResource(stub_id);
        }
    }
        
    private void queuePhoto(String url, ImageView imageView) {
        PhotoToLoad p = new PhotoToLoad(url, imageView);
        executorService.submit(new PhotosLoader(p));
    }
    
    private Bitmap getBitmap(String url) {<commit_msg>Image Loader null인 경우 수정<commit_after>package kr.co.namsang.mb.barista.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Collections;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import kr.co.namsang.mb.barista.io.FileCache;
import kr.co.namsang.mb.barista.io.MemoryCache;
import kr.co.namsang.mb.barista.util.IOUtils;
import kr.co.namsang.mb.barista.util.LogUtils;
import kr.co.namsang.mb.barista.util.UiUtils;

import kr.co.namsang.mb.barista.R;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.ImageView;

public class ImageLoader 
{    
    MemoryCache memoryCache = new MemoryCache();
    FileCache fileCache;
    private Map<ImageView, String> imageViews = Collections.synchronizedMap(new WeakHashMap<ImageView, String>());
    ExecutorService executorService; 
    
    private boolean bHideStub = false;
    
    public static void displayImage(Context context, String url, ImageView imageView) {
    	ImageLoader imageLoader = new ImageLoader(context);
    	imageLoader.displayImage(url,  imageView);
    }
    
    public ImageLoader(Context context) {
        fileCache = new FileCache(context);
        executorService = Executors.newFixedThreadPool(5);
    }
    
    public static void setStubId(int stubId) {
    	stub_id = stubId;
    }
    
    public void setStubEnable(boolean enable) {
    	bHideStub = !enable;
    }
    
    public static int stub_id = R.drawable.stub;
    public void displayImage(String url, ImageView imageView) {
        imageViews.put(imageView, url);
        Bitmap bitmap = memoryCache.get(url);
        if (bitmap != null) {
            imageView.setImageBitmap(bitmap);
        }
        else {
            queuePhoto(url, imageView);
            if (!bHideStub)
            	imageView.setImageResource(stub_id);
        }
    }
        
    private void queuePhoto(String url, ImageView imageView) {
        PhotoToLoad p = new PhotoToLoad(url, imageView);
        executorService.submit(new PhotosLoader(p));
    }
    
    private Bitmap getBitmap(String url) {
    	if (url == null) return null;
{'fraction_non_alphanumeric': 0.09562951082598235, 'fraction_numerical': 0.00040096230954290296, 'mean_word_length': 3.4150442477876104, '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': '3219197', 'n_tokens_mistral': 1517, 'n_tokens_neox': 1525, 'n_words': 319}