Skip to content

Commit

Permalink
fix kotlin style issues (android#518)
Browse files Browse the repository at this point in the history
fix kotlin style issues

remove with
  • Loading branch information
zhaonian authored and nic0lette committed Oct 3, 2019
1 parent a72c801 commit 76d16ba
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class GardenPlantingDaoTest {
@get:Rule
var instantTaskExecutorRule = InstantTaskExecutorRule()

@Before fun createDb() = runBlocking<Unit> {
@Before fun createDb() = runBlocking {
val context = InstrumentationRegistry.getInstrumentation().targetContext
database = Room.inMemoryDatabaseBuilder(context, AppDatabase::class.java).build()
gardenPlantingDao = database.gardenPlantingDao()
Expand All @@ -55,7 +55,7 @@ class GardenPlantingDaoTest {
database.close()
}

@Test fun testGetGardenPlantings() = runBlocking<Unit> {
@Test fun testGetGardenPlantings() = runBlocking {
val gardenPlanting2 = GardenPlanting(
testPlants[1].plantId,
testCalendar,
Expand All @@ -65,7 +65,7 @@ class GardenPlantingDaoTest {
assertThat(getValue(gardenPlantingDao.getGardenPlantings()).size, equalTo(2))
}

@Test fun testDeleteGardenPlanting() = runBlocking<Unit> {
@Test fun testDeleteGardenPlanting() = runBlocking {
val gardenPlanting2 = GardenPlanting(
testPlants[1].plantId,
testCalendar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class PlantDaoTest {
@get:Rule
var instantTaskExecutorRule = InstantTaskExecutorRule()

@Before fun createDb() = runBlocking<Unit> {
@Before fun createDb() = runBlocking {
val context = InstrumentationRegistry.getInstrumentation().targetContext
database = Room.inMemoryDatabaseBuilder(context, AppDatabase::class.java).build()
plantDao = database.plantDao()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ class GardenPlantingAdapter :
}

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
getItem(position).let { plantings ->
with(holder) {
bind(plantings)
}
}
holder.bind(getItem(position))
}

class ViewHolder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.google.samples.apps.sunflower.utilities

import kotlin.math.abs

/**
* A helper function to determine a Plant's growing zone for a given latitude.
*
Expand All @@ -30,7 +32,7 @@ package com.google.samples.apps.sunflower.utilities
*
* For latitude values greater than max (90.0), zone 1 is returned.
*/
fun getZoneForLatitude(latitude: Double) = when (Math.abs(latitude)) {
fun getZoneForLatitude(latitude: Double) = when (abs(latitude)) {
in 0.0..7.0 -> 13
in 7.0..14.0 -> 12
in 14.0..21.0 -> 11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ class PlantAndGardenPlantingsViewModel(plantings: PlantAndGardenPlantings) {
private val plant = checkNotNull(plantings.plant)
private val gardenPlanting = plantings.gardenPlantings[0]

val waterDateString = dateFormat.format(gardenPlanting.lastWateringDate.time)
val waterDateString: String = dateFormat.format(gardenPlanting.lastWateringDate.time)
val wateringInterval
get() = plant.wateringInterval
val imageUrl
get() = plant.imageUrl
val plantName
get() = plant.name
val plantDateString = dateFormat.format(gardenPlanting.plantDate.time)
val plantDateString: String = dateFormat.format(gardenPlanting.plantDate.time)
val plantId
get() = plant.plantId

Expand Down

0 comments on commit 76d16ba

Please sign in to comment.