<commit_before>package com.garpr.android.views

import android.content.Context
import android.util.AttributeSet
import com.garpr.android.R
import com.garpr.android.extensions.appComponent
import com.garpr.android.models.SimpleDate
import com.garpr.android.preferences.Preference
import com.garpr.android.preferences.RankingsPollingPreferenceStore
import javax.inject.Inject

class LastPollPreferenceView @JvmOverloads constructor(
        context: Context,
        attrs: AttributeSet? = null
) : SimplePreferenceView(context, attrs), Preference.OnPreferenceChangeListener<SimpleDate> {

    @Inject
    protected lateinit var rankingsPollingPreferenceStore: RankingsPollingPreferenceStore


    override fun onAttachedToWindow() {
        super.onAttachedToWindow()

        if (isInEditMode) {
            return
        }

        rankingsPollingPreferenceStore.lastPoll.addListener(this)
        refresh()
    }

    override fun onDetachedFromWindow() {
        super.onDetachedFromWindow()
        rankingsPollingPreferenceStore.lastPoll.removeListener(this)
    }

    override fun onFinishInflate() {
        super.onFinishInflate()

        if (!isInEditMode) {
            appComponent.inject(this)
            rankingsPollingPreferenceStore.lastPoll.addListener(this)
        }

        isEnabled = false
        titleText = resources.getText(R.string.last_poll)

        if (isInEditMode) {
            return
        }

        refresh()
    }

    override fun onPreferenceChange(preference: Preference<SimpleDate>) {
        if (isAlive) {
            refresh()
        }
    }

    override fun refresh() {
        super.refresh()

        val date = rankingsPollingPreferenceStore.lastPoll.get()
        descriptionText = date?.getRelativeDateTimeText(context) ?:
                resources.getText(R.string.poll_has_yet_to_occur)
    }

}<commit_msg>LastPollPreferenceView now shows description text in the preview window<commit_after>package com.garpr.android.views

import android.content.Context
import android.util.AttributeSet
import com.garpr.android.R
import com.garpr.android.extensions.appComponent
import com.garpr.android.models.SimpleDate
import com.garpr.android.preferences.Preference
import com.garpr.android.preferences.RankingsPollingPreferenceStore
import javax.inject.Inject

class LastPollPreferenceView @JvmOverloads constructor(
        context: Context,
        attrs: AttributeSet? = null
) : SimplePreferenceView(context, attrs), Preference.OnPreferenceChangeListener<SimpleDate> {

    @Inject
    protected lateinit var rankingsPollingPreferenceStore: RankingsPollingPreferenceStore


    override fun onAttachedToWindow() {
        super.onAttachedToWindow()

        if (isInEditMode) {
            return
        }

        rankingsPollingPreferenceStore.lastPoll.addListener(this)
        refresh()
    }

    override fun onDetachedFromWindow() {
        super.onDetachedFromWindow()
        rankingsPollingPreferenceStore.lastPoll.removeListener(this)
    }

    override fun onFinishInflate() {
        super.onFinishInflate()

        if (!isInEditMode) {
            appComponent.inject(this)
            rankingsPollingPreferenceStore.lastPoll.addListener(this)
        }

        isEnabled = false
        titleText = resources.getText(R.string.last_poll)

        if (isInEditMode) {
            descriptionText = resources.getText(R.string.poll_has_yet_to_occur)
        } else {
            refresh()
        }
    }

    override fun onPreferenceChange(preference: Preference<SimpleDate>) {
        if (isAlive) {
            refresh()
        }
    }

    override fun refresh() {
        super.refresh()

        val date = rankingsPollingPreferenceStore.lastPoll.get()
        descriptionText = date?.getRelativeDateTimeText(context) ?:
                resources.getText(R.string.poll_has_yet_to_occur)
    }

}
{'fraction_non_alphanumeric': 0.07849212496772527, 'fraction_numerical': 0.0, 'mean_word_length': 2.953061224489796, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3114265', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1069, 'n_words': 176}