<commit_before>package com.mklimek.library

import android.content.Context
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.view.LayoutInflater
import android.widget.TextView


class TabBarController(context: Context, val tabs: List<Tab>, val tabBarView: TabBarView) {

    var currentItem = 0
        set(value) {
            field = value
            tabs.filter { tabs.indexOf(it) != value }.forEach {
                val child = tabBarView.getChildAt(tabs.indexOf(it))
                child.background = it.background
            }
            val selectedTab = tabs.first { tabs.indexOf(it) == value }
            val selectedChild = tabBarView.getChildAt(tabs.indexOf(selectedTab))
            selectedChild.background = selectedTab.backgroundSelected

            listener?.pageHasBeenChanged(value)
        }

    private var listener: TabBarListener? = null

    init{
        val inflater = LayoutInflater.from(context)
        for(tab in tabs){
            val textView = inflater.inflate(R.layout.bottom_tab_bar_item, tabBarView, false) as TextView
            textView.text = tab.title
            textView.setTextColor(Color.WHITE)
            textView.background = tab.background
            textView.setCompoundDrawablesWithIntrinsicBounds(null, tab.iconId, null, null)
            textView.setOnClickListener { currentItem = tabs.indexOf(tab) }
            tabBarView.addView(textView)
        }
    }

    fun getTabsAsTextViews(): List<TextView>{
        var children = mutableListOf<TextView>()
        tabs.forEach {
            children.add(tabBarView.getChildAt(tabs.indexOf(it)) as TextView)
        }
        return children
    }

    fun setListener(listener: TabBarListener){
        this.listener = listener
    }

    object TabBuilder{

        private var tabs = mutableListOf<Tab>()

        fun addTab(title: String, iconId: Drawable?, backgroundId: Drawable?, backgroundSelectedId: Drawable?): TabBuilder{
            tabs.add(Tab(title, iconId, backgroundId, backgroundSelectedId))
            return this
        }

        fun build(): List<Tab>{
            return tabs
        }
    }

    class Tab(val title: String, val iconId: Drawable?, val background: Drawable?, val backgroundSelected: Drawable?){
    }

}

<commit_msg>Fix maintaining tabs in an instance<commit_after>package com.mklimek.library

import android.content.Context
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.view.LayoutInflater
import android.widget.TextView


class TabBarController(context: Context, val tabs: List<Tab>, val tabBarView: TabBarView) {

    var currentItem = 0
        set(value) {
            field = value
            tabs.filter { tabs.indexOf(it) != value }.forEach {
                val child = tabBarView.getChildAt(tabs.indexOf(it))
                child.background = it.background
            }
            val selectedTab = tabs.first { tabs.indexOf(it) == value }
            val selectedChild = tabBarView.getChildAt(tabs.indexOf(selectedTab))
            selectedChild.background = selectedTab.backgroundSelected

            listener?.pageHasBeenChanged(value)
        }

    private var listener: TabBarListener? = null

    init{
        val inflater = LayoutInflater.from(context)
        for(tab in tabs){
            val textView = inflater.inflate(R.layout.bottom_tab_bar_item, tabBarView, false) as TextView
            textView.text = tab.title
            textView.setTextColor(Color.WHITE)
            textView.background = tab.background
            textView.setCompoundDrawablesWithIntrinsicBounds(null, tab.iconId, null, null)
            textView.setOnClickListener { currentItem = tabs.indexOf(tab) }
            tabBarView.addView(textView)
        }
    }

    fun getTabsAsTextViews(): List<TextView>{
        var children = mutableListOf<TextView>()
        tabs.forEach {
            children.add(tabBarView.getChildAt(tabs.indexOf(it)) as TextView)
        }
        return children
    }

    fun setListener(listener: TabBarListener){
        this.listener = listener
    }

    object TabBuilder{

        private var tabs = mutableListOf<Tab>()

        fun addTab(title: String, iconId: Drawable?, backgroundId: Drawable?, backgroundSelectedId: Drawable?): TabBuilder{
            tabs.add(Tab(title, iconId, backgroundId, backgroundSelectedId))
            return this
        }

        fun build(): List<Tab>{
            val result = tabs.toList()
            tabs.clear()
            return result
        }
    }

    class Tab(val title: String, val iconId: Drawable?, val background: Drawable?, val backgroundSelected: Drawable?){
    }

}


{'fraction_non_alphanumeric': 0.08961260110685398, 'fraction_numerical': 0.0004257130693912303, 'mean_word_length': 2.4884929472902746, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '137430', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1238, 'n_words': 281}