diff --git a/app/src/main/java/com/google/samples/apps/sunflower/adapters/BindingAdapters.kt b/app/src/main/java/com/google/samples/apps/sunflower/adapters/BindingAdapters.kt deleted file mode 100644 index 7cc6703dd..000000000 --- a/app/src/main/java/com/google/samples/apps/sunflower/adapters/BindingAdapters.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2018 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.samples.apps.sunflower.adapters - -import android.view.View -import androidx.databinding.BindingAdapter - -@BindingAdapter("isGone") -fun bindIsGone(view: View, isGone: Boolean) { - view.visibility = if (isGone) { - View.GONE - } else { - View.VISIBLE - } -} diff --git a/app/src/main/java/com/google/samples/apps/sunflower/adapters/PlantDetailBindingAdapters.kt b/app/src/main/java/com/google/samples/apps/sunflower/adapters/PlantDetailBindingAdapters.kt deleted file mode 100644 index f57d9690c..000000000 --- a/app/src/main/java/com/google/samples/apps/sunflower/adapters/PlantDetailBindingAdapters.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2018 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.samples.apps.sunflower.adapters - -import android.text.method.LinkMovementMethod -import android.widget.ImageView -import android.widget.TextView -import androidx.core.text.HtmlCompat -import androidx.core.text.HtmlCompat.FROM_HTML_MODE_COMPACT -import androidx.databinding.BindingAdapter -import com.bumptech.glide.Glide -import com.google.android.material.floatingactionbutton.FloatingActionButton -import com.google.samples.apps.sunflower.R - -@BindingAdapter("imageFromUrl") -fun bindImageFromUrl(view: ImageView, imageUrl: String?) { - if (imageUrl.isNullOrEmpty()) { - return - } - Glide.with(view) - .load(imageUrl) - .placeholder(android.R.drawable.progress_indeterminate_horizontal) - .into(view) -} - -@BindingAdapter("isFabGone") -fun bindIsFabGone(view: FloatingActionButton, isGone: Boolean?) { - if (isGone == null || isGone) { - view.hide() - } else { - view.show() - } -} - -@BindingAdapter("renderHtml") -fun bindRenderHtml(view: TextView, description: String?) { - if (description != null) { - view.text = HtmlCompat.fromHtml(description, FROM_HTML_MODE_COMPACT) - view.movementMethod = LinkMovementMethod.getInstance() - } else { - view.text = "" - } -} - -@BindingAdapter("wateringText") -fun bindWateringText(textView: TextView, wateringInterval: Int) { - val resources = textView.context.resources - val quantityString = resources.getQuantityString( - R.plurals.watering_needs_suffix, - wateringInterval, - wateringInterval - ) - - textView.text = quantityString -}