<commit_before>package com.xamoom.android.xamoomcontentblocks.ViewHolders

import android.content.Context
import android.graphics.Bitmap
import android.os.Handler
import android.support.v4.app.Fragment
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.View
import com.xamoom.android.xamoomcontentblocks.Adapters.HorizontalRecyclerViewAdapter
import com.xamoom.android.xamoomsdk.R
import android.support.v7.widget.PagerSnapHelper
import android.widget.TextView
import com.xamoom.android.xamoomcontentblocks.Helper.LinePagerIndicatorDecoration
import com.xamoom.android.xamoomsdk.Resource.ContentBlock


class ContentBlock12ViewHolder(val view: View, val context: Context, val fragment: Fragment?, val youtubeApiKey: String?, val bitmapCache: android.support.v4.util.LruCache<String, Bitmap>?, parentRecyclerView: RecyclerView?, val interf: ContentBlock12ViewHolderInterface): RecyclerView.ViewHolder(view) {
    private var recyclerView: RecyclerView = view.findViewById(R.id.horizontal_recycler_view)

    init {
        val layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
        layoutManager.isSmoothScrollbarEnabled = false
        recyclerView.layoutManager = layoutManager
        recyclerView.setHasFixedSize(false)
        recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
            override fun onScrollStateChanged(recyclerView: RecyclerView?, newState: Int) {
                super.onScrollStateChanged(recyclerView, newState)
                //parentRecyclerView!!.adapter.notifyItemChanged(parentRecyclerView.getChildAdapterPosition(view))
                if (newState == 0) {
                    recyclerView!!.adapter.notifyDataSetChanged()
                    //interf.didScroll(parentRecyclerView!!.getChildAdapterPosition(view) + 1)
                }
            }
        })
        val snapHelper = PagerSnapHelper()
        snapHelper.attachToRecyclerView(recyclerView)
        recyclerView.addItemDecoration(LinePagerIndicatorDecoration())
    }

    fun setupContentBlock(cb: ArrayList<ContentBlock>) {
        var cbList: ArrayList<ContentBlock> = arrayListOf()
        for(block in cb) {
            if (block.blockType == 0 ||
                    block.blockType == 1 ||
                    block.blockType == 2 ||
                    block.blockType == 3) {
                cbList.add(block)
            }
        }
        recyclerView.adapter = HorizontalRecyclerViewAdapter(cbList, context, fragment, youtubeApiKey, bitmapCache)
    }
}

interface ContentBlock12ViewHolderInterface {
    fun didScroll(position: Int)
}<commit_msg>fix issue Android8+ Gallery<commit_after>package com.xamoom.android.xamoomcontentblocks.ViewHolders

import android.content.Context
import android.graphics.Bitmap
import android.os.Handler
import android.support.v4.app.Fragment
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.View
import com.xamoom.android.xamoomcontentblocks.Adapters.HorizontalRecyclerViewAdapter
import com.xamoom.android.xamoomsdk.R
import android.support.v7.widget.PagerSnapHelper
import android.widget.TextView
import com.xamoom.android.xamoomcontentblocks.Helper.LinePagerIndicatorDecoration
import com.xamoom.android.xamoomsdk.Resource.ContentBlock


class ContentBlock12ViewHolder(val view: View, val context: Context, val fragment: Fragment?, val youtubeApiKey: String?, val bitmapCache: android.support.v4.util.LruCache<String, Bitmap>?, parentRecyclerView: RecyclerView?, val interf: ContentBlock12ViewHolderInterface): RecyclerView.ViewHolder(view) {
    private var recyclerView: RecyclerView = view.findViewById(R.id.horizontal_recycler_view)

    init {
        val layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
        layoutManager.isSmoothScrollbarEnabled = false
        recyclerView.layoutManager = layoutManager
        recyclerView.setHasFixedSize(false)
        recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
            override fun onScrollStateChanged(recyclerView: RecyclerView?, newState: Int) {
                super.onScrollStateChanged(recyclerView, newState)
                //parentRecyclerView!!.adapter.notifyItemChanged(parentRecyclerView.getChildAdapterPosition(view))
                if (newState == 0) {
                    recyclerView!!.adapter.notifyDataSetChanged()
                    //interf.didScroll(parentRecyclerView!!.getChildAdapterPosition(view) + 1)
                }
            }
        })
    }

    fun setupContentBlock(cb: ArrayList<ContentBlock>) {
        var cbList: ArrayList<ContentBlock> = arrayListOf()
        for(block in cb) {
            if (block.blockType == 0 ||
                    block.blockType == 1 ||
                    block.blockType == 2 ||
                    block.blockType == 3) {
                cbList.add(block)
            }
        }
        recyclerView.adapter = HorizontalRecyclerViewAdapter(cbList, context, fragment, youtubeApiKey, bitmapCache)
        val snapHelper = PagerSnapHelper()
        snapHelper.attachToRecyclerView(recyclerView)
        recyclerView.addItemDecoration(LinePagerIndicatorDecoration())
    }
}

interface ContentBlock12ViewHolderInterface {
    fun didScroll(position: Int)
}
{'fraction_non_alphanumeric': 0.08425925925925926, 'fraction_numerical': 0.006481481481481481, 'mean_word_length': 3.4933444259567388, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3962441', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1464, 'n_words': 243}