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
/** | |
* Manages access to the Android soft keyboard. | |
*/ | |
class KeyboardManager @Inject constructor(private val activity: Activity) { | |
/** | |
* Observable of the status of the keyboard. Subscribing to this creates a | |
* Global Layout Listener which is automatically removed when this | |
* observable is disposed. | |
*/ |
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 fun onCreate(savedInstanceState: Bundle?) { | |
keyboardManager.status() | |
.to(ObservableScoper(this)) // AutoDispose https://github.com/uber/AutoDispose | |
.subscribe { showAnnoyingBanner(visible = KeyboardStatus.CLOSED == 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
/** | |
* Encapsulates a postal address. | |
*/ | |
@AutoValue | |
public abstract class PostalAddress { | |
public static Builder builder() { | |
return new AutoValue_PostalAddress.Builder(); | |
} | |
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
/** | |
* Encapsulates a postal address. | |
*/ | |
data class PostalAddress( | |
val name: String? = null, | |
val street1: String, | |
val street2: String? = null, | |
val street3: String? = null, | |
val street4: String? = null, | |
val city: String, |
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
fun toSingleLineStringForDisplay() = buildString { | |
append(street1).append(", ") | |
street2?.let { append(it).append(", ") } | |
street3?.let { append(it).append(", ") } | |
street4?.let { append(it).append(", ") } | |
append(city).append(", ") | |
append(state).append(" ") | |
append(postalCode) | |
} |
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
fun toSingleLineStringForDisplay(): String { | |
val sb = StringBuilder() | |
sb.append(street1).append(", ") | |
street2?.let { sb.append(it).append(", ") } | |
street3?.let { sb.append(it).append(", ") } | |
street4?.let { sb.append(it).append(", ") } | |
sb.append(city).append(", ") | |
.append(state).append(" ") | |
.append(postalCode) | |
return sb.toString() |
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
/** | |
* Builds new string by populating newly created [StringBuilder] using provided [builderAction] | |
* and then converting it to [String]. | |
*/ | |
public inline fun buildString(builderAction: StringBuilder.() -> Unit): String = | |
StringBuilder().apply(builderAction).toString() |
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
fun toSingleLineStringForDisplay(): String { | |
val sb = StringBuilder() | |
sb.append(street1).append(", ") | |
if (street2 != null) { | |
sb.append(street2).append(", ") | |
} | |
if (street3 != null) { | |
sb.append(street3).append(", ") | |
} | |
if (street4 != 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
fun toSingleLineStringForDisplay() = buildString { | |
append(street1, ", ") | |
street2?.let { append(it, ", ") } | |
street3?.let { append(it, ", ") } | |
street4?.let { append(it, ", ") } | |
append("$city, $state $postalCode") | |
} |
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
fun toSingleLineStringForDisplay() = | |
listOfNotNull(street1, street2, street3, street4, city, "$state $postalCode") | |
.joinToString() |
OlderNewer