Commit 2f71a8eb authored by Valentin Logvinovitch's avatar Valentin Logvinovitch

Refactored code.

parent c0a0f988
......@@ -396,7 +396,7 @@ interface GitlabApi {
@Query("per_page") pageSize: Int = 1
): Single<Result<Void>>
@GET("$API_PATH/projects/{project_id}/members/all")
@GET("$API_PATH/projects/{project_id}/members")
fun getMembers(
@Path("project_id") projectId: Long,
@Query("page") page: Int,
......
......@@ -31,6 +31,12 @@ class MembersAdapterDelegate(
) = (viewHolder as ViewHolder).bind(items[position] as Member)
private inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
private val guestTitle = view.context.getString(R.string.members_guest)
private val reporterTitle = view.context.getString(R.string.members_reporter)
private val developerTitle = view.context.getString(R.string.members_developer)
private val maintainerTitle = view.context.getString(R.string.members_maintainer)
private val ownerTitle = view.context.getString(R.string.members_owner)
private lateinit var data: Member
init {
......@@ -45,14 +51,15 @@ class MembersAdapterDelegate(
roleTextView.text = data.accessLevel.accessToString()
}
}
}
private fun Long.accessToString() =
when (this) {
10L -> "Guest"
20L -> "Reporter"
30L -> "Developer"
40L -> "Maintainer"
else -> throw IllegalArgumentException("You must provide correct value to accessLevel")
}
private fun Long.accessToString(): String =
when (this) {
10L -> guestTitle
20L -> reporterTitle
30L -> developerTitle
40L -> maintainerTitle
50L -> ownerTitle
else -> throw IllegalArgumentException("You must provide correct value to accessLevel")
}
}
}
\ No newline at end of file
......@@ -187,11 +187,18 @@
<string name="project_files_show_branches">Branches</string>
<string name="project_files_default_path">Project Files</string>
<string name="project_files_no_branches">You have no branches</string>
<!--Privacy policy screen-->
<string name="privacy_policy">Privacy policy</string>
<!--Label screen-->
<string name="label_description_empty">No description</string>
<!--Members screen-->
<string name="members_guest">Guest</string>
<string name="members_reporter">Reporter</string>
<string name="members_developer">Developer</string>
<string name="members_maintainer">Maintainer</string>
<string name="members_owner">Owner</string>
</resources>
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