<commit_before>package jp.techblog.epsiloncode.soundpoolwrapper;

import android.content.Context;
import android.media.SoundPool;
import android.util.SparseIntArray;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by yuishihara on 15/09/27.
 */
public class SoundPoolWrapper implements SoundPool.OnLoadCompleteListener {
    public interface OnLoadCompleteCallback {
        void onLoadComplete(boolean status);
    }

    private SoundPool mSoundPool;
    private SparseIntArray mResourceIdToSoundIdMap = new SparseIntArray();
    private List<Integer> mLoadedResourceIds = new ArrayList<>();
    private Map<Integer, OnLoadCompleteCallback> mResourceIdToCallbackMap = new HashMap<>();

    public SoundPoolWrapper(int maxStreams, int streamType, int srcQuality) {
        this(new SoundPool(maxStreams, streamType, srcQuality));
    }

    public SoundPoolWrapper(SoundPool soundPool) {
        mSoundPool = soundPool;
        mSoundPool.setOnLoadCompleteListener(this);
    }

    public void autoPause() {
        mSoundPool.autoPause();
    }

    public void autoResume() {
        mSoundPool.autoResume();
    }

    public void load(Context context, int resourceId, int priority) {
        load(context, resourceId, priority, null);
    }

    public void load(Context context, int resourceId, int priority, OnLoadCompleteCallback callback) {
        int soundId = mSoundPool.load(context, resourceId, priority);
        mResourceIdToSoundIdMap.put(resourceId, soundId);
        if (callback != null) {
            mResourceIdToCallbackMap.put(resourceId, callback);
        }
    }

    @Override
    public void onLoadComplete(SoundPool soundPool, int soundId, int status) {
        int resourceId = toResourceId(soundId);
        OnLoadCompleteCallback callback = mResourceIdToCallbackMap.get(resourceId);
        if (callback != null) {
            // Status 0 means success
            callback.onLoadComplete(status == 0);
            mResourceIdToCallbackMap.remove(resourceId);
        }
        mLoadedResourceIds.add(resourceId);
    }<commit_msg>Bugfix<commit_after>package jp.techblog.epsiloncode.soundpoolwrapper;

import android.content.Context;
import android.media.SoundPool;
import android.util.SparseIntArray;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by yuishihara on 15/09/27.
 */
public class SoundPoolWrapper implements SoundPool.OnLoadCompleteListener {
    public interface OnLoadCompleteCallback {
        void onLoadComplete(boolean status);
    }

    private SoundPool mSoundPool;
    private SparseIntArray mResourceIdToSoundIdMap = new SparseIntArray();
    private List<Integer> mLoadedResourceIds = new ArrayList<>();
    private Map<Integer, OnLoadCompleteCallback> mResourceIdToCallbackMap = new HashMap<>();

    public SoundPoolWrapper(int maxStreams, int streamType, int srcQuality) {
        this(new SoundPool(maxStreams, streamType, srcQuality));
    }

    public SoundPoolWrapper(SoundPool soundPool) {
        mSoundPool = soundPool;
        mSoundPool.setOnLoadCompleteListener(this);
    }

    public void autoPause() {
        mSoundPool.autoPause();
    }

    public void autoResume() {
        mSoundPool.autoResume();
    }

    public void load(Context context, int resourceId, int priority) {
        load(context, resourceId, priority, null);
    }

    public void load(Context context, int resourceId, int priority, OnLoadCompleteCallback callback) {
        int soundId = mSoundPool.load(context, resourceId, priority);
        mResourceIdToSoundIdMap.put(resourceId, soundId);
        if (callback != null) {
            mResourceIdToCallbackMap.put(resourceId, callback);
        }
    }

    @Override
    public void onLoadComplete(SoundPool soundPool, int soundId, int status) {
        int resourceId = toResourceId(soundId);
        mLoadedResourceIds.add(resourceId);
        OnLoadCompleteCallback callback = mResourceIdToCallbackMap.get(resourceId);
        if (callback != null) {
            // Status 0 means success
            callback.onLoadComplete(status == 0);
            mResourceIdToCallbackMap.remove(resourceId);
        }
    }
{'fraction_non_alphanumeric': 0.08687485325193707, 'fraction_numerical': 0.0037567504108945763, 'mean_word_length': 3.45141065830721, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '682607', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1154, 'n_words': 272}