-
Notifications
You must be signed in to change notification settings - Fork 3
/
SimpleIdlingResource.java
43 lines (31 loc) · 1.13 KB
/
SimpleIdlingResource.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.mmt.travel.app.androidMain.utilities.idlingResourceUtils;
import android.support.test.espresso.IdlingResource;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Nullable;
/**
* Created by MMT6054 on 14-Jul-17.
*/
//we ll call only one idling Resource and it will return when app is idle ,but we need return call back from visible activity code
public class SimpleIdlingResource implements IdlingResource {
@Nullable private volatile ResourceCallback resourceCallback;
private AtomicBoolean mIsIdleNow = new AtomicBoolean(true);
@Override
public String getName() {
System.out.println(this.getClass().getName());
return this.getClass().getName();
}
@Override
public boolean isIdleNow() {
return mIsIdleNow.get();
}
@Override
public void registerIdleTransitionCallback(ResourceCallback callback) {
resourceCallback = callback;
}
public void setIdleState(boolean isIdleNow){
mIsIdleNow.set(isIdleNow);
if(isIdleNow && resourceCallback != null){
resourceCallback.onTransitionToIdle();
}
}
}