Skip to content

Instantly share code, notes, and snippets.

View antonicg's full-sized avatar

Antoni Castejón antonicg

View GitHub Profile
package com.antonicastejon.cryptodata.model
import io.reactivex.Single
/**
* Created by Antoni Castejón on 31/12/2017.
*/
interface CoinMarketCapRepository {
fun getCryptoList(page:Int, limit:Int) : Single<List<Crypto>>
package com.antonicastejon.cryptodata.model
import io.reactivex.Single
/**
* Created by Antoni Castejón on 31/12/2017.
*/
class CoinMarketCapDownloader(private val coinMarketCapApi: CoinMarketCapApi) : CoinMarketCapRepository {
override fun getCryptoList(page: Int, limit: Int): Single<List<Crypto>> = coinMarketCapApi.getCryptoList(page * limit, limit)
package com.antonicastejon.cryptodata.domain
import com.antonicastejon.cryptodata.model.CoinMarketCapRepository
import com.antonicastejon.cryptodata.model.Crypto
import io.reactivex.Single
/**
* Created by Antoni Castejón on 31/12/2017.
*/
package com.antonicastejon.cryptodata.domain
import android.os.Parcel
import android.os.Parcelable
import io.reactivex.Single
/**
* Created by Antoni Castejón on 31/12/2017.
*/
interface CryptoListUseCases {
package com.antonicastejon.cryptodata.presentation.main.crypto_list
import com.antonicastejon.cryptodata.domain.CryptoViewModel
/**
* Created by Antoni Castejón
* 20/01/2018.
*/
sealed class CryptoListState {
abstract val pageNum:Int
package com.antonicastejon.cryptodata.presentation.main.crypto_list
import android.arch.lifecycle.MutableLiveData
import android.arch.lifecycle.ViewModel
import com.antonicastejon.cryptodata.di.SCHEDULER_IO
import com.antonicastejon.cryptodata.di.SCHEDULER_MAIN_THREAD
import com.antonicastejon.cryptodata.domain.CryptoListUseCases
import com.antonicastejon.cryptodata.domain.CryptoViewModel
import com.antonicastejon.cryptodata.domain.LIMIT_CRYPTO_LIST
import io.reactivex.Scheduler
package com.antonicastejon.cryptodata.presentation.main.crypto_list
import android.arch.lifecycle.Observer
import android.arch.lifecycle.ViewModelProvider
import android.arch.lifecycle.ViewModelProviders
import android.content.Context
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.widget.LinearLayoutManager
import android.view.LayoutInflater
package com.antonicastejon.cryptodata.usecases
import android.arch.core.executor.testing.InstantTaskExecutorRule
import com.antonicastejon.cryptodata.common.cryptoPOJOmodel
import com.antonicastejon.cryptodata.common.cryptoViewModelFrom
import com.antonicastejon.cryptodata.common.mock
import com.antonicastejon.cryptodata.common.whenever
import com.antonicastejon.cryptodata.domain.CryptoListInteractor
import com.antonicastejon.cryptodata.model.CoinMarketCapRepository
import io.reactivex.Single
fun limitCryptoListSizeArrayEmptyCryptoViewModel(): List<CryptoViewModel> =
ArrayList<CryptoViewModel>(Collections.nCopies(LIMIT_CRYPTO_LIST, CryptoViewModel()))
fun cryptoPOJOmodel() =
Crypto("1", "name", "sy", 10, "100", "0.1", "100", "1000", "0", "500", "5", "10", "-10", "")
fun cryptoViewModelFrom(crypto:Crypto) =
CryptoViewModel(crypto.id, crypto.name, crypto.symbol, crypto.rank, crypto.priceUsd.toFloat(), crypto.priceBtc.toFloat(), crypto.percentChange24h.toFloat())
package com.antonicastejon.cryptodata.viewmodels
import android.arch.core.executor.testing.InstantTaskExecutorRule
import android.arch.lifecycle.Observer
import com.antonicastejon.cryptodata.common.limitCryptoListSizeArrayEmptyCryptoViewModel
import com.antonicastejon.cryptodata.common.mock
import com.antonicastejon.cryptodata.common.whenever
import com.antonicastejon.cryptodata.domain.CryptoListUseCases
import com.antonicastejon.cryptodata.domain.CryptoViewModel
import com.antonicastejon.cryptodata.presentation.main.crypto_list.*