Commit 2fc12f24 authored by Eugene Shapovalov's avatar Eugene Shapovalov 💬

Resolve discussion comments.

parent d3bd5c91
This diff is collapsed.
...@@ -128,9 +128,7 @@ fun TargetHeaderTitle.getHumanName(resources: Resources) = when (this) { ...@@ -128,9 +128,7 @@ fun TargetHeaderTitle.getHumanName(resources: Resources) = when (this) {
when (action) { when (action) {
TodoAction.ASSIGNED -> { TodoAction.ASSIGNED -> {
"$author $actionName $targetName ${resources.getString(R.string.at)} $projectName ${resources.getString( "$author $actionName $targetName ${resources.getString(R.string.at)} $projectName ${resources.getString(R.string.to)} $assignee"
R.string.to
)} $assignee"
} }
TodoAction.DIRECTLY_ADDRESSED, TodoAction.DIRECTLY_ADDRESSED,
TodoAction.MENTIONED -> { TodoAction.MENTIONED -> {
......
...@@ -5,7 +5,6 @@ import ru.terrakok.cicerone.Router ...@@ -5,7 +5,6 @@ import ru.terrakok.cicerone.Router
import ru.terrakok.gitlabclient.extension.extractFileNameFromPath import ru.terrakok.gitlabclient.extension.extractFileNameFromPath
import ru.terrakok.gitlabclient.model.interactor.project.ProjectInteractor import ru.terrakok.gitlabclient.model.interactor.project.ProjectInteractor
import ru.terrakok.gitlabclient.presentation.global.BasePresenter import ru.terrakok.gitlabclient.presentation.global.BasePresenter
import ru.terrakok.gitlabclient.presentation.global.ErrorHandler
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.FilePath import ru.terrakok.gitlabclient.toothpick.qualifier.FilePath
import ru.terrakok.gitlabclient.toothpick.qualifier.FileReference import ru.terrakok.gitlabclient.toothpick.qualifier.FileReference
...@@ -21,7 +20,6 @@ class ProjectFilePresenter @Inject constructor( ...@@ -21,7 +20,6 @@ class ProjectFilePresenter @Inject constructor(
@FilePath private val filePath: String, @FilePath private val filePath: String,
@FileReference private val fileReference: String, @FileReference private val fileReference: String,
private val projectInteractor: ProjectInteractor, private val projectInteractor: ProjectInteractor,
private val errorHandler: ErrorHandler,
private val router: Router private val router: Router
) : BasePresenter<ProjectFileView>() { ) : BasePresenter<ProjectFileView>() {
...@@ -31,24 +29,20 @@ class ProjectFilePresenter @Inject constructor( ...@@ -31,24 +29,20 @@ class ProjectFilePresenter @Inject constructor(
super.onFirstViewAttach() super.onFirstViewAttach()
viewState.setTitle(filePath.extractFileNameFromPath()) viewState.setTitle(filePath.extractFileNameFromPath())
// Progress will be hidden, after code will be highlighted. loadProjectFileRaw(false)
viewState.showEmptyProgress(true) }
fun onFileReload() = loadProjectFileRaw(true)
private fun loadProjectFileRaw(isReload: Boolean) {
projectInteractor.getProjectRawFile(projectId, filePath, fileReference) projectInteractor.getProjectRawFile(projectId, filePath, fileReference)
.doOnSubscribe { if (isReload) viewState.showEmptyView(false) }
.subscribe( .subscribe(
{ viewState.setRawFile(it) }, { viewState.setRawFile(it) },
{ errorHandler.proceed(it, { viewState.showMessage(it) }) } { viewState.showEmptyView(true) }
) )
.connect() .connect()
} }
fun onCodeHighlightStarted() {
viewState.showEmptyProgress(true)
}
fun onCodeHighlightSFinished() {
viewState.showEmptyProgress(false)
}
fun onBackPressed() = router.exit() fun onBackPressed() = router.exit()
} }
\ No newline at end of file
...@@ -2,7 +2,6 @@ package ru.terrakok.gitlabclient.presentation.file ...@@ -2,7 +2,6 @@ package ru.terrakok.gitlabclient.presentation.file
import com.arellomobile.mvp.MvpView import com.arellomobile.mvp.MvpView
import com.arellomobile.mvp.viewstate.strategy.AddToEndSingleStrategy import com.arellomobile.mvp.viewstate.strategy.AddToEndSingleStrategy
import com.arellomobile.mvp.viewstate.strategy.OneExecutionStateStrategy
import com.arellomobile.mvp.viewstate.strategy.StateStrategyType import com.arellomobile.mvp.viewstate.strategy.StateStrategyType
/** /**
...@@ -13,8 +12,5 @@ interface ProjectFileView : MvpView { ...@@ -13,8 +12,5 @@ interface ProjectFileView : MvpView {
fun setTitle(title: String) fun setTitle(title: String)
fun setRawFile(rawFile: String) fun setRawFile(rawFile: String)
fun showEmptyProgress(show: Boolean) fun showEmptyView(show: Boolean)
@StateStrategyType(OneExecutionStateStrategy::class)
fun showMessage(message: String)
} }
\ No newline at end of file
...@@ -4,9 +4,9 @@ import android.os.Bundle ...@@ -4,9 +4,9 @@ import android.os.Bundle
import com.arellomobile.mvp.presenter.InjectPresenter import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter import com.arellomobile.mvp.presenter.ProvidePresenter
import kotlinx.android.synthetic.main.fragment_project_file.* import kotlinx.android.synthetic.main.fragment_project_file.*
import kotlinx.android.synthetic.main.layout_zero.*
import ru.terrakok.gitlabclient.R import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.extension.argument import ru.terrakok.gitlabclient.extension.argument
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.extension.visible import ru.terrakok.gitlabclient.extension.visible
import ru.terrakok.gitlabclient.presentation.file.ProjectFilePresenter import ru.terrakok.gitlabclient.presentation.file.ProjectFilePresenter
import ru.terrakok.gitlabclient.presentation.file.ProjectFileView import ru.terrakok.gitlabclient.presentation.file.ProjectFileView
...@@ -16,7 +16,8 @@ import ru.terrakok.gitlabclient.toothpick.qualifier.FilePath ...@@ -16,7 +16,8 @@ import ru.terrakok.gitlabclient.toothpick.qualifier.FilePath
import ru.terrakok.gitlabclient.toothpick.qualifier.FileReference import ru.terrakok.gitlabclient.toothpick.qualifier.FileReference
import ru.terrakok.gitlabclient.toothpick.qualifier.ProjectId import ru.terrakok.gitlabclient.toothpick.qualifier.ProjectId
import ru.terrakok.gitlabclient.ui.global.BaseFragment import ru.terrakok.gitlabclient.ui.global.BaseFragment
import ru.terrakok.gitlabclient.ui.global.view.custom.code_highlight.CodeHighlightView import ru.terrakok.gitlabclient.ui.global.ZeroViewHolder
import ru.terrakok.gitlabclient.ui.global.view.custom.codehighlight.CodeHighlightView
import toothpick.Scope import toothpick.Scope
import toothpick.config.Module import toothpick.config.Module
...@@ -57,20 +58,23 @@ class ProjectFileFragment : BaseFragment(), ProjectFileView { ...@@ -57,20 +58,23 @@ class ProjectFileFragment : BaseFragment(), ProjectFileView {
@ProvidePresenter @ProvidePresenter
fun providePresenter(): ProjectFilePresenter = scope.getInstance(ProjectFilePresenter::class.java) fun providePresenter(): ProjectFilePresenter = scope.getInstance(ProjectFilePresenter::class.java)
private var zeroViewHolder: ZeroViewHolder? = null
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
toolbar.setNavigationOnClickListener { onBackPressed() } toolbar.setNavigationOnClickListener { onBackPressed() }
projectFileCodeHighlightView.setOnCodeHighlightProgressLister( projectFileCodeHighlightView.setOnCodeHighlightProgressLister(
object : CodeHighlightView.OnCodeHighlightListener { object : CodeHighlightView.OnCodeHighlightListener {
override fun onCodeHighlightStarted() { override fun onCodeHighlightStarted() {
presenter.onCodeHighlightStarted() fullscreenProgressView.visible(true)
} }
override fun onCodeHighlightFinished() { override fun onCodeHighlightFinished() {
presenter.onCodeHighlightSFinished() fullscreenProgressView.visible(false)
} }
} }
) )
zeroViewHolder = ZeroViewHolder(zeroLayout) { presenter.onFileReload() }
} }
override fun onResume() { override fun onResume() {
...@@ -101,12 +105,14 @@ class ProjectFileFragment : BaseFragment(), ProjectFileView { ...@@ -101,12 +105,14 @@ class ProjectFileFragment : BaseFragment(), ProjectFileView {
projectFileCodeHighlightView.highlightCode(rawFile) projectFileCodeHighlightView.highlightCode(rawFile)
} }
override fun showEmptyProgress(show: Boolean) { override fun showEmptyView(show: Boolean) {
fullscreenProgressView.visible(show) if (show) {
} zeroViewHolder?.showEmptyData()
fullscreenProgressView.visible(false)
override fun showMessage(message: String) { } else {
showSnackMessage(message) zeroViewHolder?.hide()
fullscreenProgressView.visible(true)
}
} }
companion object { companion object {
......
package ru.terrakok.gitlabclient.ui.global.view.custom.code_highlight package ru.terrakok.gitlabclient.ui.global.view.custom.codehighlight
object CodeHighlightJsPage { object CodeHighlightJsPage {
......
package ru.terrakok.gitlabclient.ui.global.view.custom.code_highlight package ru.terrakok.gitlabclient.ui.global.view.custom.codehighlight
import android.content.Context import android.content.Context
import android.graphics.Bitmap import android.graphics.Bitmap
...@@ -57,7 +57,7 @@ class CodeHighlightView @JvmOverloads constructor( ...@@ -57,7 +57,7 @@ class CodeHighlightView @JvmOverloads constructor(
fun highlightCode(rawFile: String) { fun highlightCode(rawFile: String) {
val jsPage = CodeHighlightJsPage.generatePage(rawFile, "default.css") val jsPage = CodeHighlightJsPage.generatePage(rawFile, "default.css")
loadDataWithBaseURL("file:///android_asset/code_highlight/", jsPage, "text/html", "utf-8", null) loadDataWithBaseURL("file:///android_asset/codehighlight/", jsPage, "text/html", "utf-8", null)
} }
companion object { companion object {
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
tools:subtitle="app/src/main/java/ru/terrakok/gitlabclient/entity/app/ProjectFile.kt" tools:subtitle="app/src/main/java/ru/terrakok/gitlabclient/entity/app/ProjectFile.kt"
tools:title="ProjectFile.kt" /> tools:title="ProjectFile.kt" />
<ru.terrakok.gitlabclient.ui.global.view.custom.code_highlight.CodeHighlightView <ru.terrakok.gitlabclient.ui.global.view.custom.codehighlight.CodeHighlightView
android:id="@+id/projectFileCodeHighlightView" android:id="@+id/projectFileCodeHighlightView"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
...@@ -32,10 +32,19 @@ ...@@ -32,10 +32,19 @@
layout="@layout/layout_gitlab_progress" layout="@layout/layout_gitlab_progress"
android:layout_width="80dp" android:layout_width="80dp"
android:layout_height="80dp" android:layout_height="80dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/projectFileCodeHighlightView" app:layout_constraintBottom_toBottomOf="@id/projectFileCodeHighlightView"
app:layout_constraintEnd_toEndOf="@id/projectFileCodeHighlightView" app:layout_constraintEnd_toEndOf="@id/projectFileCodeHighlightView"
app:layout_constraintStart_toStartOf="@id/projectFileCodeHighlightView" app:layout_constraintStart_toStartOf="@id/projectFileCodeHighlightView"
app:layout_constraintTop_toTopOf="@id/projectFileCodeHighlightView" /> app:layout_constraintTop_toTopOf="@id/projectFileCodeHighlightView" />
<include
layout="@layout/layout_zero"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar" />
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment