Search in sources :

Example 1 with CapabilitiesOverall

use of com.nextcloud.talk.models.json.capabilities.CapabilitiesOverall in project talk-android by nextcloud.

the class CapabilitiesJob method onRunJob.

@NonNull
@Override
protected Result onRunJob(Params params) {
    NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
    long internalUserId = getParams().getExtras().getLong(BundleKeys.KEY_INTERNAL_USER_ID, -1);
    UserEntity userEntity;
    List userEntityObjectList = new ArrayList();
    if (internalUserId == -1 || (userEntity = userUtils.getUserWithInternalId(internalUserId)) == null) {
        userEntityObjectList = userUtils.getUsers();
    } else {
        userEntityObjectList.add(userEntity);
    }
    for (Object userEntityObject : userEntityObjectList) {
        UserEntity internalUserEntity = (UserEntity) userEntityObject;
        ncApi = retrofit.newBuilder().client(okHttpClient.newBuilder().cookieJar(new JavaNetCookieJar(new java.net.CookieManager())).build()).build().create(NcApi.class);
        ncApi.getCapabilities(ApiUtils.getCredentials(internalUserEntity.getUsername(), internalUserEntity.getToken()), ApiUtils.getUrlForCapabilities(internalUserEntity.getBaseUrl())).subscribeOn(Schedulers.newThread()).subscribe(new Observer<CapabilitiesOverall>() {

            @Override
            public void onSubscribe(Disposable d) {
            }

            @Override
            public void onNext(CapabilitiesOverall capabilitiesOverall) {
                updateUser(capabilitiesOverall, internalUserEntity);
            }

            @Override
            public void onError(Throwable e) {
            }

            @Override
            public void onComplete() {
            }
        });
    }
    return Result.SUCCESS;
}
Also used : JavaNetCookieJar(okhttp3.JavaNetCookieJar) Disposable(io.reactivex.disposables.Disposable) ArrayList(java.util.ArrayList) UserEntity(com.nextcloud.talk.models.database.UserEntity) CapabilitiesOverall(com.nextcloud.talk.models.json.capabilities.CapabilitiesOverall) ArrayList(java.util.ArrayList) List(java.util.List) NcApi(com.nextcloud.talk.api.NcApi) NonNull(android.support.annotation.NonNull)

Aggregations

NonNull (android.support.annotation.NonNull)1 NcApi (com.nextcloud.talk.api.NcApi)1 UserEntity (com.nextcloud.talk.models.database.UserEntity)1 CapabilitiesOverall (com.nextcloud.talk.models.json.capabilities.CapabilitiesOverall)1 Disposable (io.reactivex.disposables.Disposable)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 JavaNetCookieJar (okhttp3.JavaNetCookieJar)1