<commit_before>package io.github.rfonzi.rxaware_sample

import android.arch.lifecycle.ViewModelProviders
import android.os.Bundle
import android.util.DisplayMetrics
import android.view.View
import android.widget.ImageButton
import com.jakewharton.rxbinding2.view.clicks
import io.github.rfonzi.rxaware.BaseActivity
import io.reactivex.Observable

class MainActivity : BaseActivity() {

    lateinit var vm: MainViewModel
    lateinit var puck: ImageButton

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        vm = ViewModelProviders.of(this).get(MainViewModel::class.java)

        puck = findViewById(R.id.puck)

        vm.exposePuck(puck.clicks())

        val metrics = DisplayMetrics()
        windowManager.defaultDisplay.getMetrics(metrics)
        val dimens = Observable.fromCallable { metrics.widthPixels to metrics.heightPixels }


        vm.exposeDimens(dimens)

        vm.coordinates()
                .subscribe {
                    puck.x = it.first.toFloat()
                    puck.y = it.second.toFloat()
                }
                .lifecycleAware()

        vm.winSignal()
                .subscribe {
                    puck.visibility = View.GONE
                }
                .lifecycleAware()
    }


}<commit_msg>Shift the puck's coordinates to take into account its anchor point<commit_after>package io.github.rfonzi.rxaware_sample

import android.arch.lifecycle.ViewModelProviders
import android.os.Bundle
import android.util.DisplayMetrics
import android.view.View
import android.widget.ImageButton
import com.jakewharton.rxbinding2.view.clicks
import io.github.rfonzi.rxaware.BaseActivity
import io.reactivex.Observable

class MainActivity : BaseActivity() {

    lateinit var vm: MainViewModel
    lateinit var puck: ImageButton

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        vm = ViewModelProviders.of(this).get(MainViewModel::class.java)

        puck = findViewById(R.id.puck)

        vm.exposePuck(puck.clicks())

        val metrics = DisplayMetrics()
        windowManager.defaultDisplay.getMetrics(metrics)
        val dimens = Observable.fromCallable { metrics.widthPixels to metrics.heightPixels }


        vm.exposeDimens(dimens)

        vm.coordinates()
                .subscribe {
                    puck.x = it.first.toFloat() - (puck.width / 2)
                    puck.y = it.second.toFloat() - (puck.height / 2)
                }
                .lifecycleAware()

        vm.winSignal()
                .subscribe {
                    puck.visibility = View.GONE
                }
                .lifecycleAware()
    }


}
{'fraction_non_alphanumeric': 0.08737517831669044, 'fraction_numerical': 0.0014265335235378032, 'mean_word_length': 2.3432657926102505, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '258909', 'n_tokens_mistral': 832, 'n_tokens_neox': 764, 'n_words': 140}