add tags as chips

This commit is contained in:
Felix 2020-04-17 00:20:38 +02:00
parent 2c5c6c5111
commit 1962d5f644
6 changed files with 28 additions and 30 deletions

View file

@ -39,7 +39,10 @@ class ConferenceGroupFragment : Fragment() {
view.layoutManager = layoutManager
val conferencesAdapter = ConferenceRecyclerViewAdapter {
findNavController().navigate(
ConferencesTabBrowseFragmentDirections.actionConferencesTabBrowseFragmentToEventsListFragment(conference = it)
ConferencesTabBrowseFragmentDirections
.actionConferencesTabBrowseFragmentToEventsListFragment(
conference = it, conferenceName = it.acronym
)
)
}
conferencesAdapter.setHasStableIds(true)

View file

@ -37,7 +37,7 @@ class ConferenceEventListFragment : EventsListFragment() {
}
binding.swipeRefreshLayout.isEnabled = true
binding.swipeRefreshLayout.setOnRefreshListener {
args.conference?.let { viewModel.updateEventsForConference(it) }
viewModel.updateEventsForConference(args.conference)
}
}
}

View file

@ -42,7 +42,6 @@ abstract class EventsListFragment : Fragment() {
val binding = FragmentEventsListBinding.inflate(inflater, container, false)
val activity = requireActivity() as AppCompatActivity
activity.setSupportActionBar(binding.incToolbar.toolbar)
// overlay = binding.incOverlay.loadingOverlay
layoutManager = if (columnCount <= 1) {
LinearLayoutManager(context)
} else {
@ -93,14 +92,6 @@ abstract class EventsListFragment : Fragment() {
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater)
inflater.inflate(R.menu.events_menu, menu)
// val searchMenuItem = menu.findItem(R.id.search)
// val searchManager = activity?.getSystemService(Context.SEARCH_SERVICE) as SearchManager
// (searchMenuItem.actionView as SearchView).apply {
// setSearchableInfo(searchManager.getSearchableInfo(activity?.componentName))
// isSubmitButtonEnabled = true
// isIconified = false
// setOnQueryTextListener(this@EventsListFragment)
// }
}
companion object {

View file

@ -27,6 +27,7 @@ import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.chip.Chip
import com.google.android.material.snackbar.Snackbar
import de.nicidienase.chaosflix.common.ChaosflixUtil
import de.nicidienase.chaosflix.common.OfflineItemManager
@ -44,7 +45,6 @@ import kotlinx.coroutines.launch
class EventDetailsFragment : Fragment() {
private var appBarExpanded: Boolean = false
// private lateinit var event: Event
private var watchlistItem: WatchlistItem? = null
private var layout: View? = null
@ -57,27 +57,14 @@ class EventDetailsFragment : Fragment() {
private val args: EventDetailsFragmentArgs by navArgs()
// private val eventGuid: String
// get() = args.eventGuid
// ?: error("Event Missing")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setHasOptionsMenu(true)
// postponeEnterTransition()
// val transition = TransitionInflater.from(context)
// .inflateTransition(android.R.transition.move)
// // transition.setDuration(getResources().getInteger(R.integer.anim_duration));
// transition.setDuration(getResources().getInteger(R.integer.anim_duration));
// sharedElementEnterTransition = transition
// if (arguments != null) {
// val parcelable = arguments?.getParcelable<Event>(EVENT_PARAM)
// if (parcelable != null) {
// event = parcelable
// } else {
// throw IllegalStateException("Event Missing")
// }
// }
}
override fun onCreateView(
@ -115,6 +102,17 @@ class EventDetailsFragment : Fragment() {
Log.d(TAG, "Loading Event ${event.title}, ${event.guid}")
binding.thumbImage.transitionName = getString(R.string.thumbnail) + event.guid
binding.tagChipGroup.removeAllViews()
val chips = event.tags?.map {
Chip(requireContext()).apply {
text = it
isClickable = false
}
}
chips?.forEach {
binding.tagChipGroup.addView(it)
}
Glide.with(binding.thumbImage)
.load(event.thumbUrl)
.apply(RequestOptions().fitCenter())

View file

@ -117,6 +117,11 @@
android:text="@{event.extendedDescription}"
tools:text="description text"/>
<com.google.android.material.chip.ChipGroup
android:id="@+id/tag_chip_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/related_items_text"
android:layout_width="match_parent"

View file

@ -53,6 +53,7 @@
<fragment
android:id="@+id/eventsListFragment"
android:name="de.nicidienase.chaosflix.touch.browse.eventslist.ConferenceEventListFragment"
android:label="{conferenceName}"
tools:layout="@layout/fragment_events_list">
<action
android:id="@+id/action_eventsListFragment_to_eventDetailsFragment"
@ -60,14 +61,14 @@
<argument
android:name="conference"
app:argType="de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Conference" />
<deepLink
android:id="@+id/deepLink"
app:uri="media.ccc.de/c/{conferenceName}" />
<argument
android:name="conferenceName"
android:defaultValue="@null"
app:argType="string"
app:nullable="true" />
<deepLink
android:id="@+id/deepLink"
app:uri="media.ccc.de/c/{conferenceName}" />
</fragment>
<fragment
android:id="@+id/exoPlayerFragment"
@ -90,7 +91,7 @@
<fragment
android:id="@+id/searchFragment"
android:name="de.nicidienase.chaosflix.touch.search.SearchFragment"
android:label="{query}"
android:label="Search: {query}"
tools:layout="@layout/fragment_events_list">
<action
android:id="@+id/action_searchFragment_to_eventDetailsFragment"