<commit_before>@file:JvmName("ModulesFragment") // ANALYTICS
package org.mtransit.android.ui.modules

import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import dagger.hilt.android.AndroidEntryPoint
import org.mtransit.android.R
import org.mtransit.android.commons.MTLog
import org.mtransit.android.databinding.FragmentModulesBinding

@AndroidEntryPoint
class ModulesFragment : Fragment(R.layout.fragment_modules), MTLog.Loggable {

    companion object {
        private val LOG_TAG = ModulesFragment::class.java.simpleName
    }

    override fun getLogTag(): String = LOG_TAG

    private val viewModel by viewModels<ModulesViewModel>()
    @Suppress("unused")
    private val addedViewModel: ModulesViewModel?
        get() = if (isAdded) viewModel else null

    private val listAdapter: ModulesAdapter by lazy { ModulesAdapter() }

    private var binding: FragmentModulesBinding? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setHasOptionsMenu(true)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        binding = FragmentModulesBinding.bind(view).apply {
            modulesList.adapter = listAdapter
        }
        viewModel.agencies.observe(this, { newAgencies ->
            listAdapter.submitList(newAgencies)
            binding?.modulesLinearLayout?.isVisible = !newAgencies.isNullOrEmpty()<commit_msg>Fix observing live data on wrong lifecycle owner<commit_after>@file:JvmName("ModulesFragment") // ANALYTICS
package org.mtransit.android.ui.modules

import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import dagger.hilt.android.AndroidEntryPoint
import org.mtransit.android.R
import org.mtransit.android.commons.MTLog
import org.mtransit.android.databinding.FragmentModulesBinding

@AndroidEntryPoint
class ModulesFragment : Fragment(R.layout.fragment_modules), MTLog.Loggable {

    companion object {
        private val LOG_TAG = ModulesFragment::class.java.simpleName
    }

    override fun getLogTag(): String = LOG_TAG

    private val viewModel by viewModels<ModulesViewModel>()
    @Suppress("unused")
    private val addedViewModel: ModulesViewModel?
        get() = if (isAdded) viewModel else null

    private val listAdapter: ModulesAdapter by lazy { ModulesAdapter() }

    private var binding: FragmentModulesBinding? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setHasOptionsMenu(true)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        binding = FragmentModulesBinding.bind(view).apply {
            modulesList.adapter = listAdapter
        }
        viewModel.agencies.observe(viewLifecycleOwner, { newAgencies ->
            listAdapter.submitList(newAgencies)
            binding?.modulesLinearLayout?.isVisible = !newAgencies.isNullOrEmpty()
{'fraction_non_alphanumeric': 0.08345577431677931, 'fraction_numerical': 0.0, 'mean_word_length': 4.189024390243903, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6647070', 'n_tokens_mistral': 947, 'n_tokens_neox': 919, 'n_words': 196}