Created
March 8, 2018 02:20
-
-
Save cdmunoz/f1195bfdfc21b67c0198a9bedcd4c33c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CryptocurrenciesActivity : AppCompatActivity() { | |
@Inject | |
lateinit var cryptocurrenciesViewModelFactory: CryptocurrenciesViewModelFactory | |
lateinit var cryptocurrenciesViewModel: CryptocurrenciesViewModel | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(layout.activity_main) | |
AndroidInjection.inject(this) | |
cryptocurrenciesViewModel = ViewModelProviders.of(this, cryptocurrenciesViewModelFactory).get( | |
CryptocurrenciesViewModel::class.java) | |
cryptocurrenciesViewModel.loadCryptocurrencies() | |
cryptocurrenciesViewModel.cryptocurrenciesResult().observe(this, | |
Observer<List<Cryptocurrency>> { | |
hello_world_textview.text = "Hello ${it?.size} cryptocurrencies" | |
}) | |
cryptocurrenciesViewModel.cryptocurrenciesError().observe(this, Observer<String>{ | |
hello_world_textview.text = "Hello error $it" | |
}) | |
} | |
override fun onDestroy() { | |
cryptocurrenciesViewModel.disposeElements() | |
super.onDestroy() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment