<commit_before>package com.github.ramonrabello.kiphy

import android.os.Bundle
import android.widget.ProgressBar
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.github.ramonrabello.kiphy.data.model.Trending
import com.github.ramonrabello.kiphy.common.extensions.gone
import com.github.ramonrabello.kiphy.common.extensions.visible
import com.github.ramonrabello.kiphy.trends.SpacingItemDecoration
import com.github.ramonrabello.kiphy.trends.TrendingAdapter
import com.github.ramonrabello.kiphy.trends.TrendingContract
import com.github.ramonrabello.kiphy.trends.TrendingPresenter
import com.google.android.material.snackbar.Snackbar

/**
 * Main Activity for the app.
 */
class MainActivity : AppCompatActivity(), TrendingContract.View {

    private lateinit var trendingPresenter: TrendingContract.Presenter
    private lateinit var progressBar: ProgressBar
    private lateinit var trendsRecyclerView: RecyclerView
    private lateinit var coordinatorLayout: CoordinatorLayout

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        progressBar = findViewById(R.id.progress_bar)
        trendsRecyclerView = findViewById(R.id.trends_recycler_view)
        coordinatorLayout = findViewById(R.id.coordinator_layout)
    }

    override fun onResume() {
        super.onResume()
        trendingPresenter = TrendingPresenter(this)
        trendingPresenter.loadTrending()
    }

    override fun showProgress() {
        progressBar.visible()
    }

    override fun hideProgress() {
        progressBar.gone()
        trendsRecyclerView.visible()
    }

    override fun showTrending(trending: Trending) {

        trendsRecyclerView.apply {
            layoutManager = StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)
            addItemDecoration(SpacingItemDecoration(10))
            adapter = TrendingAdapter(trending.data)
        }
    }

    override fun showTrendingError() {
        Snackbar.make(coordinatorLayout, getString(R.string.trending_error), Snackbar.LENGTH_SHORT).show()
    }

    override fun showApikeyError() {
        val alertDialogError = AlertDialog.Builder(this)
                .setTitle(getString(R.string.dialog_title))
                .setPositiveButton(getString(R.string.dialog_close_button), null)
                .setMessage(getString(R.string.api_key_error))
                .create()
        alertDialogError.show()
    }
}<commit_msg>Refactor on View methods references.<commit_after>package com.github.ramonrabello.kiphy

import android.os.Bundle
import android.widget.ProgressBar
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.github.ramonrabello.kiphy.common.extensions.gone
import com.github.ramonrabello.kiphy.common.extensions.visible
import com.github.ramonrabello.kiphy.trends.SpacingItemDecoration
import com.github.ramonrabello.kiphy.trends.TrendingAdapter
import com.github.ramonrabello.kiphy.trends.TrendingContract
import com.github.ramonrabello.kiphy.trends.TrendingPresenter
import com.github.ramonrabello.kiphy.trends.model.TrendingResponse
import com.google.android.material.snackbar.Snackbar

/**
 * Main Activity for the app.
 */
class MainActivity : AppCompatActivity(), TrendingContract.View {

    private val trendingAdapter by lazy { TrendingAdapter() }
    private lateinit var trendingPresenter: TrendingContract.Presenter
    private lateinit var progressBar: ProgressBar
    private lateinit var trendsRecyclerView: RecyclerView
    private lateinit var coordinatorLayout: CoordinatorLayout

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        progressBar = findViewById(R.id.progress_bar)
        trendsRecyclerView = findViewById(R.id.trends_recycler_view)
        coordinatorLayout = findViewById(R.id.coordinator_layout)
        setupRecyclerView()
    }

    private fun setupRecyclerView() {
        trendsRecyclerView.apply {
            layoutManager = StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)
            addItemDecoration(SpacingItemDecoration(resources.getDimensionPixelSize(R.dimen.spacing_item_decoration_offset)))
            adapter = trendingAdapter
        }
    }

    override fun onResume() {
        super.onResume()
        trendingPresenter = TrendingPresenter(this)
        trendingPresenter.loadTrends()
    }

    override fun showProgress() {
        progressBar.visible()
    }

    override fun hideProgress() {
        progressBar.gone()
        trendsRecyclerView.visible()
    }

    override fun showTrending(trending: TrendingResponse) {
        trendingAdapter.addTrends(trending.data)
    }

    override fun showTrendingError() {
        Snackbar.make(coordinatorLayout, getString(R.string.trending_error), Snackbar.LENGTH_SHORT).show()
    }

    override fun showApiKeyNotSetDialog() {
        val alertDialogError = AlertDialog.Builder(this)
                .setTitle(getString(R.string.dialog_title))
                .setPositiveButton(getString(R.string.dialog_close_button), null)
                .setMessage(getString(R.string.api_key_error))
                .create()
        alertDialogError.show()
    }
}
{'fraction_non_alphanumeric': 0.07958719608186111, 'fraction_numerical': 0.0006996676578625153, 'mean_word_length': 3.849872773536896, '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': '2560744', 'n_tokens_mistral': 1712, 'n_tokens_neox': 1625, 'n_words': 251}