Commit 6fc510fe authored by Eugene Shapovalov's avatar Eugene Shapovalov 💬

Fix discussion comments.

parent 0468b472
......@@ -6,7 +6,7 @@ import com.hannesdorfmann.adapterdelegates3.ListDelegationAdapter
import ru.terrakok.gitlabclient.presentation.global.NoteWithFormattedBody
class TargetNotesAdapter(
private val nextListener: () -> Unit
private val nextPageListener: () -> Unit
) : ListDelegationAdapter<MutableList<Any>>() {
init {
......@@ -49,7 +49,7 @@ class TargetNotesAdapter(
) {
super.onBindViewHolder(holder, position, payloads)
if (position == items.size - 10) nextListener()
if (position == items.size - 10) nextPageListener()
}
private inner class DiffCallback(
......
......@@ -5,6 +5,7 @@ import android.support.v7.widget.LinearLayoutManager
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import kotlinx.android.synthetic.main.layout_base_list.*
import kotlinx.android.synthetic.main.layout_zero.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.extension.visible
......@@ -13,6 +14,7 @@ import ru.terrakok.gitlabclient.presentation.issue.notes.IssueNotesPresenter
import ru.terrakok.gitlabclient.presentation.issue.notes.IssueNotesView
import ru.terrakok.gitlabclient.toothpick.DI
import ru.terrakok.gitlabclient.ui.global.BaseFragment
import ru.terrakok.gitlabclient.ui.global.ZeroViewHolder
import ru.terrakok.gitlabclient.ui.global.list.SimpleDividerDecorator
import ru.terrakok.gitlabclient.ui.global.list.TargetNotesAdapter
import toothpick.Toothpick
......@@ -25,6 +27,7 @@ class IssueNotesFragment : BaseFragment(), IssueNotesView {
override val layoutRes = R.layout.fragment_issue_notes
private val adapter by lazy { TargetNotesAdapter({ presenter.loadNextIssuesPage() }) }
private var zeroViewHolder: ZeroViewHolder? = null
@InjectPresenter
lateinit var presenter: IssueNotesPresenter
......@@ -45,29 +48,38 @@ class IssueNotesFragment : BaseFragment(), IssueNotesView {
}
swipeToRefresh.setOnRefreshListener { presenter.refreshNotes() }
zeroViewHolder = ZeroViewHolder(zeroLayout, { presenter.refreshNotes() })
}
override fun showRefreshProgress(show: Boolean) {
swipeToRefresh.post { swipeToRefresh.isRefreshing = show }
postViewAction { swipeToRefresh.isRefreshing = show }
}
override fun showEmptyProgress(show: Boolean) {
swipeToRefresh.post { swipeToRefresh.isRefreshing = false }
fullscreenProgressView.visible(show)
//trick for disable and hide swipeToRefresh on fullscreen progress
swipeToRefresh.visible(!show)
postViewAction { swipeToRefresh.isRefreshing = false }
}
override fun showPageProgress(show: Boolean) {
recyclerView.post { adapter.showProgress(show) }
postViewAction { adapter.showProgress(show) }
}
override fun showEmptyView(show: Boolean) {
if (show) zeroViewHolder?.showEmptyData()
else zeroViewHolder?.hide()
}
override fun showEmptyError(show: Boolean, message: String?) {
if (show) zeroViewHolder?.showEmptyError(message)
else zeroViewHolder?.hide()
}
override fun showNotes(show: Boolean, notes: List<NoteWithFormattedBody>) {
recyclerView.visible(show)
recyclerView.post { adapter.setData(notes) }
postViewAction { adapter.setData(notes) }
}
override fun showMessage(message: String) {
......
......@@ -5,6 +5,7 @@ import android.support.v7.widget.LinearLayoutManager
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import kotlinx.android.synthetic.main.layout_base_list.*
import kotlinx.android.synthetic.main.layout_zero.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.extension.visible
......@@ -13,6 +14,7 @@ import ru.terrakok.gitlabclient.presentation.mergerequest.notes.MergeRequestNote
import ru.terrakok.gitlabclient.presentation.mergerequest.notes.MergeRequestNotesView
import ru.terrakok.gitlabclient.toothpick.DI
import ru.terrakok.gitlabclient.ui.global.BaseFragment
import ru.terrakok.gitlabclient.ui.global.ZeroViewHolder
import ru.terrakok.gitlabclient.ui.global.list.SimpleDividerDecorator
import ru.terrakok.gitlabclient.ui.global.list.TargetNotesAdapter
import toothpick.Toothpick
......@@ -25,6 +27,7 @@ class MergeRequestNotesFragment : BaseFragment(), MergeRequestNotesView {
override val layoutRes = R.layout.fragment_mr_notes
private val adapter by lazy { TargetNotesAdapter({ presenter.loadNextMergeRequestsPage() }) }
private var zeroViewHolder: ZeroViewHolder? = null
@InjectPresenter
lateinit var presenter: MergeRequestNotesPresenter
......@@ -45,29 +48,38 @@ class MergeRequestNotesFragment : BaseFragment(), MergeRequestNotesView {
}
swipeToRefresh.setOnRefreshListener { presenter.refreshNotes() }
zeroViewHolder = ZeroViewHolder(zeroLayout, { presenter.refreshNotes() })
}
override fun showRefreshProgress(show: Boolean) {
swipeToRefresh.post { swipeToRefresh.isRefreshing = show }
postViewAction { swipeToRefresh.isRefreshing = show }
}
override fun showEmptyProgress(show: Boolean) {
swipeToRefresh.post { swipeToRefresh.isRefreshing = false }
fullscreenProgressView.visible(show)
//trick for disable and hide swipeToRefresh on fullscreen progress
swipeToRefresh.visible(!show)
postViewAction { swipeToRefresh.isRefreshing = false }
}
override fun showPageProgress(show: Boolean) {
recyclerView.post { adapter.showProgress(show) }
postViewAction { adapter.showProgress(show) }
}
override fun showEmptyView(show: Boolean) {
if (show) zeroViewHolder?.showEmptyData()
else zeroViewHolder?.hide()
}
override fun showEmptyError(show: Boolean, message: String?) {
if (show) zeroViewHolder?.showEmptyError(message)
else zeroViewHolder?.hide()
}
override fun showNotes(show: Boolean, notes: List<NoteWithFormattedBody>) {
recyclerView.visible(show)
recyclerView.post { adapter.setData(notes) }
postViewAction { adapter.setData(notes) }
}
override fun showMessage(message: String) {
......
......@@ -11,7 +11,7 @@ import ru.terrakok.gitlabclient.ui.global.list.TargetHeaderAdapterDelegate
class TargetsAdapter(
userClickListener: (Long) -> Unit,
clickListener: (TargetHeader) -> Unit,
private val nextListener: () -> Unit
private val nextPageListener: () -> Unit
) : ListDelegationAdapter<MutableList<Any>>() {
init {
......@@ -56,7 +56,7 @@ class TargetsAdapter(
) {
super.onBindViewHolder(holder, position, payloads)
if (position == items.size - 10) nextListener()
if (position == items.size - 10) nextPageListener()
}
private inner class DiffCallback(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment