diff --git a/touch/build.gradle b/touch/build.gradle index 01b75f85..17a6f421 100644 --- a/touch/build.gradle +++ b/touch/build.gradle @@ -123,7 +123,10 @@ dependencies { } implementation 'com.google.android.exoplayer:exoplayer:r2.5.2' implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.9.0' + + implementation 'com.github.bumptech.glide:glide:4.6.1' implementation 'com.squareup.picasso:picasso:2.5.2' + implementation 'net.opacapp:multiline-collapsingtoolbar:27.1.1' implementation 'net.rdrei.android.dirchooser:library:3.2@aar' // implementation 'com.gu:option:1.3' diff --git a/touch/src/main/java/de/nicidienase/chaosflix/touch/BindingAdapters.kt b/touch/src/main/java/de/nicidienase/chaosflix/touch/BindingAdapters.kt index 23969db2..f870afb3 100644 --- a/touch/src/main/java/de/nicidienase/chaosflix/touch/BindingAdapters.kt +++ b/touch/src/main/java/de/nicidienase/chaosflix/touch/BindingAdapters.kt @@ -2,14 +2,14 @@ package de.nicidienase.chaosflix.touch import android.databinding.BindingAdapter import android.widget.ImageView -import com.squareup.picasso.Picasso +import com.bumptech.glide.Glide +import com.bumptech.glide.request.RequestOptions @BindingAdapter("bind:imageUrl") fun loadImage(imageView: ImageView, url: String){ - Picasso.with(imageView.context) + Glide.with(imageView.context) .load(url) - .fit() - .centerInside() + .apply(RequestOptions().fitCenter()) .into(imageView) } \ No newline at end of file diff --git a/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/ConferenceGroupFragment.java b/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/ConferenceGroupFragment.java index f5c1918d..826be7e1 100644 --- a/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/ConferenceGroupFragment.java +++ b/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/ConferenceGroupFragment.java @@ -74,7 +74,7 @@ public class ConferenceGroupFragment extends BrowseFragment { if(conferenceList.size() > 0){ setLoadingOverlayVisibility(false); } - conferencesAdapter.setItems(conferenceList); + conferencesAdapter.setConferences(conferenceList); Parcelable layoutState = getArguments().getParcelable(LAYOUTMANAGER_STATE); if (layoutState != null) { layoutManager.onRestoreInstanceState(layoutState); diff --git a/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/adapters/ConferenceRecyclerViewAdapter.kt b/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/adapters/ConferenceRecyclerViewAdapter.kt index 6a7dd36b..fa7b45c4 100644 --- a/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/adapters/ConferenceRecyclerViewAdapter.kt +++ b/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/adapters/ConferenceRecyclerViewAdapter.kt @@ -10,18 +10,18 @@ import de.nicidienase.chaosflix.touch.databinding.ItemConferenceCardviewBinding class ConferenceRecyclerViewAdapter(private val mListener: ConferencesTabBrowseFragment.OnInteractionListener?) : RecyclerView.Adapter() { - var items: List = ArrayList() + var conferences: List = emptyList() set(value) { field = value notifyDataSetChanged() } - override fun getItemCount() = items.size + override fun getItemCount() = conferences.size class ViewHolder(val binding: ItemConferenceCardviewBinding) : RecyclerView.ViewHolder(binding.root) override fun getItemId(position: Int): Long { - return items.get(position).id + return conferences.get(position).id } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { @@ -30,10 +30,10 @@ class ConferenceRecyclerViewAdapter(private val mListener: ConferencesTabBrowseF } override fun onBindViewHolder(holder: ViewHolder, position: Int) { - holder.binding.conference = items[position] + holder.binding.conference = conferences[position] holder.binding.root.setOnClickListener { _ -> - mListener?.onConferenceSelected((items[position])) + mListener?.onConferenceSelected((conferences[position])) } } } diff --git a/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/adapters/EventRecyclerViewAdapter.kt b/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/adapters/EventRecyclerViewAdapter.kt index 2442d4ae..910996d6 100644 --- a/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/adapters/EventRecyclerViewAdapter.kt +++ b/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/adapters/EventRecyclerViewAdapter.kt @@ -1,16 +1,16 @@ package de.nicidienase.chaosflix.touch.browse.adapters import android.support.v4.view.ViewCompat -import android.view.View -import com.squareup.picasso.Picasso -import de.nicidienase.chaosflix.touch.R +import android.support.v7.widget.RecyclerView +import android.view.LayoutInflater +import android.view.ViewGroup import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event import de.nicidienase.chaosflix.touch.OnEventSelectedListener +import de.nicidienase.chaosflix.touch.databinding.ItemEventCardviewBinding import java.util.* open class EventRecyclerViewAdapter(val listener: OnEventSelectedListener) : - ItemRecyclerViewAdapter() { - + ItemRecyclerViewAdapter() { override fun getComparator(): Comparator? { return Comparator { o1, o2 -> o1.title.compareTo(o2.title) } } @@ -27,40 +27,22 @@ open class EventRecyclerViewAdapter(val listener: OnEventSelectedListener) : ).filterNotNull() } - - override val layout = R.layout.item_event_cardview - var showTags: Boolean = false - - override fun onBindViewHolder(holder: ItemRecyclerViewAdapter.ViewHolder, position: Int) { - val event = items[position] - - holder.titleText.text = event.title - holder.subtitle.text = event.subtitle - if (showTags) { - val tagString = StringBuilder() - for (tag in event.tags!!) { - if (tagString.length > 0) { - tagString.append(", ") - } - tagString.append(tag) - } - holder.tag.text = tagString - } - Picasso.with(holder.icon.context) - .load(event.thumbUrl) - .noFade() - .fit() - .centerInside() - .into(holder.icon) - - val resources = holder.titleText.context.getResources() - ViewCompat.setTransitionName(holder.titleText, - resources.getString(R.string.title) + event.id) - ViewCompat.setTransitionName(holder.subtitle, - resources.getString(R.string.subtitle) + event.id) - ViewCompat.setTransitionName(holder.icon, - resources.getString(R.string.thumbnail) + event.id) - - holder.mView.setOnClickListener({ _: View -> listener.onEventSelected(items[position]) }) + override fun onCreateViewHolder(p0: ViewGroup, pItemConferenceCardviewBinding1: Int): ViewHolder { + val binding = ItemEventCardviewBinding.inflate(LayoutInflater.from(p0.context), p0, false) + return ViewHolder(binding) } + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + val event = items[position] + holder.binding.event = event + holder.binding.root.setOnClickListener { + listener.onEventSelected(event) + } + + ViewCompat.setTransitionName(holder.binding.titleText, "title_${event.guid}") + ViewCompat.setTransitionName(holder.binding.subtitleText, "subtitle_${event.guid}") + ViewCompat.setTransitionName(holder.binding.imageView, "thumb_${event.guid}") + } + + inner class ViewHolder(val binding: ItemEventCardviewBinding) : RecyclerView.ViewHolder(binding.root) } diff --git a/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/adapters/ItemRecyclerViewAdapter.kt b/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/adapters/ItemRecyclerViewAdapter.kt index 421c967b..2cb4e2a0 100644 --- a/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/adapters/ItemRecyclerViewAdapter.kt +++ b/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/adapters/ItemRecyclerViewAdapter.kt @@ -11,10 +11,8 @@ import android.widget.TextView import de.nicidienase.chaosflix.touch.R import java.util.* -abstract class ItemRecyclerViewAdapter() - : RecyclerView.Adapter.ViewHolder>(), Filterable { - - internal abstract val layout: Int +abstract class ItemRecyclerViewAdapter() + : RecyclerView.Adapter(), Filterable { abstract fun getComparator(): Comparator? @@ -52,23 +50,10 @@ abstract class ItemRecyclerViewAdapter() } } - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - val view = LayoutInflater.from(parent.context) - .inflate(layout, parent, false) - return ViewHolder(view) - } - override fun getItemCount(): Int { return filteredItems.size } - inner class ViewHolder(val mView: View) : RecyclerView.ViewHolder(mView) { - val icon: ImageView = mView.findViewById(R.id.imageView) as ImageView - val titleText: TextView = mView.findViewById(R.id.title_text) as TextView - val subtitle: TextView = mView.findViewById(R.id.subtitle_text) as TextView - val tag: TextView = mView.findViewById(R.id.tag_text) as TextView - } - inner class ItemFilter : Filter() { override fun performFiltering(filterText: CharSequence?): FilterResults { val filterResults = FilterResults() diff --git a/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/eventslist/EventsListFragment.java b/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/eventslist/EventsListFragment.java index c1327762..968465c7 100644 --- a/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/eventslist/EventsListFragment.java +++ b/touch/src/main/java/de/nicidienase/chaosflix/touch/browse/eventslist/EventsListFragment.java @@ -117,7 +117,7 @@ public class EventsListFragment extends BrowseFragment implements SearchView.OnQ } else if (type == TYPE_EVENTS) { { setupToolbar(binding.incToolbar.toolbar, conference.getTitle(), false); - eventAdapter.setShowTags(conference.getTagsUsefull()); +// eventAdapter.setShowTags(conference.getTagsUsefull()); getViewModel().getEventsforConference(conference).observe(this, events -> { if(events != null){ setEvents(events); diff --git a/touch/src/main/java/de/nicidienase/chaosflix/touch/eventdetails/EventDetailsFragment.kt b/touch/src/main/java/de/nicidienase/chaosflix/touch/eventdetails/EventDetailsFragment.kt index f64dc212..5cc59711 100644 --- a/touch/src/main/java/de/nicidienase/chaosflix/touch/eventdetails/EventDetailsFragment.kt +++ b/touch/src/main/java/de/nicidienase/chaosflix/touch/eventdetails/EventDetailsFragment.kt @@ -31,7 +31,6 @@ import de.nicidienase.chaosflix.common.viewmodel.DetailsViewModel import de.nicidienase.chaosflix.touch.databinding.FragmentEventDetailsBinding import de.nicidienase.chaosflix.touch.OnEventSelectedListener import de.nicidienase.chaosflix.common.viewmodel.ViewModelFactory -import de.nicidienase.chaosflix.touch.browse.adapters.EventRecyclerViewAdapter class EventDetailsFragment : Fragment() { @@ -44,7 +43,7 @@ class EventDetailsFragment : Fragment() { private var selectDialog: AlertDialog? = null private lateinit var viewModel: DetailsViewModel - private lateinit var relatedEventsAdapter: EventRecyclerViewAdapter + private lateinit var relatedEventsAdapter: RelatedEventsRecyclerViewAdapter override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -120,7 +119,9 @@ class EventDetailsFragment : Fragment() { }) viewModel.getRelatedEvents(event).observe(this, Observer { - relatedEventsAdapter.items = ArrayList(it) + if(it != null){ + relatedEventsAdapter.events = it + } }) viewModel.state.observe(this, Observer { liveEvent -> diff --git a/touch/src/main/java/de/nicidienase/chaosflix/touch/eventdetails/RelatedEventsRecyclerViewAdapter.kt b/touch/src/main/java/de/nicidienase/chaosflix/touch/eventdetails/RelatedEventsRecyclerViewAdapter.kt index a83cc233..b1d4a77c 100644 --- a/touch/src/main/java/de/nicidienase/chaosflix/touch/eventdetails/RelatedEventsRecyclerViewAdapter.kt +++ b/touch/src/main/java/de/nicidienase/chaosflix/touch/eventdetails/RelatedEventsRecyclerViewAdapter.kt @@ -1,9 +1,34 @@ package de.nicidienase.chaosflix.touch.eventdetails -import de.nicidienase.chaosflix.touch.R +import android.support.v7.widget.RecyclerView +import android.view.LayoutInflater +import android.view.ViewGroup +import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event import de.nicidienase.chaosflix.touch.OnEventSelectedListener -import de.nicidienase.chaosflix.touch.browse.adapters.EventRecyclerViewAdapter +import de.nicidienase.chaosflix.touch.databinding.RelatedEventCardviewLayoutBinding -class RelatedEventsRecyclerViewAdapter(listener: OnEventSelectedListener) : EventRecyclerViewAdapter(listener) { - override val layout = R.layout.related_event_cardview_layout -} \ No newline at end of file +class RelatedEventsRecyclerViewAdapter(listener: OnEventSelectedListener) : RecyclerView.Adapter() { + + init { + setHasStableIds(true) + } + + var events: List = emptyList() + set(value) { + field = value + notifyDataSetChanged() + } + + override fun getItemCount() = events.size + + override fun onCreateViewHolder(p0: ViewGroup, pItemConferenceCardviewBinding1: Int): ViewHolder { + val binding = RelatedEventCardviewLayoutBinding.inflate(LayoutInflater.from(p0.context), p0, false) + return ViewHolder(binding) + } + + override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) { + viewHolder.binding.event = events[position] + } + + inner class ViewHolder(val binding: RelatedEventCardviewLayoutBinding) : RecyclerView.ViewHolder(binding.root) +} diff --git a/touch/src/main/res/layout-large/item_event_cardview.xml b/touch/src/main/res/layout-large/item_event_cardview.xml index b6081fd6..61db2fe4 100644 --- a/touch/src/main/res/layout-large/item_event_cardview.xml +++ b/touch/src/main/res/layout-large/item_event_cardview.xml @@ -5,7 +5,9 @@ xmlns:tools="http://schemas.android.com/tools"> - + - + + + + + + + + @@ -55,7 +70,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" - android:text="" + android:text="@{event.subtitle}" tools:text="Subtitle" android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"/> diff --git a/touch/src/main/res/layout/related_event_cardview_layout.xml b/touch/src/main/res/layout/related_event_cardview_layout.xml index 1a83f85c..1c6bf7f5 100644 --- a/touch/src/main/res/layout/related_event_cardview_layout.xml +++ b/touch/src/main/res/layout/related_event_cardview_layout.xml @@ -1,88 +1,98 @@ - + - + + + + + android:layout_height="wrap_content"> - + android:layout_gravity="center" + android:foreground="?android:attr/selectableItemBackground" + card_view:cardCornerRadius="4dp"> - - - + android:layout_margin="8dp"> - + - + - - + - \ No newline at end of file + + + + + + + \ No newline at end of file