Commit 8daeb2f7 authored by Eugene Shapovalov's avatar Eugene Shapovalov 💬

Merge remote-tracking branch 'remotes/origin/develop' into feature/prepare_to_release

# Conflicts:
#	app/build.gradle
parents 1a3dcd9a e793b5ae
# Build files and folders
.gradle/
build/
keys/
# Properties
local.properties
......
/build
google-services.json
......@@ -2,17 +2,18 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
apply from: '../ci.gradle'
android {
compileSdkVersion 27
compileSdkVersion 28
buildToolsVersion '28.0.2'
defaultConfig {
applicationId "ru.terrakok.gitlabclient"
applicationId "com.gitlab.terrakok.gitfox"
minSdkVersion 19
targetSdkVersion 27
targetSdkVersion 28
versionName "1.0"
versionCode getBuildNumber()
......@@ -25,6 +26,13 @@ android {
buildConfigField "String", "WEB_AUTH_USER_AGENT", '"gitfox_user_agent"'
buildConfigField "String", "ORIGIN_GITLAB_ENDPOINT", '"https://gitlab.com/"'
//todo: put prod value for release
buildConfigField "String", "OAUTH_APP_ID", '"808b7f51c6634294afd879edd75d5eaf55f1a75e7fe5bd91ca8b7140a5af639d"'
buildConfigField "String", "OAUTH_SECRET", '"a9dd39c8d2e781b65814007ca0f8b555d34f79b4d30c9356c38bb7ad9909c6f3"'
buildConfigField "String", "OAUTH_CALLBACK", '"app://gitlab.client/"'
multiDexEnabled true
javaCompileOptions {
annotationProcessorOptions {
arguments = [toothpick_registry_package_name: 'ru.terrakok.gitlabclient']
......@@ -32,6 +40,16 @@ android {
}
}
signingConfigs {
//todo put key params for release
prod {
storeFile file("./keys/play/key.jks")
storePassword "pass"
keyAlias "alias"
keyPassword "pass"
}
}
buildTypes {
debugPG {
initWith debug
......@@ -39,19 +57,19 @@ android {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationIdSuffix '.debugPG'
versionNameSuffix ' debugPG'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.prod
}
}
}
ext {
supportLibraryVersion = "27.1.1"
supportLibraryVersion = "28.0.0-rc02"
moxyVersion = "1.4.6"
toothpickVersion = "1.0.6"
retrofitVersion = "2.2.0"
......@@ -102,6 +120,10 @@ dependencies {
implementation 'com.jakewharton.threetenabp:threetenabp:1.0.5'
//FlexBox Layout
implementation 'com.google.android:flexbox:1.0.0'
//Firebase
implementation 'com.google.firebase:firebase-core:16.0.3'
//Crashlytics
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
//JUnit
testImplementation "junit:junit:4.12"
......@@ -115,4 +137,6 @@ configurations.all {
resolutionStrategy {
force "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
}
}
\ No newline at end of file
}
apply plugin: 'com.google.gms.google-services'
\ No newline at end of file
......@@ -3,13 +3,18 @@
"name": "Konstantin Tskhovrebov",
"avatarUrl": "https://assets.gitlab-static.net/uploads/-/system/user/avatar/62974/avatar.png",
"gitlabId": 62974,
"role": "owner"
"role": "main developer"
},
{
"name": "Eugene Shapovalov",
"avatarUrl": "https://assets.gitlab-static.net/uploads/-/system/user/avatar/1583723/avatar.png",
"gitlabId": 1583723,
"role": "developer"
"role": "main developer"
},
{
"name": "Ilyas Gaifullin",
"avatarUrl": "https://mir-s3-cdn-cf.behance.net/user/230/e0e22a1584077.581bca76bcad5.jpeg",
"role": "designer"
},
{
"name": "Vladimir Parfenov",
......@@ -40,10 +45,5 @@
"avatarUrl": "https://assets.gitlab-static.net/uploads/-/system/user/avatar/1601949/avatar.png",
"gitlabId": 1601949,
"role": "developer"
},
{
"name": "Ilyas Gaifullin",
"avatarUrl": "https://mir-s3-cdn-cf.behance.net/user/230/e0e22a1584077.581bca76bcad5.jpeg",
"role": "designer"
}
]
\ No newline at end of file
......@@ -83,5 +83,10 @@
"name": "Google / Flexbox-layout",
"url": "https://github.com/google/flexbox-layout",
"license": "APACHE_2"
},
{
"name": "Noties / Markwon",
"url": "https://github.com/noties/Markwon",
"license": "APACHE_2"
}
]
\ No newline at end of file
......@@ -2,7 +2,9 @@ package ru.terrakok.gitlabclient
import android.app.Application
import android.graphics.Color
import com.crashlytics.android.Crashlytics
import com.jakewharton.threetenabp.AndroidThreeTen
import io.fabric.sdk.android.Fabric
import ru.noties.markwon.SpannableConfiguration
import ru.noties.markwon.spans.SpannableTheme
import ru.terrakok.gitlabclient.model.data.auth.AuthHolder
......@@ -24,6 +26,7 @@ class App : Application() {
super.onCreate()
initLogger()
initFabric()
initToothpick()
initAppScope()
initMarkwon()
......@@ -36,6 +39,15 @@ class App : Application() {
}
}
private fun initFabric() {
Fabric.with(
Fabric.Builder(this)
.kits(Crashlytics())
.debuggable(BuildConfig.DEBUG)
.build()
)
}
private fun initToothpick() {
if (BuildConfig.DEBUG) {
Toothpick.setConfiguration(Configuration.forDevelopment().preventMultipleRootScopes())
......
package ru.terrakok.gitlabclient.entity
import com.google.gson.annotations.SerializedName
data class Discussion(
@SerializedName("id") val id: String,
@SerializedName("individual_note") val isIndividualNote: Boolean,
@SerializedName("notes") val notes: List<Note>
)
\ No newline at end of file
......@@ -5,6 +5,7 @@ import android.content.res.Resources
import android.support.annotation.DrawableRes
import org.threeten.bp.Duration
import org.threeten.bp.LocalDateTime
import org.threeten.bp.format.DateTimeFormatter
import retrofit2.HttpException
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.app.develop.LicenseType
......@@ -38,6 +39,7 @@ fun Throwable.userMessage(resourceManager: ResourceManager) = when (this) {
else -> resourceManager.getString(R.string.unknown_error)
}
private val DATE_FORMAT = DateTimeFormatter.ofPattern("dd MMM yyyy")
fun LocalDateTime.humanTime(resources: Resources): String {
val delta = Duration.between(this, LocalDateTime.now()).seconds
val timeStr =
......@@ -46,7 +48,7 @@ fun LocalDateTime.humanTime(resources: Resources): String {
delta < 60 * 60 -> resources.getString(R.string.time_min, delta / 60)
delta < 60 * 60 * 24 -> resources.getString(R.string.time_hour, delta / (60 * 60))
delta < 60 * 60 * 24 * 7 -> resources.getString(R.string.time_day, delta / (60 * 60 * 24))
else -> return this.toLocalDate().toString()
else -> return this.toLocalDate().format(DATE_FORMAT)
}
return resources.getString(R.string.time_ago, timeStr)
......
......@@ -3,21 +3,8 @@ package ru.terrakok.gitlabclient.model.data.server
import io.reactivex.Completable
import io.reactivex.Single
import org.threeten.bp.LocalDateTime
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query
import ru.terrakok.gitlabclient.entity.File
import ru.terrakok.gitlabclient.entity.Note
import ru.terrakok.gitlabclient.entity.OrderBy
import ru.terrakok.gitlabclient.entity.Project
import ru.terrakok.gitlabclient.entity.RepositoryTreeNode
import ru.terrakok.gitlabclient.entity.Sort
import ru.terrakok.gitlabclient.entity.TokenData
import ru.terrakok.gitlabclient.entity.User
import ru.terrakok.gitlabclient.entity.Visibility
import retrofit2.http.*
import ru.terrakok.gitlabclient.entity.*
import ru.terrakok.gitlabclient.entity.event.Event
import ru.terrakok.gitlabclient.entity.event.EventAction
import ru.terrakok.gitlabclient.entity.event.EventTarget
......@@ -204,19 +191,15 @@ interface GitlabApi {
@POST("$API_PATH/todos/mark_as_done")
fun markAllPendingTodosAsDone(): Completable
@GET("$API_PATH/projects/{project_id}/issues/{issue_id}/notes")
fun getIssueNotes(
@GET("$API_PATH/projects/{project_id}/issues/{issue_id}/discussions")
fun getIssueDiscussions(
@Path("project_id") projectId: Long,
@Path("issue_id") issueId: Long,
@Query("order_by") orderBy: OrderBy?,
@Query("sort") sort: Sort?
): Single<List<Note>>
@Path("issue_id") issueId: Long
): Single<List<Discussion>>
@GET("$API_PATH/projects/{project_id}/merge_requests/{merge_request_id}/notes")
fun getMergeRequestNotes(
@GET("$API_PATH/projects/{project_id}/merge_requests/{merge_request_id}/discussions")
fun getMergeRequestDiscussions(
@Path("project_id") projectId: Long,
@Path("merge_request_id") mergeRequestId: Long,
@Query("order_by") orderBy: OrderBy?,
@Query("sort") sort: Sort?
): Single<List<Note>>
@Path("merge_request_id") mergeRequestId: Long
): Single<List<Discussion>>
}
\ No newline at end of file
......@@ -7,21 +7,14 @@ import ru.terrakok.gitlabclient.entity.Note
import ru.terrakok.gitlabclient.entity.OrderBy
import ru.terrakok.gitlabclient.entity.Project
import ru.terrakok.gitlabclient.entity.Sort
import ru.terrakok.gitlabclient.entity.app.target.AppTarget
import ru.terrakok.gitlabclient.entity.app.target.TargetBadge
import ru.terrakok.gitlabclient.entity.app.target.TargetBadgeIcon
import ru.terrakok.gitlabclient.entity.app.target.TargetBadgeStatus
import ru.terrakok.gitlabclient.entity.app.target.TargetHeader
import ru.terrakok.gitlabclient.entity.app.target.TargetHeaderIcon
import ru.terrakok.gitlabclient.entity.app.target.TargetHeaderTitle
import ru.terrakok.gitlabclient.entity.app.target.TargetInternal
import ru.terrakok.gitlabclient.entity.app.target.*
import ru.terrakok.gitlabclient.entity.event.EventAction
import ru.terrakok.gitlabclient.entity.issue.Issue
import ru.terrakok.gitlabclient.entity.issue.IssueScope
import ru.terrakok.gitlabclient.entity.issue.IssueState
import ru.terrakok.gitlabclient.model.data.server.GitlabApi
import ru.terrakok.gitlabclient.model.system.SchedulersProvider
import ru.terrakok.gitlabclient.model.data.server.MarkDownUrlResolver
import ru.terrakok.gitlabclient.model.system.SchedulersProvider
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.DefaultPageSize
import javax.inject.Inject
......@@ -140,28 +133,32 @@ class IssueRepository @Inject constructor(
fun getIssueNotes(
projectId: Long,
issueId: Long,
orderBy: OrderBy? = null,
sort: Sort? = Sort.ASC
) =
Single
.zip(
api.getProject(projectId),
api.getIssueNotes(projectId, issueId, orderBy, sort),
BiFunction<Project, List<Note>, List<Note>> { project, notes ->
ArrayList(notes).apply {
val iterator = listIterator()
while (iterator.hasNext()) {
val note = iterator.next()
val resolved = markDownUrlResolver.resolve(note.body, project)
issueId: Long
) = Single
.zip(
api.getProject(projectId),
getDiscussionNotes(projectId, issueId),
BiFunction<Project, List<Note>, List<Note>> { project, notes ->
ArrayList(notes).apply {
val iterator = listIterator()
while (iterator.hasNext()) {
val note = iterator.next()
val resolved = markDownUrlResolver.resolve(note.body, project)
if (resolved != note.body) {
iterator.set(note.copy(body = resolved))
}
if (resolved != note.body) {
iterator.set(note.copy(body = resolved))
}
}
}
)
.subscribeOn(schedulers.io())
.observeOn(schedulers.ui())
}
)
.subscribeOn(schedulers.io())
.observeOn(schedulers.ui())
private fun getDiscussionNotes(projectId: Long, issueId: Long) =
api
.getIssueDiscussions(projectId, issueId)
.flattenAsObservable { it }
.concatMap { discussion -> Observable.fromIterable(discussion.notes) }
.toList()
}
\ No newline at end of file
......@@ -8,22 +8,15 @@ import ru.terrakok.gitlabclient.entity.Note
import ru.terrakok.gitlabclient.entity.OrderBy
import ru.terrakok.gitlabclient.entity.Project
import ru.terrakok.gitlabclient.entity.Sort
import ru.terrakok.gitlabclient.entity.app.target.AppTarget
import ru.terrakok.gitlabclient.entity.app.target.TargetBadge
import ru.terrakok.gitlabclient.entity.app.target.TargetBadgeIcon
import ru.terrakok.gitlabclient.entity.app.target.TargetBadgeStatus
import ru.terrakok.gitlabclient.entity.app.target.TargetHeader
import ru.terrakok.gitlabclient.entity.app.target.TargetHeaderIcon
import ru.terrakok.gitlabclient.entity.app.target.TargetHeaderTitle
import ru.terrakok.gitlabclient.entity.app.target.TargetInternal
import ru.terrakok.gitlabclient.entity.app.target.*
import ru.terrakok.gitlabclient.entity.event.EventAction
import ru.terrakok.gitlabclient.entity.mergerequest.MergeRequest
import ru.terrakok.gitlabclient.entity.mergerequest.MergeRequestScope
import ru.terrakok.gitlabclient.entity.mergerequest.MergeRequestState
import ru.terrakok.gitlabclient.entity.mergerequest.MergeRequestViewType
import ru.terrakok.gitlabclient.model.data.server.GitlabApi
import ru.terrakok.gitlabclient.model.system.SchedulersProvider
import ru.terrakok.gitlabclient.model.data.server.MarkDownUrlResolver
import ru.terrakok.gitlabclient.model.system.SchedulersProvider
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.DefaultPageSize
import javax.inject.Inject
......@@ -154,28 +147,32 @@ class MergeRequestRepository @Inject constructor(
fun getMergeRequestNotes(
projectId: Long,
mergeRequestId: Long,
orderBy: OrderBy? = null,
sort: Sort? = Sort.ASC
) =
Single
.zip(
api.getProject(projectId),
api.getMergeRequestNotes(projectId, mergeRequestId, orderBy, sort),
BiFunction<Project, List<Note>, List<Note>> { project, notes ->
ArrayList(notes).apply {
val iterator = listIterator()
while (iterator.hasNext()) {
val note = iterator.next()
val resolved = markDownUrlResolver.resolve(note.body, project)
mergeRequestId: Long
) = Single
.zip(
api.getProject(projectId),
getDiscussionNotes(projectId, mergeRequestId),
BiFunction<Project, List<Note>, List<Note>> { project, notes ->
ArrayList(notes).apply {
val iterator = listIterator()
while (iterator.hasNext()) {
val note = iterator.next()
val resolved = markDownUrlResolver.resolve(note.body, project)
if (resolved != note.body) {
iterator.set(note.copy(body = resolved))
}
if (resolved != note.body) {
iterator.set(note.copy(body = resolved))
}
}
}
)
.subscribeOn(schedulers.io())
.observeOn(schedulers.ui())
}
)
.subscribeOn(schedulers.io())
.observeOn(schedulers.ui())
private fun getDiscussionNotes(projectId: Long, mergeRequestId: Long) =
api
.getMergeRequestDiscussions(projectId, mergeRequestId)
.flattenAsObservable { it }
.concatMap { discussion -> Observable.fromIterable(discussion.notes) }
.toList()
}
\ No newline at end of file
......@@ -15,8 +15,7 @@ class AppPresenter @Inject constructor(
private val authInteractor: AuthInteractor
) : MvpPresenter<MvpView>() {
override fun onFirstViewAttach() {
super.onFirstViewAttach()
fun coldStart() {
if (authInteractor.isSignedIn()) router.newRootScreen(Screens.DRAWER_FLOW)
else router.newRootScreen(Screens.AUTH_FLOW)
}
......
......@@ -2,6 +2,7 @@ package ru.terrakok.gitlabclient.toothpick.module
import com.google.gson.Gson
import okhttp3.OkHttpClient
import ru.terrakok.gitlabclient.BuildConfig
import ru.terrakok.gitlabclient.model.data.server.GitlabApi
import ru.terrakok.gitlabclient.model.data.server.MarkDownUrlResolver
import ru.terrakok.gitlabclient.model.interactor.auth.AuthInteractor
......@@ -44,13 +45,8 @@ class ServerModule(serverUrl: String) : Module() {
bind(MarkDownUrlResolver::class.java)
//Auth
//todo: before release change and move to private config
bind(OAuthParams::class.java).toInstance(
OAuthParams(
"808b7f51c6634294afd879edd75d5eaf55f1a75e7fe5bd91ca8b7140a5af639d",
"a9dd39c8d2e781b65814007ca0f8b555d34f79b4d30c9356c38bb7ad9909c6f3",
"app://gitlab.client/"
)
OAuthParams(BuildConfig.OAUTH_APP_ID, BuildConfig.OAUTH_SECRET, BuildConfig.OAUTH_CALLBACK)
)
bind(AuthRepository::class.java).singletonInScope()
bind(AuthInteractor::class.java).singletonInScope()
......
......@@ -81,6 +81,10 @@ class AppActivity : MvpAppCompatActivity(), MvpView {
Toothpick.inject(this, Toothpick.openScope(DI.SERVER_SCOPE))
super.onCreate(savedInstanceState)
setContentView(R.layout.layout_container)
if (savedInstanceState == null) {
presenter.coldStart()
}
}
override fun onResumeFragments() {
......
package ru.terrakok.gitlabclient.ui.global.list
import android.support.v7.util.DiffUtil
/**
* Created by Konstantin Tskhovrebov (aka @terrakok) on 04.01.18.
*/
class DiffCallback(
private val newData: List<Any>,
private val oldData: List<Any>
) : DiffUtil.Callback() {
override fun getOldListSize() = oldData.size
override fun getNewListSize() = newData.size
//without optimization at the moment
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) =
oldData[oldItemPosition] === newData[newItemPosition]
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) =
oldData[oldItemPosition] == newData[newItemPosition]
}
\ No newline at end of file
......@@ -23,7 +23,7 @@ class SimpleDividerDecorator(
ContextCompat.getColor(context, R.color.divider)
)
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State?) {
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
super.getItemOffsets(outRect, view, parent, state)
if (parent.getChildAdapterPosition(view) == 0) return
......@@ -31,12 +31,12 @@ class SimpleDividerDecorator(
outRect.top = dividerSizePx
}
override fun onDraw(canvas: Canvas, parent: RecyclerView, state: RecyclerView.State?) {
override fun onDraw(canvas: Canvas, parent: RecyclerView, state: RecyclerView.State) {
val dividerLeft = parent.paddingLeft
val dividerRight = parent.width - parent.paddingRight
val childCount = parent.childCount
for (i in 0..childCount - 1) {
for (i in 0 until childCount) {
val child = parent.getChildAt(i)
val params = child.layoutParams as RecyclerView.LayoutParams
......
......@@ -14,21 +14,22 @@ import ru.terrakok.gitlabclient.presentation.global.NoteWithFormattedBody
/**
* @author Konstantin Tskhovrebov (aka terrakok) on 18.06.17.
*/
class SystemNoteAdapterDelegate(private val clickListener: (Note) -> Unit) : AdapterDelegate<MutableList<Any>>() {
class SystemNoteAdapterDelegate(
private val clickListener: (Note) -> Unit
) : AdapterDelegate<MutableList<NoteWithFormattedBody>>() {
override fun isForViewType(items: MutableList<Any>, position: Int) =
with(items[position]) { this is NoteWithFormattedBody && this.note.isSystem }
override fun isForViewType(items: MutableList<NoteWithFormattedBody>, position: Int) =
items[position].note.isSystem
override fun onCreateViewHolder(parent: ViewGroup): RecyclerView.ViewHolder =
ViewHolder(parent.inflate(R.layout.item_system_note))
override fun onBindViewHolder(
items: MutableList<Any>,
items: MutableList<NoteWithFormattedBody>,
position: Int,
viewHolder: RecyclerView.ViewHolder,
payloads: MutableList<Any>
) =
(viewHolder as ViewHolder).bind(items[position] as NoteWithFormattedBody)
) = (viewHolder as ViewHolder).bind(items[position])
private inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
private lateinit var note: Note
......
package ru.terrakok.gitlabclient.ui.global.list
import android.support.v7.util.DiffUtil
import com.hannesdorfmann.adapterdelegates3.ListDelegationAdapter
import ru.terrakok.gitlabclient.presentation.global.NoteWithFormattedBody
class TargetNotesAdapter : ListDelegationAdapter<MutableList<NoteWithFormattedBody>>() {
init {
items = mutableListOf()
delegatesManager.addDelegate(UserNoteAdapterDelegate({}))
delegatesManager.addDelegate(SystemNoteAdapterDelegate({}))
}
fun setData(data: List<NoteWithFormattedBody>) {
val oldItems = items.toList()
items.clear()
items.addAll(data)
DiffUtil
.calculateDiff(DiffCallback(items, oldItems), false)
.dispatchUpdatesTo(this)
}
private inner class DiffCallback(
private val newItems: List<NoteWithFormattedBody>,
private val oldItems: List<NoteWithFormattedBody>
) : DiffUtil.Callback() {
override fun getOldListSize() = oldItems.size
override fun getNewListSize() = newItems.size
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) =
newItems[newItemPosition].note.id == oldItems[oldItemPosition].note.id
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) =
newItems[newItemPosition] == oldItems[oldItemPosition]
}
}
\ No newline at end of file
......@@ -16,20 +16,22 @@ import ru.terrakok.gitlabclient.presentation.global.NoteWithFormattedBody
/**
* @author Konstantin Tskhovrebov (aka terrakok) on 18.06.17.
*/
class UserNoteAdapterDelegate(private val clickListener: (Note) -> Unit) : AdapterDelegate<MutableList<Any>>() {
class UserNoteAdapterDelegate(
private val clickListener: (Note) -> Unit
) : AdapterDelegate<MutableList<NoteWithFormattedBody>>() {
override fun isForViewType(items: MutableList<Any>, position: Int) =
with(items[position]) { this is NoteWithFormattedBody && !this.note.isSystem }
override fun isForViewType(items: MutableList<NoteWithFormattedBody>, position: Int) =
!items[position].note.isSystem
override fun onCreateViewHolder(parent: ViewGroup): RecyclerView.ViewHolder =
ViewHolder(parent.inflate(R.layout.item_user_note))
override fun onBindViewHolder(
items: MutableList<Any>,
items: MutableList<NoteWithFormattedBody>,
position: Int,
viewHolder: RecyclerView.ViewHolder,
payloads: MutableList<Any>
) = (viewHolder as ViewHolder).bind(items[position] as NoteWithFormattedBody)
) = (viewHolder as ViewHolder).bind(items[position])
private inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
private lateinit var note: Note
......
......@@ -4,7 +4,6 @@ import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import com.hannesdorfmann.adapterdelegates3.ListDelegationAdapter
import kotlinx.android.synthetic.main.layout_base_list.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.extension.showSnackMessage
......@@ -14,17 +13,17 @@ import ru.terrakok.gitlabclient.presentation.issue.notes.IssueNotesView
import ru.terrakok.gitlabclient.toothpick.DI
import ru.terrakok.gitlabclient.ui.global.BaseFragment
import ru.terrakok.gitlabclient.ui.global.list.SimpleDividerDecorator
import ru.terrakok.gitlabclient.ui.global.list.SystemNoteAdapterDelegate
import ru.terrakok.gitlabclient.ui.global.list.UserNoteAdapterDelegate
import ru.terrakok.gitlabclient.ui.global.list.TargetNotesAdapter
import toothpick.Toothpick
/**
* Created by Konstantin Tskhovrebov (aka @terrakok) on 15.02.18.
*/
class IssueNotesFragment : BaseFragment(), IssueNotesView {
override val layoutRes = R.layout.fragment_issue_notes
private val adapter by lazy { NotesAdapter() }
private val adapter by lazy { TargetNotesAdapter() }
@InjectPresenter
lateinit var presenter: IssueNotesPresenter
......@@ -58,19 +57,4 @@ class IssueNotesFragment : BaseFragment(), IssueNotesView {
override fun showMessage(message: String) {
showSnackMessage(message)
}
private inner class NotesAdapter : ListDelegationAdapter<MutableList<Any>>() {
init {
items = mutableListOf()
delegatesManager.addDelegate(UserNoteAdapterDelegate({}))
delegatesManager.addDelegate(SystemNoteAdapterDelegate({}))
}
fun setData(data: List<NoteWithFormattedBody>) {
items.clear()
items.addAll(data)
notifyDataSetChanged()
}
}
}
\ No newline at end of file
......@@ -4,7 +4,6 @@ import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import com.hannesdorfmann.adapterdelegates3.ListDelegationAdapter
import kotlinx.android.synthetic.main.layout_base_list.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.extension.showSnackMessage
......@@ -14,17 +13,17 @@ import ru.terrakok.gitlabclient.presentation.mergerequest.notes.MergeRequestNote
import ru.terrakok.gitlabclient.toothpick.DI
import ru.terrakok.gitlabclient.ui.global.BaseFragment
import ru.terrakok.gitlabclient.ui.global.list.SimpleDividerDecorator
import ru.terrakok.gitlabclient.ui.global.list.SystemNoteAdapterDelegate
import ru.terrakok.gitlabclient.ui.global.list.UserNoteAdapterDelegate
import ru.terrakok.gitlabclient.ui.global.list.TargetNotesAdapter