當前位置: 首頁>>代碼示例>>Java>>正文


Java FlowableEmitter.onNext方法代碼示例

本文整理匯總了Java中io.reactivex.FlowableEmitter.onNext方法的典型用法代碼示例。如果您正苦於以下問題:Java FlowableEmitter.onNext方法的具體用法?Java FlowableEmitter.onNext怎麽用?Java FlowableEmitter.onNext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.reactivex.FlowableEmitter的用法示例。


在下文中一共展示了FlowableEmitter.onNext方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: SimpleRemoteSourceMapper

import io.reactivex.FlowableEmitter; //導入方法依賴的package包/類
public SimpleRemoteSourceMapper(FlowableEmitter<Resource<T>> emitter) {
    emitter.onNext(Resource.loading(null));
    // since realm instance was created on Main Thread, so if we need to touch on realm database after calling
    // api (such as save response data to local database, we must make request on main thread
    // by setting shouldUpdateUi params = true
    Disposable disposable = RestHelper.makeRequest(getRemote(), true, response -> {
        Log.d(TAG, "SimpleRemoteSourceMapper: call API success!");
        saveCallResult(response);
        emitter.onNext(Resource.success(response));
    }, errorEntity -> {
        Log.d(TAG, "SimpleRemoteSourceMapper: call API error: " + errorEntity.getMessage());
        emitter.onNext(Resource.error(errorEntity.getMessage(), null));
    });

    // set emitter disposable to ensure that when it is going to be disposed, our api request should be disposed as well
    emitter.setDisposable(disposable);
}
 
開發者ID:duyp,項目名稱:mvvm-template,代碼行數:18,代碼來源:SimpleRemoteSourceMapper.java

示例2: ListDataNetworkBounceResource

import io.reactivex.FlowableEmitter; //導入方法依賴的package包/類
public ListDataNetworkBounceResource(FlowableEmitter<Resource<LocalType>> emitter) {
    emitter.onNext(Resource.success(getLocal()));

    emitter.onNext(Resource.loading(null));

    // since realm instance was created on Main Thread, so if we need to touch on realm database after calling
    // api (such as save response data to local database, we must make request on main thread
    // by setting shouldUpdateUi params = true
    Disposable disposable = RestHelper.makeRequest(getRemote(), true, response -> {
        Single.just(response)
                .map(mapper())
                .subscribe(localData -> {
                    Log.d(TAG, "SimpleRemoteSourceMapper: call API success!");
                    saveCallResult(localData);
                    emitter.onNext(Resource.success(localData));
                });
    }, errorEntity -> {
        Log.d(TAG, "SimpleRemoteSourceMapper: call API error: " + errorEntity.getMessage());
        emitter.onNext(Resource.error(errorEntity.getMessage(), null));
    });

    // set emitter disposable to ensure that when it is going to be disposed, our api request should be disposed as well
    emitter.setDisposable(disposable);
}
 
開發者ID:duyp,項目名稱:mvvm-template,代碼行數:25,代碼來源:ListDataNetworkBounceResource.java

示例3: initializeSensorEventListenerFor

import io.reactivex.FlowableEmitter; //導入方法依賴的package包/類
private SensorEventListener initializeSensorEventListenerFor(final FlowableEmitter<SensorRecord> subscriber) {
    return new SensorEventListener() {

        @Override
        public void onSensorChanged(SensorEvent event) {
            subscriber.onNext(createSensorRecordFrom(event));
        }

        @Override
        public void onAccuracyChanged(Sensor sensor, int accuracy) {}
    };
}
 
開發者ID:ubikgs,項目名稱:AndroidSensors,代碼行數:13,代碼來源:IMUSensorGatherer.java

示例4: defineBroadcastReceiverFor

import io.reactivex.FlowableEmitter; //導入方法依賴的package包/類
private BroadcastReceiver defineBroadcastReceiverFor(final FlowableEmitter<SensorRecord> subscriber){
    return new BroadcastReceiver() {
        Timer timer = new Timer();
        long prevCallTime = new Date().getTime();

        @Override
        public void onReceive(Context context, Intent intent) {
            long actualTime = new Date().getTime();
            long delay = calculateDiffDelay(prevCallTime, actualTime);
            prevCallTime = actualTime;

            subscriber.onNext(new WifiMeasurementsRecord(wifiManager.getScanResults()));

            if (delay > 0)
                timer.schedule(createScanTask(), delay);
            else
                createScanTask().run();
        }
    };
}
 
開發者ID:ubikgs,項目名稱:AndroidSensors,代碼行數:21,代碼來源:WifiMeasurementsGatherer.java

示例5: subscribe

import io.reactivex.FlowableEmitter; //導入方法依賴的package包/類
@Override
public void subscribe(FlowableEmitter<T> e) throws Exception {
	try {
		Response response = call.execute();

		if (!e.isCancelled()) {
			if (response.isSuccessful()) {
				e.onNext(rxEasyConverter.convert(response.body().string()));
			} else {
				e.onError(new Throwable("response is unsuccessful"));
			}
		}
	} catch (Throwable t) {
		if (!e.isCancelled()) {
			e.onError(t);
		}
	} finally {
		e.onComplete();
	}
}
 
開發者ID:LaurenceYang,項目名稱:EasyHttp,代碼行數:21,代碼來源:RxEasyHttpManager.java

示例6: recvFile

import io.reactivex.FlowableEmitter; //導入方法依賴的package包/類
/**
 * 下載文件
 *
 * @param emitter
 * @param response
 * @param file
 * @throws Exception
 */
private void recvFile(FlowableEmitter emitter, Response response, File file) throws Exception {
    long fileSize = response.body().contentLength();
    InputStream is =
            response.body().byteStream();

    float preProgress = 0;
    float progress = 0;
    FileOutputStream fos = new FileOutputStream(file);
    int pullLength = 0;
    byte[] b = new byte[1024];
    int len;
    while ((len = is.read(b)) != -1) {
        fos.write(b, 0, len);
        pullLength += len;
        progress = (float) (pullLength * 100 / fileSize);
        if (preProgress != progress) {
            emitter.onNext(progress);
        }
        preProgress = progress;
    }
    fos.flush();
    fos.close();
    is.close();
}
 
開發者ID:xiaoxige,項目名稱:AutoNet,代碼行數:33,代碼來源:AutoNetRepoImpl.java

示例7: onGoogleApiClientReady

import io.reactivex.FlowableEmitter; //導入方法依賴的package包/類
@Override
protected void onGoogleApiClientReady(GoogleApiClient apiClient, final FlowableEmitter<Location> emitter) {
    locationListener = new LocationListener() {
        @Override
        public void onLocationChanged(Location value) {
            emitter.onNext(value);
        }
    };

    //noinspection MissingPermission
    setupLocationPendingResult(
            LocationServices.FusedLocationApi.requestLocationUpdates(apiClient, locationRequest, locationListener, looper),
            new StatusErrorResultCallBack(emitter)
    );
}
 
開發者ID:TechIsFun,項目名稱:RxJava2-weather-example,代碼行數:16,代碼來源:LocationUpdatesFlowableOnSubscribe.java

示例8: initializeScanCallbackFor

import io.reactivex.FlowableEmitter; //導入方法依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private ScanCallback initializeScanCallbackFor(final FlowableEmitter<SensorRecord> subscriber){
    return new ScanCallback() {
        @Override
        public void onBatchScanResults(List<ScanResult> results) {
            subscriber.onNext(new BLEMeasurementsRecord(results));
        }
    };
}
 
開發者ID:ubikgs,項目名稱:AndroidSensors,代碼行數:10,代碼來源:BLEMeasurementsGatherer.java

示例9: initializeGnssMeasurementsCallbackFor

import io.reactivex.FlowableEmitter; //導入方法依賴的package包/類
@RequiresApi(Build.VERSION_CODES.N)
private GnssMeasurementsEvent.Callback initializeGnssMeasurementsCallbackFor(final FlowableEmitter<SensorRecord> subscriber) {
    return new GnssMeasurementsEvent.Callback() {
        @Override
        public void onGnssMeasurementsReceived(GnssMeasurementsEvent event) {
            subscriber.onNext(new RawGPSMeasurementsRecord(event));
        }
    };
}
 
開發者ID:ubikgs,項目名稱:AndroidSensors,代碼行數:10,代碼來源:RawGPSMeasurementsGatherer.java

示例10: initializeGnssStatusCallbackFor

import io.reactivex.FlowableEmitter; //導入方法依賴的package包/類
@RequiresApi(Build.VERSION_CODES.N)
private GnssStatus.Callback initializeGnssStatusCallbackFor(final FlowableEmitter<SensorRecord> subscriber) {
    return new GnssStatus.Callback() {
        @Override
        public void onSatelliteStatusChanged(GnssStatus status) {
            subscriber.onNext(new RawGPSStatusRecord(status));
        }
    };
}
 
開發者ID:ubikgs,項目名稱:AndroidSensors,代碼行數:10,代碼來源:RawGPSStatusGatherer.java

示例11: initializeGnssNavigationCallbackFor

import io.reactivex.FlowableEmitter; //導入方法依賴的package包/類
@RequiresApi(Build.VERSION_CODES.N)
private GnssNavigationMessage.Callback initializeGnssNavigationCallbackFor(final FlowableEmitter<SensorRecord> subscriber) {
    return new GnssNavigationMessage.Callback() {
        @Override
        public void onGnssNavigationMessageReceived(GnssNavigationMessage event) {
            subscriber.onNext(new RawGPSNavigationRecord(event));
        }
    };
}
 
開發者ID:ubikgs,項目名稱:AndroidSensors,代碼行數:10,代碼來源:RawGPSNavigationGatherer.java

示例12: onGoogleApiClientReady

import io.reactivex.FlowableEmitter; //導入方法依賴的package包/類
@Override
protected void onGoogleApiClientReady(GoogleApiClient apiClient, FlowableEmitter<GoogleApiClient> emitter) {
    emitter.onNext(apiClient);
}
 
開發者ID:florent37,項目名稱:RxGps,代碼行數:5,代碼來源:GoogleApiClientFlowable.java

示例13: walk

import io.reactivex.FlowableEmitter; //導入方法依賴的package包/類
/**
 * Walk the directory tree.
 *
 * @param path the starting path
 * @param depth offset, where 1 == data directory, 2 == zoom directory, 3 == row, 4 == column
 * @param subscriber to provide feedback and terminate according to
 */
private static void walk(String path, int depth, FlowableEmitter<File> subscriber) {

  final File root = new File(path);

  File[] list;
  switch (depth) {
    case 1:
    case 2:
      list = root.listFiles(File::isDirectory);
      break;
    case 3:
      list = root.listFiles(file -> file.isFile() && PATTERN.matcher(file.toString()).matches());
      break;
    case 4:
      // consider removing out of walk
      list = getSingleMatchOrEmpty(root);
      break;
    default:
      throw new IllegalArgumentException("unsupported depth");
  }

  if (list == null) {
    return;
  }

  for (final File f : list) {
    if (subscriber.isCancelled()) {
      return;
    }

    if (f.isDirectory()) {
      walk(f.getAbsolutePath(), depth + 1, subscriber);
    } else {
      // move close as possible - but no guarantee!
      final boolean isSubscribed = !subscriber.isCancelled();
      if (isSubscribed) {
        subscriber.onNext(f);
      }
    }
  }
}
 
開發者ID:OrdnanceSurvey,項目名稱:vt-support,代碼行數:49,代碼來源:FilesystemUtil.java


注:本文中的io.reactivex.FlowableEmitter.onNext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。