当前位置: 首页>>代码示例>>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;未经允许,请勿转载。