当前位置: 首页>>代码示例>>Java>>正文


Java RegistryListener类代码示例

本文整理汇总了Java中org.fourthline.cling.registry.RegistryListener的典型用法代码示例。如果您正苦于以下问题:Java RegistryListener类的具体用法?Java RegistryListener怎么用?Java RegistryListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RegistryListener类属于org.fourthline.cling.registry包,在下文中一共展示了RegistryListener类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: UpnpServiceImpl

import org.fourthline.cling.registry.RegistryListener; //导入依赖的package包/类
public UpnpServiceImpl(RegistryListener... registryListeners) {
    this(new DefaultUpnpServiceConfiguration(), registryListeners);
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:4,代码来源:UpnpServiceImpl.java

示例2: DLNARouteProvider

import org.fourthline.cling.registry.RegistryListener; //导入依赖的package包/类
public DLNARouteProvider(Context context) {
	super(context);

	// Use custom logger
	org.eclipse.jetty.util.log.Log.setLog(new JettyAndroidLog());

	this.downloadService = (DownloadService) context;
	dlnaServiceConnection = new ServiceConnection() {
		@Override
		public void onServiceConnected(ComponentName name, IBinder service) {
			dlnaService = (AndroidUpnpService) service;
			dlnaService.getRegistry().addListener(registryListener = new RegistryListener() {
				@Override
				public void remoteDeviceDiscoveryStarted(Registry registry, RemoteDevice remoteDevice) {

				}

				@Override
				public void remoteDeviceDiscoveryFailed(Registry registry, RemoteDevice remoteDevice, Exception e) {
					// Error is displayed in log anyways under W/trieveRemoteDescriptors
				}

				@Override
				public void remoteDeviceAdded(Registry registry, RemoteDevice remoteDevice) {
					deviceAdded(remoteDevice);
				}

				@Override
				public void remoteDeviceUpdated(Registry registry, RemoteDevice remoteDevice) {
					deviceAdded(remoteDevice);
				}

				@Override
				public void remoteDeviceRemoved(Registry registry, RemoteDevice remoteDevice) {
					deviceRemoved(remoteDevice);
				}

				@Override
				public void localDeviceAdded(Registry registry, LocalDevice localDevice) {
					deviceAdded(localDevice);
				}

				@Override
				public void localDeviceRemoved(Registry registry, LocalDevice localDevice) {
					deviceRemoved(localDevice);
				}

				@Override
				public void beforeShutdown(Registry registry) {

				}

				@Override
				public void afterShutdown() {

				}
			});

			for (Device<?, ?, ?> device : dlnaService.getControlPoint().getRegistry().getDevices()) {
				deviceAdded(device);
			}
			if(searchOnConnect) {
				dlnaService.getControlPoint().search();
			}
		}

		@Override
		public void onServiceDisconnected(ComponentName name) {
			dlnaService = null;
			registryListener = null;
		}
	};

	if(!context.getApplicationContext().bindService(new Intent(context, AndroidUpnpServiceImpl.class), dlnaServiceConnection, Context.BIND_AUTO_CREATE)) {
		Log.e(TAG, "Failed to bind to DLNA service");
	}
}
 
开发者ID:popeen,项目名称:Popeens-DSub,代码行数:78,代码来源:DLNARouteProvider.java

示例3: listRootsInternal

import org.fourthline.cling.registry.RegistryListener; //导入依赖的package包/类
@Override
protected void listRootsInternal(Uri uri, IBinder binder, Bundle args) {
    Observable.using(
            mConnectionFactory,
            new Func1<UpnpServiceServiceConnection, Observable<List<org.opensilk.music.model.Container>>>() {
                @Override
                public Observable<List<org.opensilk.music.model.Container>> call(
                        final UpnpServiceServiceConnection upnpServiceServiceConnection) {
                    final AndroidUpnpService service = upnpServiceServiceConnection.getService();
                    return Observable.create(new Observable.OnSubscribe<List<org.opensilk.music.model.Container>>() {
                        @Override
                        public void call(final Subscriber<? super List<org.opensilk.music.model.Container>> subscriber) {
                            //first send all the devices we know about
                            List<org.opensilk.music.model.Container> devices = new ArrayList<>();
                            for (RemoteDevice rd : service.getRegistry().getRemoteDevices()) {
                                if (rd.findService(sCDServiceType) != null) {
                                    devices.add(ModelUtil.parseDevice(mAuthority, rd));
                                }
                            }
                            if (!devices.isEmpty() && !subscriber.isUnsubscribed()) {
                                subscriber.onNext(devices);
                            }
                            if (subscriber.isUnsubscribed()) {
                                return;
                            }
                            final RegistryListener listener = new DefaultRegistryListener() {
                                @Override
                                public void remoteDeviceAdded(Registry registry, RemoteDevice device) {
                                    if (device.findService(sCDServiceType) != null) {
                                        Folder f = ModelUtil.parseDevice(mAuthority, device);
                                        if (!subscriber.isUnsubscribed()) {
                                            subscriber.onNext(Collections.singletonList(
                                                    (org.opensilk.music.model.Container) f));
                                        }
                                    }
                                }
                            };
                            //make sure we remove our listener
                            subscriber.add(Subscriptions.create(new Action0() {
                                @Override
                                @DebugLog
                                public void call() {
                                    service.getRegistry().removeListener(listener);
                                }
                            }));
                            //post new devices as they come in
                            service.getRegistry().addListener(listener);
                            service.getControlPoint().search(
                                    new UDAServiceTypeHeader(sCDServiceType));
                        }
                    });
                }
            },
            mConnectionCloseAction
    ).subscribeOn(Schedulers.computation())
            .subscribe(new BundleableSubscriber<org.opensilk.music.model.Container>(binder));
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:58,代码来源:UpnpCDProvider.java


注:本文中的org.fourthline.cling.registry.RegistryListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。