redesign library and search fragment
* library/search now use a grid view with 2 columns * media is now represented as card * media details: poster and episodes have now rounded corners
This commit is contained in:
@ -13,6 +13,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import jp.wasabeef.glide.transformations.BlurTransformation
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation
|
||||
import kotlinx.android.synthetic.main.fragment_media.*
|
||||
import org.mosad.teapod.MainActivity
|
||||
import org.mosad.teapod.R
|
||||
@ -46,6 +47,7 @@ class MediaFragment(private val media: Media, private val tmdb: TMDBResponse) :
|
||||
// generic gui
|
||||
val backdropUrl = if (tmdb.backdropUrl.isNotEmpty()) tmdb.backdropUrl else media.info.posterLink
|
||||
val posterUrl = if (tmdb.posterUrl.isNotEmpty()) tmdb.posterUrl else media.info.posterLink
|
||||
val posterCornerRadius = if (tmdb.posterUrl.isNotEmpty()) 60 else 30
|
||||
|
||||
Glide.with(requireContext()).load(backdropUrl)
|
||||
.apply(RequestOptions.placeholderOf(ColorDrawable(Color.DKGRAY)))
|
||||
@ -53,6 +55,7 @@ class MediaFragment(private val media: Media, private val tmdb: TMDBResponse) :
|
||||
.into(image_backdrop)
|
||||
|
||||
Glide.with(requireContext()).load(posterUrl)
|
||||
.apply(RequestOptions.bitmapTransform(RoundedCornersTransformation(posterCornerRadius, 0)))
|
||||
.into(image_poster)
|
||||
|
||||
text_title.text = media.title
|
||||
|
@ -6,6 +6,7 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import kotlinx.android.synthetic.main.fragment_library.*
|
||||
import kotlinx.android.synthetic.main.item_media.view.*
|
||||
import kotlinx.coroutines.*
|
||||
import org.mosad.teapod.MainActivity
|
||||
import org.mosad.teapod.R
|
||||
@ -33,7 +34,7 @@ class LibraryFragment : Fragment() {
|
||||
withContext(Dispatchers.Main) {
|
||||
context?.let {
|
||||
adapter = CustomAdapter(it, AoDParser.mediaList)
|
||||
list_library.adapter = adapter
|
||||
grid_media_library.adapter = adapter
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -42,12 +43,11 @@ class LibraryFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun initActions() {
|
||||
list_library.setOnItemClickListener { _, _, position, _ ->
|
||||
grid_media_library.setOnItemClickListener { _, _, position, _ ->
|
||||
val media = adapter.getItem(position) as Media
|
||||
println("selected item is: ${media.title}")
|
||||
|
||||
val mainActivity = activity as MainActivity
|
||||
mainActivity.showDetailFragment(media)
|
||||
(activity as MainActivity).showDetailFragment(media)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class SearchFragment : Fragment() {
|
||||
withContext(Dispatchers.Main) {
|
||||
context?.let {
|
||||
adapter = CustomAdapter(it, AoDParser.mediaList)
|
||||
list_search.adapter = adapter
|
||||
grid_media_search.adapter = adapter
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -57,7 +57,7 @@ class SearchFragment : Fragment() {
|
||||
}
|
||||
})
|
||||
|
||||
list_search.setOnItemClickListener { _, _, position, _ ->
|
||||
grid_media_search.setOnItemClickListener { _, _, position, _ ->
|
||||
search_text.clearFocus() // remove focus from the SearchView
|
||||
|
||||
runBlocking {
|
||||
|
@ -15,7 +15,7 @@ class CustomAdapter(val context: Context, private val originalMedia: ArrayList<M
|
||||
private val customFilter = CustomFilter()
|
||||
|
||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
||||
val view = convertView ?: LayoutInflater.from(context).inflate(R.layout.linear_media, parent, false)
|
||||
val view = convertView ?: LayoutInflater.from(context).inflate(R.layout.item_media, parent, false)
|
||||
|
||||
val textTitle = view.findViewById<TextView>(R.id.text_title)
|
||||
val imagePoster = view.findViewById<ImageView>(R.id.image_poster)
|
||||
|
@ -6,7 +6,9 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
import kotlinx.android.synthetic.main.component_episode.view.*
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation
|
||||
import kotlinx.android.synthetic.main.item_episode.view.*
|
||||
import org.mosad.teapod.R
|
||||
|
||||
class EpisodesAdapter(private val episodes: List<Episode>, private val context: Context) : RecyclerView.Adapter<EpisodesAdapter.MyViewHolder>() {
|
||||
@ -14,7 +16,7 @@ class EpisodesAdapter(private val episodes: List<Episode>, private val context:
|
||||
var onItemClick: ((String, Int) -> Unit)? = null
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.component_episode, parent, false)
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_episode, parent, false)
|
||||
|
||||
return MyViewHolder(view)
|
||||
}
|
||||
@ -28,7 +30,9 @@ class EpisodesAdapter(private val episodes: List<Episode>, private val context:
|
||||
holder.view.text_episode_desc.text = episodes[position].shortDesc
|
||||
|
||||
if (episodes[position].posterLink.isNotEmpty()) {
|
||||
Glide.with(context).load(episodes[position].posterLink).into(holder.view.image_episode)
|
||||
Glide.with(context).load(episodes[position].posterLink)
|
||||
.apply(RequestOptions.bitmapTransform(RoundedCornersTransformation(10, 0)))
|
||||
.into(holder.view.image_episode)
|
||||
}
|
||||
|
||||
if (!episodes[position].watched) {
|
||||
|
Reference in New Issue
Block a user