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) {
when (action) {
TodoAction.ASSIGNED -> {
"$author $actionName $targetName ${resources.getString(R.string.at)} $projectName ${resources.getString(
R.string.to
)} $assignee"
"$author $actionName $targetName ${resources.getString(R.string.at)} $projectName ${resources.getString(R.string.to)} $assignee"
}
TodoAction.DIRECTLY_ADDRESSED,
TodoAction.MENTIONED -> {
......
......@@ -5,7 +5,6 @@ import ru.terrakok.cicerone.Router
import ru.terrakok.gitlabclient.extension.extractFileNameFromPath
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.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.FilePath
import ru.terrakok.gitlabclient.toothpick.qualifier.FileReference
......@@ -21,7 +20,6 @@ class ProjectFilePresenter @Inject constructor(
@FilePath private val filePath: String,
@FileReference private val fileReference: String,
private val projectInteractor: ProjectInteractor,
private val errorHandler: ErrorHandler,
private val router: Router
) : BasePresenter<ProjectFileView>() {
......@@ -31,24 +29,20 @@ class ProjectFilePresenter @Inject constructor(
super.onFirstViewAttach()
viewState.setTitle(filePath.extractFileNameFromPath())
// Progress will be hidden, after code will be highlighted.
viewState.showEmptyProgress(true)
loadProjectFileRaw(false)
}
fun onFileReload() = loadProjectFileRaw(true)
private fun loadProjectFileRaw(isReload: Boolean) {
projectInteractor.getProjectRawFile(projectId, filePath, fileReference)
.doOnSubscribe { if (isReload) viewState.showEmptyView(false) }
.subscribe(
{ viewState.setRawFile(it) },
{ errorHandler.proceed(it, { viewState.showMessage(it) }) }
{ viewState.showEmptyView(true) }
)
.connect()
}
fun onCodeHighlightStarted() {
viewState.showEmptyProgress(true)
}
fun onCodeHighlightSFinished() {
viewState.showEmptyProgress(false)
}
fun onBackPressed() = router.exit()
}
\ No newline at end of file
......@@ -2,7 +2,6 @@ package ru.terrakok.gitlabclient.presentation.file
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
/**
......@@ -13,8 +12,5 @@ interface ProjectFileView : MvpView {
fun setTitle(title: String)
fun setRawFile(rawFile: String)
fun showEmptyProgress(show: Boolean)
@StateStrategyType(OneExecutionStateStrategy::class)
fun showMessage(message: String)
fun showEmptyView(show: Boolean)
}
\ No newline at end of file
......@@ -4,9 +4,9 @@ import android.os.Bundle
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import kotlinx.android.synthetic.main.fragment_project_file.*
import kotlinx.android.synthetic.main.layout_zero.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.extension.argument
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.extension.visible
import ru.terrakok.gitlabclient.presentation.file.ProjectFilePresenter
import ru.terrakok.gitlabclient.presentation.file.ProjectFileView
......@@ -16,7 +16,8 @@ import ru.terrakok.gitlabclient.toothpick.qualifier.FilePath
import ru.terrakok.gitlabclient.toothpick.qualifier.FileReference
import ru.terrakok.gitlabclient.toothpick.qualifier.ProjectId
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.config.Module
......@@ -57,20 +58,23 @@ class ProjectFileFragment : BaseFragment(), ProjectFileView {
@ProvidePresenter
fun providePresenter(): ProjectFilePresenter = scope.getInstance(ProjectFilePresenter::class.java)
private var zeroViewHolder: ZeroViewHolder? = null
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
toolbar.setNavigationOnClickListener { onBackPressed() }
projectFileCodeHighlightView.setOnCodeHighlightProgressLister(
object : CodeHighlightView.OnCodeHighlightListener {
override fun onCodeHighlightStarted() {
presenter.onCodeHighlightStarted()
fullscreenProgressView.visible(true)
}
override fun onCodeHighlightFinished() {
presenter.onCodeHighlightSFinished()
fullscreenProgressView.visible(false)
}
}
)
zeroViewHolder = ZeroViewHolder(zeroLayout) { presenter.onFileReload() }
}
override fun onResume() {
......@@ -101,12 +105,14 @@ class ProjectFileFragment : BaseFragment(), ProjectFileView {
projectFileCodeHighlightView.highlightCode(rawFile)
}
override fun showEmptyProgress(show: Boolean) {
fullscreenProgressView.visible(show)
}
override fun showMessage(message: String) {
showSnackMessage(message)
override fun showEmptyView(show: Boolean) {
if (show) {
zeroViewHolder?.showEmptyData()
fullscreenProgressView.visible(false)
} else {
zeroViewHolder?.hide()
fullscreenProgressView.visible(true)
}
}
companion object {
......
package ru.terrakok.gitlabclient.ui.global.view.custom.code_highlight
package ru.terrakok.gitlabclient.ui.global.view.custom.codehighlight
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.graphics.Bitmap
......@@ -57,7 +57,7 @@ class CodeHighlightView @JvmOverloads constructor(
fun highlightCode(rawFile: String) {
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 {
......
......@@ -18,7 +18,7 @@
tools:subtitle="app/src/main/java/ru/terrakok/gitlabclient/entity/app/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:layout_width="0dp"
android:layout_height="0dp"
......@@ -32,10 +32,19 @@
layout="@layout/layout_gitlab_progress"
android:layout_width="80dp"
android:layout_height="80dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/projectFileCodeHighlightView"
app:layout_constraintEnd_toEndOf="@id/projectFileCodeHighlightView"
app:layout_constraintStart_toStartOf="@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>
\ 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