Skip to content

Commit

Permalink
Merge pull request android#258 from pfmaggi/pfm/alpha09
Browse files Browse the repository at this point in the history
Update to alpha09 and remove throttle on first event collet.
  • Loading branch information
pfmaggi authored Jul 12, 2021
2 parents ade3f16 + 927e309 commit cb73be1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 60 deletions.
15 changes: 7 additions & 8 deletions WindowManager/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,19 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0-alpha01'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0-alpha02'

def window_version = '1.0.0-alpha08'
def window_version = '1.0.0-alpha09'
implementation "androidx.window:window:$window_version"
implementation "androidx.window:window-java:$window_version"

androidTestImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.arch.core:core-testing:2.1.0'

androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation 'androidx.test:runner:1.4.0-beta02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0-beta02'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.3.0'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0'
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"
androidTestImplementation "androidx.window:window-testing:$window_version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.example.windowmanagersample.databinding.ActivityDisplayFeaturesBindin
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
Expand All @@ -55,18 +56,15 @@ class DisplayFeaturesActivity : AppCompatActivity() {
windowInfoRepo = windowInfoRepository()

// Create a new coroutine since repeatOnLifecycle is a suspend function
lifecycleScope.launch {
lifecycleScope.launch(Dispatchers.Main) {
// The block passed to repeatOnLifecycle is executed when the lifecycle
// is at least STARTED and is cancelled when the lifecycle is STOPPED.
// It automatically restarts the block when the lifecycle is STARTED again.
lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) {
// Safely collect from windowInfoRepo when the lifecycle is STARTED
// and stops collection when the lifecycle is STOPPED
windowInfoRepo.windowLayoutInfo
// Throttle first event 10ms to allow the UI to pickup the posture
.throttleFirst(10)
.collect { newLayoutInfo ->
// New posture information
updateStateLog(newLayoutInfo)
updateCurrentState(newLayoutInfo)
}
Expand Down Expand Up @@ -123,7 +121,7 @@ class DisplayFeaturesActivity : AppCompatActivity() {
stateStringBuilder
.append(" - ")
.append(
if (foldFeature.orientation == FoldingFeature.ORIENTATION_HORIZONTAL) {
if (foldFeature.orientation == FoldingFeature.Orientation.HORIZONTAL) {
getString(R.string.screen_is_horizontal)
} else {
getString(R.string.screen_is_vertical)
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions WindowManager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
*/

buildscript {
ext.kotlin_version = '1.5.10'
ext.kotlin_version = '1.5.20'
ext.coroutines_version = '1.5.0'
ext.ktlint_version = '0.40.0'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down

0 comments on commit cb73be1

Please sign in to comment.