<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.yobidashi.media.image.preview

import android.graphics.ColorFilter
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.github.chrisbanes.photoview.PhotoView
import jp.toastkid.yobidashi.media.image.Image

/**
 * @author toastkidjp
 */
class Adapter : RecyclerView.Adapter<ViewHolder>() {

    private val images = mutableListOf<Image>()

    private var colorFilter: ColorFilter? = null

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = PhotoView(parent.context)
        view.layoutParams = layoutParams
        view.maximumScale = 15f
        return ViewHolder(view)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        holder.setImage(images[position].path)
        holder.setColorFilter(colorFilter)
    }

    override fun getItemCount(): Int = images.size

    fun setColorFilter(it: ColorFilter?) {
        this.colorFilter = it
        notifyDataSetChanged()
    }

    fun setImageBitmap() {
        // TODO binding.photo.setImageBitmap(it)
    }

    fun setImages(images: List<Image>) {
        this.images.addAll(images)
    }

    fun getPath(position: Int): String? {
        return images.get(position).path
    }

    companion object {<commit_msg>refactor #506 Delete unused function from Adapter.<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.yobidashi.media.image.preview

import android.graphics.ColorFilter
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.github.chrisbanes.photoview.PhotoView
import jp.toastkid.yobidashi.media.image.Image

/**
 * @author toastkidjp
 */
class Adapter : RecyclerView.Adapter<ViewHolder>() {

    private val images = mutableListOf<Image>()

    private var colorFilter: ColorFilter? = null

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = PhotoView(parent.context)
        view.layoutParams = layoutParams
        view.maximumScale = 15f
        return ViewHolder(view)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        holder.setImage(images[position].path)
        holder.setColorFilter(colorFilter)
    }

    override fun getItemCount(): Int = images.size

    fun setColorFilter(it: ColorFilter?) {
        this.colorFilter = it
        notifyDataSetChanged()
    }

    fun setImages(images: List<Image>) {
        this.images.addAll(images)
    }

    fun getPath(position: Int): String? {
        return images.get(position).path
    }

    companion object {
{'fraction_non_alphanumeric': 0.09260410192666252, 'fraction_numerical': 0.007147296457426973, 'mean_word_length': 3.4338842975206614, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3403950', 'n_tokens_mistral': 962, 'n_tokens_neox': 904, 'n_words': 232}