use of com.nextcloud.talk.adapters.items.CallItem in project talk-android by nextcloud.
the class CallsListController method onItemClick.
@Override
public boolean onItemClick(View view, int position) {
CallItem callItem = adapter.getItem(position);
if (callItem != null && getActivity() != null) {
Room room = callItem.getModel();
Bundle bundle = new Bundle();
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, callItem.getModel().getToken());
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(userEntity));
if (room.hasPassword && (room.participantType.equals(Participant.ParticipantType.GUEST) || room.participantType.equals(Participant.ParticipantType.USER_FOLLOWING_LINK))) {
bundle.putInt(BundleKeys.KEY_OPERATION_CODE, 99);
prepareAndShowBottomSheetWithBundle(bundle, false);
} else {
overridePushHandler(new NoOpControllerChangeHandler());
overridePopHandler(new NoOpControllerChangeHandler());
Intent callIntent = new Intent(getActivity(), CallActivity.class);
callIntent.putExtras(bundle);
startActivity(callIntent);
}
}
return true;
}
use of com.nextcloud.talk.adapters.items.CallItem in project talk-android by nextcloud.
the class CallsListController method fetchData.
private void fetchData(boolean fromBottomSheet) {
dispose(null);
callItems = new ArrayList<>();
roomsQueryDisposable = ncApi.getRooms(ApiUtils.getCredentials(userEntity.getUsername(), userEntity.getToken()), ApiUtils.getUrlForGetRooms(userEntity.getBaseUrl())).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(roomsOverall -> {
if (roomsOverall != null) {
for (int i = 0; i < roomsOverall.getOcs().getData().size(); i++) {
callItems.add(new CallItem(roomsOverall.getOcs().getData().get(i), userEntity));
}
adapter.updateDataSet(callItems, true);
Collections.sort(callItems, (callItem, t1) -> Long.compare(t1.getModel().getLastPing(), callItem.getModel().getLastPing()));
if (searchItem != null) {
searchItem.setVisible(callItems.size() > 0);
}
}
if (swipeRefreshLayout != null) {
swipeRefreshLayout.setRefreshing(false);
}
}, throwable -> {
if (searchItem != null) {
searchItem.setVisible(false);
}
if (throwable instanceof HttpException) {
HttpException exception = (HttpException) throwable;
switch(exception.code()) {
case 401:
if (getParentController() != null && getParentController().getRouter() != null) {
getParentController().getRouter().pushController((RouterTransaction.with(new WebViewLoginController(userEntity.getBaseUrl(), true)).pushChangeHandler(new VerticalChangeHandler()).popChangeHandler(new VerticalChangeHandler())));
}
break;
default:
break;
}
}
if (swipeRefreshLayout != null) {
swipeRefreshLayout.setRefreshing(false);
}
dispose(roomsQueryDisposable);
}, () -> {
dispose(roomsQueryDisposable);
if (swipeRefreshLayout != null) {
swipeRefreshLayout.setRefreshing(false);
}
if (fromBottomSheet) {
new Handler().postDelayed(() -> {
bottomSheet.setCancelable(true);
if (bottomSheet.isShowing()) {
bottomSheet.cancel();
}
}, 2500);
}
});
}
Aggregations