<commit_before>package viper.collection

import android.os.Bundle
import rx.Subscription
import viper.presenter.FragmentPresenter
import viper.view.ViperFragment

/**
 * A generic collection fragment is driven by a collection presenter.
 * Created by <NAME> on 11/2/16.
 */
abstract class CollectionFragment<P : CollectionPresenter<*,*>> : CollectionView,
        ViperFragment<P>() {
    lateinit var adapter: CollectionAdapter<CollectionPresenter<*, *>>
    var actionSub: Subscription? = null

    abstract fun createAdapter(): CollectionAdapter<CollectionPresenter<*, *>>

    override fun onCreate(bundle: Bundle?) {
        super.onCreate(bundle)
        adapter = createAdapter()
        adapter.presenter = presenter as? CollectionPresenter<*, *>
        actionSub = adapter.actionObserver.subscribe { sendItemAction(it.actionId,it.itemIndex) }
    }

    override fun onDestroy() {
        super.onDestroy()
        actionSub?.unsubscribe()
        actionSub = null
        adapter.presenter = null
    }

    override fun onCollectionUpdated() {
        adapter.onCollectionUpdated()
    }

    override fun onItemUpdated(itemIndex: Int) {
        adapter.onCollectionUpdated()
    }<commit_msg>Collection fragment and it's owned adapter now expect the same type of presenter.<commit_after>package viper.collection

import android.os.Bundle
import rx.Subscription
import viper.presenter.FragmentPresenter
import viper.view.ViperFragment

/**
 * A generic collection fragment is driven by a collection presenter.
 * Created by <NAME> on 11/2/16.
 */
abstract class CollectionFragment<P : CollectionPresenter<*,*>> : CollectionView,
        ViperFragment<P>() {
    lateinit var adapter: CollectionAdapter<P>
    var actionSub: Subscription? = null

    abstract fun createAdapter(): CollectionAdapter<P>

    override fun onCreate(bundle: Bundle?) {
        super.onCreate(bundle)
        adapter = createAdapter()
        adapter.presenter = presenter
        actionSub = adapter.actionObserver.subscribe { sendItemAction(it.actionId,it.itemIndex) }
    }

    override fun onDestroy() {
        super.onDestroy()
        actionSub?.unsubscribe()
        actionSub = null
        adapter.presenter = null
    }

    override fun onCollectionUpdated() {
        adapter.onCollectionUpdated()
    }

    override fun onItemUpdated(itemIndex: Int) {
        adapter.onCollectionUpdated()
    }
{'fraction_non_alphanumeric': 0.09333333333333334, 'fraction_numerical': 0.004166666666666667, 'mean_word_length': 3.421731123388582, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, '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': '4891187', 'n_tokens_mistral': 643, 'n_tokens_neox': 620, 'n_words': 160}