<commit_before>package ru.recoilme.freeamp.artworks;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.support.v4.util.LruCache;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import ru.recoilme.freeamp.ClsTrack;
import ru.recoilme.freeamp.MediaUtils;
import ru.recoilme.freeamp.R;

import java.util.ArrayList;

/**
 * Created by recoil on 29.01.14.
 */
public class AdpArtworks extends BaseAdapter {

    ArrayList<ClsTrack> data;
    Activity activity;
    private int scrollState;
    Bitmap placeHolder;
    AbsListView.LayoutParams layoutParams;
    Animation fadeIn;

    //Создаем LruCache: http://developer.android.com/training/displaying-bitmaps/cache-bitmap.html
    final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
    final int cacheSize = Math.min(20 * 360000,(int)maxMemory/2); // <7MiB = 300width * 300heigth * 4bytesperpixel * 20images

    LruCache bitmapCache = new LruCache(Math.max((int)maxMemory/8,cacheSize)) {
        protected int sizeOf(int key, Bitmap value) {
            return value.getRowBytes() * value.getHeight();//здесь по чесноку считаем
        }
    };


    public void addBitmapToMemoryCache(Activity activity, int key, Bitmap bitmap) {
        synchronized (bitmapCache) {
            if (getBitmapFromMemCache(activity, key) == null) {
                bitmapCache.put(key, bitmap);
            }
        }
    }

    public Bitmap getBitmapFromMemCache(Activity activity,int key) {
        return (Bitmap) bitmapCache.get(key);
    }

    public AdpArtworks(Activity activity, ArrayList<ClsTrack> data){
        this.data = data;
        this.activity = activity;

        int iDisplayWidth = activity.getResources().getDisplayMetrics().widthPixels ;
        int numColumns = (iDisplayWidth / 310);
        int width = (iDisplayWidth / numColumns);<commit_msg>124: error division on zero<commit_after>package ru.recoilme.freeamp.artworks;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.preference.PreferenceManager;
import android.support.v4.util.LruCache;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import ru.recoilme.freeamp.ClsTrack;
import ru.recoilme.freeamp.MediaUtils;
import ru.recoilme.freeamp.R;

import java.util.ArrayList;

/**
 * Created by recoil on 29.01.14.
 */
public class AdpArtworks extends BaseAdapter {

    ArrayList<ClsTrack> data;
    Activity activity;
    private int scrollState;
    Bitmap placeHolder;
    AbsListView.LayoutParams layoutParams;
    Animation fadeIn;

    //Создаем LruCache: http://developer.android.com/training/displaying-bitmaps/cache-bitmap.html
    final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
    final int cacheSize = Math.min(20 * 360000,(int)maxMemory/2); // <7MiB = 300width * 300heigth * 4bytesperpixel * 20images

    LruCache bitmapCache = new LruCache(Math.max((int)maxMemory/8,cacheSize)) {
        protected int sizeOf(int key, Bitmap value) {
            return value.getRowBytes() * value.getHeight();//здесь по чесноку считаем
        }
    };


    public void addBitmapToMemoryCache(Activity activity, int key, Bitmap bitmap) {
        synchronized (bitmapCache) {
            if (getBitmapFromMemCache(activity, key) == null) {
                bitmapCache.put(key, bitmap);
            }
        }
    }

    public Bitmap getBitmapFromMemCache(Activity activity,int key) {
        return (Bitmap) bitmapCache.get(key);
    }

    public AdpArtworks(Activity activity, ArrayList<ClsTrack> data){
        this.data = data;
        this.activity = activity;

        int iDisplayWidth= PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext()).getInt("screenWidth",800);
        int numColumns = (iDisplayWidth / 310);
        int width = (iDisplayWidth / numColumns);
{'fraction_non_alphanumeric': 0.10235162374020157, 'fraction_numerical': 0.016573348264277716, 'mean_word_length': 3.735949098621421, 'pattern_counts': {'":': 0, '<': 9, '<?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': '3219971', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1308, 'n_words': 281}