Skip to content

Commit

Permalink
Merge pull request #5 from maksim789456/master
Browse files Browse the repository at this point in the history
Новый диалог для пометки серии как непросмотренной
  • Loading branch information
RadiationX authored Jul 17, 2020
2 parents f19cbe8 + 3f9b628 commit 75de9ef
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ class ReleaseInfoPresenter @Inject constructor(
releaseInteractor.putEpisode(episode)
}

fun markEpisodeUnviewed(episode: ReleaseFull.Episode) {
episode.isViewed = false
episode.lastAccess = 0
releaseInteractor.putEpisode(episode)
}

fun onTorrentClick() {
currentData?.let {
when {
Expand Down Expand Up @@ -162,6 +168,10 @@ class ReleaseInfoPresenter @Inject constructor(
}
}

fun onLongClickEpisode(episode: ReleaseFull.Episode) {
currentData?.also { viewState.showLongPressEpisodeDialog(episode) }
}

fun onClickLink(url: String): Boolean {
return linkHandler.handle(url, router)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ interface ReleaseInfoView : IBaseView {

@StateStrategyType(SkipStrategy::class)
fun showEpisodesMenuDialog()

@StateStrategyType(SkipStrategy::class)
fun showLongPressEpisodeDialog(episode: ReleaseFull.Episode)
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ class ReleaseEpisodeDelegate(
containerView.setOnClickListener {
itemListener.onClickEpisode(currentItem)
}
containerView.setOnLongClickListener {
if (currentItem.isViewed)
{
itemListener.onLongClickEpisode(currentItem)
true
}
else
false
}
}

fun bind(item: ReleaseFull.Episode, isEven: Boolean) {
Expand Down Expand Up @@ -85,5 +94,7 @@ class ReleaseEpisodeDelegate(
fun onClickFullHd(episode: ReleaseFull.Episode)

fun onClickEpisode(episode: ReleaseFull.Episode)

fun onLongClickEpisode(episode: ReleaseFull.Episode)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,20 @@ class ReleaseInfoFragment : BaseFragment(), ReleaseInfoView {
.show()
}

override fun showLongPressEpisodeDialog(episode: ReleaseFull.Episode) {
val context = context ?: return
val items = arrayOf(
"Отметить как непросмотренная"
)
AlertDialog.Builder(context)
.setItems(items) { _, which ->
when (which) {
0 -> presenter.markEpisodeUnviewed(episode)
}
}
.show()
}

override fun playEpisode(release: ReleaseFull, episode: ReleaseFull.Episode, playFlag: Int?, quality: Int?) {
if (episode.type == ReleaseFull.Episode.Type.SOURCE) {
if (quality == null) {
Expand Down Expand Up @@ -422,6 +436,10 @@ class ReleaseInfoFragment : BaseFragment(), ReleaseInfoView {
presenter.onPlayEpisodeClick(episode, MyPlayerActivity.PLAY_FLAG_FORCE_CONTINUE)
}

override fun onLongClickEpisode(episode: ReleaseFull.Episode) {
presenter.onLongClickEpisode(episode)
}

override fun onClickTorrent() {
presenter.onTorrentClick()
}
Expand Down

0 comments on commit 75de9ef

Please sign in to comment.