本文整理匯總了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();
}