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
/** | |
* This class is the current implementation. | |
* | |
* Notice that in [addPendingPrescriptionCard] and [addActivePrescriptionCard], | |
* we have relatively identical code: | |
* | |
* 1. Create the group. | |
* 2. Create all the models and add them to the group. | |
* 3. Add the group to the main controller. | |
* |
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
data class PatientDTO( | |
@field:Json(name = "id") | |
val id: String? = null, | |
@field:Json(name = "firstName") | |
val firstName: String? = null, | |
@field:Json(name = "lastName") | |
val lastName: String? = null | |
) { | |
fun toPatient(): Patient { | |
val id = this.id.orEmpty() |
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
/** | |
* Given a supplied [dateString] that matches our [RFC_3339_FORMAT], convert it to a | |
* [Calendar] instance for the corresponding [timeZoneString]. | |
* | |
* The only way I've been able to do this is: | |
* 1. Take the date string, which is GMT, and convert it to a Date. | |
* 2. Update the TZ on our SimpleDateFormat, to get the string in the desired TimeZone. | |
* 3. Reverse engineer that back into a date. | |
* 4. Return this calendar. | |
* |
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
class MyEpoxyController : TypedEpoxyController<ViewState> { | |
/** | |
* This buildModels method takes in the current ViewState and builds all of the Epoxy Models | |
* that need to be displayed for this state. | |
*/ | |
override fun buildModels(data: ViewState) { | |
data.usersAndItems.forEach { userItems -> | |
addUserItemsModels(userItems) | |
} | |
} |
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
// Easy to do this | |
@Entity | |
data class User( | |
@PrimaryKey(autoGenerate = false) | |
@field:Json(name = "id") | |
val id: String = "", | |
@field:Json(name = "display_name") | |
val displayName: String? = 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
# If you want to include deletions, `+ git.deleted_files` | |
modifiedOrNewFiles = (git.added_files + git.modified_files) | |
diffWithoutPackageLock = modifiedOrNewFiles.select { |file| | |
file != "package-lock.json" | |
}.map { |file| | |
git.info_for_file(file) | |
}.map { |info| | |
info[:insertions] + info[:deletions] | |
}.sum() |
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
class FakePreferences : Preferences { | |
var storedLongCallCount = 0 | |
private set | |
var getLongCallCount = 0 | |
private set | |
/** | |
* In this fake, we're just incrementing the number of calls to get long, but we could be more | |
* thorough and track the key that was called. |
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
/** | |
* This defines the contract for communicating with some data source to request profile information. | |
*/ | |
interface ProfileRepository { | |
fun fetchProfile(userId: String): Single<User> | |
} |
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
package com.adammcneilly.androiduniversity.room; | |
import android.database.Cursor; | |
import androidx.collection.LongSparseArray; | |
import androidx.lifecycle.LiveData; | |
import androidx.room.RoomDatabase; | |
import androidx.room.RoomSQLiteQuery; | |
import androidx.room.util.CursorUtil; | |
import androidx.room.util.DBUtil; | |
import androidx.room.util.StringUtil; |