-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from Trendyol/feature/selection-dialog-search
Feature/selection dialog search
- Loading branch information
Showing
23 changed files
with
370 additions
and
61 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 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 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 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 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 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 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 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
42 changes: 42 additions & 0 deletions
42
libraries/dialogs/src/main/java/com/trendyol/uicomponents/dialogs/SingleLiveEvent.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.trendyol.uicomponents.dialogs | ||
|
||
import androidx.annotation.MainThread | ||
import androidx.lifecycle.LifecycleOwner | ||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.Observer | ||
import java.util.concurrent.atomic.AtomicBoolean | ||
|
||
/** | ||
* A lifecycle-aware observable that sends only new updates after subscription, used for events like | ||
* navigation and Snackbar messages. | ||
* | ||
* | ||
* This avoids a common problem with events: on configuration change (like rotation) an update | ||
* can be emitted if the observer is active. This LiveData only calls the observable if there's an | ||
* explicit call to setValue() or call(). | ||
* | ||
* | ||
* Note that only one observer is going to be notified of changes. | ||
* | ||
* Source: https://github.com/android/play-billing-samples/blob/master/ClassyTaxi/android/ClassyTaxi/app/src/main/java/com/example/subscriptions/ui/SingleLiveEvent.kt | ||
*/ | ||
internal class SingleLiveEvent<T> : MutableLiveData<T>() { | ||
|
||
private val pending = AtomicBoolean(false) | ||
|
||
@MainThread | ||
override fun observe(owner: LifecycleOwner, observer: Observer<in T>) { | ||
// Observe the internal MutableLiveData | ||
super.observe(owner, Observer { t -> | ||
if (pending.compareAndSet(true, false)) { | ||
observer.onChanged(t) | ||
} | ||
}) | ||
} | ||
|
||
@MainThread | ||
override fun setValue(t: T?) { | ||
pending.set(true) | ||
super.setValue(t) | ||
} | ||
} |
Oops, something went wrong.