Merge branch 'use_complete_user_id' into 'master'
Use complete user id (with instance) See merge request pixeldroid/PixelDroid!389
This commit is contained in:
commit
0c323d27d4
|
@ -125,7 +125,7 @@ class MainActivity : BaseActivity() {
|
|||
|| instanceOfNotification != user?.instance_uri)
|
||||
) {
|
||||
|
||||
switchUser(userOfNotification)
|
||||
switchUser(userOfNotification, instanceOfNotification)
|
||||
|
||||
val newIntent = Intent(this, MainActivity::class.java)
|
||||
newIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
|
@ -165,14 +165,14 @@ class MainActivity : BaseActivity() {
|
|||
|
||||
DrawerImageLoader.init(object : AbstractDrawerImageLoader() {
|
||||
override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable, tag: String?) {
|
||||
Glide.with(imageView.context)
|
||||
Glide.with(this@MainActivity)
|
||||
.load(uri)
|
||||
.placeholder(placeholder)
|
||||
.into(imageView)
|
||||
}
|
||||
|
||||
override fun cancel(imageView: ImageView) {
|
||||
Glide.with(imageView.context).clear(imageView)
|
||||
Glide.with(this@MainActivity).clear(imageView)
|
||||
}
|
||||
|
||||
override fun placeholder(ctx: Context, tag: String?): Drawable {
|
||||
|
@ -227,7 +227,7 @@ class MainActivity : BaseActivity() {
|
|||
launchActivity(LoginActivity(), firstTime = true)
|
||||
} else {
|
||||
val newActive = remainingUsers.first()
|
||||
db.userDao().activateUser(newActive.user_id)
|
||||
db.userDao().activateUser(newActive.user_id, newActive.instance_uri)
|
||||
apiHolder.setToCurrentUser()
|
||||
//relaunch the app
|
||||
launchActivity(MainActivity(), firstTime = true)
|
||||
|
@ -270,7 +270,7 @@ class MainActivity : BaseActivity() {
|
|||
return false
|
||||
}
|
||||
|
||||
switchUser(profile.identifier.toString())
|
||||
switchUser(profile.identifier.toString(), profile.tag as String)
|
||||
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
|
@ -281,9 +281,9 @@ class MainActivity : BaseActivity() {
|
|||
return false
|
||||
}
|
||||
|
||||
private fun switchUser(userId: String) {
|
||||
private fun switchUser(userId: String, instance_uri: String) {
|
||||
db.userDao().deActivateActiveUsers()
|
||||
db.userDao().activateUser(userId)
|
||||
db.userDao().activateUser(userId, instance_uri)
|
||||
apiHolder.setToCurrentUser()
|
||||
}
|
||||
|
||||
|
@ -313,6 +313,7 @@ class MainActivity : BaseActivity() {
|
|||
isNameShown = true
|
||||
identifier = user.user_id.toLong()
|
||||
descriptionText = user.fullHandle
|
||||
tag = user.instance_uri
|
||||
}
|
||||
}.toMutableList()
|
||||
|
||||
|
|
|
@ -33,14 +33,12 @@ interface UserDao {
|
|||
@Query("UPDATE users SET isActive=0")
|
||||
fun deActivateActiveUsers()
|
||||
|
||||
//TODO also check instance_uri
|
||||
@Query("UPDATE users SET isActive=1 WHERE user_id=:id")
|
||||
fun activateUser(id: String)
|
||||
@Query("UPDATE users SET isActive=1 WHERE user_id=:id AND instance_uri=:instance_uri")
|
||||
fun activateUser(id: String, instance_uri: String)
|
||||
|
||||
@Query("DELETE FROM users WHERE isActive=1")
|
||||
fun deleteActiveUsers()
|
||||
|
||||
//TODO also check instance_uri
|
||||
@Query("SELECT * FROM users WHERE user_id=:id LIMIT 1")
|
||||
fun getUserWithId(id: String): UserDatabaseEntity
|
||||
@Query("SELECT * FROM users WHERE user_id=:id AND instance_uri=:instance_uri LIMIT 1")
|
||||
fun getUserWithId(id: String, instance_uri: String): UserDatabaseEntity
|
||||
}
|
Loading…
Reference in New Issue