Skip to content

Commit

Permalink
added rule to enforce max-lines-length and fixed all the length issue…
Browse files Browse the repository at this point in the history
…s 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
  • Loading branch information
zhaonian authored and tiembo committed Oct 3, 2019
1 parent 76d16ba commit 1ec7a01
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ class PlantDetailFragmentTest {
@Ignore("Share button redesign pending")
@Test
fun testShareTextIntent() {
val shareText = activityTestRule.activity.getString(R.string.share_text_plant, testPlant.name)
val shareText = activityTestRule.activity.getString(
R.string.share_text_plant,
testPlant.name
)

Intents.init()
onView(withId(R.id.action_share)).perform(click())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class GardenFragment : Fragment() {

// TODO: convert to data binding if applicable
private fun navigateToPlantListPage() {
requireActivity().findViewById<ViewPager2>(R.id.view_pager).currentItem = PLANT_LIST_PAGE_INDEX
requireActivity().findViewById<ViewPager2>(R.id.view_pager).currentItem =
PLANT_LIST_PAGE_INDEX
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ import com.google.samples.apps.sunflower.databinding.FragmentViewPagerBinding

class HomeViewPagerFragment : Fragment() {

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val binding = FragmentViewPagerBinding.inflate(inflater, container, false)
val tabLayout = binding.tabs
val viewPager = binding.viewPager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ class PlantDetailFragment : Fragment() {
// https://android-developers.googleblog.com/2012/02/share-with-intents.html
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// If we're on Lollipop, we can open the intent as a document
addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT or Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
addFlags(
Intent.FLAG_ACTIVITY_NEW_DOCUMENT or Intent.FLAG_ACTIVITY_MULTIPLE_TASK
)
} else {
// Else, we will use the old CLEAR_WHEN_TASK_RESET flag
addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import com.google.samples.apps.sunflower.databinding.ListItemGardenPlantingBindi
import com.google.samples.apps.sunflower.viewmodels.PlantAndGardenPlantingsViewModel

class GardenPlantingAdapter :
ListAdapter<PlantAndGardenPlantings, GardenPlantingAdapter.ViewHolder>(GardenPlantDiffCallback()) {
ListAdapter<PlantAndGardenPlantings, GardenPlantingAdapter.ViewHolder>(
GardenPlantDiffCallback()
) {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ class PlantAdapter : ListAdapter<Plant, RecyclerView.ViewHolder>(PlantDiffCallba
plant: Plant,
it: View
) {
val direction = HomeViewPagerFragmentDirections.actionViewPagerFragmentToPlantDetailFragment(plant.plantId)
val direction =
HomeViewPagerFragmentDirections.actionViewPagerFragmentToPlantDetailFragment(
plant.plantId
)
it.findNavController().navigate(direction)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ import java.util.Calendar
*/
@Entity(
tableName = "garden_plantings",
foreignKeys = [ForeignKey(entity = Plant::class, parentColumns = ["id"], childColumns = ["plant_id"])],
foreignKeys = [
ForeignKey(entity = Plant::class, parentColumns = ["id"], childColumns = ["plant_id"])
],
indices = [Index("plant_id")]
)
data class GardenPlanting(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ class MaskedCardView @JvmOverloads constructor(
@SuppressLint("RestrictedApi")
private val pathProvider = ShapeAppearancePathProvider()
private val path: Path = Path()
private val shapeAppearance: ShapeAppearanceModel =
ShapeAppearanceModel(context, attrs, defStyle, R.style.Widget_MaterialComponents_CardView)
private val shapeAppearance: ShapeAppearanceModel = ShapeAppearanceModel(
context,
attrs,
defStyle,
R.style.Widget_MaterialComponents_CardView
)
private val rectF = RectF(0f, 0f, 0f, 0f)

override fun onDraw(canvas: Canvas) {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ allprojects {
spotless {
kotlin {
target "**/*.kt"
ktlint(ktlintVersion)
ktlint(ktlintVersion).userData(['max_line_length' : '100'])
}
}

0 comments on commit 1ec7a01

Please sign in to comment.