Java 类android.os.RemoteCallbackList 实例源码

项目:Musicoco    文件:PlayControlImpl.java   
public PlayControlImpl(Context context) {
    this.context = context;
    this.mSongChangeListeners = new RemoteCallbackList<>();
    this.mStatusChangeListeners = new RemoteCallbackList<>();
    this.mPlayListChangeListeners = new RemoteCallbackList<>();
    this.mDataIsReadyListeners = new RemoteCallbackList<>();

    this.sessionManager = new MediaSessionManager(context, this);
    this.focusManager = new AudioFocusManager(context, this);
    this.manager = PlayController.getMediaController(
            context,
            focusManager,
            sessionManager,
            new NotifyStatusChange(),
            new NotifySongChange(),
            new NotifyPlayListChange());
}
项目:Zom-Android    文件:ImConnectionAdapter.java   
public ImConnectionAdapter(long providerId, long accountId, ImConnection connection, RemoteImService service) {
    mProviderId = providerId;
    mAccountId = accountId;
    mConnection = connection;
    mService = service;
    mConnectionListener = new ConnectionListenerAdapter();
    mConnection.addConnectionListener(mConnectionListener);
    if ((connection.getCapability() & ImConnection.CAPABILITY_GROUP_CHAT) != 0) {
        mGroupManager = mConnection.getChatGroupManager();
        mInvitationListener = new InvitationListenerAdapter();
        mGroupManager.setInvitationListener(mInvitationListener);
    }

    mChatSessionManager = new ChatSessionManagerAdapter(this);
    mContactListManager = new ContactListManagerAdapter(this);
    mRemoteConnListeners = new RemoteCallbackList<>();

}
项目:ics-openconnect    文件:ExternalOpenVPNService.java   
@Override public void handleMessage(Message msg) {

            RemoteCallbackList<IOpenVPNStatusCallback> callbacks;
            switch (msg.what) {
            case SEND_TOALL:
                if(service ==null || service.get() == null)
                    return;

                callbacks = service.get().mCallbacks;


                // Broadcast to all clients the new value.
                final int N = callbacks.beginBroadcast();
                for (int i=0; i<N; i++) {
                    try {
                        sendUpdate(callbacks.getBroadcastItem(i),(UpdateMessage) msg.obj);
                    } catch (RemoteException e) {
                        // The RemoteCallbackList will take care of removing
                        // the dead object for us.
                    }
                }
                callbacks.finishBroadcast();
                break;
            }
        }
项目:network-buffer    文件:NetworkService.java   
@Override
public void onCreate() {
  // TODO: make this multi-threaded... someday.
  mScheduledExecutor = Executors.newScheduledThreadPool(1);

  // Start a periodic garbage collection task to check for and cleanup any
  // terminated delay sockets.
  mScheduledExecutor.scheduleAtFixedRate(new Runnable() {
    @Override
    public void run() {
      for (Long handle : mDelaySockets.keySet()) {
        DelaySocket delaySocket = mDelaySockets.get(handle);
        if (delaySocket != null && delaySocket.isTerminated()) {
          delaySocket.close();
          mDelaySockets.remove(handle);
        }
      }
    }
  }, 0, 4000, TimeUnit.MILLISECONDS);

  mCallbacks = new RemoteCallbackList<INetworkServiceCallback>();
  mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
  mDelaySockets = new ConcurrentHashMap<Long, DelaySocket>();
  showNotification();
}
项目:FullRobolectricTestSample    文件:RemoteCallbackListTest.java   
@Test
public void testBasicWiring() throws Exception {
  RemoteCallbackList<Foo> fooRemoteCallbackList = new RemoteCallbackList<Foo>();
  Foo callback = new Foo();
  fooRemoteCallbackList.register(callback);

  fooRemoteCallbackList.beginBroadcast();

  assertThat(fooRemoteCallbackList.getBroadcastItem(0)).isSameAs(callback);
}
项目:NotiziePolitiche    文件:FeedRetrieverService.java   
@Override
public void onCreate() {
    super.onCreate();

    try {
        listeners = new RemoteCallbackList<IFeedRetrieverServiceCallback>();
        NotiziePoliticheApplication app = (NotiziePoliticheApplication) getApplication();
        app.firstTimeInitApplication();

        Intent i = new Intent(getApplicationContext(),
                RefreshAllReceiver.class);
        intentRefreshAll = PendingIntent.getBroadcast(
                getApplicationContext(), 0, i,
                PendingIntent.FLAG_UPDATE_CURRENT);

        i = new Intent(getApplicationContext(),
                RemoveExpiredDataReceiver.class);
        intentExpiredData = PendingIntent.getBroadcast(
                getApplicationContext(), 0, i,
                PendingIntent.FLAG_UPDATE_CURRENT);

        configureServiceParameters();

    } catch (Exception e) {
        Log.e(getClass().getName(), "Creating the feeds service", e);
        throw new RuntimeException(e);
    }
}
项目:yyox    文件:ConnectionEvent.java   
public ConnectionEvent(RemoteCallbackList<ConnectionCallBack> mCallbackList) {
    this.mCallbackList = mCallbackList;
}