Skip to content

Instantly share code, notes, and snippets.

View tolmachevroman's full-sized avatar

Roman Tolmachev tolmachevroman

  • Santiago, Chile
View GitHub Profile
@tolmachevroman
tolmachevroman / invalid-name.json
Created November 25, 2017 14:19
Medium Post 3. invalid-name.json
[
{
"id": 1,
"cuisine": 1,
"lat": -33.431756,
"lng": -70.578719,
"price": 8900,
"image": "https://www.atrapalo.cl/common/photo/res/44559/106814/ticr_0_0.jpg",
"description": "Todo el sabor del Perú está presente en el restaurante Mi Cevichazo."
}
@tolmachevroman
tolmachevroman / RestaurantsRepositoryTest.kt
Last active November 26, 2017 05:09
Medium Post 3. RestaurantsRepositoryTest
@RunWith(AndroidJUnit4::class)
class RestaurantsRepositoryTest {
@Rule
@JvmField
var instantExecutor = InstantTaskExecutorRule()
@Mock
private lateinit var observer: Observer<Resource<List<Restaurant>>>
@tolmachevroman
tolmachevroman / RestaurantsMapActivityTest.kt
Last active November 26, 2017 05:09
Medium Post 3. RestaurantsMapActivityTest
@RunWith(AndroidJUnit4::class)
class RestaurantsMapActivityTest {
@Rule
@JvmField
var activityRule = ActivityTestRule(RestaurantsMapActivity::class.java)
companion object {
val packageName = BuildConfig.APPLICATION_ID
}
@tolmachevroman
tolmachevroman / POSTRequestUsingViewModel.kt
Created November 20, 2018 15:44
Example of POST request using ViewModel
class LoginViewModel @Inject constructor(private val repository: UsersRepository) : ViewModel() {
var loginInput: MutableLiveData<LoginRequest> = MutableLiveData()
val login: LiveData<Resource<User>> = Transformations.switchMap(loginInput) { emailPasswordRequest ->
repository.login(emailPasswordRequest)
}
}
class LoginActivity : BaseActivity() {
//...