Search in sources :

Example 1 with User

use of chat.rocket.core.models.User in project Rocket.Chat.Android by RocketChat.

the class RoomPresenter method getUserPreferences.

private void getUserPreferences() {
    final Disposable subscription = userRepository.getCurrent().filter(Optional::isPresent).map(Optional::get).filter(user -> user.getSettings() != null).map(User::getSettings).filter(settings -> settings.getPreferences() != null).map(Settings::getPreferences).distinctUntilChanged().subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(preferences -> {
        if (preferences.isAutoImageLoad()) {
            view.autoloadImages();
        } else {
            view.manualLoadImages();
        }
    }, Logger::report);
    addSubscription(subscription);
}
Also used : Disposable(io.reactivex.disposables.Disposable) User(chat.rocket.core.models.User) Settings(chat.rocket.core.models.Settings) Optional(com.fernandocejas.arrow.optional.Optional) UserRepository(chat.rocket.core.repositories.UserRepository) RoomRepository(chat.rocket.core.repositories.RoomRepository) Logger(chat.rocket.android.helper.Logger) NonNull(android.support.annotation.NonNull) Single(io.reactivex.Single) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) LogIfError(chat.rocket.android.helper.LogIfError) MessageInteractor(chat.rocket.core.interactors.MessageInteractor) Message(chat.rocket.core.models.Message) MethodCallHelper(chat.rocket.android.api.MethodCallHelper) Disposable(io.reactivex.disposables.Disposable) ConnectivityManagerApi(chat.rocket.android.service.ConnectivityManagerApi) Pair(android.support.v4.util.Pair) Room(chat.rocket.core.models.Room) SyncState(chat.rocket.core.SyncState) Nullable(android.support.annotation.Nullable) BackgroundLooper(chat.rocket.android.BackgroundLooper) BasePresenter(chat.rocket.android.shared.BasePresenter) AbsoluteUrlHelper(chat.rocket.android.helper.AbsoluteUrlHelper) User(chat.rocket.core.models.User) Optional(com.fernandocejas.arrow.optional.Optional) Logger(chat.rocket.android.helper.Logger) Settings(chat.rocket.core.models.Settings)

Example 2 with User

use of chat.rocket.core.models.User in project Rocket.Chat.Android by RocketChat.

the class RoomPresenter method resendMessage.

@Override
public void resendMessage(Message message) {
    final Disposable subscription = getCurrentUser().flatMap(user -> messageInteractor.resend(message, user)).subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe();
    addSubscription(subscription);
}
Also used : Disposable(io.reactivex.disposables.Disposable) User(chat.rocket.core.models.User) Settings(chat.rocket.core.models.Settings) Optional(com.fernandocejas.arrow.optional.Optional) UserRepository(chat.rocket.core.repositories.UserRepository) RoomRepository(chat.rocket.core.repositories.RoomRepository) Logger(chat.rocket.android.helper.Logger) NonNull(android.support.annotation.NonNull) Single(io.reactivex.Single) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) LogIfError(chat.rocket.android.helper.LogIfError) MessageInteractor(chat.rocket.core.interactors.MessageInteractor) Message(chat.rocket.core.models.Message) MethodCallHelper(chat.rocket.android.api.MethodCallHelper) Disposable(io.reactivex.disposables.Disposable) ConnectivityManagerApi(chat.rocket.android.service.ConnectivityManagerApi) Pair(android.support.v4.util.Pair) Room(chat.rocket.core.models.Room) SyncState(chat.rocket.core.SyncState) Nullable(android.support.annotation.Nullable) BackgroundLooper(chat.rocket.android.BackgroundLooper) BasePresenter(chat.rocket.android.shared.BasePresenter) AbsoluteUrlHelper(chat.rocket.android.helper.AbsoluteUrlHelper)

Example 3 with User

use of chat.rocket.core.models.User in project Rocket.Chat.Android by RocketChat.

the class RoomPresenter method updateMessage.

@Override
public void updateMessage(Message message, String content) {
    final Disposable subscription = getCurrentUser().flatMap(user -> messageInteractor.update(message, user, content)).subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(success -> {
        if (success) {
            view.onMessageSendSuccessfully();
        }
    }, Logger::report);
    addSubscription(subscription);
}
Also used : Disposable(io.reactivex.disposables.Disposable) User(chat.rocket.core.models.User) Settings(chat.rocket.core.models.Settings) Optional(com.fernandocejas.arrow.optional.Optional) UserRepository(chat.rocket.core.repositories.UserRepository) RoomRepository(chat.rocket.core.repositories.RoomRepository) Logger(chat.rocket.android.helper.Logger) NonNull(android.support.annotation.NonNull) Single(io.reactivex.Single) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) LogIfError(chat.rocket.android.helper.LogIfError) MessageInteractor(chat.rocket.core.interactors.MessageInteractor) Message(chat.rocket.core.models.Message) MethodCallHelper(chat.rocket.android.api.MethodCallHelper) Disposable(io.reactivex.disposables.Disposable) ConnectivityManagerApi(chat.rocket.android.service.ConnectivityManagerApi) Pair(android.support.v4.util.Pair) Room(chat.rocket.core.models.Room) SyncState(chat.rocket.core.SyncState) Nullable(android.support.annotation.Nullable) BackgroundLooper(chat.rocket.android.BackgroundLooper) BasePresenter(chat.rocket.android.shared.BasePresenter) AbsoluteUrlHelper(chat.rocket.android.helper.AbsoluteUrlHelper) Logger(chat.rocket.android.helper.Logger)

Example 4 with User

use of chat.rocket.core.models.User in project Rocket.Chat.Android by RocketChat.

the class RoomUserAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RoomUserViewHolder holder, int position) {
    String username = usernames.get(position);
    if (TextUtils.isEmpty(username)) {
        return;
    }
    RealmUser realmUser = realmHelper.executeTransactionForRead(realm -> realm.where(RealmUser.class).equalTo(RealmUser.USERNAME, username).findFirst());
    if (realmUser == null) {
        User user = User.builder().setId("some-local-is").setUsername(username).setUtcOffset(0).build();
        new UserRenderer(context, user).avatarInto(holder.avatar, absoluteUrl).usernameInto(holder.username);
    } else {
        new UserRenderer(context, realmUser.asUser()).statusColorInto(holder.status).avatarInto(holder.avatar, absoluteUrl).usernameInto(holder.username);
    }
}
Also used : User(chat.rocket.core.models.User) RealmUser(chat.rocket.persistence.realm.models.ddp.RealmUser) RealmUser(chat.rocket.persistence.realm.models.ddp.RealmUser) UserRenderer(chat.rocket.android.renderer.UserRenderer)

Aggregations

User (chat.rocket.core.models.User)4 NonNull (android.support.annotation.NonNull)3 Nullable (android.support.annotation.Nullable)3 Pair (android.support.v4.util.Pair)3 BackgroundLooper (chat.rocket.android.BackgroundLooper)3 MethodCallHelper (chat.rocket.android.api.MethodCallHelper)3 AbsoluteUrlHelper (chat.rocket.android.helper.AbsoluteUrlHelper)3 LogIfError (chat.rocket.android.helper.LogIfError)3 Logger (chat.rocket.android.helper.Logger)3 ConnectivityManagerApi (chat.rocket.android.service.ConnectivityManagerApi)3 BasePresenter (chat.rocket.android.shared.BasePresenter)3 SyncState (chat.rocket.core.SyncState)3 MessageInteractor (chat.rocket.core.interactors.MessageInteractor)3 Message (chat.rocket.core.models.Message)3 Room (chat.rocket.core.models.Room)3 Settings (chat.rocket.core.models.Settings)3 RoomRepository (chat.rocket.core.repositories.RoomRepository)3 UserRepository (chat.rocket.core.repositories.UserRepository)3 Optional (com.fernandocejas.arrow.optional.Optional)3 Single (io.reactivex.Single)3