Skip to content

Commit 1ec7a01

Browse files
zhaoniantiembo
authored andcommitted
added rule to enforce max-lines-length and fixed all the length issues in the project (android#517)
added rule to enforce max-lines-length and fixed all the length issues in the project fix wrong indentation fix kotlin style issues (android#518) fix kotlin style issues remove with
1 parent 76d16ba commit 1ec7a01

File tree

9 files changed

+31
-10
lines changed

9 files changed

+31
-10
lines changed

app/src/androidTest/java/com/google/samples/apps/sunflower/PlantDetailFragmentTest.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ class PlantDetailFragmentTest {
6060
@Ignore("Share button redesign pending")
6161
@Test
6262
fun testShareTextIntent() {
63-
val shareText = activityTestRule.activity.getString(R.string.share_text_plant, testPlant.name)
63+
val shareText = activityTestRule.activity.getString(
64+
R.string.share_text_plant,
65+
testPlant.name
66+
)
6467

6568
Intents.init()
6669
onView(withId(R.id.action_share)).perform(click())

app/src/main/java/com/google/samples/apps/sunflower/GardenFragment.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class GardenFragment : Fragment() {
6464

6565
// TODO: convert to data binding if applicable
6666
private fun navigateToPlantListPage() {
67-
requireActivity().findViewById<ViewPager2>(R.id.view_pager).currentItem = PLANT_LIST_PAGE_INDEX
67+
requireActivity().findViewById<ViewPager2>(R.id.view_pager).currentItem =
68+
PLANT_LIST_PAGE_INDEX
6869
}
6970
}

app/src/main/java/com/google/samples/apps/sunflower/HomeViewPagerFragment.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ import com.google.samples.apps.sunflower.databinding.FragmentViewPagerBinding
3030

3131
class HomeViewPagerFragment : Fragment() {
3232

33-
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
33+
override fun onCreateView(
34+
inflater: LayoutInflater,
35+
container: ViewGroup?,
36+
savedInstanceState: Bundle?
37+
): View? {
3438
val binding = FragmentViewPagerBinding.inflate(inflater, container, false)
3539
val tabLayout = binding.tabs
3640
val viewPager = binding.viewPager

app/src/main/java/com/google/samples/apps/sunflower/PlantDetailFragment.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ class PlantDetailFragment : Fragment() {
131131
// https://android-developers.googleblog.com/2012/02/share-with-intents.html
132132
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
133133
// If we're on Lollipop, we can open the intent as a document
134-
addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT or Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
134+
addFlags(
135+
Intent.FLAG_ACTIVITY_NEW_DOCUMENT or Intent.FLAG_ACTIVITY_MULTIPLE_TASK
136+
)
135137
} else {
136138
// Else, we will use the old CLEAR_WHEN_TASK_RESET flag
137139
addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)

app/src/main/java/com/google/samples/apps/sunflower/adapters/GardenPlantingAdapter.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ import com.google.samples.apps.sunflower.databinding.ListItemGardenPlantingBindi
3131
import com.google.samples.apps.sunflower.viewmodels.PlantAndGardenPlantingsViewModel
3232

3333
class GardenPlantingAdapter :
34-
ListAdapter<PlantAndGardenPlantings, GardenPlantingAdapter.ViewHolder>(GardenPlantDiffCallback()) {
34+
ListAdapter<PlantAndGardenPlantings, GardenPlantingAdapter.ViewHolder>(
35+
GardenPlantDiffCallback()
36+
) {
3537

3638
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
3739
return ViewHolder(

app/src/main/java/com/google/samples/apps/sunflower/adapters/PlantAdapter.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ class PlantAdapter : ListAdapter<Plant, RecyclerView.ViewHolder>(PlantDiffCallba
5858
plant: Plant,
5959
it: View
6060
) {
61-
val direction = HomeViewPagerFragmentDirections.actionViewPagerFragmentToPlantDetailFragment(plant.plantId)
61+
val direction =
62+
HomeViewPagerFragmentDirections.actionViewPagerFragmentToPlantDetailFragment(
63+
plant.plantId
64+
)
6265
it.findNavController().navigate(direction)
6366
}
6467

app/src/main/java/com/google/samples/apps/sunflower/data/GardenPlanting.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ import java.util.Calendar
3333
*/
3434
@Entity(
3535
tableName = "garden_plantings",
36-
foreignKeys = [ForeignKey(entity = Plant::class, parentColumns = ["id"], childColumns = ["plant_id"])],
36+
foreignKeys = [
37+
ForeignKey(entity = Plant::class, parentColumns = ["id"], childColumns = ["plant_id"])
38+
],
3739
indices = [Index("plant_id")]
3840
)
3941
data class GardenPlanting(

app/src/main/java/com/google/samples/apps/sunflower/views/MaskedCardView.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ class MaskedCardView @JvmOverloads constructor(
3939
@SuppressLint("RestrictedApi")
4040
private val pathProvider = ShapeAppearancePathProvider()
4141
private val path: Path = Path()
42-
private val shapeAppearance: ShapeAppearanceModel =
43-
ShapeAppearanceModel(context, attrs, defStyle, R.style.Widget_MaterialComponents_CardView)
42+
private val shapeAppearance: ShapeAppearanceModel = ShapeAppearanceModel(
43+
context,
44+
attrs,
45+
defStyle,
46+
R.style.Widget_MaterialComponents_CardView
47+
)
4448
private val rectF = RectF(0f, 0f, 0f, 0f)
4549

4650
override fun onDraw(canvas: Canvas) {

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ allprojects {
7575
spotless {
7676
kotlin {
7777
target "**/*.kt"
78-
ktlint(ktlintVersion)
78+
ktlint(ktlintVersion).userData(['max_line_length' : '100'])
7979
}
8080
}

0 commit comments

Comments
 (0)