Simplify PreferencesActivity

This commit is contained in:
Lucas Lima 2020-06-28 12:22:59 -03:00
parent b5e78e543f
commit cd73a834d2
No known key found for this signature in database
GPG key ID: 0259A3F43EC1027A
3 changed files with 5 additions and 9 deletions

View file

@ -150,6 +150,7 @@
<activity
android:name="dev.lucasnlm.antimine.stats.StatsActivity"
android:label="@string/events"
android:theme="@style/AppTheme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"

View file

@ -7,10 +7,9 @@ import androidx.preference.PreferenceManager
import dev.lucasnlm.antimine.R
class PreferencesActivity : AppCompatActivity() {
class PreferencesActivity : AppCompatActivity(R.layout.activity_empty) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_empty)
PreferenceManager.setDefaultValues(this, R.xml.preferences, false)
// Load the preferences from an XML resource

View file

@ -1,9 +1,9 @@
package dev.lucasnlm.antimine.stats
import android.os.Bundle
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import dagger.hilt.android.AndroidEntryPoint
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.common.level.repository.IStatsRepository
@ -14,18 +14,14 @@ import kotlinx.coroutines.launch
import javax.inject.Inject
@AndroidEntryPoint
class StatsActivity : AppCompatActivity() {
class StatsActivity : AppCompatActivity(R.layout.activity_stats) {
@Inject
lateinit var statsRepository: IStatsRepository
private lateinit var viewModel: StatsViewModel
private val viewModel: StatsViewModel by viewModels()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_stats)
setTitle(R.string.events)
viewModel = ViewModelProviders.of(this).get(StatsViewModel::class.java)
viewModel.statsObserver.observe(
this,
Observer {