Commit 042626cd authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update RoomPresenter.java

Add method getUserByUsername(...).
parent f8975ff0
...@@ -4,7 +4,9 @@ import android.support.annotation.NonNull; ...@@ -4,7 +4,9 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.util.Pair; import android.support.v4.util.Pair;
import chat.rocket.persistence.realm.models.ddp.RealmUser;
import com.hadisatrio.optional.Optional; import com.hadisatrio.optional.Optional;
import io.reactivex.Flowable;
import io.reactivex.Single; import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
...@@ -217,11 +219,28 @@ public class RoomPresenter extends BasePresenter<RoomContract.View> ...@@ -217,11 +219,28 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
.map(Optional::get) .map(Optional::get)
.subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())) .subscribeOn(AndroidSchedulers.from(BackgroundLooper.get()))
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe( .subscribe(room -> {
room -> view.render(room), if (room.isDirectMessage()) {
getUserByUsername(room, room.getName());
} else {
view.render(room, null);
}
},
Logger::report Logger::report
); );
addSubscription(subscription);
}
private void getUserByUsername(Room room, String username) {
final Disposable subscription = userRepository.getByUsername(username)
.distinctUntilChanged()
.filter(Optional::isPresent)
.map(Optional::get)
.subscribeOn(AndroidSchedulers.from(BackgroundLooper.get()))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(user -> view.render(room, user),
Logger::report
);
addSubscription(subscription); addSubscription(subscription);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment