rx.android.schedulers.AndroidSchedulers Java Examples

The following examples show how to use rx.android.schedulers.AndroidSchedulers. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AuthActivity.java    From RxUploader with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_auth);
    SampleApplication
            .authorize()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(() -> {
                Timber.d("auth complete: token=%s token_secret=%s",
                        SampleApplication.getToken(), SampleApplication.getSecret());
                Toast.makeText(this, "Auth complete", Toast.LENGTH_LONG).show();
                startActivity(new Intent(this, MainActivity.class));
                finish();
            }, error -> {
                Timber.e(error, "Failed to complete auth");
                Toast.makeText(this, "Auth failed", Toast.LENGTH_LONG).show();
                finish();
            });
}
 
Example #2
Source File: ChatPresenter.java    From talk-android with MIT License 6 votes vote down vote up
public void getMoreNewPublicMessages(final String roomId, final String minId, Date minCreateTime) {
    MessageRealm.getInstance()
            .getLocalMessage(roomId, teamId, minId, minCreateTime.getTime(), 0)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Action1<List<Message>>() {
                @Override
                public void call(List<Message> messages) {
                    if (messages.isEmpty()) {
                        getMoreNewPublicMessages(roomId, minId);
                    } else {
                        callback.showMoreNewMessages(messages, true);
                    }
                }
            }, new Action1<Throwable>() {
                @Override
                public void call(Throwable throwable) {

                }
            });
}
 
Example #3
Source File: CoachAuthModel.java    From Android-Application-ZJB with Apache License 2.0 6 votes vote down vote up
/**
 * 提交教练认证申请
 *
 * @return
 */
public Observable<String> authentication() {
    //1.创建Request
    HttpGsonRequest<String> mRefreshRequest = RequestBuilder.create(String.class)
            .requestMethod(Request.Method.POST)
            .url(ApiConstant.API_COACH_AUTH)
            .put("driverLicense", mCoachCardUrl)
            .put("idCard", mIDCardUrl)
            .putHeaders("Authorization", LoginManager.getInstance().getLoginUser().getToken())
            .build();
    //2.进行数据的处理
    return gRequestPool.request(mRefreshRequest)
            .filter((resp) -> null != resp)
            .map(HttpResponse::getData)
            .observeOn(AndroidSchedulers.mainThread());
}
 
Example #4
Source File: InvitationDetailController.java    From PlayTogether with Apache License 2.0 6 votes vote down vote up
/**
 * 将邀请设置为已过期
 */
public void setExpire(Invitation invitation)
{
	mInviteBll.setExpire(invitation)
					.observeOn(AndroidSchedulers.mainThread())
					.subscribeOn(Schedulers.io())
					.subscribe(new Subscriber<Void>()
					{
						@Override
						public void onCompleted()
						{
							mActivity.setExpireSuccess();
						}

						@Override
						public void onError(Throwable e)
						{
							e.printStackTrace();
						}

						@Override
						public void onNext(Void aVoid)
						{
						}
					});
}
 
Example #5
Source File: CoachInfoModel.java    From Android-Application-ZJB with Apache License 2.0 6 votes vote down vote up
/**
 * 获取教练信息
 *
 * @return
 */
public Observable<Coach> getCoachInfo() {
    //1.创建Request
    HttpGsonRequest<Coach> mRefreshRequest = RequestBuilder.create(Coach.class)
            .requestMethod(Request.Method.GET)
            .url(ApiConstant.API_GET_COACH_INFO)
            .putHeaders("Authorization", getUser().getToken())
            .build();
    //2.进行数据的处理
    return gRequestPool.request(mRefreshRequest)
            .filter((resp) -> null != resp && null != resp.data)
            .map(HttpResponse::getData)
            .doOnNext(coach -> {
                PreferenceUtil.putString(SPConstant.KEY_COACH, GsonUtil.toJson(coach));
                LoginManager.getInstance().setCoach(coach);
                //更新占位符基本参数
                UrlParserManager.getInstance().updateBaseParams();
            })
            .observeOn(AndroidSchedulers.mainThread());
}
 
Example #6
Source File: ZhihuDomainImpl.java    From XiaoxiaZhihu with Apache License 2.0 6 votes vote down vote up
@Override
public Observable<GetStoryExtraResponse> getStoryExtraById(int id) {
    return Observable.just(new GetStoryExtraRequest(id))
            .flatMap(new Func1<GetStoryExtraRequest, Observable<GetStoryExtraResponse>>() {
                @Override
                public Observable<GetStoryExtraResponse> call(GetStoryExtraRequest request) {
                    try {
                        GetStoryExtraResponse response = zhihuApi.getStoryExtraResponse(request);
                        return Observable.just(response);
                    } catch (AppException e) {
                        return Observable.error(e);
                    }
                }
            })
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread());
}
 
Example #7
Source File: SystemNotificationShower.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@NonNull private Single<Notification> buildNewFeatureNotification(Context context, String title,
    String body, @StringRes int actionButtonString, PendingIntent pressIntentAction,
    PendingIntent onDismissAction) {

  return Single.fromCallable(() -> {
    Notification notification =
        new NotificationCompat.Builder(context).setContentIntent(pressIntentAction)
            .setSmallIcon(R.drawable.ic_stat_aptoide_notification)
            .setColor(ContextCompat.getColor(context, R.color.default_orange_gradient_end))
            .setContentTitle(title)
            .setContentText(body)
            .addAction(0, context.getResources()
                .getString(R.string.updates_notification_dismiss_button), onDismissAction)
            .addAction(0, context.getResources()
                .getString(actionButtonString), pressIntentAction)
            .build();
    notification.flags =
        android.app.Notification.DEFAULT_LIGHTS | android.app.Notification.FLAG_AUTO_CANCEL;
    return notification;
  })
      .subscribeOn(Schedulers.computation())
      .observeOn(AndroidSchedulers.mainThread());
}
 
Example #8
Source File: HttpTransformer.java    From BaseProject with Apache License 2.0 6 votes vote down vote up
@Override
public Observable<T> call(Observable<R> rObservable) {
    return rObservable.flatMap(new Func1<R, Observable<T>>() {
        @Override
        public Observable<T> call(R r) {

            Log.d(TAG, r.isError() ? "HttpResult is error" : "HttpResult is right");

            if (r.isError()) {
                return Observable.error(new ApiException("网络出错"));
            } else {
                return createData(r.getResults());
            }
        }
    }).subscribeOn(Schedulers.io()).unsubscribeOn(Schedulers.io()).subscribeOn(AndroidSchedulers.mainThread()).observeOn(AndroidSchedulers.mainThread());
}
 
Example #9
Source File: NoteController.java    From nono-android with GNU General Public License v3.0 6 votes vote down vote up
public static void saveNoteZipAsync(final SaveNoteListener l){
    Observable.create(new Observable.OnSubscribe<String>() {
        @Override
        public void call(Subscriber<? super String> subscriber) {
            String zipFilePath =  NotePersistenceController.saveNoteFiles();
            subscriber.onNext(zipFilePath);
            subscriber.onCompleted();
        }
    }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
            .subscribe(
                    new Action1<String>() {
                        @Override
                        public void call(String path) {
                            l.onZipPath(path);
                        }
                    });
}
 
Example #10
Source File: HttpDownLoadManager.java    From TestChat with Apache License 2.0 6 votes vote down vote up
public void start(final DownInfo info) {
//                如果消息实体为空,或正在下载,则返回
                if (info == null || mDownInfoMap.get(info.getUrl()) != null) return;
                DownLoadSubscriber<DownInfo> downLoadSubscriber = new DownLoadSubscriber<>(info);
                mDownInfoMap.put(info.getUrl(), downLoadSubscriber);
//                HttpService service;
//                增加一个拦截器,用于获取数据的进度回调
                DownLoadInterceptor interceptor = new DownLoadInterceptor(downLoadSubscriber);
                OkHttpClient.Builder builder = new OkHttpClient.Builder();
                builder.connectTimeout(info.getConnectedTime(), TimeUnit.SECONDS).addInterceptor(interceptor);
                Retrofit retrofit = new Retrofit.Builder().
                        addConverterFactory(ScalarsConverterFactory.create()).addCallAdapterFactory(RxJavaCallAdapterFactory.create()).
                        baseUrl(CommonUtils.getBaseUrl(info.getUrl())).client(builder.build()).build();
                HttpService service = retrofit.create(HttpService.class);
                info.setHttpService(service);
                service.download("bytes=" + info.getReadLength() + "-", info.getUrl()).subscribeOn(Schedulers.io())
                        .unsubscribeOn(Schedulers.io()).retryWhen(new RetryWhenNetWorkException()).map(new Func1<ResponseBody, DownInfo>() {
                        @Override
                        public DownInfo call(ResponseBody responseBody) {
                                FileUtil.writeToCache(responseBody, info.getSavedFilePath(), info.getReadLength(), info.getTotalLength());
//                                这里进行转化
                                return info;
                        }
                }).observeOn(AndroidSchedulers.mainThread()).subscribe(downLoadSubscriber);
        }
 
Example #11
Source File: VideoDetailsActivity.java    From HeroVideo-master with Apache License 2.0 6 votes vote down vote up
@Override
public void loadData() {

    RetrofitHelper.getBiliAppAPI()
            .getVideoDetails(av)
            .compose(this.bindToLifecycle())
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(videoDetails -> {

                mVideoDetailsInfo = videoDetails.getData();
                LogUtil.test(" VideoDetails finishTask" + mVideoDetailsInfo.getTitle());
                finishTask();
            }, throwable -> {

                mFAB.setClickable(false);
                mFAB.setBackgroundTintList(ColorStateList.valueOf(
                        getResources().getColor(R.color.gray_20)));
            });
}
 
Example #12
Source File: NewsInteractor.java    From Dota2Helper with Apache License 2.0 6 votes vote down vote up
public void queryMoreNews() {
    RxCenter.INSTANCE.getCompositeSubscription(TaskIds.newsTaskId).add(AppNetWork.INSTANCE.getNewsApi().loadMoreNews(mLastNewsNid)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Action1<NewsList>() {
                @Override
                public void call(NewsList newsList) {
                    int size = newsList.getNews().size();
                    if (size > 0) {
                        mLastNewsNid = newsList.getNews().get(size - 1).getNid();
                    }
                    mCallback.onUpdateSuccessed(newsList.getNews(), true);
                }
            }, new Action1<Throwable>() {
                @Override
                public void call(Throwable throwable) {
                    mCallback.onUpdateFailed(true);
                }
            }));
}
 
Example #13
Source File: RepoListItemViewModel.java    From Anago with Apache License 2.0 6 votes vote down vote up
public void onStarClick(View view) {
    if (starred.get()) {
        unstarUseCase.run(repo.get().owner.login, repo.get().name)
                .compose(bindToLifecycle().forCompletable())
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(() -> {
                    eventBus.post(new StarEvent());
                    Snackbar.make(view, "Unstarred!", Snackbar.LENGTH_SHORT).show();
                });
    } else {
        starUseCase.run(repo.get().owner.login, repo.get().name)
                .compose(bindToLifecycle().forCompletable())
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(() -> {
                    eventBus.post(new StarEvent());
                    Snackbar.make(view, "Starred!", Snackbar.LENGTH_SHORT).show();
                });
    }
}
 
Example #14
Source File: HomeActivity.java    From talk-android with MIT License 6 votes vote down vote up
public void startNotificationWithChatActivity(final String messageType, final String _targetId) {
    final Bundle bundle = new Bundle();
    bundle.putBoolean(NOTIFICATION, true);
    if (XiaomiPushReceiver.DMS.equalsIgnoreCase(messageType)) {
        final Member member = MainApp.globalMembers.get(_targetId);
        bundle.putParcelable(ChatActivity.EXTRA_MEMBER, Parcels.wrap(member));
        TransactionUtil.goTo(this, ChatActivity.class, bundle);
    } else if (XiaomiPushReceiver.ROOM.equalsIgnoreCase(messageType)) {
        final Room room = MainApp.globalRooms.get(_targetId);
        bundle.putParcelable(ChatActivity.EXTRA_ROOM, Parcels.wrap(room));
        TransactionUtil.goTo(this, ChatActivity.class, bundle);
    } else if (XiaomiPushReceiver.STORY.equalsIgnoreCase(messageType)) {
        StoryRealm.getInstance().getSingleStory(_targetId)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<Story>() {
                    @Override
                    public void call(Story story) {
                        if (story != null) {
                            bundle.putParcelable(ChatActivity.EXTRA_STORY, Parcels.wrap(story));
                            TransactionUtil.goTo(HomeActivity.this, ChatActivity.class, bundle);
                        }
                    }
                }, new RealmErrorAction());
    }
}
 
Example #15
Source File: BookDetailPresenter.java    From BookReader with Apache License 2.0 6 votes vote down vote up
public void getBookDetail(String bookId) {
    Subscription rxSubscription = bookApi.getBookDetail(bookId).subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Observer<BookDetail>() {
                @Override
                public void onNext(BookDetail data) {
                    if (data != null && mView != null) {
                        mView.showBookDetail(data);
                    }
                }

                @Override
                public void onCompleted() {
                }

                @Override
                public void onError(Throwable e) {
                    Log.e(TAG, "onError: " + e);
                }
            });
    addSubscrebe(rxSubscription);
}
 
Example #16
Source File: BookDetailPresenter.java    From BookReader with Apache License 2.0 6 votes vote down vote up
@Override
public void getRecommendBookList(String bookId, String limit) {
    Subscription rxSubscription = bookApi.getRecommendBookList(bookId, limit).subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Observer<RecommendBookList>() {
                @Override
                public void onNext(RecommendBookList data) {
                    LogUtils.i(data.booklists);
                    List<RecommendBookList.RecommendBook> list = data.booklists;
                    if (list != null && !list.isEmpty() && mView != null) {
                        mView.showRecommendBookList(list);
                    }
                }

                @Override
                public void onCompleted() {
                }

                @Override
                public void onError(Throwable e) {
                    LogUtils.e("+++" + e.toString());
                }
            });
    addSubscrebe(rxSubscription);
}
 
Example #17
Source File: SearchPresenter.java    From talk-android with MIT License 6 votes vote down vote up
public void searchMessages(String keyword) {
    callback.showProgressBar();
    talkApi.searchMessages(BizLogic.getTeamId(), keyword, 20)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Action1<SearchResponseData>() {
                @Override
                public void call(SearchResponseData searchResponseData) {
                    callback.dismissProgressBar();
                    if (searchResponseData.messages != null) {
                        callback.onSearchFinish(searchResponseData.messages);
                    }
                }
            }, new Action1<Throwable>() {
                @Override
                public void call(Throwable throwable) {
                    callback.dismissProgressBar();
                    callback.onSearchFinish(new ArrayList<Message>());
                }
            });
}
 
Example #18
Source File: FileCategoryPresenter.java    From FileManager with Apache License 2.0 6 votes vote down vote up
@Override
public void updateMemoryInfo() {

    mCategoryManager.getAvaliableMemoryUsingObservable()
            .zipWith(mCategoryManager.getTotalMemoryUsingObservable(),
                    (avaliable, total) -> {
                        long usedMemory = total - avaliable;
                        mView.setMemoryProgress(usedMemory * 100 / total);
                        return FormatUtil.formatFileSize(usedMemory).toString() + "/" +
                                FormatUtil.formatFileSize(total).toString();
                    })
            .observeOn(Schedulers.io())
            .subscribeOn(AndroidSchedulers.mainThread())
            .subscribe(memory -> {
                mView.setMemoryText(memory);
            }, Throwable::printStackTrace);
}
 
Example #19
Source File: ChatActivity.java    From talk-android with MIT License 6 votes vote down vote up
@Override
public void showLatestMessages(List<Message> messages) {
    showMessages(messages, false);
    if (StringUtil.isNotBlank(messageToSend)) {
        sendTextMessage(messageToSend);
    }
    if (imageToSend != null) {
        Observable.from(imageToSend)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<String>() {
                    @Override
                    public void call(String s) {
                        sendImageMessage(s);
                    }
                });
    }
    checkShareData();
}
 
Example #20
Source File: CreateWebSiteModel.java    From Android-Application-ZJB with Apache License 2.0 6 votes vote down vote up
/**
 * 获取优秀的个人网站
 *
 * @return
 */
public Observable<List<WebSite>> getExcellentWebSite() {
    //1.创建Request
    HttpGsonRequest<List<WebSite>> mRefreshRequest = RequestBuilder.<List<WebSite>>create()
            .requestMethod(Request.Method.POST)
            .url(ApiConstant.API_EXCELLENT_WEBSITE)
            .parser(new WebSiteParser())
            .build();
    //2.进行数据的处理
    return gRequestPool.request(mRefreshRequest)
            .filter((resp) -> null != resp && null != resp.data)
            .map(HttpResponse::getData)
            .filter(ValidateUtil::isValidate)
            .doOnNext(data -> mWebSites = data)
            .observeOn(AndroidSchedulers.mainThread());
}
 
Example #21
Source File: TryWhenFragment.java    From AndroidRxJavaSample with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    super.onClick(v);
    switch (v.getId()) {
        case R.id.btn_operator:
            tvLogs.setText("");
            userApi.getUserInfoNoToken()
                    .retryWhen(new RetryWithDelay(3, 3000))
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribeOn(Schedulers.io())
                    .subscribe(new Action1<Response>() {
                        @Override
                        public void call(Response response) {
                            String content = new String(((TypedByteArray) response.getBody()).getBytes());
                            printLog(tvLogs, "", content);
                        }
                    }, new Action1<Throwable>() {
                        @Override
                        public void call(Throwable throwable) {
                            throwable.printStackTrace();
                        }
                    });
    }
}
 
Example #22
Source File: CategoryFragment.java    From FlipGank with Apache License 2.0 6 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    unbinder = ButterKnife.bind(this, view);

    if (mCategoryAdapter == null) {
        mCategoryAdapter = new CategoryAdapter();
    }
    recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
    recyclerView.setAdapter(mCategoryAdapter);
    recyclerView.addItemDecoration(new GridItemDecoration(getContext()));

    DataManager.getInstance(getContext())
            .loadCategory()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(onLoad, onError);
}
 
Example #23
Source File: BookReviewDetailPresenter.java    From fangzhuishushenqi with Apache License 2.0 6 votes vote down vote up
@Override
public void getBookReviewDetail(String id) {
    Subscription rxSubscription = bookApi.getBookReviewDetail(id).subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Observer<BookReview>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    LogUtils.e("getBookReviewDetail:" + e.toString());
                }

                @Override
                public void onNext(BookReview data) {
                    mView.showBookReviewDetail(data);
                }
            });
    addSubscrebe(rxSubscription);
}
 
Example #24
Source File: RxUtil.java    From fangzhuishushenqi with Apache License 2.0 6 votes vote down vote up
public static <T> Observable.Transformer<T, T> rxCacheBeanHelper(final String key) {
    return new Observable.Transformer<T, T>() {
        @Override
        public Observable<T> call(Observable<T> observable) {
            return observable
                    .subscribeOn(Schedulers.io())//指定doOnNext执行线程是新线程
                    .doOnNext(new Action1<T>() {
                        @Override
                        public void call(final T data) {
                            Schedulers.io().createWorker().schedule(new Action0() {
                                @Override
                                public void call() {
                                    LogUtils.d("get data from network finish ,start cache...");
                                    ACache.get(ReaderApplication.getsInstance())
                                            .put(key, new Gson().toJson(data, data.getClass()));
                                    LogUtils.d("cache finish");
                                }
                            });
                        }
                    })
                    .observeOn(AndroidSchedulers.mainThread());
        }
    };
}
 
Example #25
Source File: ChatPresenter.java    From talk-android with MIT License 6 votes vote down vote up
private void getMoreOldPrivateMessages(final String userId, String maxId) {
    msgModel.getPreviousUserMessages(userId, teamId, maxId, 30)
            .map(new UnreadFunc(userId))
            .doOnNext(saveMsgAction)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Action1<List<Message>>() {
                @Override
                public void call(List<Message> messages) {
                    Collections.reverse(messages);
                    callback.showMoreOldMessages(messages, false);
                }
            }, new Action1<Throwable>() {
                @Override
                public void call(Throwable throwable) {

                }
            });
}
 
Example #26
Source File: OkhttpActivity.java    From android-advanced-light with MIT License 6 votes vote down vote up
private void postAsynHttp(String size) {
    getObservable(size).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<String>() {
        @Override
        public void onCompleted() {
            Log.d(TAG, "onCompleted");
        }
        @Override
        public void onError(Throwable e) {
            Log.d(TAG, e.getMessage());
        }
        @Override
        public void onNext(String s) {
            Log.d(TAG, s);
            Toast.makeText(getApplicationContext(), "请求成功", Toast.LENGTH_SHORT).show();
        }
    });
}
 
Example #27
Source File: EstablishmentInteractorImpl.java    From Saude-no-Mapa with MIT License 6 votes vote down vote up
@Override
public void requestUserUf(Double lat, Double lng, StringListener listener) {
    ReactiveLocationProvider locationProvider = new ReactiveLocationProvider(mContext);
    locationProvider.getReverseGeocodeObservable(lat, lng, 1)
            .retry(10)
            .subscribeOn(Schedulers.computation())
            .observeOn(AndroidSchedulers.mainThread())
            .onErrorReturn(throwable1 -> new ArrayList<>())
            .subscribe(addresses -> {
                if (addresses != null && !addresses.isEmpty()) {
                    String addressLine = addresses.get(0).getAddressLine(1);
                    if (addressLine.contains("-")) {
                        listener.onNext(getUfFromAddress(addressLine));
                    } else {
                        listener.onNext(addressLine);
                    }
                }
            });
}
 
Example #28
Source File: BookReadPresenter.java    From fangzhuishushenqi with Apache License 2.0 6 votes vote down vote up
@Override
public void getBookSource(String viewSummary, String book) {
    Subscription rxSubscription = bookApi.getBookSource(viewSummary, book).subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Observer<List<BookSource>>() {
                @Override
                public void onNext(List<BookSource> data) {
                    if (data != null && mView != null) {
                        mView.showBookSource(data);
                    }
                }

                @Override
                public void onCompleted() {
                }

                @Override
                public void onError(Throwable e) {
                    LogUtils.e("onError: " + e);
                }
            });
    addSubscrebe(rxSubscription);
}
 
Example #29
Source File: MentionedMessagePresenter.java    From talk-android with MIT License 6 votes vote down vote up
public void getMessageMentionedMe(String teamId, String maxId) {
    view.showProgressBar();
    Observable<List<Message>> messageStream =
            maxId == null ? talkApi.getMentionedMessages(teamId, 30)
                    : talkApi.getMoreMentionedMessages(teamId, maxId, 30);
    messageStream.observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Action1<List<Message>>() {
                @Override
                public void call(List<Message> messages) {
                    view.dismissProgressBar();
                    view.showMessages(messages);
                }
            }, new Action1<Throwable>() {
                @Override
                public void call(Throwable e) {
                    view.dismissProgressBar();
                    Logger.e(TAG, "get mentioned msg error", e);
                }
            });
}
 
Example #30
Source File: Oauth2Activity.java    From talk-android with MIT License 6 votes vote down vote up
private void checkIsNew(User user) {
    if (user.wasNew()) {
        this.user = user;
        MainApp.IMAGE_LOADER.displayImage(user.getAvatarUrl(), dialogAvatar,
                ImageLoaderConfig.AVATAR_OPTIONS);
        TalkClient.getInstance().getTalkApi().getStrikerToken().observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<StrikerTokenResponseData>() {
                    @Override
                    public void call(StrikerTokenResponseData responseData) {
                        if (responseData != null) {
                            MainApp.PREF_UTIL.putString(Constant.STRIKER_TOKEN, responseData.getToken());
                            userDialog.show();
                        }
                    }
                }, new Action1<Throwable>() {
                    @Override
                    public void call(Throwable throwable) {
                        Logger.e("Oauth2Activity", "fail to get file auth key", throwable);
                    }
                });
    } else {
        TransactionUtil.goTo(this, ChooseTeamActivity.class, true);
    }
}