mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-15 08:45:04 +01:00
Fix NcApi usage for conversations list
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
bd70363a43
commit
7e8957fd97
@ -67,6 +67,7 @@ import com.nextcloud.talk.utils.ApiUtils;
|
|||||||
import com.nextcloud.talk.utils.KeyboardUtils;
|
import com.nextcloud.talk.utils.KeyboardUtils;
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
import com.nextcloud.talk.utils.database.user.UserUtils;
|
||||||
|
import com.nextcloud.talk.utils.singletons.ApplicationWideApiHolder;
|
||||||
|
|
||||||
import org.apache.commons.lang3.builder.CompareToBuilder;
|
import org.apache.commons.lang3.builder.CompareToBuilder;
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
@ -106,8 +107,8 @@ public class ConversationsListController extends BaseController implements Searc
|
|||||||
@Inject
|
@Inject
|
||||||
EventBus eventBus;
|
EventBus eventBus;
|
||||||
|
|
||||||
@Inject
|
|
||||||
NcApi ncApi;
|
NcApi ncApi;
|
||||||
|
|
||||||
@BindView(R.id.recycler_view)
|
@BindView(R.id.recycler_view)
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
|
|
||||||
@ -130,6 +131,8 @@ public class ConversationsListController extends BaseController implements Searc
|
|||||||
private View view;
|
private View view;
|
||||||
private boolean shouldUseLastMessageLayout;
|
private boolean shouldUseLastMessageLayout;
|
||||||
|
|
||||||
|
private String credentials;
|
||||||
|
|
||||||
public ConversationsListController() {
|
public ConversationsListController() {
|
||||||
super();
|
super();
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
@ -149,20 +152,17 @@ public class ConversationsListController extends BaseController implements Searc
|
|||||||
getActionBar().show();
|
getActionBar().show();
|
||||||
}
|
}
|
||||||
|
|
||||||
currentUser = userUtils.getCurrentUser();
|
|
||||||
|
|
||||||
if (currentUser == null &&
|
|
||||||
getParentController() != null && getParentController().getRouter() != null) {
|
|
||||||
getParentController().getRouter().setRoot((RouterTransaction.with(new ServerSelectionController())
|
|
||||||
.pushChangeHandler(new HorizontalChangeHandler())
|
|
||||||
.popChangeHandler(new HorizontalChangeHandler())));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (adapter == null) {
|
if (adapter == null) {
|
||||||
adapter = new FlexibleAdapter<>(callItems, getActivity(), false);
|
adapter = new FlexibleAdapter<>(callItems, getActivity(), false);
|
||||||
|
currentUser = userUtils.getCurrentUser();
|
||||||
|
|
||||||
if (currentUser != null) {
|
if (currentUser != null) {
|
||||||
shouldUseLastMessageLayout = currentUser.hasSpreedCapabilityWithName("last-room-activity");
|
shouldUseLastMessageLayout = currentUser.hasSpreedCapabilityWithName("last-room-activity");
|
||||||
|
|
||||||
|
ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(currentUser.getId(), null);
|
||||||
|
credentials = ApiUtils.getCredentials(currentUser.getUserId(), currentUser.getToken());
|
||||||
|
|
||||||
fetchData(false);
|
fetchData(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,8 +178,6 @@ public class ConversationsListController extends BaseController implements Searc
|
|||||||
if (getActionBar() != null) {
|
if (getActionBar() != null) {
|
||||||
getActionBar().setDisplayHomeAsUpEnabled(false);
|
getActionBar().setDisplayHomeAsUpEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentUser = userUtils.getCurrentUser();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -274,8 +272,7 @@ public class ConversationsListController extends BaseController implements Searc
|
|||||||
|
|
||||||
callItems = new ArrayList<>();
|
callItems = new ArrayList<>();
|
||||||
|
|
||||||
roomsQueryDisposable = ncApi.getRooms(ApiUtils.getCredentials(currentUser.getUsername(),
|
roomsQueryDisposable = ncApi.getRooms(credentials, ApiUtils.getUrlForGetRooms(currentUser.getBaseUrl()))
|
||||||
currentUser.getToken()), ApiUtils.getUrlForGetRooms(currentUser.getBaseUrl()))
|
|
||||||
.subscribeOn(Schedulers.newThread())
|
.subscribeOn(Schedulers.newThread())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(roomsOverall -> {
|
.subscribe(roomsOverall -> {
|
||||||
|
Loading…
Reference in New Issue
Block a user