Skip to content

Commit

Permalink
Merge branch 'clean-up-addfragment' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
UweTrottmann committed Oct 17, 2024
2 parents dea7b5a + bed43ed commit 062fc14
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 373 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class AddShowDialogFragment : AppCompatDialogFragment() {
// Not added, offer to add.
binding.buttonPositive.setText(R.string.action_shows_add)
binding.buttonPositive.setOnClickListener {
EventBus.getDefault().post(AddFragment.OnAddingShowEvent(showTmdbId))
EventBus.getDefault().post(OnAddingShowEvent(showTmdbId))
addShowListener.onAddShow(SearchResult().also {
it.tmdbId = showTmdbId
it.title = show.title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import android.view.MenuItem
import android.view.View
import androidx.appcompat.widget.PopupMenu
import com.battlelancer.seriesguide.R
import com.battlelancer.seriesguide.shows.search.discover.AddFragment.OnAddingShowEvent
import com.battlelancer.seriesguide.util.TaskManager
import com.battlelancer.seriesguide.util.tasks.AddShowToWatchlistTask
import com.battlelancer.seriesguide.util.tasks.RemoveShowFromWatchlistTask
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ abstract class BaseAddShowsFragment : Fragment() {
* actually added, yet.
*/
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventAddingShow(event: AddFragment.OnAddingShowEvent) {
fun onEventAddingShow(event: OnAddingShowEvent) {
if (event.showTmdbId > 0) {
setStateForTmdbId(event.showTmdbId, SearchResult.STATE_ADDING)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ open class ItemAddShowClickListener(
}

override fun onAddClick(item: SearchResult) {
EventBus.getDefault().post(AddFragment.OnAddingShowEvent(item.tmdbId))
EventBus.getDefault().post(OnAddingShowEvent(item.tmdbId))
TaskManager.getInstance().performAddTask(context, item)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,17 @@ class ItemAddShowViewHolder(
}

// image
ImageTools.loadShowPosterResizeCrop(
context,
binding.imageViewAddPoster,
item.posterPath
// If item is provided from Trakt source, it does not provide images,
// so need to resolve them.
val posterUrl = ImageTools.posterUrlOrResolve(
item.posterPath,
item.tmdbId,
item.language,
context
)
ImageTools.loadShowPosterUrlResizeCrop(
context, binding.imageViewAddPoster,
posterUrl
)

// context/long press listener and more options button
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2024 Uwe Trottmann

package com.battlelancer.seriesguide.shows.search.discover

/**
* Event posted when a show is about to be added to the database.
*/
class OnAddingShowEvent(
/**
* Is -1 if adding all shows this lists.
*/
val showTmdbId: Int
) {
/**
* Sets TMDB id to -1 to indicate all shows of this are added.
*/
constructor() : this(-1)
}
Loading

0 comments on commit 062fc14

Please sign in to comment.