Commit ef958e9b authored by Eugene Shapovalov's avatar Eugene Shapovalov 💬

Fix discussion comments.

parent 240225e4
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<AndroidXmlCodeStyleSettings>
<option name="USE_CUSTOM_SETTINGS" value="true" />
</AndroidXmlCodeStyleSettings>
<JetCodeStyleSettings>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
<XML>
<option name="XML_KEEP_LINE_BREAKS" value="false" />
<option name="XML_ALIGN_ATTRIBUTES" value="false" />
<option name="XML_SPACE_INSIDE_EMPTY_TAG" value="true" />
</XML>
<codeStyleSettings language="XML">
<option name="FORCE_REARRANGE_MODE" value="1" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
<codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
</component>
\ No newline at end of file
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>
\ No newline at end of file
......@@ -4,7 +4,6 @@ import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.net.Uri
import android.os.Bundle
import android.support.annotation.LayoutRes
import android.support.design.widget.Snackbar
import android.support.v4.app.Fragment
......@@ -160,9 +159,4 @@ fun Fragment.showSnackMessage(message: String) {
messageTextView.setTextColor(Color.WHITE)
snackbar.show()
}
}
inline fun <reified T : Enum<T>> Bundle.getEnum(key: String): T? = if (containsKey(key))
getInt(key).let { return@let enumValues<T>()[it] } else null
fun <T : Enum<T>> Bundle.putEnum(key: String, value: T) = putInt(key, value.ordinal)
\ No newline at end of file
}
\ No newline at end of file
......@@ -14,7 +14,7 @@ import javax.inject.Inject
/**
* Created by Konstantin Tskhovrebov (aka @terrakok) on 14.02.18.
*/
class IssueFragment : BaseFragment(), IssueInfoFragment.ToolbarConfigurator {
class IssueFragment : BaseFragment(), IssueInfoFragment.IssueInfoToolbar {
override val layoutRes = R.layout.fragment_issue
......
......@@ -34,7 +34,7 @@ class IssueInfoFragment : BaseFragment(), IssueInfoView {
override fun showIssue(issueInfo: IssueInfoView.IssueInfo) {
val issue = issueInfo.issue
(parentFragment as? ToolbarConfigurator)
(parentFragment as? IssueInfoToolbar)
?.setTitle("#${issue.iid}", issueInfo.project.name)
titleTextView.text = issue.title
......@@ -68,7 +68,7 @@ class IssueInfoFragment : BaseFragment(), IssueInfoView {
showSnackMessage(message)
}
interface ToolbarConfigurator {
interface IssueInfoToolbar {
fun setTitle(title: String, subTitle: String)
}
}
\ No newline at end of file
......@@ -14,7 +14,7 @@ import javax.inject.Inject
/**
* Created by Konstantin Tskhovrebov (aka @terrakok) on 14.02.18.
*/
class MergeRequestFragment : BaseFragment(), MergeRequestInfoFragment.ToolbarConfigurator {
class MergeRequestFragment : BaseFragment(), MergeRequestInfoFragment.MergeRequestInfoToolbar {
override val layoutRes = R.layout.fragment_mr
......
......@@ -31,7 +31,7 @@ class MergeRequestInfoFragment : BaseFragment(), MergeRequestInfoView {
override fun showInfo(mrInfo: MergeRequestInfoView.MergeRequestInfo) {
val mergeRequest = mrInfo.mr
(parentFragment as? ToolbarConfigurator)
(parentFragment as? MergeRequestInfoToolbar)
?.setTitle("!${mergeRequest.iid}", mrInfo.project.name)
titleTextView.text = mergeRequest.title
......@@ -69,7 +69,7 @@ class MergeRequestInfoFragment : BaseFragment(), MergeRequestInfoView {
showSnackMessage(message)
}
interface ToolbarConfigurator {
interface MergeRequestInfoToolbar {
fun setTitle(title: String, subTitle: String)
}
}
\ No newline at end of file
......@@ -17,7 +17,7 @@ import javax.inject.Inject
/**
* Created by Eugene Shapovalov (@CraggyHaggy) on 10.02.18.
*/
class ProjectFragment : BaseFragment(), ProjectInfoFragment.ToolbarConfigurator {
class ProjectFragment : BaseFragment(), ProjectInfoFragment.ProjectInfoToolbar {
override val layoutRes: Int = R.layout.fragment_project
private val currentTabFragment: BaseFragment?
......
......@@ -33,7 +33,7 @@ class ProjectInfoFragment : BaseFragment(), ProjectInfoView {
.getInstance(ProjectInfoPresenter::class.java)
override fun showProject(project: Project, mdReadme: CharSequence) {
(parentFragment as? ToolbarConfigurator)?.apply {
(parentFragment as? ProjectInfoToolbar)?.apply {
setTitle(project.name)
setShareUrl(project.webUrl)
}
......@@ -64,7 +64,7 @@ class ProjectInfoFragment : BaseFragment(), ProjectInfoView {
showSnackMessage(message)
}
interface ToolbarConfigurator {
interface ProjectInfoToolbar {
fun setTitle(title: String)
fun setShareUrl(url: String?)
}
......
......@@ -9,8 +9,6 @@ import kotlinx.android.synthetic.main.layout_zero.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.app.target.TargetHeader
import ru.terrakok.gitlabclient.entity.issue.IssueState
import ru.terrakok.gitlabclient.extension.getEnum
import ru.terrakok.gitlabclient.extension.putEnum
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.extension.visible
import ru.terrakok.gitlabclient.presentation.project.issues.ProjectIssuesPresenter
......@@ -38,7 +36,7 @@ class ProjectIssuesFragment : BaseFragment(), ProjectIssuesView {
scope.installModules(object : Module() {
init {
bind(IssueState::class.java)
.toInstance(arguments!!.getEnum<IssueState>(ARG_ISSUE_STATE))
.toInstance(arguments!!.getSerializable(ARG_ISSUE_STATE) as IssueState)
}
})
......@@ -59,7 +57,7 @@ class ProjectIssuesFragment : BaseFragment(), ProjectIssuesView {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (arguments?.getEnum<IssueState>(ARG_ISSUE_STATE) == null) {
if (arguments?.getSerializable(ARG_ISSUE_STATE) == null) {
throw IllegalArgumentException("Provide issue state as args.")
}
}
......@@ -118,7 +116,7 @@ class ProjectIssuesFragment : BaseFragment(), ProjectIssuesView {
fun create(issueState: IssueState) =
ProjectIssuesFragment().apply {
arguments = Bundle().apply {
putEnum(ARG_ISSUE_STATE, issueState)
putSerializable(ARG_ISSUE_STATE, issueState)
}
}
}
......
......@@ -9,8 +9,6 @@ import kotlinx.android.synthetic.main.layout_zero.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.app.target.TargetHeader
import ru.terrakok.gitlabclient.entity.mergerequest.MergeRequestState
import ru.terrakok.gitlabclient.extension.getEnum
import ru.terrakok.gitlabclient.extension.putEnum
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.extension.visible
import ru.terrakok.gitlabclient.presentation.project.mergerequest.ProjectMergeRequestsPresenter
......@@ -38,7 +36,7 @@ class ProjectMergeRequestsFragment : BaseFragment(), ProjectMergeRequestsView {
scope.installModules(object : Module() {
init {
bind(MergeRequestState::class.java)
.toInstance(arguments!!.getEnum<MergeRequestState>(ARG_MERGE_REQUEST_STATE))
.toInstance(arguments!!.getSerializable(ARG_MERGE_REQUEST_STATE) as MergeRequestState)
}
})
......@@ -59,7 +57,7 @@ class ProjectMergeRequestsFragment : BaseFragment(), ProjectMergeRequestsView {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (arguments?.getEnum<MergeRequestState>(ARG_MERGE_REQUEST_STATE) == null) {
if (arguments?.getSerializable(ARG_MERGE_REQUEST_STATE) == null) {
throw IllegalArgumentException("Provide merge request state as args.")
}
}
......@@ -116,10 +114,10 @@ class ProjectMergeRequestsFragment : BaseFragment(), ProjectMergeRequestsView {
private const val ARG_MERGE_REQUEST_STATE = "arg merge request state"
fun create(mergeRequestState: MergeRequestState) =
ProjectMergeRequestsFragment().apply {
arguments = Bundle().apply {
putEnum(ARG_MERGE_REQUEST_STATE, mergeRequestState)
}
ProjectMergeRequestsFragment().apply {
arguments = Bundle().apply {
putSerializable(ARG_MERGE_REQUEST_STATE, mergeRequestState)
}
}
}
}
\ 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