|
@@ -1,21 +1,34 @@
|
|
|
package me.vadik.knigopis.repository.model
|
|
package me.vadik.knigopis.repository.model
|
|
|
|
|
|
|
|
-import java.util.*
|
|
|
|
|
|
|
+import android.net.Uri
|
|
|
|
|
+import me.vadik.knigopis.common.toUriOrNull
|
|
|
|
|
+
|
|
|
|
|
+private val defaultAvatars = setOf(
|
|
|
|
|
+ "https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg?sz=100",
|
|
|
|
|
+ "https://lh6.googleusercontent.com/-cfU0I0DdeGE/AAAAAAAAAAI/AAAAAAAAANs/RoQmKyJjwLo/photo.jpg?sz=100",
|
|
|
|
|
+ "https://vk.com/images/camera_50.png",
|
|
|
|
|
+ "http://vk.com/images/camera_50.png",
|
|
|
|
|
+ "https://ulogin.ru/img/photo.png",
|
|
|
|
|
+ "http://avt-27.foto.mail.ru/mail/newmoon56/_avatar"
|
|
|
|
|
+)
|
|
|
|
|
|
|
|
class User(
|
|
class User(
|
|
|
val id: String,
|
|
val id: String,
|
|
|
- val lang: String,
|
|
|
|
|
val nickname: String?,
|
|
val nickname: String?,
|
|
|
- val photo: String,
|
|
|
|
|
- val profile: String,
|
|
|
|
|
- val identity: String,
|
|
|
|
|
- val booksCount: Int,
|
|
|
|
|
- val subscriptions: Map<String, Int>?,
|
|
|
|
|
- val createdAt: Date,
|
|
|
|
|
- val updatedAt: Date
|
|
|
|
|
|
|
+ val photo: String?,
|
|
|
|
|
+ private val profile: String?,
|
|
|
|
|
+ private val identity: String?,
|
|
|
|
|
+ val booksCount: Int
|
|
|
) {
|
|
) {
|
|
|
- // TODO https://trello.com/c/UymHYoPK
|
|
|
|
|
- val fixedCreatedAt get() = Date(createdAt.time + TimeZone.getDefault().rawOffset)
|
|
|
|
|
- val fixedUpdatedAt get() = Date(updatedAt.time + TimeZone.getDefault().rawOffset)
|
|
|
|
|
|
|
+
|
|
|
val fixedProfile get() = "http://www.knigopis.com/#/user/books?u=$id"
|
|
val fixedProfile get() = "http://www.knigopis.com/#/user/books?u=$id"
|
|
|
|
|
+
|
|
|
|
|
+ val name get() = nickname ?: id
|
|
|
|
|
+
|
|
|
|
|
+ val avatar: String? get() = photo.takeUnless { it in defaultAvatars }
|
|
|
|
|
+
|
|
|
|
|
+ val profiles: List<Uri>
|
|
|
|
|
+ get() = listOfNotNull(profile, identity)
|
|
|
|
|
+ .mapNotNull(String::toUriOrNull)
|
|
|
|
|
+
|
|
|
}
|
|
}
|