This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<TextView | |
android:id="@+id/name_label" | |
android:text="Name:"/> | |
<TextView | |
android:id="@+id/cat_name" | |
android:text="Eliza" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ImageView | |
android:id="@+id/star" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:importantForAccessibility="no" | |
app:srcCompat=“@drawable/vd_star" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ImageView | |
android:id="@+id/star" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:contentDescription=“@null" | |
app:srcCompat=“@drawable/vd_star" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ImageView | |
android:id="@+id/star" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:contentDescription=“Twinkly star” | |
app:srcCompat=“@drawable/vd_star" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install -g create-react-kotlin-app | |
npx create-react-kotlin-app inspirobot | |
npm start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@KtorExperimentalAPI | |
override suspend fun getInspiration(): URL? { | |
val httpClient = HttpClient(CIO) | |
val url = httpClient.get<String?>(INSPIROBOT_URL) | |
return if (url != null) { | |
URL(url) | |
} else { | |
null | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
compile "io.ktor:ktor-client-cio:$ktor_version" | |
compile "com.h2database:h2:1.4.198" | |
compile "org.jetbrains.exposed:exposed:0.12.2" | |
compile "com.zaxxer:HikariCP:2.7.8" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override suspend fun findInspirationsByUserId(userId: Long): List<Inspiration> { | |
return dbQuery { | |
Inspirations.select { Inspirations.userId eq userId }.mapNotNull { | |
mapInspirationsToInspiration(it) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private suspend fun <T> dbQuery(block: () -> T): T { | |
return withContext(Dispatchers.IO) { | |
transaction { block() } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override suspend fun createInspiration( | |
userId: Long, | |
fileExtension: String, | |
inputStream: ByteArrayInputStream | |
): Inspiration? { | |
return dbQuery { | |
//Save the file | |
val inspirationImage = File("$IMAGE_DIR/${UUID.randomUUID()}.$fileExtension") | |
inspirationImage.writeBytes(inputStream.readBytes()) |