<commit_before>package org.smerty.zooborns;

import android.R;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter {
    private ZooBorns that;
    

    public ImageAdapter(ZooBorns c) {
    	that = c;
    }

    public int getCount() {
        return (that.imgCache != null) ? that.imgCache.images.size() : 0;
    }

    public Object getItem(int position) {
        return null;
    }

    public long getItemId(int position) {
        return 0;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
    	//Log.d("ImageAdapter", "getView()");
    	
        ImageView imageView;
        if (convertView == null) {
            imageView = new ImageView(that);
            imageView.setLayoutParams(new GridView.LayoutParams(that.columnWidth, that.columnWidth));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageView.setPadding(1, 1, 1, 1);
        } else {
            imageView = (ImageView) convertView;
        }
        if (position < that.imgCache.images.size() && (that.imgCache.images.get(position).isComplete() || that.imgCache.images.get(position).isFailed())) {
        	
        	try {
        		if (that.imgCache.images.get(position).getBitmapIcon() != null) {
         		imageView.setImageBitmap(that.imgCache.images.get(position).getBitmapIcon());
        		
        		}
        		else {
        			imageView.setImageDrawable(that.getResources().getDrawable(R.drawable.ic_menu_delete));
        		}
			} 
        	finally {
        		//do nothing
        	}
        }
        else {<commit_msg>check to see if it is an ImageView before casting it<commit_after>package org.smerty.zooborns;

import android.R;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter {
    private ZooBorns that;
    
    public ImageAdapter(ZooBorns c) {
    	that = c;
    }

    public int getCount() {
        return (that.imgCache != null) ? that.imgCache.images.size() : 0;
    }

    public Object getItem(int position) {
        return null;
    }

    public long getItemId(int position) {
        return 0;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
    	//Log.d("ImageAdapter", "getView()");
    	
        ImageView imageView;
        if (convertView == null) {
            imageView = new ImageView(that);
            imageView.setLayoutParams(new GridView.LayoutParams(that.columnWidth, that.columnWidth));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageView.setPadding(1, 1, 1, 1);
        } else {
        	if (convertView instanceof ImageView) {
        		imageView = (ImageView) convertView;
        	}
        	else {
        		Log.d("ImageAdapter:getView", "View was not an ImageView at position: " + position);
        		return null;
        	}
        }
        if (position < that.imgCache.images.size() && (that.imgCache.images.get(position).isComplete() || that.imgCache.images.get(position).isFailed())) {
        	
        	try {
        		if (that.imgCache.images.get(position).getBitmapIcon() != null) {
         		imageView.setImageBitmap(that.imgCache.images.get(position).getBitmapIcon());
        		
        		}
        		else {
        			imageView.setImageDrawable(that.getResources().getDrawable(R.drawable.ic_menu_delete));
        		}
			} 
        	finally {
        		//do nothing
        	}
        }
        else {
{'fraction_non_alphanumeric': 0.110752688172043, 'fraction_numerical': 0.0032258064516129032, 'mean_word_length': 2.31935771632471, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1548582', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1109, 'n_words': 214}