Commit 680a420b authored by Eugene Shapovalov's avatar Eugene Shapovalov 💬

Implement issue info screen.

parent 75aaf5d5
......@@ -12,10 +12,7 @@ import ru.terrakok.gitlabclient.ui.auth.AuthFlowFragment
import ru.terrakok.gitlabclient.ui.auth.AuthFragment
import ru.terrakok.gitlabclient.ui.drawer.DrawerFlowFragment
import ru.terrakok.gitlabclient.ui.file.ProjectFileFragment
import ru.terrakok.gitlabclient.ui.issue.IssueFlowFragment
import ru.terrakok.gitlabclient.ui.issue.IssueInfoFragment
import ru.terrakok.gitlabclient.ui.issue.IssueNotesFragment
import ru.terrakok.gitlabclient.ui.issue.MainIssueFragment
import ru.terrakok.gitlabclient.ui.issue.*
import ru.terrakok.gitlabclient.ui.libraries.LibrariesFragment
import ru.terrakok.gitlabclient.ui.main.MainFragment
import ru.terrakok.gitlabclient.ui.mergerequest.*
......@@ -229,6 +226,10 @@ object Screens {
override fun getFragment() = IssueInfoFragment()
}
object IssueDetails : SupportAppScreen() {
override fun getFragment() = IssueDetailsFragment()
}
object IssueNotes : SupportAppScreen() {
override fun getFragment() = IssueNotesFragment()
}
......
package ru.terrakok.gitlabclient.entity
import com.google.gson.annotations.SerializedName
data class Author(
@SerializedName("id") val id: Long,
@SerializedName("state") val state: String?,
@SerializedName("web_url") val webUrl: String?,
@SerializedName("name") val name: String,
@SerializedName("avatar_url") val avatarUrl: String?,
@SerializedName("username") val username: String
)
......@@ -7,7 +7,7 @@ import ru.terrakok.gitlabclient.entity.event.EventTargetType
data class Note(
@SerializedName("id") val id: Long,
@SerializedName("body") val body: String,
@SerializedName("author") val author: Author,
@SerializedName("author") val author: ShortUser,
@SerializedName("created_at") val createdAt: LocalDateTime,
@SerializedName("updated_at") val updatedAt: LocalDateTime?,
@SerializedName("system") val isSystem: Boolean,
......
......@@ -2,7 +2,7 @@ package ru.terrakok.gitlabclient.entity
import com.google.gson.annotations.SerializedName
data class Assignee(
data class ShortUser(
@SerializedName("id") val id: Long,
@SerializedName("state") val state: String?,
@SerializedName("name") val name: String,
......
package ru.terrakok.gitlabclient.entity.target
package ru.terrakok.gitlabclient.entity
import com.google.gson.annotations.SerializedName
......
package ru.terrakok.gitlabclient.entity.app.target
import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.Author
import ru.terrakok.gitlabclient.entity.ShortUser
/**
* Created by Konstantin Tskhovrebov (aka @terrakok) on 24.12.17.
*/
sealed class TargetHeader {
data class Public(
val author: Author,
val author: ShortUser,
val icon: TargetHeaderIcon,
val title: TargetHeaderTitle,
val body: CharSequence,
......
......@@ -2,10 +2,9 @@ package ru.terrakok.gitlabclient.entity.event
import com.google.gson.annotations.SerializedName
import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.Author
import ru.terrakok.gitlabclient.entity.Note
import ru.terrakok.gitlabclient.entity.PushData
import ru.terrakok.gitlabclient.entity.ShortUser
/**
* Created by Konstantin Tskhovrebov (aka @terrakok) on 22.07.17.
......@@ -19,7 +18,7 @@ data class Event(
@SerializedName("author_id") val authorId: Long,
@SerializedName("target_title") val targetTitle: String?,
@SerializedName("created_at") val createdAt: LocalDateTime,
@SerializedName("author") val author: Author,
@SerializedName("author") val author: ShortUser,
@SerializedName("author_username") val authorUsername: String,
@SerializedName("push_data") val pushData: PushData?,
@SerializedName("note") val note: Note?
......
package ru.terrakok.gitlabclient.entity.issue
import com.google.gson.annotations.SerializedName
import org.threeten.bp.LocalDate
import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.Assignee
import ru.terrakok.gitlabclient.entity.Author
import ru.terrakok.gitlabclient.entity.ShortUser
import ru.terrakok.gitlabclient.entity.TimeStats
import ru.terrakok.gitlabclient.entity.milestone.Milestone
data class Issue(
......@@ -11,16 +12,16 @@ data class Issue(
@SerializedName("iid") val iid: Long,
@SerializedName("state") val state: IssueState,
@SerializedName("description") val description: String,
@SerializedName("author") val author: Author,
@SerializedName("author") val author: ShortUser,
@SerializedName("milestone") val milestone: Milestone?,
@SerializedName("project_id") val projectId: Long,
@SerializedName("assignees") val assignees: List<Assignee>,
@SerializedName("assignees") val assignees: List<ShortUser>,
@SerializedName("updated_at") val updatedAt: LocalDateTime?,
@SerializedName("title") val title: String?,
@SerializedName("created_at") val createdAt: LocalDateTime,
@SerializedName("labels") val labels: List<String>,
@SerializedName("user_notes_count") val userNotesCount: Int,
@SerializedName("due_date") val dueDate: String?,
@SerializedName("due_date") val dueDate: LocalDate?,
@SerializedName("web_url") val webUrl: String?,
@SerializedName("confidential") val confidential: Boolean,
@SerializedName("upvotes") val upvotes: Int,
......@@ -28,8 +29,11 @@ data class Issue(
// The closed_by attribute was introduced in GitLab 10.6.
// This value will only be present for issues which were closed after GitLab 10.6 and
// when the user account that closed the issue still exists.
@SerializedName("closed_by") val closedBy: Author?,
@SerializedName("closed_by") val closedBy: ShortUser?,
@SerializedName("closed_at") val closedAt: LocalDateTime?,
// The merge_requests_count attribute was introduced in GitLab 11.9.
@SerializedName("merge_requests_count") val relatedMergeRequestCount: Int
@SerializedName("merge_requests_count") val relatedMergeRequestCount: Int,
@SerializedName("time_stats") val timeStats: TimeStats,
@SerializedName("weight") val weight: Int?,
@SerializedName("discussion_locked") val discussionLocked: Boolean
)
\ No newline at end of file
......@@ -2,8 +2,7 @@ package ru.terrakok.gitlabclient.entity.mergerequest
import com.google.gson.annotations.SerializedName
import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.Author
import ru.terrakok.gitlabclient.entity.User
import ru.terrakok.gitlabclient.entity.ShortUser
import ru.terrakok.gitlabclient.entity.milestone.Milestone
data class MergeRequest(
......@@ -18,8 +17,8 @@ data class MergeRequest(
@SerializedName("state") val state: MergeRequestState,
@SerializedName("upvotes") val upvotes: Int,
@SerializedName("downvotes") val downvotes: Int,
@SerializedName("author") val author: Author,
@SerializedName("assignee") val assignee: User?,
@SerializedName("author") val author: ShortUser,
@SerializedName("assignee") val assignee: ShortUser?,
@SerializedName("source_project_id") val sourceProjectId: Int,
@SerializedName("target_project_id") val targetProjectId: Int,
@SerializedName("description") val description: String,
......@@ -38,9 +37,9 @@ data class MergeRequest(
// The closed_by attribute was introduced in GitLab 10.6.
// This value will only be present for merge requests which were closed/merged after GitLab 10.6
// and when the user account that closed/merged the issue still exists.
@SerializedName("closed_by") val closedBy: Author?,
@SerializedName("closed_by") val closedBy: ShortUser?,
@SerializedName("closed_at") val closedAt: LocalDateTime?,
@SerializedName("merged_by") val mergedBy: Author?,
@SerializedName("merged_by") val mergedBy: ShortUser?,
@SerializedName("merged_at") val mergedAt: LocalDateTime?,
@SerializedName("changes") val changes: List<MergeRequestChange>?
)
......@@ -2,8 +2,8 @@ package ru.terrakok.gitlabclient.entity.target
import com.google.gson.annotations.SerializedName
import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.Assignee
import ru.terrakok.gitlabclient.entity.Author
import ru.terrakok.gitlabclient.entity.ShortUser
import ru.terrakok.gitlabclient.entity.TimeStats
import ru.terrakok.gitlabclient.entity.milestone.Milestone
/**
......@@ -29,11 +29,11 @@ abstract class Target {
@SerializedName("milestone")
val milestone: Milestone? = null
@SerializedName("assignees")
private val _assignees: List<Assignee>? = null
private val _assignees: List<ShortUser>? = null
@SerializedName("author")
val _author: Author? = null
val _author: ShortUser? = null
@SerializedName("assignee")
val assignee: Assignee? = null
val assignee: ShortUser? = null
@SerializedName("user_notes_count")
private val _userNotesCount: Int? = null
@SerializedName("upvotes")
......
package ru.terrakok.gitlabclient.entity.todo
import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.Author
import ru.terrakok.gitlabclient.entity.Project
import ru.terrakok.gitlabclient.entity.ShortUser
import ru.terrakok.gitlabclient.entity.target.Target
import ru.terrakok.gitlabclient.entity.target.TargetType
......@@ -12,7 +12,7 @@ import ru.terrakok.gitlabclient.entity.target.TargetType
data class Todo(
val id: Long,
val project: Project,
val author: Author,
val author: ShortUser,
val actionName: TodoAction,
val targetType: TargetType,
val target: Target,
......
......@@ -273,7 +273,7 @@ interface GitlabApi {
@Path("merge_request_id") mergeRequestId: Long,
@Query("page") page: Int,
@Query("per_page") pageSize: Int
): Single<List<Author>>
): Single<List<ShortUser>>
@GET("$API_PATH/projects/{project_id}/merge_requests/{merge_request_id}/changes")
fun getMergeRequestChanges(
......
......@@ -5,8 +5,8 @@ import com.google.gson.JsonDeserializer
import com.google.gson.JsonElement
import com.google.gson.JsonParseException
import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.Author
import ru.terrakok.gitlabclient.entity.Project
import ru.terrakok.gitlabclient.entity.ShortUser
import ru.terrakok.gitlabclient.entity.target.Target
import ru.terrakok.gitlabclient.entity.target.TargetType
import ru.terrakok.gitlabclient.entity.target.issue.Issue
......@@ -34,7 +34,7 @@ class TodoDeserializer : JsonDeserializer<Todo> {
Todo(
jsonObject.get("id").asLong,
context.deserialize<Project>(jsonObject.get("project"), Project::class.java),
context.deserialize<Author>(jsonObject.get("author"), Author::class.java),
context.deserialize<ShortUser>(jsonObject.get("author"), ShortUser::class.java),
context.deserialize<TodoAction>(
jsonObject.get("action_name"),
TodoAction::class.java
......
......@@ -229,7 +229,7 @@ class MergeRequestRepository @Inject constructor(
.zip(
getAllMergeRequestParticipants(projectId, mergeRequestId),
api.getMergeRequestCommits(projectId, mergeRequestId, page, pageSize),
BiFunction<List<Author>, List<Commit>, List<CommitWithAvatarUrl>> { participants, commits ->
BiFunction<List<ShortUser>, List<Commit>, List<CommitWithAvatarUrl>> { participants, commits ->
commits.map { commit ->
CommitWithAvatarUrl(
commit,
......
......@@ -2,7 +2,7 @@ package ru.terrakok.gitlabclient.model.repository.todo
import ru.terrakok.gitlabclient.di.DefaultPageSize
import ru.terrakok.gitlabclient.di.PrimitiveWrapper
import ru.terrakok.gitlabclient.entity.Assignee
import ru.terrakok.gitlabclient.entity.ShortUser
import ru.terrakok.gitlabclient.entity.User
import ru.terrakok.gitlabclient.entity.app.target.*
import ru.terrakok.gitlabclient.entity.target.TargetState
......@@ -43,7 +43,7 @@ class TodoRepository @Inject constructor(
val target = todo.target
val assignee = if (todo.actionName != TodoAction.MARKED) {
currentUser.let {
Assignee(it.id, it.state, it.name, it.webUrl, it.avatarUrl, it.username)
ShortUser(it.id, it.state, it.name, it.webUrl, it.avatarUrl, it.username)
}
} else {
null
......
package ru.terrakok.gitlabclient.presentation.issue.details
import com.arellomobile.mvp.InjectViewState
import ru.terrakok.gitlabclient.di.IssueId
import ru.terrakok.gitlabclient.di.PrimitiveWrapper
import ru.terrakok.gitlabclient.di.ProjectId
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 javax.inject.Inject
/**
* Created by Eugene Shapovalov (@CraggyHaggy) on 26.05.19.
*/
@InjectViewState
class IssueDetailsPresenter @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<IssueDetailsView>() {
private val projectId = projectIdWrapper.value
private val issueId = issueIdWrapper.value
override fun onFirstViewAttach() {
super.onFirstViewAttach()
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.showDetails(issue, mdDescription) },
{ errorHandler.proceed(it, { viewState.showMessage(it) }) }
)
.connect()
}
}
\ No newline at end of file
package ru.terrakok.gitlabclient.presentation.issue.details
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.entity.issue.Issue
/**
* Created by Eugene Shapovalov (@CraggyHaggy) on 26.05.19.
*/
@StateStrategyType(AddToEndSingleStrategy::class)
interface IssueDetailsView : MvpView {
fun showDetails(issue: Issue, mdDescription: CharSequence)
fun showEmptyProgress(show: Boolean)
@StateStrategyType(OneExecutionStateStrategy::class)
fun showMessage(message: String)
}
\ No newline at end of file
package ru.terrakok.gitlabclient.presentation.issue.info
import com.arellomobile.mvp.InjectViewState
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.di.IssueId
import ru.terrakok.gitlabclient.di.PrimitiveWrapper
import ru.terrakok.gitlabclient.di.ProjectId
import ru.terrakok.gitlabclient.entity.ShortUser
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 javax.inject.Inject
/**
......@@ -18,8 +20,8 @@ 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
private val errorHandler: ErrorHandler,
private val router: FlowRouter
) : BasePresenter<IssueInfoView>() {
private val projectId = projectIdWrapper.value
......@@ -30,17 +32,14 @@ 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) },
{ viewState.showInfo(it) },
{ errorHandler.proceed(it, { viewState.showMessage(it) }) }
)
.connect()
}
fun onAssigneeClicked(assignee: ShortUser) = router.startFlow(Screens.UserFlow(assignee.id))
}
\ No newline at end of file
......@@ -11,7 +11,8 @@ 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)
......
package ru.terrakok.gitlabclient.ui.global.list
import androidx.recyclerview.widget.DiffUtil
import com.hannesdorfmann.adapterdelegates4.ListDelegationAdapter
import ru.terrakok.gitlabclient.entity.ShortUser
/**
* Created by Eugene Shapovalov (@CraggyHaggy) on 26.05.19.
*/
class AssigneesAdapter(
clickListener: (ShortUser) -> Unit
) : ListDelegationAdapter<MutableList<ShortUser>>() {
init {
items = mutableListOf()
delegatesManager.addDelegate(AssigneesAdapterDelegate(clickListener))
}
fun setData(assignees: List<ShortUser>) {
val oldData = items.toList()
items.clear()
items.addAll(assignees)
//yes, on main thread...
DiffUtil
.calculateDiff(DiffCallback(items, oldData), false)
.dispatchUpdatesTo(this)
}
private inner class DiffCallback(
private val newItems: List<ShortUser>,
private val oldItems: List<ShortUser>
) : DiffUtil.Callback() {
override fun getOldListSize() = oldItems.size
override fun getNewListSize() = newItems.size
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
val oldItem = oldItems[oldItemPosition]
val newItem = newItems[newItemPosition]
return newItem.id == oldItem.id
}
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
val oldItem = oldItems[oldItemPosition]
val newItem = newItems[newItemPosition]
return newItem == oldItem
}
}
}
\ No newline at end of file
package ru.terrakok.gitlabclient.ui.global.list
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.hannesdorfmann.adapterdelegates4.AdapterDelegate
import kotlinx.android.synthetic.main.item_assignee.view.*
import kotlinx.android.synthetic.main.item_target_header_public.view.avatarImageView
import kotlinx.android.synthetic.main.item_target_header_public.view.titleTextView
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.ShortUser
import ru.terrakok.gitlabclient.extension.inflate
import ru.terrakok.gitlabclient.extension.loadRoundedImage
/**
* Created by Eugene Shapovalov (@CraggyHaggy) on 26.05.19.
*/
class AssigneesAdapterDelegate(
private val clickListener: (ShortUser) -> Unit
) : AdapterDelegate<MutableList<ShortUser>>() {
override fun isForViewType(items: MutableList<ShortUser>, position: Int) = true
override fun onCreateViewHolder(parent: ViewGroup): RecyclerView.ViewHolder =
ViewHolder(parent.inflate(R.layout.item_assignee))
override fun onBindViewHolder(
items: MutableList<ShortUser>,
position: Int,
holder: RecyclerView.ViewHolder,
payloads: MutableList<Any>
) = (holder as ViewHolder).bind(items[position])
private inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
private lateinit var item: ShortUser
init {
view.setOnClickListener { clickListener(item) }
}
fun bind(item: ShortUser) {
this.item = item
with(itemView) {
titleTextView.text = item.name
subtitleTextView.text = item.username
avatarImageView.loadRoundedImage(item.avatarUrl)
}
}
}
}
\ No newline at end of file
package ru.terrakok.gitlabclient.ui.global.view.custom
import android.content.Context
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.text.style.ForegroundColorSpan
import android.util.AttributeSet
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import kotlinx.android.synthetic.main.view_time_stats.view.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.TimeStats
import ru.terrakok.gitlabclient.extension.color
import ru.terrakok.gitlabclient.extension.visible
/**
* Created by Eugene Shapovalov (@CraggyHaggy) on 26.05.19.
*/
class TimeStatsView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr) {
private val subHeadTextColor = context.color(R.color.subhead_text)
private val subTitleTextColor = context.color(R.color.subtitle_text)
init {
inflate(context, R.layout.view_time_stats, this)
}
fun setTimeStats(timeStats: TimeStats) {
emptyTimeStats.visible(false)
singleTimeStats.visible(false)
progressGroup.visible(false)
when {
timeStats.totalTimeSpent > 0 && timeStats.timeEstimate > 0 -> initProgressViews(timeStats)
timeStats.totalTimeSpent > 0 -> {
initSingleSpentView(
resources.getString(R.string.time_stats_spent_time),
timeStats.humanTotalTimeSpent,
singleTimeStats
)
}
timeStats.timeEstimate > 0 -> {
initSingleSpentView(
resources.getString(R.string.time_stats_estimated_time),
timeStats.humanTimeEstimate,
singleTimeStats
)
}
else -> emptyTimeStats.visible(true)
}
}
private fun initProgressViews(timeStats: TimeStats) {
setTimeSpans(
resources.getString(R.string.time_stats_spent_time),
timeStats.humanTotalTimeSpent,
progressSpentTime
)
setTimeSpans(
resources.getString(R.string.time_stats_est_time),
timeStats.humanTimeEstimate,
progressEstimatedTime
)
val progress = (timeStats.totalTimeSpent.toFloat() / timeStats.timeEstimate.toFloat() * 100).toInt()
progressTimeStats.progress = progress
progressGroup.visible(true)
}
private fun initSingleSpentView(title: String, value: String?, textView: TextView) {
setTimeSpans(title, value, textView)
textView.visible(true)
}
private fun setTimeSpans(title: String, value: String?, textView: TextView) {
textView.setText(
SpannableStringBuilder().apply {
append(title)
append(value)
setSpan(
ForegroundColorSpan(subTitleTextColor),
0,
title.length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
setSpan(
ForegroundColorSpan(subHeadTextColor),
title.length,
length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
},
TextView.BufferType.SPANNABLE
)
}
}
\ No newline at end of file
package ru.terrakok.gitlabclient.ui.issue
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import kotlinx.android.synthetic.main.fragment_issue_details.*
import ru.noties.markwon.Markwon
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.issue.Issue
import ru.terrakok.gitlabclient.entity.issue.IssueState
import ru.terrakok.gitlabclient.extension.*
import ru.terrakok.gitlabclient.presentation.issue.details.IssueDetailsPresenter
import ru.terrakok.gitlabclient.presentation.issue.details.IssueDetailsView
import ru.terrakok.gitlabclient.ui.global.BaseFragment
/**
* Created by Eugene Shapovalov (@CraggyHaggy) on 26.05.19.
*/
class IssueDetailsFragment : BaseFragment(), IssueDetailsView {
override val layoutRes = R.layout.fragment_issue_details
@InjectPresenter
lateinit var presenter: IssueDetailsPresenter
@ProvidePresenter
fun providePresenter(): IssueDetailsPresenter =
scope.getInstance(IssueDetailsPresenter::class.java)
override fun showDetails(issue: Issue, mdDescription: CharSequence) {
titleTextView.text = issue.title
stateImageView.setImageResource(R.drawable.circle)
when (issue.state) {
IssueState.OPENED -> {
stateImageView.setColorFilter(context!!.color(R.color.green))
subtitleTextView.text = String.format(
getString(R.string.issue_info_subtitle),
getString(R.string.target_status_opened),
issue.author.name,
issue.createdAt.humanTime(resources)
)
}
IssueState.CLOSED -> {
stateImageView.setColorFilter(context!!.color(R.color.red))