Skip to content

Commit

Permalink
fix: Launch (fragment-ktx), Product Photos, Contributions bug fixes. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
santansarah committed Apr 6, 2023
1 parent 359d5d2 commit 2ab9bbe
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
Expand Up @@ -47,14 +47,8 @@ class ContributorsFragment : BaseFragment() {
lateinit var localeManager: LocaleManager

private lateinit var productState: ProductState

private val dateFormat = DateFormat.getDateFormat(requireContext()).apply {
timeZone = TimeZone.getTimeZone("CET")
}
private val timeFormatter = DateFormat.getTimeFormat(requireContext()).apply {
timeZone = TimeZone.getTimeZone("CET")
}

private lateinit var dateFormat: java.text.DateFormat
private lateinit var timeFormatter: java.text.DateFormat

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
_binding = FragmentContributorsBinding.inflate(inflater)
Expand All @@ -64,6 +58,13 @@ class ContributorsFragment : BaseFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

dateFormat = DateFormat.getDateFormat(requireContext()).apply {
timeZone = TimeZone.getTimeZone("CET")
}
timeFormatter = DateFormat.getTimeFormat(requireContext()).apply {
timeZone = TimeZone.getTimeZone("CET")
}

binding.incompleteStates.setOnClickListener { toggleIncompleteStatesVisibility() }
binding.completeStates.setOnClickListener { toggleCompleteStatesVisibility() }

Expand Down
Expand Up @@ -13,11 +13,9 @@ import javax.inject.Inject

class ProductPhotoViewHolder(
private val binding: ImagesItemBinding,
private val picasso: Picasso
) : RecyclerView.ViewHolder(binding.root) {

@Inject
lateinit var picasso: Picasso

fun setImage(barcode: Barcode, imageName: String) {
val imageUrl = getImageUrl(barcode, imageName, IMAGE_EDIT_SIZE)
logcat(LogPriority.DEBUG) { "Loading image $imageUrl..." }
Expand Down
Expand Up @@ -4,6 +4,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.squareup.picasso.Picasso
import openfoodfacts.github.scrachx.openfood.databinding.ImagesItemBinding
import openfoodfacts.github.scrachx.openfood.models.Product

Expand All @@ -15,14 +16,15 @@ class ProductPhotosAdapter(
private val imageNames: List<String>,
private val onImageTap: (Int) -> Unit,
private val onLoginNeeded: (View, Int) -> Unit,
private val picasso: Picasso
) : RecyclerView.Adapter<ProductPhotoViewHolder>() {

override fun getItemCount() = imageNames.count()

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ProductPhotoViewHolder {
val inflater = LayoutInflater.from(parent.context)
val itemView = ImagesItemBinding.inflate(inflater, parent, false)
return ProductPhotoViewHolder(itemView)
return ProductPhotoViewHolder(itemView, picasso)
}

override fun onBindViewHolder(holder: ProductPhotoViewHolder, position: Int) {
Expand Down
Expand Up @@ -106,7 +106,8 @@ class ProductPhotosFragment : BaseFragment() {
} else {
showEditPopup(view, imageNames, position, product)
}
}
},
picasso
)

binding.progress.hide()
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Expand Up @@ -41,7 +41,7 @@ kotlin-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-co
kotlin-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlin-coroutines" }
test-kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlin-coroutines" }
# Android KTX
android-ktx-fragment = "androidx.fragment:fragment-ktx:1.4.1"
android-ktx-fragment = "androidx.fragment:fragment-ktx:1.5.6"
android-ktx-activity = "androidx.activity:activity-ktx:1.7.0"
android-ktx-preference = "androidx.preference:preference-ktx:1.2.0"
android-ktx-core = "androidx.core:core-ktx:1.8.0"
Expand Down

0 comments on commit 2ab9bbe

Please sign in to comment.