...
 
Commits (17)
......@@ -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,
......
......@@ -2,4 +2,4 @@ package ru.terrakok.gitlabclient.presentation.global
import ru.terrakok.gitlabclient.entity.Note
data class NoteWithFormattedBody(val note: Note, val body: CharSequence)
\ No newline at end of file
data class NoteWithProjectId(val note: Note, val projectId: Long)
\ No newline at end of file
......@@ -4,7 +4,6 @@ import com.arellomobile.mvp.InjectViewState
import ru.terrakok.gitlabclient.model.interactor.issue.IssueInteractor
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.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.IssueId
import ru.terrakok.gitlabclient.toothpick.qualifier.ProjectId
......@@ -18,7 +17,6 @@ class IssueInfoPresenter @Inject constructor(
@ProjectId private val projectIdWrapper: PrimitiveWrapper<Long>,
@IssueId private val issueIdWrapper: PrimitiveWrapper<Long>,
private val issueInteractor: IssueInteractor,
private val mdConverter: MarkDownConverter,
private val errorHandler: ErrorHandler
) : BasePresenter<IssueInfoView>() {
......@@ -30,15 +28,10 @@ class IssueInfoPresenter @Inject constructor(
issueInteractor
.getIssue(projectId, issueId)
.flatMap { issue ->
mdConverter
.markdownToSpannable(issue.description)
.map { Pair(issue, it) }
}
.doOnSubscribe { viewState.showEmptyProgress(true) }
.doAfterTerminate { viewState.showEmptyProgress(false) }
.subscribe(
{ (issue, mdDescription) -> viewState.showInfo(issue, mdDescription) },
{ issue -> viewState.showInfo(issue) },
{ errorHandler.proceed(it, { viewState.showMessage(it) }) }
)
.connect()
......
......@@ -11,7 +11,7 @@ import ru.terrakok.gitlabclient.entity.issue.Issue
*/
@StateStrategyType(AddToEndSingleStrategy::class)
interface IssueInfoView : MvpView {
fun showInfo(issue: Issue, mdDescription: CharSequence)
fun showInfo(issue: Issue)
fun showEmptyProgress(show: Boolean)
@StateStrategyType(OneExecutionStateStrategy::class)
......
......@@ -2,10 +2,9 @@ package ru.terrakok.gitlabclient.presentation.issue.notes
import com.arellomobile.mvp.InjectViewState
import ru.terrakok.gitlabclient.model.interactor.issue.IssueInteractor
import ru.terrakok.gitlabclient.presentation.global.NoteWithProjectId
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.NoteWithFormattedBody
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.IssueId
import ru.terrakok.gitlabclient.toothpick.qualifier.ProjectId
......@@ -19,7 +18,6 @@ class IssueNotesPresenter @Inject constructor(
@ProjectId projectIdWrapper: PrimitiveWrapper<Long>,
@IssueId issueIdWrapper: PrimitiveWrapper<Long>,
private val issueInteractor: IssueInteractor,
private val mdConverter: MarkDownConverter,
private val errorHandler: ErrorHandler
) : BasePresenter<IssueNotesView>() {
......@@ -33,15 +31,13 @@ class IssueNotesPresenter @Inject constructor(
.getAllIssueNotes(projectId, issueId)
.doOnSubscribe { viewState.showEmptyProgress(true) }
.doAfterTerminate { viewState.showEmptyProgress(false) }
.flattenAsObservable { it }
.concatMap { note ->
mdConverter.markdownToSpannable(note.body)
.map { NoteWithFormattedBody(note, it) }
.toObservable()
}
.toList()
.subscribe(
{ viewState.showNotes(it, false) },
{ viewState.showNotes(it.map {
NoteWithProjectId(
it,
projectId
)
}, false) },
{ errorHandler.proceed(it, { viewState.showMessage(it) }) }
)
.connect()
......@@ -51,18 +47,16 @@ class IssueNotesPresenter @Inject constructor(
issueInteractor.createIssueNote(projectId, issueId, body)
.flatMap {
issueInteractor.getAllIssueNotes(projectId, issueId)
.flattenAsObservable { it }
.concatMap { note ->
mdConverter.markdownToSpannable(note.body)
.map { NoteWithFormattedBody(note, it) }
.toObservable()
}
.toList()
}
.doOnSubscribe { viewState.showBlockingProgress(true) }
.doAfterTerminate { viewState.showBlockingProgress(false) }
.subscribe(
{ viewState.showNotes(it, true) },
{ viewState.showNotes(it.map {
NoteWithProjectId(
it,
projectId
)
}, true) },
{ errorHandler.proceed(it, { viewState.showMessage(it) }) }
)
.connect()
......
......@@ -4,7 +4,7 @@ import com.arellomobile.mvp.MvpView
import com.arellomobile.mvp.viewstate.strategy.AddToEndSingleStrategy
import com.arellomobile.mvp.viewstate.strategy.OneExecutionStateStrategy
import com.arellomobile.mvp.viewstate.strategy.StateStrategyType
import ru.terrakok.gitlabclient.presentation.global.NoteWithFormattedBody
import ru.terrakok.gitlabclient.presentation.global.NoteWithProjectId
/**
* Created by Konstantin Tskhovrebov (aka @terrakok) on 12.02.18.
......@@ -13,7 +13,7 @@ import ru.terrakok.gitlabclient.presentation.global.NoteWithFormattedBody
interface IssueNotesView : MvpView {
fun showEmptyProgress(show: Boolean)
fun showNotes(notes: List<NoteWithFormattedBody>, scrollToEnd: Boolean)
fun showNotes(notes: List<NoteWithProjectId>, scrollToEnd: Boolean)
fun showBlockingProgress(show: Boolean)
@StateStrategyType(OneExecutionStateStrategy::class)
......
package ru.terrakok.gitlabclient.presentation.markdown
import com.arellomobile.mvp.InjectViewState
import io.reactivex.disposables.Disposable
import ru.terrakok.gitlabclient.presentation.global.BasePresenter
import ru.terrakok.gitlabclient.presentation.global.ErrorHandler
import ru.terrakok.gitlabclient.presentation.global.MarkDownConverter
import javax.inject.Inject
@InjectViewState
class MarkdownPresenter @Inject constructor(
private val markDownConverter: MarkDownConverter,
private val errorHandler: ErrorHandler
) : BasePresenter<MarkdownView>() {
private var conversionDisposable: Disposable? = null
fun setMarkdown(markdown: String, projectId: Long?) {
conversionDisposable?.dispose()
conversionDisposable = markDownConverter
.markdownToSpannable(markdown)
.subscribe(
{ viewState.setMarkdownText(it) },
{ errorHandler.proceed(it) }
)
}
override fun detachView(view: MarkdownView?) {
super.detachView(view)
conversionDisposable?.dispose()
}
override fun onDestroy() {
super.onDestroy()
conversionDisposable?.dispose()
}
}
\ No newline at end of file
package ru.terrakok.gitlabclient.presentation.markdown
import com.arellomobile.mvp.MvpView
import com.arellomobile.mvp.viewstate.strategy.OneExecutionStateStrategy
import com.arellomobile.mvp.viewstate.strategy.StateStrategyType
@StateStrategyType(OneExecutionStateStrategy::class)
interface MarkdownView : MvpView {
fun setMarkdownText(text: CharSequence)
}
\ No newline at end of file
......@@ -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>() {
......
......@@ -4,7 +4,6 @@ import com.arellomobile.mvp.InjectViewState
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.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.MergeRequestId
import ru.terrakok.gitlabclient.toothpick.qualifier.ProjectId
......@@ -18,7 +17,6 @@ class MergeRequestInfoPresenter @Inject constructor(
@ProjectId projectIdWrapper: PrimitiveWrapper<Long>,
@MergeRequestId mrIdWrapper: PrimitiveWrapper<Long>,
private val mrInteractor: MergeRequestInteractor,
private val mdConverter: MarkDownConverter,
private val errorHandler: ErrorHandler
) : BasePresenter<MergeRequestInfoView>() {
......@@ -30,15 +28,10 @@ class MergeRequestInfoPresenter @Inject constructor(
mrInteractor
.getMergeRequest(projectId, mrId)
.flatMap { mr ->
mdConverter
.markdownToSpannable(mr.description)
.map { Pair(mr, it) }
}
.doOnSubscribe { viewState.showEmptyProgress(true) }
.doAfterTerminate { viewState.showEmptyProgress(false) }
.subscribe(
{ (mr, mdDescription) -> viewState.showInfo(mr, mdDescription) },
{ mr -> viewState.showInfo(mr) },
{ errorHandler.proceed(it, { viewState.showMessage(it) }) }
)
.connect()
......
......@@ -11,7 +11,7 @@ import ru.terrakok.gitlabclient.entity.mergerequest.MergeRequest
*/
@StateStrategyType(AddToEndSingleStrategy::class)
interface MergeRequestInfoView : MvpView {
fun showInfo(mr: MergeRequest, mdDescription: CharSequence)
fun showInfo(mr: MergeRequest)
fun showEmptyProgress(show: Boolean)
@StateStrategyType(OneExecutionStateStrategy::class)
......
......@@ -4,8 +4,7 @@ import com.arellomobile.mvp.InjectViewState
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.NoteWithFormattedBody
import ru.terrakok.gitlabclient.presentation.global.NoteWithProjectId
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.MergeRequestId
import ru.terrakok.gitlabclient.toothpick.qualifier.ProjectId
......@@ -19,7 +18,6 @@ class MergeRequestNotesPresenter @Inject constructor(
@ProjectId projectIdWrapper: PrimitiveWrapper<Long>,
@MergeRequestId mrIdWrapper: PrimitiveWrapper<Long>,
private val mrInteractor: MergeRequestInteractor,
private val mdConverter: MarkDownConverter,
private val errorHandler: ErrorHandler
) : BasePresenter<MergeRequestNotesView>() {
......@@ -33,15 +31,8 @@ class MergeRequestNotesPresenter @Inject constructor(
.getAllMergeRequestNotes(projectId, mrId)
.doOnSubscribe { viewState.showEmptyProgress(true) }
.doAfterTerminate { viewState.showEmptyProgress(false) }
.flattenAsObservable { it }
.concatMap { note ->
mdConverter.markdownToSpannable(note.body)
.map { NoteWithFormattedBody(note, it) }
.toObservable()
}
.toList()
.subscribe(
{ viewState.showNotes(it, false) },
{ viewState.showNotes(it.map { NoteWithProjectId(it, projectId) }, false) },
{ errorHandler.proceed(it, { viewState.showMessage(it) }) }
)
.connect()
......@@ -49,20 +40,11 @@ class MergeRequestNotesPresenter @Inject constructor(
fun onSendClicked(body: String) =
mrInteractor.createMergeRequestNote(projectId, mrId, body)
.flatMap {
mrInteractor.getAllMergeRequestNotes(projectId, mrId)
.flattenAsObservable { it }
.concatMap { note ->
mdConverter.markdownToSpannable(note.body)
.map { NoteWithFormattedBody(note, it) }
.toObservable()
}
.toList()
}
.flatMap { mrInteractor.getAllMergeRequestNotes(projectId, mrId) }
.doOnSubscribe { viewState.showBlockingProgress(true) }
.doAfterTerminate { viewState.showBlockingProgress(false) }
.subscribe(
{ viewState.showNotes(it, true) },
{ viewState.showNotes(it.map { NoteWithProjectId(it, projectId) }, true) },
{ errorHandler.proceed(it, { viewState.showMessage(it) }) }
)
.connect()
......
......@@ -4,7 +4,7 @@ import com.arellomobile.mvp.MvpView
import com.arellomobile.mvp.viewstate.strategy.AddToEndSingleStrategy
import com.arellomobile.mvp.viewstate.strategy.OneExecutionStateStrategy
import com.arellomobile.mvp.viewstate.strategy.StateStrategyType
import ru.terrakok.gitlabclient.presentation.global.NoteWithFormattedBody
import ru.terrakok.gitlabclient.presentation.global.NoteWithProjectId
/**
* Created by Konstantin Tskhovrebov (aka @terrakok) on 12.02.18.
......@@ -13,7 +13,7 @@ import ru.terrakok.gitlabclient.presentation.global.NoteWithFormattedBody
interface MergeRequestNotesView : MvpView {
fun showEmptyProgress(show: Boolean)
fun showNotes(notes: List<NoteWithFormattedBody>, scrollToEnd: Boolean)
fun showNotes(notes: List<NoteWithProjectId>, scrollToEnd: Boolean)
fun showBlockingProgress(show: Boolean)
@StateStrategyType(OneExecutionStateStrategy::class)
......
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)
......
......@@ -5,7 +5,6 @@ import io.reactivex.Single
import ru.terrakok.gitlabclient.model.interactor.project.ProjectInteractor
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.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.ProjectId
import javax.inject.Inject
......@@ -17,7 +16,6 @@ import javax.inject.Inject
class ProjectInfoPresenter @Inject constructor(
@ProjectId private val projectIdWrapper: PrimitiveWrapper<Long>,
private val projectInteractor: ProjectInteractor,
private val mdConverter: MarkDownConverter,
private val errorHandler: ErrorHandler
) : BasePresenter<ProjectInfoView>() {
......@@ -37,7 +35,6 @@ class ProjectInfoPresenter @Inject constructor(
else -> Single.error(throwable)
}
}
.flatMap { mdConverter.markdownToSpannable(it) }
.map { mdReadme -> Pair(project, mdReadme) }
}
.doOnSubscribe { viewState.showProgress(true) }
......
......@@ -12,7 +12,7 @@ import ru.terrakok.gitlabclient.entity.Project
@StateStrategyType(AddToEndSingleStrategy::class)
interface ProjectInfoView : MvpView {
fun showProject(project: Project, mdReadme: CharSequence)
fun showProject(project: Project, mdReadme: String)
fun showProgress(show: Boolean)
@StateStrategyType(OneExecutionStateStrategy::class)
......
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)
......
......@@ -3,21 +3,23 @@ package ru.terrakok.gitlabclient.ui.global.list
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import com.arellomobile.mvp.MvpDelegate
import com.hannesdorfmann.adapterdelegates3.AdapterDelegate
import kotlinx.android.synthetic.main.item_system_note.view.*
import ru.noties.markwon.Markwon
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.Note
import ru.terrakok.gitlabclient.extension.inflate
import ru.terrakok.gitlabclient.presentation.global.NoteWithFormattedBody
import ru.terrakok.gitlabclient.presentation.global.NoteWithProjectId
/**
* @author Konstantin Tskhovrebov (aka terrakok) on 18.06.17.
*/
class SystemNoteAdapterDelegate : AdapterDelegate<MutableList<Any>>() {
class SystemNoteAdapterDelegate(
val mvpDelegate: MvpDelegate<*>
) : AdapterDelegate<MutableList<Any>>() {
override fun isForViewType(items: MutableList<Any>, position: Int) =
with(items[position]) { this is NoteWithFormattedBody && this.note.isSystem }
with(items[position]) { this is NoteWithProjectId && this.note.isSystem }
override fun onCreateViewHolder(parent: ViewGroup): RecyclerView.ViewHolder =
ViewHolder(parent.inflate(R.layout.item_system_note))
......@@ -27,16 +29,17 @@ class SystemNoteAdapterDelegate : AdapterDelegate<MutableList<Any>>() {
position: Int,
viewHolder: RecyclerView.ViewHolder,
payloads: MutableList<Any>
) = (viewHolder as ViewHolder).bind(items[position] as NoteWithFormattedBody)
) = (viewHolder as ViewHolder).bind(items[position] as NoteWithProjectId)
private inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
private lateinit var note: Note
fun bind(data: NoteWithFormattedBody) {
fun bind(data: NoteWithProjectId) {
this.note = data.note
with(itemView) {
titleTextView.text = note.author.name
Markwon.setText(subtitleTextView, data.body)
subtitleMarkdownTextView.initWithParentDelegate(mvpDelegate)
subtitleMarkdownTextView.setMarkdown(note.body, data.projectId)
}
}
}
......
......@@ -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)
......
package ru.terrakok.gitlabclient.ui.global.list
import android.support.v7.util.DiffUtil
import com.arellomobile.mvp.MvpDelegate
import com.hannesdorfmann.adapterdelegates3.ListDelegationAdapter
import ru.terrakok.gitlabclient.presentation.global.NoteWithFormattedBody
import ru.terrakok.gitlabclient.presentation.global.NoteWithProjectId
class TargetNotesAdapter : ListDelegationAdapter<MutableList<Any>>() {
class TargetNotesAdapter(
mvpDelegate: MvpDelegate<*>
) : ListDelegationAdapter<MutableList<Any>>() {
init {
items = mutableListOf()
delegatesManager.addDelegate(UserNoteAdapterDelegate())
delegatesManager.addDelegate(SystemNoteAdapterDelegate())
delegatesManager.addDelegate(UserNoteAdapterDelegate(mvpDelegate))
delegatesManager.addDelegate(SystemNoteAdapterDelegate(mvpDelegate))
}
override fun getItemId(position: Int): Long {
return (items[position] as NoteWithFormattedBody).note.id
return (items[position] as NoteWithProjectId).note.id
}
fun setData(data: List<NoteWithFormattedBody>) {
fun setData(data: List<NoteWithProjectId>) {
val oldItems = items.toList()
items.clear()
......@@ -36,15 +39,15 @@ class TargetNotesAdapter : ListDelegationAdapter<MutableList<Any>>() {
override fun getNewListSize() = newItems.size
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
val oldItem = oldItems[oldItemPosition] as NoteWithFormattedBody
val newItem = newItems[newItemPosition] as NoteWithFormattedBody
val oldItem = oldItems[oldItemPosition] as NoteWithProjectId
val newItem = newItems[newItemPosition] as NoteWithProjectId
return newItem.note.id == oldItem.note.id
}
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
val oldItem = oldItems[oldItemPosition] as NoteWithFormattedBody
val newItem = newItems[newItemPosition] as NoteWithFormattedBody
val oldItem = oldItems[oldItemPosition] as NoteWithProjectId
val newItem = newItems[newItemPosition] as NoteWithProjectId
return newItem == oldItem
}
......
......@@ -3,23 +3,25 @@ package ru.terrakok.gitlabclient.ui.global.list
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import com.arellomobile.mvp.MvpDelegate
import com.hannesdorfmann.adapterdelegates3.AdapterDelegate
import kotlinx.android.synthetic.main.item_user_note.view.*
import ru.noties.markwon.Markwon
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.Note
import ru.terrakok.gitlabclient.extension.humanTime
import ru.terrakok.gitlabclient.extension.inflate
import ru.terrakok.gitlabclient.extension.loadRoundedImage
import ru.terrakok.gitlabclient.presentation.global.NoteWithFormattedBody
import ru.terrakok.gitlabclient.presentation.global.NoteWithProjectId
/**
* @author Konstantin Tskhovrebov (aka terrakok) on 18.06.17.
*/
class UserNoteAdapterDelegate : AdapterDelegate<MutableList<Any>>() {
class UserNoteAdapterDelegate(
val mvpDelegate: MvpDelegate<*>
) : AdapterDelegate<MutableList<Any>>() {
override fun isForViewType(items: MutableList<Any>, position: Int) =
with(items[position]) { this is NoteWithFormattedBody && !this.note.isSystem }
with(items[position]) { this is NoteWithProjectId && !this.note.isSystem }
override fun onCreateViewHolder(parent: ViewGroup): RecyclerView.ViewHolder =
ViewHolder(parent.inflate(R.layout.item_user_note))
......@@ -29,18 +31,19 @@ class UserNoteAdapterDelegate : AdapterDelegate<MutableList<Any>>() {
position: Int,
viewHolder: RecyclerView.ViewHolder,
payloads: MutableList<Any>
) = (viewHolder as ViewHolder).bind(items[position] as NoteWithFormattedBody)
) = (viewHolder as ViewHolder).bind(items[position] as NoteWithProjectId)
private inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
private lateinit var note: Note
fun bind(data: NoteWithFormattedBody) {
fun bind(data: NoteWithProjectId) {
this.note = data.note
with(itemView) {
avatarImageView.loadRoundedImage(note.author.avatarUrl)
titleTextView.text = note.author.name
subtitleTextView.text = note.createdAt.humanTime(context.resources)
Markwon.setText(descriptionTextView, data.body)
descriptionMarkdownTextView.initWithParentDelegate(mvpDelegate)
descriptionMarkdownTextView.setMarkdown(note.body, data.projectId)
}
}
}
......
package ru.terrakok.gitlabclient.ui.global.markdown
import android.annotation.TargetApi
import android.content.Context
import android.os.Build
import android.util.AttributeSet
import android.widget.TextView
import com.arellomobile.mvp.MvpDelegate
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import ru.noties.markwon.Markwon
import ru.terrakok.gitlabclient.presentation.markdown.MarkdownPresenter
import ru.terrakok.gitlabclient.presentation.markdown.MarkdownView
import ru.terrakok.gitlabclient.toothpick.DI
import timber.log.Timber
import toothpick.Toothpick
class MarkdownTextView : TextView, MarkdownView {
@JvmOverloads
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
defStyleRes: Int = 0
) : super(
context,
attrs,
defStyleAttr,
defStyleRes
)
private lateinit var parentDelegate: MvpDelegate<*>
private val mvpDelegate: MvpDelegate<MarkdownTextView> by lazy {
MvpDelegate(this).apply {
setParentDelegate(parentDelegate, hashCode().toString())
}
}
@InjectPresenter
internal lateinit var presenter: MarkdownPresenter
@ProvidePresenter
fun providePresenter(): MarkdownPresenter = Toothpick
.openScope(DI.SERVER_SCOPE)
.getInstance(MarkdownPresenter::class.java)
fun initWithParentDelegate(parentDelegate: MvpDelegate<*>) {
this.parentDelegate = parentDelegate
mvpDelegate.onCreate()
mvpDelegate.onAttach()
}
fun setMarkdown(markdown: String?, projectId: Long? = null) {
setText(null)
if (markdown != null) {
presenter.setMarkdown(markdown, projectId)
} else {
Timber.e("Text in markdown text view ${if (id != NO_ID) resources.getResourceName(id) else ""} is null")
}
}
override fun setMarkdownText(text: CharSequence) {
Markwon.setText(this, text)
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
mvpDelegate.onSaveInstanceState()
mvpDelegate.onDetach()
}
}
\ No newline at end of file
package ru.terrakok.gitlabclient.ui.issue
import android.os.Bundle
import android.view.View
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import kotlinx.android.synthetic.main.fragment_issue_info.*
import ru.noties.markwon.Markwon
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.issue.Issue
import ru.terrakok.gitlabclient.entity.issue.IssueState
......@@ -26,7 +27,12 @@ class IssueInfoFragment : BaseFragment(), IssueInfoView {
fun providePresenter(): IssueInfoPresenter =
scope.getInstance(IssueInfoPresenter::class.java)
override fun showInfo(issue: Issue, mdDescription: CharSequence) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
descriptionMarkdownTextView.initWithParentDelegate(mvpDelegate)
}
override fun showInfo(issue: Issue) {
titleTextView.text = issue.title
stateImageView.setImageResource(R.drawable.circle)
when (issue.state) {
......@@ -54,7 +60,7 @@ class IssueInfoFragment : BaseFragment(), IssueInfoView {
}
}
avatarImageView.loadRoundedImage(issue.author.avatarUrl, context)
Markwon.setText(descriptionTextView, mdDescription)
descriptionMarkdownTextView.setMarkdown(issue.description, issue.projectId)
}
override fun showEmptyProgress(show: Boolean) {
......
......@@ -12,7 +12,7 @@ import kotlinx.android.synthetic.main.fragment_issue_notes.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.extension.visible
import ru.terrakok.gitlabclient.presentation.global.NoteWithFormattedBody
import ru.terrakok.gitlabclient.presentation.global.NoteWithProjectId
import ru.terrakok.gitlabclient.presentation.issue.notes.IssueNotesPresenter
import ru.terrakok.gitlabclient.presentation.issue.notes.IssueNotesView
import ru.terrakok.gitlabclient.ui.global.BaseFragment
......@@ -27,7 +27,7 @@ class IssueNotesFragment : BaseFragment(), IssueNotesView {
override val layoutRes = R.layout.fragment_issue_notes
private val adapter by lazy { TargetNotesAdapter() }
private val adapter by lazy { TargetNotesAdapter(mvpDelegate) }
private val fadeFabScrollToBottom by lazy {
Fade().apply {
addTarget(fabScrollToBottom)
......@@ -80,7 +80,7 @@ class IssueNotesFragment : BaseFragment(), IssueNotesView {
showProgressDialog(show)
}
override fun showNotes(notes: List<NoteWithFormattedBody>, scrollToEnd: Boolean) {
override fun showNotes(notes: List<NoteWithProjectId>, scrollToEnd: Boolean) {
adapter.setData(notes)
if (scrollToEnd) {
recyclerView.scrollToPosition(adapter.itemCount - 1)
......
package ru.terrakok.gitlabclient.ui.mergerequest
import android.os.Bundle
import android.view.View
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import kotlinx.android.synthetic.main.fragment_mr_info.*
......@@ -26,7 +28,12 @@ class MergeRequestInfoFragment : BaseFragment(), MergeRequestInfoView {
fun providePresenter() =
scope.getInstance(MergeRequestInfoPresenter::class.java)
override fun showInfo(mr: MergeRequest, mdDescription: CharSequence) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
descriptionMarkdownTextView.initWithParentDelegate(mvpDelegate)
}
override fun showInfo(mr: MergeRequest) {
titleTextView.text = mr.title
when (mr.state) {
MergeRequestState.OPENED -> {
......@@ -68,7 +75,7 @@ class MergeRequestInfoFragment : BaseFragment(), MergeRequestInfoView {
}
}
avatarImageView.loadRoundedImage(mr.author.avatarUrl, context)
Markwon.setText(descriptionTextView, mdDescription)
descriptionMarkdownTextView.setMarkdown(mr.description, mr.projectId)
}
override fun showEmptyProgress(show: Boolean) {
......
......@@ -12,7 +12,7 @@ import kotlinx.android.synthetic.main.fragment_issue_notes.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.extension.visible
import ru.terrakok.gitlabclient.presentation.global.NoteWithFormattedBody
import ru.terrakok.gitlabclient.presentation.global.NoteWithProjectId
import ru.terrakok.gitlabclient.presentation.mergerequest.notes.MergeRequestNotesPresenter
import ru.terrakok.gitlabclient.presentation.mergerequest.notes.MergeRequestNotesView
import ru.terrakok.gitlabclient.ui.global.BaseFragment
......@@ -27,7 +27,7 @@ class MergeRequestNotesFragment : BaseFragment(), MergeRequestNotesView {
override val layoutRes = R.layout.fragment_mr_notes
private val adapter by lazy { TargetNotesAdapter() }
private val adapter by lazy { TargetNotesAdapter(mvpDelegate) }
private val fadeFabScrollToBottom by lazy {
Fade().apply {
addTarget(fabScrollToBottom)
......@@ -80,7 +80,7 @@ class MergeRequestNotesFragment : BaseFragment(), MergeRequestNotesView {
showProgressDialog(show)
}
override fun showNotes(notes: List<NoteWithFormattedBody>, scrollToEnd: Boolean) {
override fun showNotes(notes: List<NoteWithProjectId>, scrollToEnd: Boolean) {
adapter.setData(notes)
if (scrollToEnd) {
recyclerView.scrollToPosition(adapter.itemCount - 1)
......
......@@ -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() }
......
......@@ -5,7 +5,6 @@ import android.view.View
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import kotlinx.android.synthetic.main.fragment_project_info.*
import ru.noties.markwon.Markwon
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.Project
import ru.terrakok.gitlabclient.entity.Visibility
......@@ -35,9 +34,11 @@ class ProjectInfoFragment : BaseFragment(), ProjectInfoView {
starsTextView.setStartDrawable(context.getTintDrawable(R.drawable.ic_star_black_24dp, R.color.colorPrimary))
forksTextView.setStartDrawable(context.getTintDrawable(R.drawable.ic_fork, R.color.colorPrimary))
}
readmeMarkdownTextView.initWithParentDelegate(mvpDelegate)
}
override fun showProject(project: Project, mdReadme: CharSequence) {
override fun showProject(project: Project, mdReadme: String) {
titleTextView.text = project.nameWithNamespace
descriptionTextView.text = project.description
starsTextView.text = project.starCount.toString()
......@@ -53,7 +54,7 @@ class ProjectInfoFragment : BaseFragment(), ProjectInfoView {
}
)
Markwon.setText(readmeTextView, mdReadme)
readmeMarkdownTextView.setMarkdown(mdReadme, project.id)
}
override fun showProgress(show: Boolean) {
......
......@@ -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() }
......
......@@ -72,8 +72,8 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/subtitleTextView" />
<TextView
android:id="@+id/descriptionTextView"
<ru.terrakok.gitlabclient.ui.global.markdown.MarkdownTextView
android:id="@+id/descriptionMarkdownTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:linksClickable="true"
......
......@@ -72,8 +72,8 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/subtitleTextView" />
<TextView
android:id="@+id/descriptionTextView"
<ru.terrakok.gitlabclient.ui.global.markdown.MarkdownTextView
android:id="@+id/descriptionMarkdownTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:linksClickable="true"
......
......@@ -107,8 +107,8 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/descriptionTextView" />
<TextView
android:id="@+id/readmeTextView"
<ru.terrakok.gitlabclient.ui.global.markdown.MarkdownTextView
android:id="@+id/readmeMarkdownTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:linksClickable="true"
......
......@@ -29,8 +29,8 @@
app:layout_constraintTop_toTopOf="@id/iconImageView"
tools:text="Marc MacLeod"/>
<TextView
android:id="@+id/subtitleTextView"
<ru.terrakok.gitlabclient.ui.global.markdown.MarkdownTextView
android:id="@+id/subtitleMarkdownTextView"
style="@style/TextBody"
android:layout_width="0dp"
android:layout_height="wrap_content"
......
......@@ -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"
......
......@@ -41,8 +41,8 @@
app:layout_constraintTop_toBottomOf="@id/titleTextView"
tools:text="commented a month ago"/>
<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"
......