<commit_before>/*
 * Copyright (c) 2019 toastkidjp.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompany this distribution.
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html.
 */
package jp.toastkid.image.preview

import android.os.Build
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import coil.ImageLoader
import coil.decode.GifDecoder
import coil.decode.ImageDecoderDecoder
import coil.load
import java.io.File

/**
 * @author toastkidjp
 */
class ViewHolder(private val view: ImageView) : RecyclerView.ViewHolder(view) {

    fun setImage(path: String) {
        view.load(File(path), imageLoader)
    }

    private val imageLoader = ImageLoader.Builder(view.context)
            .componentRegistry {
                add(if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) ImageDecoderDecoder(view.context) else GifDecoder())
            }
            .build()

}<commit_msg>refactor #853 Modify making imageLoader.<commit_after>/*
 * Copyright (c) 2019 toastkidjp.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompany this distribution.
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html.
 */
package jp.toastkid.image.preview

import android.os.Build
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import coil.ComponentRegistry
import coil.ImageLoader
import coil.decode.GifDecoder
import coil.decode.ImageDecoderDecoder
import coil.load
import java.io.File

/**
 * @author toastkidjp
 */
class ViewHolder(private val view: ImageView) : RecyclerView.ViewHolder(view) {

    fun setImage(path: String) {
        view.load(File(path), imageLoader)
    }

    private val imageLoader = ImageLoader.Builder(view.context)
            .components() {
                ComponentRegistry.Builder()
                    .add(
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) ImageDecoderDecoder.Factory()
                        else GifDecoder.Factory()
                    )
            }
            .build()

}
{'fraction_non_alphanumeric': 0.0906318082788671, 'fraction_numerical': 0.008278867102396514, 'mean_word_length': 3.092691622103387, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5281493', 'n_tokens_mistral': 671, 'n_tokens_neox': 618, 'n_words': 170}