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


Java ObservableEmitter.onComplete方法代碼示例

本文整理匯總了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();
}
 
開發者ID:quangctkm9207,項目名稱:rxjava-family,代碼行數:18,代碼來源:RxLifecycleActivity.java

示例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();
    }
}
 
開發者ID:xiaoyaoyou1212,項目名稱:XSnow,代碼行數:20,代碼來源:ApiCache.java

示例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();
    }
}
 
開發者ID:zhou-you,項目名稱:RxEasyHttp,代碼行數:22,代碼來源:RxCache.java

示例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();
    }
}
 
開發者ID:riteshakya037,項目名稱:Subs,代碼行數:19,代碼來源:DatabaseCompletionListener.java

示例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();
    }
}
 
開發者ID:qiaodashaoye,項目名稱:SuperHttp,代碼行數:20,代碼來源:ApiCache.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:RxDownload.java

示例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();
}
 
開發者ID:quangctkm9207,項目名稱:rxjava-family,代碼行數:12,代碼來源:RxAndroidActivity.java

示例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();
    }
}
 
開發者ID:changjiashuai,項目名稱:RxJava2-Android-Sample,代碼行數:9,代碼來源:SimpleExampleActivity.java

示例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();
}
 
開發者ID:quangctkm9207,項目名稱:rxjava-family,代碼行數:7,代碼來源:CreateFragment.java

示例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();
}
 
開發者ID:broakenmedia,項目名稱:MultiContactPicker,代碼行數:68,代碼來源:RxContacts.java


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