本文整理汇总了Java中io.reactivex.ObservableEmitter.onComplete方法的典型用法代码示例。如果您正苦于以下问题:Java ObservableEmitter.onComplete方法的具体用法?Java ObservableEmitter.onComplete怎么用?Java ObservableEmitter.onComplete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.ObservableEmitter
的用法示例。
在下文中一共展示了ObservableEmitter.onComplete方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override public void subscribe(@NonNull ObservableEmitter<Integer> emitter) throws Exception {
// Suppose we have a long task which is simulated by using Thread.sleep().
// We need to run it in the background to avoid blocking the main thread.
emitter.onNext(1);
Thread.sleep(1000);
emitter.onNext(2);
Thread.sleep(1000);
emitter.onNext(3);
Thread.sleep(1000);
emitter.onNext(4);
Thread.sleep(1000);
emitter.onNext(5);
Thread.sleep(1000);
emitter.onNext(6);
Thread.sleep(1000);
emitter.onComplete();
}
示例2: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(ObservableEmitter<T> subscriber) throws Exception {
try {
T data = execute();
if (!subscriber.isDisposed() && data != null) {
subscriber.onNext(data);
}
} catch (Throwable e) {
ViseLog.e(e);
Exceptions.throwIfFatal(e);
if (!subscriber.isDisposed()) {
subscriber.onError(e);
}
return;
}
if (!subscriber.isDisposed()) {
subscriber.onComplete();
}
}
示例3: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(@NonNull ObservableEmitter<T> subscriber) throws Exception {
try {
T data = execute();
if (!subscriber.isDisposed()) {
subscriber.onNext(data);
}
} catch (Throwable e) {
HttpLog.e(e.getMessage());
if (!subscriber.isDisposed()) {
subscriber.onError(e);
}
Exceptions.throwIfFatal(e);
//RxJavaPlugins.onError(e);
return;
}
if (!subscriber.isDisposed()) {
subscriber.onComplete();
}
}
示例4: updateChildren
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
public <T> void updateChildren(DatabaseReference databaseReference,
@NonNull final ObservableEmitter<T> emitter, Map<String, Object> childUpdates) {
if (isNetworkAvailable) {
databaseReference.updateChildren(childUpdates, (databaseError, databaseReference1) -> {
if (emitter.isDisposed()) {
return;
}
if (databaseError == null) {
emitter.onComplete();
} else {
emitter.onError(new Throwable(databaseError.getMessage()));
}
});
} else {
databaseReference.updateChildren(childUpdates);
emitter.onComplete();
}
}
示例5: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(ObservableEmitter<T> subscriber) throws Exception {
try {
T data = execute();
if (!subscriber.isDisposed() && data != null) {
subscriber.onNext(data);
}
} catch (Throwable e) {
Exceptions.throwIfFatal(e);
if (!subscriber.isDisposed()) {
subscriber.onError(e);
}
return;
}
if (!subscriber.isDisposed()) {
subscriber.onComplete();
}
}
示例6: doCall
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
private void doCall(GeneralObservableCallback callback, ObservableEmitter<Object> emitter) {
if (callback != null) {
try {
callback.call();
} catch (Exception e) {
emitter.onError(e);
}
}
emitter.onNext(object);
emitter.onComplete();
}
示例7: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override public void subscribe(@NonNull ObservableEmitter<Integer> emitter) throws Exception {
// Suppose we have a long task which is simulated by using Thread.sleep().
// We need to run it in the background to avoid blocking the main thread.
emitter.onNext(1);
Thread.sleep(1000);
emitter.onNext(2);
Thread.sleep(1000);
emitter.onNext(3);
Thread.sleep(1000);
emitter.onComplete();
}
示例8: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(ObservableEmitter<String> e) throws Exception {
if (getStrFromMemory() != null) {
e.onNext(getStrFromMemory());
} else {
e.onComplete();
}
}
示例9: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override public void subscribe(@NonNull ObservableEmitter<Integer> emitter) throws Exception {
emitter.onNext(1);
emitter.onNext(2);
emitter.onNext(3);
emitter.onComplete();
}
示例10: fetch
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
private void fetch (ObservableEmitter emitter) {
LongSparseArray<Contact> contacts = new LongSparseArray<>();
Cursor cursor = createCursor();
cursor.moveToFirst();
int idColumnIndex = cursor.getColumnIndex(ContactsContract.Contacts._ID);
int inVisibleGroupColumnIndex = cursor.getColumnIndex(ContactsContract.Contacts.IN_VISIBLE_GROUP);
int displayNamePrimaryColumnIndex = cursor.getColumnIndex(DISPLAY_NAME);
int starredColumnIndex = cursor.getColumnIndex(ContactsContract.Contacts.STARRED);
int photoColumnIndex = cursor.getColumnIndex(ContactsContract.Contacts.PHOTO_URI);
int thumbnailColumnIndex = cursor.getColumnIndex(ContactsContract.Contacts.PHOTO_THUMBNAIL_URI);
while (!cursor.isAfterLast()) {
long id = cursor.getLong(idColumnIndex);
Contact contact = contacts.get(id, null);
if (contact == null) {
contact = new Contact(id);
ColumnMapper.mapInVisibleGroup(cursor, contact, inVisibleGroupColumnIndex);
ColumnMapper.mapDisplayName(cursor, contact, displayNamePrimaryColumnIndex);
ColumnMapper.mapStarred(cursor, contact, starredColumnIndex);
ColumnMapper.mapPhoto(cursor, contact, photoColumnIndex);
ColumnMapper.mapThumbnail(cursor, contact, thumbnailColumnIndex);
Cursor emailCursor = mResolver.query(EMAIL_CONTENT_URI, EMAIL_PROJECTION,
ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = ?", new String[]{String.valueOf(id)}, null);
if(emailCursor != null) {
emailCursor.moveToFirst();
int emailDataColumnIndex = emailCursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA);
while (!emailCursor.isAfterLast()) {
ColumnMapper.mapEmail(emailCursor, contact, emailDataColumnIndex);
emailCursor.moveToNext();
}
emailCursor.close();
}
int hasPhoneNumber = Integer.parseInt(cursor.getString(cursor.getColumnIndex(HAS_PHONE_NUMBER)));
if (hasPhoneNumber > 0) {
Cursor phoneCursor = mResolver.query(PHONE_CONTENT_URI, NUMBER_PROJECTION,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[]{String.valueOf(id)}, null);
if (phoneCursor != null) {
phoneCursor.moveToFirst();
int phoneNumberColumnIndex = phoneCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
while (!phoneCursor.isAfterLast()) {
ColumnMapper.mapPhoneNumber(phoneCursor, contact, phoneNumberColumnIndex);
phoneCursor.moveToNext();
}
phoneCursor.close();
}
}
contacts.put(id, contact);
}
cursor.moveToNext();
//noinspection unchecked
emitter.onNext(contact);
}
cursor.close();
/*for (int i = 0; i < contacts.size(); i++) {
//noinspection unchecked
emitter.onNext(contacts.valueAt(i));
}*/
emitter.onComplete();
}