Skip to content
Snippets Groups Projects
Commit e2dcf003 authored by John Carlson's avatar John Carlson
Browse files

Fix for repeated accounts in preferences

parent d07086ac
No related branches found
No related tags found
No related merge requests found
Pipeline #
Loading
Loading
@@ -234,8 +234,8 @@ class ProjectActivity : BaseActivity() {
if (ref == null) {
ref = Ref(Ref.TYPE_BRANCH, project.defaultBranch)
}
toolbar.title = this.project!!.name
toolbar.subtitle = this.project!!.namespace.name
toolbar.title = project.name
toolbar.subtitle = project.namespace.name
setupTabs()
}
 
Loading
Loading
Loading
Loading
@@ -10,7 +10,6 @@ import com.commit451.gitlab.R
import com.commit451.gitlab.model.Account
import com.commit451.gitlab.viewHolder.AccountFooterViewHolder
import com.commit451.gitlab.viewHolder.AccountViewHolder
import java.util.*
 
/**
* Adapter to show all the accounts
Loading
Loading
@@ -24,7 +23,7 @@ class AccountAdapter(context: Context, private val listener: AccountAdapter.List
private val FOOTER_COUNT = 1
}
 
private val accounts: ArrayList<Account> = ArrayList()
private val accounts = mutableListOf<Account>()
private val colorControlHighlight: Int = Easel.getThemeAttrColor(context, R.attr.colorControlHighlight)
 
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
Loading
Loading
Loading
Loading
@@ -31,4 +31,24 @@ open class Account : Comparable<Account> {
override fun compareTo(another: Account): Int {
return lastUsed!!.compareTo(another.lastUsed)
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other?.javaClass != javaClass) return false
other as Account
if (serverUrl != other.serverUrl) return false
if (user != other.user) return false
return true
}
override fun hashCode(): Int {
var result = serverUrl?.hashCode() ?: 0
result = 31 * result + (user?.hashCode() ?: 0)
return result
}
}
Loading
Loading
@@ -91,4 +91,19 @@ open class User {
var privateToken: String? = null
@field:Json(name = "access_level")
var accessLevel: Int = 0
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other?.javaClass != javaClass) return false
other as User
if (id != other.id) return false
return true
}
override fun hashCode(): Int {
return id.hashCode()
}
}
Loading
Loading
@@ -9,11 +9,14 @@ import com.commit451.gitlab.model.api.User
object ImageUtil {
fun getAvatarUrl(user: User?, size: Int): Uri {
if (user != null) {
val avatarUrl = Uri.parse(user.avatarUrl)
if (avatarUrl != null && avatarUrl != Uri.EMPTY) {
return avatarUrl.buildUpon()
.appendQueryParameter("s", Integer.toString(size))
.build()
if (user.avatarUrl != null) {
val avatarUrl = Uri.parse(user.avatarUrl)
if (avatarUrl != null && avatarUrl != Uri.EMPTY) {
return avatarUrl.buildUpon()
.appendQueryParameter("s", Integer.toString(size))
.build()
}
}
 
val email = user.email
Loading
Loading
Loading
Loading
@@ -103,7 +103,7 @@ class LabCoatNavigationView : NavigationView {
false
}
 
private val mAccountsAdapterListener = object : AccountAdapter.Listener {
private val accountsAdapterListener = object : AccountAdapter.Listener {
override fun onAccountClicked(account: Account) {
switchToAccount(account)
}
Loading
Loading
@@ -176,7 +176,7 @@ class LabCoatNavigationView : NavigationView {
params.setMargins(0, resources.getDimensionPixelSize(R.dimen.account_header_height), 0, 0)
listAccounts.setBackgroundColor(colorPrimary)
listAccounts.visibility = View.GONE
adapterAccounts = AccountAdapter(context, mAccountsAdapterListener)
adapterAccounts = AccountAdapter(context, accountsAdapterListener)
listAccounts.adapter = adapterAccounts
setSelectedNavigationItem()
setAccounts()
Loading
Loading
@@ -206,8 +206,6 @@ class LabCoatNavigationView : NavigationView {
fun setAccounts() {
val accounts = Prefs.getAccounts()
Timber.d("Got %s accounts", accounts.size)
Collections.sort(accounts)
Collections.reverse(accounts)
adapterAccounts.setAccounts(accounts)
}
 
Loading
Loading
Loading
Loading
@@ -9,7 +9,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha8'
classpath 'com.android.tools.build:gradle:3.0.0-alpha9'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath 'com.github.ben-manes:gradle-versions-plugin:0.15.0'
classpath 'com.github.Commit451:updatewrapper:1.1.2'
Loading
Loading
#Mon Jul 24 16:08:09 CDT 2017
#Sat Aug 05 16:54:25 CDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment