Search in sources :

Example 76 with Handler

use of android.os.Handler in project platform_frameworks_base by android.

the class AttachInfo_Accessor method setAttachInfo.

public static void setAttachInfo(View view) {
    Context context = view.getContext();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    ViewRootImpl root = new ViewRootImpl(context, display);
    AttachInfo info = new AttachInfo(new BridgeWindowSession(), new BridgeWindow(), display, root, new Handler(), null);
    info.mHasWindowFocus = true;
    info.mWindowVisibility = View.VISIBLE;
    // this is so that we can display selections.
    info.mInTouchMode = false;
    info.mHardwareAccelerated = false;
    view.dispatchAttachedToWindow(info, 0);
}
Also used : Context(android.content.Context) BridgeWindowSession(com.android.layoutlib.bridge.android.BridgeWindowSession) BridgeWindow(com.android.layoutlib.bridge.android.BridgeWindow) Handler(android.os.Handler) AttachInfo(android.view.View.AttachInfo)

Example 77 with Handler

use of android.os.Handler in project platform_frameworks_base by android.

the class WifiNetworkScoreCacheTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    when(mockContext.getApplicationContext()).thenReturn(mockApplicationContext);
    mValidScoredNetwork = buildScoredNetwork(VALID_KEY, mockRssiCurve);
    mScoreCache = new WifiNetworkScoreCache(mockContext);
    initializeCacheWithValidScoredNetwork();
    HandlerThread thread = new HandlerThread("WifiNetworkScoreCacheTest Handler Thread");
    thread.start();
    mHandler = new Handler(thread.getLooper());
    mLatch = new CountDownLatch(1);
    mCacheListener = new CacheListener(mHandler) {

        @Override
        public void networkCacheUpdated(List<ScoredNetwork> updatedNetworks) {
            mUpdatedNetworksCaptor = updatedNetworks;
            mLatch.countDown();
        }
    };
}
Also used : HandlerThread(android.os.HandlerThread) ScoredNetwork(android.net.ScoredNetwork) Handler(android.os.Handler) CountDownLatch(java.util.concurrent.CountDownLatch) CacheListener(android.net.wifi.WifiNetworkScoreCache.CacheListener) Before(org.junit.Before)

Example 78 with Handler

use of android.os.Handler in project platform_frameworks_base by android.

the class WifiManager method getChannel.

private synchronized AsyncChannel getChannel() {
    if (mAsyncChannel == null) {
        Messenger messenger = getWifiServiceMessenger();
        if (messenger == null) {
            throw new IllegalStateException("getWifiServiceMessenger() returned null!  This is invalid.");
        }
        mAsyncChannel = new AsyncChannel();
        mConnected = new CountDownLatch(1);
        Handler handler = new ServiceHandler(mLooper);
        mAsyncChannel.connect(mContext, handler, messenger);
        try {
            mConnected.await();
        } catch (InterruptedException e) {
            Log.e(TAG, "interrupted wait at init");
        }
    }
    return mAsyncChannel;
}
Also used : Handler(android.os.Handler) AsyncChannel(com.android.internal.util.AsyncChannel) Messenger(android.os.Messenger) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 79 with Handler

use of android.os.Handler in project platform_frameworks_base by android.

the class HdmiCecController method init.

private void init(long nativePtr) {
    mIoHandler = new Handler(mService.getIoLooper());
    mControlHandler = new Handler(mService.getServiceLooper());
    mNativePtr = nativePtr;
}
Also used : Handler(android.os.Handler)

Example 80 with Handler

use of android.os.Handler in project storio by pushtorefresh.

the class RxChangesObserverTest method contentObserverShouldReturnFalseOnDeliverSelfNotificationsOnAllSdkVersions.

@Test
public void contentObserverShouldReturnFalseOnDeliverSelfNotificationsOnAllSdkVersions() {
    for (int sdkVersion = MIN_SDK_VERSION; sdkVersion < MAX_SDK_VERSION; sdkVersion++) {
        ContentResolver contentResolver = mock(ContentResolver.class);
        Uri uri = mock(Uri.class);
        final AtomicReference<ContentObserver> contentObserver = new AtomicReference<ContentObserver>();
        doAnswer(new Answer() {

            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
                contentObserver.set((ContentObserver) invocation.getArguments()[2]);
                return null;
            }
        }).when(contentResolver).registerContentObserver(same(uri), eq(true), any(ContentObserver.class));
        Handler handler = mock(Handler.class);
        Observable<Changes> observable = RxChangesObserver.observeChanges(contentResolver, singleton(uri), handler, sdkVersion);
        Subscription subscription = observable.subscribe();
        assertThat(contentObserver.get().deliverSelfNotifications()).isFalse();
        subscription.unsubscribe();
    }
}
Also used : Changes(com.pushtorefresh.storio.contentresolver.Changes) Handler(android.os.Handler) AtomicReference(java.util.concurrent.atomic.AtomicReference) Uri(android.net.Uri) ContentResolver(android.content.ContentResolver) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Subscription(rx.Subscription) ContentObserver(android.database.ContentObserver) Test(org.junit.Test)

Aggregations

Handler (android.os.Handler)1906 Message (android.os.Message)254 View (android.view.View)207 Intent (android.content.Intent)174 HandlerThread (android.os.HandlerThread)156 TextView (android.widget.TextView)118 MediumTest (android.test.suitebuilder.annotation.MediumTest)116 ArrayList (java.util.ArrayList)97 Test (org.junit.Test)85 Context (android.content.Context)71 IntentFilter (android.content.IntentFilter)69 RemoteException (android.os.RemoteException)63 IOException (java.io.IOException)63 ComponentName (android.content.ComponentName)57 ImageView (android.widget.ImageView)57 Bundle (android.os.Bundle)56 RecyclerView (android.support.v7.widget.RecyclerView)54 Looper (android.os.Looper)53 File (java.io.File)46 ContentObserver (android.database.ContentObserver)44