This file contains hidden or 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
| sealed class Animal { | |
| object Cat : Animal() // We can define a Object classes like this | |
| data class Dog(val name: String) : Animal() // We can define data classes like this | |
| } |
This file contains hidden or 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 FakeUser( | |
| override val id: String = "", | |
| override val firstName: String = "", | |
| override val lastName: String = "", | |
| override val email: String = "", | |
| override val image: String = "", | |
| override val mobile: Long = 0, | |
| override val gender: String = "", | |
| override val profileCompleted: Int = 0 | |
| ) : UserAbstract(id,firstName,lastName,email,image,mobile,gender,profileCompleted) |
This file contains hidden or 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
| /** | |
| * A data model class for User with required fields. | |
| */ | |
| data class User( | |
| override val id: String = "", | |
| override val firstName: String = "", | |
| override val lastName: String = "", | |
| override val email: String = "", | |
| override val image: String = "", | |
| override val mobile: Long = 0, |
This file contains hidden or 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 User( | |
| val id: String = "", | |
| val firstName: String = "", | |
| val lastName: String = "", | |
| val email: String = "", | |
| val image: String = "", | |
| val mobile: Long = 0, | |
| val gender: String = "", | |
| val profileCompleted: Int = 0 | |
| ) |
This file contains hidden or 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
| // https://medium.com/swlh/callback-flows-in-android-d2c6ed5bc488 | |
| fun TextView.textWatcherFlow(): Flow<CharSequence?> = callbackFlow<CharSequence?> { | |
| val textWatcher = object: TextWatcher { | |
| override fun afterTextChanged(s: Editable?) { | |
| sendBlocking(s) | |
| } | |
| // Other callback mehthods | |
| } | |
| addTextChangedListener(textWatcher) | |
| awaitClose { removeTextChangedListener(textWatcher) } |
This file contains hidden or 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
| // DEFINITION: -> Creates a CompletableDeferred in an active state. It is optionally a child of a parent job. | |
| @Suppress("FunctionName") | |
| public fun <T> CompletableDeferred(parent: Job? = null): CompletableDeferred<T> = CompletableDeferredImpl(parent) |
This file contains hidden or 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 readMessage(dialog: QBChatDialog): Flow<ArrayList<QBChatMessage>> { | |
| val historyDeferred = CompletableDeferred<ArrayList<QBChatMessage>>() | |
| chatHelper.ReadChatHistory(dialog, object : QBEntityCallback<ArrayList<QBChatMessage>> { | |
| override fun onSuccess(listmessage: ArrayList<QBChatMessage>?, p1: Bundle?) { | |
| historyDeferred.complete(listmessage ?: arrayListOf()) | |
| } | |
| override fun onError(p0: QBResponseException?) { | |
| historyDeferred.completeExceptionally(p0 ?: CancellationException()) | |
| } |
This file contains hidden or 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 getAllPosts() = flow<State<List<Post>>> { | |
| // Emit loading state | |
| emit(State.loading()) | |
| val snapshot = mPostsCollection.get().await() | |
| val posts = snapshot.toObjects(Post::class.java) | |
| // Emit success state with data | |
| emit(State.success(posts)) |
This file contains hidden or 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
| public interface Element { | |
| Boolean accept(Visitor visitor); | |
| } |
This file contains hidden or 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
| [merge] | |
| tool = studio | |
| [mergetool "studio"] | |
| prompt = false | |
| cmd = /Applications/Android\\ Studio.app/Contents/MacOS/studio merge $(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE") $(cd $(dirname "$BASE") && pwd)/$(basename "$BASE") $(cd $(dirname "$MERGED") && pwd)/$(basename "$MERGED") | |
| trustExitCode = true | |
| [diff] | |
| tool = studio | |
| [difftool "studio"] | |
| prompt = false |