Commit aad285a6 authored by Konstantin Tskhovrebov's avatar Konstantin Tskhovrebov 🤖

Merge branch...

Merge branch 'task/markdown-text-view_replace-markdown-converters-with-markdown-text-view-on-all-lists' into 'feature/markdown-view'

[After !136] Replaced every MarkDownConverter usage with MarkdownTextView on all lists.

See merge request terrakok/gitlab-client!137
parents 08563a4a 63af66a1
......@@ -11,7 +11,7 @@ sealed class TargetHeader {
val author: Author,
val icon: TargetHeaderIcon,
val title: TargetHeaderTitle,
val body: CharSequence,
val body: String,
val date: LocalDateTime,
val target: AppTarget,
val targetId: Long,
......
......@@ -5,7 +5,6 @@ import ru.terrakok.gitlabclient.entity.app.CommitWithAvatarUrl
import ru.terrakok.gitlabclient.model.interactor.mergerequest.MergeRequestInteractor
import ru.terrakok.gitlabclient.presentation.global.BasePresenter
import ru.terrakok.gitlabclient.presentation.global.ErrorHandler
import ru.terrakok.gitlabclient.presentation.global.MarkDownConverter
import ru.terrakok.gitlabclient.presentation.global.Paginator
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.MergeRequestId
......@@ -20,7 +19,6 @@ class MergeRequestCommitsPresenter @Inject constructor(
@ProjectId projectIdWrapper: PrimitiveWrapper<Long>,
@MergeRequestId mrIdWrapper: PrimitiveWrapper<Long>,
private val mrInteractor: MergeRequestInteractor,
private val mdConverter: MarkDownConverter,
private val errorHandler: ErrorHandler
) : BasePresenter<MergeRequestCommitsView>() {
......
package ru.terrakok.gitlabclient.presentation.my.events
import com.arellomobile.mvp.InjectViewState
import io.reactivex.Observable
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.entity.app.target.TargetHeader
import ru.terrakok.gitlabclient.extension.openInfo
import ru.terrakok.gitlabclient.model.interactor.event.EventInteractor
import ru.terrakok.gitlabclient.model.system.flow.FlowRouter
import ru.terrakok.gitlabclient.presentation.global.*
import ru.terrakok.gitlabclient.presentation.global.BasePresenter
import ru.terrakok.gitlabclient.presentation.global.ErrorHandler
import ru.terrakok.gitlabclient.presentation.global.GlobalMenuController
import ru.terrakok.gitlabclient.presentation.global.Paginator
import javax.inject.Inject
/**
......@@ -16,7 +18,6 @@ import javax.inject.Inject
@InjectViewState
class MyEventsPresenter @Inject constructor(
private val eventInteractor: EventInteractor,
private val mdConverter: MarkDownConverter,
private val menuController: GlobalMenuController,
private val errorHandler: ErrorHandler,
private val router: FlowRouter
......@@ -29,21 +30,7 @@ class MyEventsPresenter @Inject constructor(
}
private val paginator = Paginator(
{
eventInteractor.getEvents(it)
.flattenAsObservable { it }
.concatMap { item ->
when (item) {
is TargetHeader.Public -> {
mdConverter.markdownToSpannable(item.body.toString())
.map { md -> item.copy(body = md) }
.toObservable()
}
is TargetHeader.Confidential -> Observable.just(item)
}
}
.toList()
},
{ eventInteractor.getEvents(it) },
object : Paginator.ViewController<TargetHeader> {
override fun showEmptyProgress(show: Boolean) {
viewState.showEmptyProgress(show)
......
package ru.terrakok.gitlabclient.presentation.my.issues
import com.arellomobile.mvp.InjectViewState
import io.reactivex.Observable
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.entity.app.target.TargetHeader
import ru.terrakok.gitlabclient.extension.openInfo
......@@ -9,7 +8,6 @@ import ru.terrakok.gitlabclient.model.interactor.issue.IssueInteractor
import ru.terrakok.gitlabclient.model.system.flow.FlowRouter
import ru.terrakok.gitlabclient.presentation.global.BasePresenter
import ru.terrakok.gitlabclient.presentation.global.ErrorHandler
import ru.terrakok.gitlabclient.presentation.global.MarkDownConverter
import ru.terrakok.gitlabclient.presentation.global.Paginator
import javax.inject.Inject
......@@ -20,7 +18,6 @@ import javax.inject.Inject
class MyIssuesPresenter @Inject constructor(
initFilter: Filter,
private val issueInteractor: IssueInteractor,
private val mdConverter: MarkDownConverter,
private val errorHandler: ErrorHandler,
private val router: FlowRouter
) : BasePresenter<MyIssuesView>() {
......@@ -35,21 +32,7 @@ class MyIssuesPresenter @Inject constructor(
}
private val paginator = Paginator(
{
issueInteractor.getMyIssues(filter.createdByMe, filter.onlyOpened, it)
.flattenAsObservable { it }
.concatMap { item ->
when (item) {
is TargetHeader.Public -> {
mdConverter.markdownToSpannable(item.body.toString())
.map { md -> item.copy(body = md) }
.toObservable()
}
is TargetHeader.Confidential -> Observable.just(item)
}
}
.toList()
},
{ issueInteractor.getMyIssues(filter.createdByMe, filter.onlyOpened, it) },
object : Paginator.ViewController<TargetHeader> {
override fun showEmptyProgress(show: Boolean) {
viewState.showEmptyProgress(show)
......
package ru.terrakok.gitlabclient.presentation.my.mergerequests
import com.arellomobile.mvp.InjectViewState
import io.reactivex.Observable
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.entity.app.target.TargetHeader
import ru.terrakok.gitlabclient.extension.openInfo
......@@ -9,7 +8,6 @@ import ru.terrakok.gitlabclient.model.interactor.mergerequest.MergeRequestIntera
import ru.terrakok.gitlabclient.model.system.flow.FlowRouter
import ru.terrakok.gitlabclient.presentation.global.BasePresenter
import ru.terrakok.gitlabclient.presentation.global.ErrorHandler
import ru.terrakok.gitlabclient.presentation.global.MarkDownConverter
import ru.terrakok.gitlabclient.presentation.global.Paginator
import javax.inject.Inject
......@@ -17,7 +15,6 @@ import javax.inject.Inject
class MyMergeRequestsPresenter @Inject constructor(
initFilter: Filter,
private val interactor: MergeRequestInteractor,
private val mdConverter: MarkDownConverter,
private val errorHandler: ErrorHandler,
private val router: FlowRouter
) : BasePresenter<MyMergeRequestListView>() {
......@@ -32,21 +29,7 @@ class MyMergeRequestsPresenter @Inject constructor(
}
private val paginator = Paginator(
{
interactor.getMyMergeRequests(filter.createdByMe, filter.onlyOpened, it)
.flattenAsObservable { it }
.concatMap { item ->
when (item) {
is TargetHeader.Public -> {
mdConverter.markdownToSpannable(item.body.toString())
.map { md -> item.copy(body = md) }
.toObservable()
}
is TargetHeader.Confidential -> Observable.just(item)
}
}
.toList()
},
{ interactor.getMyMergeRequests(filter.createdByMe, filter.onlyOpened, it) },
object : Paginator.ViewController<TargetHeader> {
override fun showEmptyProgress(show: Boolean) {
viewState.showEmptyProgress(show)
......
package ru.terrakok.gitlabclient.presentation.my.todos
import com.arellomobile.mvp.InjectViewState
import io.reactivex.Observable
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.entity.app.target.TargetHeader
import ru.terrakok.gitlabclient.extension.openInfo
......@@ -9,7 +8,6 @@ import ru.terrakok.gitlabclient.model.interactor.todo.TodoListInteractor
import ru.terrakok.gitlabclient.model.system.flow.FlowRouter
import ru.terrakok.gitlabclient.presentation.global.BasePresenter
import ru.terrakok.gitlabclient.presentation.global.ErrorHandler
import ru.terrakok.gitlabclient.presentation.global.MarkDownConverter
import ru.terrakok.gitlabclient.presentation.global.Paginator
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.TodoListPendingState
......@@ -22,7 +20,6 @@ import javax.inject.Inject
class MyTodosPresenter @Inject constructor(
@TodoListPendingState private val pendingStateWrapper: PrimitiveWrapper<Boolean>,
private val todoListInteractor: TodoListInteractor,
private val mdConverter: MarkDownConverter,
private val errorHandler: ErrorHandler,
private val router: FlowRouter
) : BasePresenter<MyTodoListView>() {
......@@ -36,21 +33,7 @@ class MyTodosPresenter @Inject constructor(
}
private val paginator = Paginator(
{
todoListInteractor.getMyTodos(isPending, it)
.flattenAsObservable { it }
.concatMap { item ->
when (item) {
is TargetHeader.Public -> {
mdConverter.markdownToSpannable(item.body.toString())
.map { md -> item.copy(body = md) }
.toObservable()
}
is TargetHeader.Confidential -> Observable.just(item)
}
}
.toList()
},
{ todoListInteractor.getMyTodos(isPending, it) },
object : Paginator.ViewController<TargetHeader> {
override fun showEmptyProgress(show: Boolean) {
viewState.showEmptyProgress(show)
......
package ru.terrakok.gitlabclient.presentation.project.events
import com.arellomobile.mvp.InjectViewState
import io.reactivex.Observable
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.entity.app.target.TargetHeader
import ru.terrakok.gitlabclient.extension.openInfo
......@@ -9,7 +8,6 @@ import ru.terrakok.gitlabclient.model.interactor.event.EventInteractor
import ru.terrakok.gitlabclient.model.system.flow.FlowRouter
import ru.terrakok.gitlabclient.presentation.global.BasePresenter
import ru.terrakok.gitlabclient.presentation.global.ErrorHandler
import ru.terrakok.gitlabclient.presentation.global.MarkDownConverter
import ru.terrakok.gitlabclient.presentation.global.Paginator
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.ProjectId
......@@ -22,7 +20,6 @@ import javax.inject.Inject
class ProjectEventsPresenter @Inject constructor(
@ProjectId private val projectIdWrapper: PrimitiveWrapper<Long>,
private val eventInteractor: EventInteractor,
private val mdConverter: MarkDownConverter,
private val errorHandler: ErrorHandler,
private val router: FlowRouter
) : BasePresenter<ProjectEventsView>() {
......@@ -36,21 +33,7 @@ class ProjectEventsPresenter @Inject constructor(
}
private val paginator = Paginator(
{
eventInteractor.getProjectEvents(projectId, it)
.flattenAsObservable { it }
.concatMap { item ->
when (item) {
is TargetHeader.Public -> {
mdConverter.markdownToSpannable(item.body.toString())
.map { md -> item.copy(body = md) }
.toObservable()
}
is TargetHeader.Confidential -> Observable.just(item)
}
}
.toList()
},
{ eventInteractor.getProjectEvents(projectId, it) },
object : Paginator.ViewController<TargetHeader> {
override fun showEmptyProgress(show: Boolean) {
viewState.showEmptyProgress(show)
......
package ru.terrakok.gitlabclient.presentation.project.issues
import com.arellomobile.mvp.InjectViewState
import io.reactivex.Observable
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.entity.app.target.TargetHeader
import ru.terrakok.gitlabclient.entity.issue.IssueState
......@@ -10,7 +9,6 @@ import ru.terrakok.gitlabclient.model.interactor.issue.IssueInteractor
import ru.terrakok.gitlabclient.model.system.flow.FlowRouter
import ru.terrakok.gitlabclient.presentation.global.BasePresenter
import ru.terrakok.gitlabclient.presentation.global.ErrorHandler
import ru.terrakok.gitlabclient.presentation.global.MarkDownConverter
import ru.terrakok.gitlabclient.presentation.global.Paginator
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.ProjectId
......@@ -24,7 +22,6 @@ class ProjectIssuesPresenter @Inject constructor(
@ProjectId private val projectIdWrapper: PrimitiveWrapper<Long>,
private val issueState: IssueState,
private val issueInteractor: IssueInteractor,
private val mdConverter: MarkDownConverter,
private val errorHandler: ErrorHandler,
private val router: FlowRouter
) : BasePresenter<ProjectIssuesView>() {
......@@ -38,21 +35,7 @@ class ProjectIssuesPresenter @Inject constructor(
}
private val paginator = Paginator(
{
issueInteractor.getIssues(projectId, issueState, it)
.flattenAsObservable { it }
.concatMap { item ->
when (item) {
is TargetHeader.Public -> {
mdConverter.markdownToSpannable(item.body.toString())
.map { md -> item.copy(body = md) }
.toObservable()
}
is TargetHeader.Confidential -> Observable.just(item)
}
}
.toList()
},
{ issueInteractor.getIssues(projectId, issueState, it) },
object : Paginator.ViewController<TargetHeader> {
override fun showEmptyProgress(show: Boolean) {
viewState.showEmptyProgress(show)
......
package ru.terrakok.gitlabclient.presentation.project.mergerequest
import com.arellomobile.mvp.InjectViewState
import io.reactivex.Observable
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.entity.app.target.TargetHeader
import ru.terrakok.gitlabclient.entity.mergerequest.MergeRequestState
......@@ -10,7 +9,6 @@ import ru.terrakok.gitlabclient.model.interactor.mergerequest.MergeRequestIntera
import ru.terrakok.gitlabclient.model.system.flow.FlowRouter
import ru.terrakok.gitlabclient.presentation.global.BasePresenter
import ru.terrakok.gitlabclient.presentation.global.ErrorHandler
import ru.terrakok.gitlabclient.presentation.global.MarkDownConverter
import ru.terrakok.gitlabclient.presentation.global.Paginator
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.ProjectId
......@@ -24,7 +22,6 @@ class ProjectMergeRequestsPresenter @Inject constructor(
@ProjectId private val projectIdWrapper: PrimitiveWrapper<Long>,
private val mergeRequestState: MergeRequestState,
private val mergeRequestInteractor: MergeRequestInteractor,
private val mdConverter: MarkDownConverter,
private val errorHandler: ErrorHandler,
private val router: FlowRouter
) : BasePresenter<ProjectMergeRequestsView>() {
......@@ -38,21 +35,7 @@ class ProjectMergeRequestsPresenter @Inject constructor(
}
private val paginator = Paginator(
{
mergeRequestInteractor.getMergeRequests(projectId, mergeRequestState, it)
.flattenAsObservable { it }
.concatMap { item ->
when (item) {
is TargetHeader.Public -> {
mdConverter.markdownToSpannable(item.body.toString())
.map { md -> item.copy(body = md) }
.toObservable()
}
is TargetHeader.Confidential -> Observable.just(item)
}
}
.toList()
},
{ mergeRequestInteractor.getMergeRequests(projectId, mergeRequestState, it) },
object : Paginator.ViewController<TargetHeader> {
override fun showEmptyProgress(show: Boolean) {
viewState.showEmptyProgress(show)
......
......@@ -4,10 +4,10 @@ import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.arellomobile.mvp.MvpDelegate
import com.hannesdorfmann.adapterdelegates3.AdapterDelegate
import kotlinx.android.synthetic.main.item_target_badge.view.*
import kotlinx.android.synthetic.main.item_target_header_public.view.*
import ru.noties.markwon.Markwon
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.app.target.TargetBadge
import ru.terrakok.gitlabclient.entity.app.target.TargetBadgeIcon
......@@ -19,6 +19,7 @@ import ru.terrakok.gitlabclient.extension.*
* @author Konstantin Tskhovrebov (aka terrakok) on 18.06.17.
*/
class TargetHeaderPublicAdapterDelegate(
private val mvpDelegate: MvpDelegate<*>,
private val avatarClickListener: (Long) -> Unit,
private val clickListener: (TargetHeader.Public) -> Unit
) : AdapterDelegate<MutableList<Any>>() {
......@@ -65,13 +66,14 @@ class TargetHeaderPublicAdapterDelegate(
this.item = item
with(itemView) {
titleTextView.text = item.title.getHumanName(resources)
Markwon.setText(descriptionTextView, item.body)
descriptionTextView.movementMethod = null //disable internal link click
descriptionMarkdownTextView.initWithParentDelegate(mvpDelegate)
descriptionMarkdownTextView.setMarkdown(item.body, item.internal?.projectId)
descriptionMarkdownTextView.movementMethod = null //disable internal link click
avatarImageView.loadRoundedImage(item.author.avatarUrl)
iconImageView.setImageResource(item.icon.getIcon())
dateTextView.text = item.date.humanTime(resources)
descriptionTextView.visible(item.body.isNotEmpty())
descriptionMarkdownTextView.visible(item.body.isNotEmpty())
iconImageView.visible(item.icon != TargetHeaderIcon.NONE)
bindBadges(item.badges)
......
......@@ -2,6 +2,7 @@ package ru.terrakok.gitlabclient.ui.my
import android.support.v7.util.DiffUtil
import android.support.v7.widget.RecyclerView
import com.arellomobile.mvp.MvpDelegate
import com.hannesdorfmann.adapterdelegates3.ListDelegationAdapter
import ru.terrakok.gitlabclient.entity.app.target.TargetHeader
import ru.terrakok.gitlabclient.ui.global.list.ProgressAdapterDelegate
......@@ -10,6 +11,7 @@ import ru.terrakok.gitlabclient.ui.global.list.TargetHeaderConfidentialAdapterDe
import ru.terrakok.gitlabclient.ui.global.list.TargetHeaderPublicAdapterDelegate
class TargetsAdapter(
mvpDelegate: MvpDelegate<*>,
userClickListener: (Long) -> Unit,
clickListener: (TargetHeader.Public) -> Unit,
private val nextPageListener: () -> Unit
......@@ -17,7 +19,7 @@ class TargetsAdapter(
init {
items = mutableListOf()
delegatesManager.addDelegate(TargetHeaderPublicAdapterDelegate(userClickListener, clickListener))
delegatesManager.addDelegate(TargetHeaderPublicAdapterDelegate(mvpDelegate, userClickListener, clickListener))
delegatesManager.addDelegate(TargetHeaderConfidentialAdapterDelegate())
delegatesManager.addDelegate(ProgressAdapterDelegate())
}
......
......@@ -28,6 +28,7 @@ class MyEventsFragment : BaseFragment(), MyEventsView {
private val adapter: TargetsAdapter by lazy {
TargetsAdapter(
mvpDelegate,
{ presenter.onUserClick(it) },
{ presenter.onItemClick(it) },
{ presenter.loadNextEventsPage() }
......
......@@ -30,6 +30,7 @@ class MyIssuesFragment : BaseFragment(), MyIssuesView {
private val adapter: TargetsAdapter by lazy {
TargetsAdapter(
mvpDelegate,
{ presenter.onUserClick(it) },
{ presenter.onIssueClick(it) },
{ presenter.loadNextIssuesPage() }
......
......@@ -30,6 +30,7 @@ class MyMergeRequestsFragment : BaseFragment(), MyMergeRequestListView {
private val adapter: TargetsAdapter by lazy {
TargetsAdapter(
mvpDelegate,
{ presenter.onUserClick(it) },
{ presenter.onMergeRequestClick(it) },
{ presenter.loadNextMergeRequestsPage() }
......
......@@ -29,6 +29,7 @@ class MyTodosFragment : BaseFragment(), MyTodoListView {
private val adapter: TargetsAdapter by lazy {
TargetsAdapter(
mvpDelegate,
{ presenter.onUserClick(it) },
{ presenter.onTodoClick(it) },
{ presenter.loadNextTodosPage() }
......
......@@ -27,6 +27,7 @@ class ProjectEventsFragment : BaseFragment(), ProjectEventsView {
private val adapter: TargetsAdapter by lazy {
TargetsAdapter(
mvpDelegate,
{ presenter.onUserClick(it) },
{ presenter.onItemClick(it) },
{ presenter.loadNextEventsPage() }
......
......@@ -43,6 +43,7 @@ class ProjectIssuesFragment : BaseFragment(), ProjectIssuesView {
private val adapter: TargetsAdapter by lazy {
TargetsAdapter(
mvpDelegate,
{ presenter.onUserClick(it) },
{ presenter.onIssueClick(it) },
{ presenter.loadNextIssuesPage() }
......
......@@ -43,6 +43,7 @@ class ProjectMergeRequestsFragment : BaseFragment(), ProjectMergeRequestsView {
private val adapter: TargetsAdapter by lazy {
TargetsAdapter(
mvpDelegate,
{ presenter.onUserClick(it) },
{ presenter.onMergeRequestClick(it) },
{ presenter.loadNextMergeRequestsPage() }
......
......@@ -40,8 +40,8 @@
app:layout_constraintTop_toTopOf="@id/avatarImageView"
tools:text="GitLab Community Edition by Annabel Dunstone Gray" />
<TextView
android:id="@+id/descriptionTextView"
<ru.terrakok.gitlabclient.ui.global.markdown.MarkdownTextView
android:id="@+id/descriptionMarkdownTextView"
style="@style/TextBody"
android:layout_width="0dp"
android:layout_height="wrap_content"
......@@ -60,7 +60,7 @@
app:flexWrap="wrap"
app:layout_constraintLeft_toLeftOf="@id/titleTextView"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/descriptionTextView" />
app:layout_constraintTop_toBottomOf="@+id/descriptionMarkdownTextView" />
<TextView
android:id="@+id/dateTextView"
......
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