-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 #2569 from owncloud/new_arch/improve_viewmodels
[New architecture] Improve viewmodel behaviour
- Loading branch information
Showing
17 changed files
with
511 additions
and
367 deletions.
There are no files selected for viewing
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
39 changes: 39 additions & 0 deletions
39
...p/src/androidTest/java/com/owncloud/android/shares/ui/FragmentVisibilityIdlingResource.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,39 @@ | ||
package com.owncloud.android.shares.ui | ||
|
||
import android.view.View | ||
import androidx.fragment.app.Fragment | ||
import androidx.test.espresso.IdlingResource | ||
|
||
class FragmentVisibilityIdlingResource(private val fragment: Fragment?, private val expectedVisibility: Int) : | ||
IdlingResource { | ||
private var idle: Boolean = false | ||
private var resourceCallback: IdlingResource.ResourceCallback? = null | ||
|
||
init { | ||
this.idle = false | ||
this.resourceCallback = null | ||
} | ||
|
||
override fun getName(): String { | ||
return FragmentVisibilityIdlingResource::class.java.simpleName | ||
} | ||
|
||
override fun isIdleNow(): Boolean { | ||
if (fragment == null) return false | ||
|
||
idle = idle || (fragment.isVisible && expectedVisibility == View.VISIBLE) || | ||
(!fragment.isVisible && expectedVisibility == View.INVISIBLE) | ||
|
||
if (idle) { | ||
if (resourceCallback != null) { | ||
resourceCallback!!.onTransitionToIdle() | ||
} | ||
} | ||
|
||
return idle | ||
} | ||
|
||
override fun registerIdleTransitionCallback(resourceCallback: IdlingResource.ResourceCallback) { | ||
this.resourceCallback = resourceCallback | ||
} | ||
} |
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
Oops, something went wrong.