Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor update #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@ package com.radityalabs.android.corona.extensions
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.annotation.LayoutRes
import com.squareup.picasso.Picasso

fun ViewGroup.create(@LayoutRes resource: Int): View {
return LayoutInflater.from(this.context).inflate(resource, this, false)
}

fun ImageView.load(url: String, centerCrop: Boolean = true, fit: Boolean = true) {
Picasso.get()
.load(url)
.also { if (centerCrop) it.centerCrop() }
.also { if (fit) it.fit() }
.into(this)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.radityalabs.android.corona.R
import com.radityalabs.android.corona.features.main.presentation.uimodel.FeedModel
import com.radityalabs.android.corona.extensions.create
import com.radityalabs.android.corona.extensions.load
import com.squareup.picasso.Picasso

class MainAdapter :
Expand All @@ -35,11 +36,7 @@ class MainAdapter :
private val tvDescription by lazy { view.findViewById<TextView>(R.id.tvDescription) }

fun bind(feed: FeedModel) {
Picasso.get()
.load(feed.image)
.fit()
.tag(view.context)
.into(ivPhoto)
ivPhoto.load(feed.image, centerCrop = true, fit = true)
tvDescription.text = feed.description
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ class BottomSheetFragment : Fragment(R.layout.fragment_bottom_sheet) {
MainAdapter()

rvFeeds = view.findViewById(R.id.feeds)
rvFeeds.adapter = rvAdapter
rvFeeds.layoutManager = LinearLayoutManager(context)
rvFeeds.apply {
adapter = rvAdapter
layoutManager = LinearLayoutManager(context)
}
}

companion object {
Expand Down