| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.view; |
| 18 |
|
| 19 |
import android.os.Handler; |
| 20 |
import android.os.HandlerThread; |
| 21 |
import android.os.Trace; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
public class InsetsAnimationThread extends HandlerThread { |
| 28 |
|
| 29 |
private static InsetsAnimationThread sInstance; |
| 30 |
private static Handler sHandler; |
| 31 |
|
| 32 |
private InsetsAnimationThread() { |
| 33 |
|
| 34 |
super("InsetsAnimations"); |
| 35 |
} |
| 36 |
|
| 37 |
private static void ensureThreadLocked() { |
| 38 |
if (sInstance == null) { |
| 39 |
sInstance = new InsetsAnimationThread(); |
| 40 |
sInstance.start(); |
| 41 |
sInstance.getLooper().setTraceTag(Trace.TRACE_TAG_VIEW); |
| 42 |
sHandler = new Handler(sInstance.getLooper()); |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
public static void release() { |
| 47 |
synchronized (InsetsAnimationThread.class) { |
| 48 |
if (sInstance == null) { |
| 49 |
return; |
| 50 |
} |
| 51 |
sInstance.getLooper().quitSafely(); |
| 52 |
sInstance = null; |
| 53 |
sHandler = null; |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
public static InsetsAnimationThread get() { |
| 58 |
synchronized (InsetsAnimationThread.class) { |
| 59 |
ensureThreadLocked(); |
| 60 |
return sInstance; |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
public static Handler getHandler() { |
| 65 |
synchronized (InsetsAnimationThread.class) { |
| 66 |
ensureThreadLocked(); |
| 67 |
return sHandler; |
| 68 |
} |
| 69 |
} |
| 70 |
} |