Search in sources :

Example 1 with CallItem

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;
}
Also used : Bundle(android.os.Bundle) CallItem(com.nextcloud.talk.adapters.items.CallItem) Intent(android.content.Intent) Room(com.nextcloud.talk.models.json.rooms.Room) NoOpControllerChangeHandler(com.bluelinelabs.conductor.internal.NoOpControllerChangeHandler)

Example 2 with CallItem

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);
        }
    });
}
Also used : AutoInjector(autodagger.AutoInjector) Bundle(android.os.Bundle) UserUtils(com.nextcloud.talk.utils.database.user.UserUtils) EntryMenuController(com.nextcloud.talk.controllers.bottomsheet.EntryMenuController) SearchView(android.support.v7.widget.SearchView) CallMenuController(com.nextcloud.talk.controllers.bottomsheet.CallMenuController) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) BindView(butterknife.BindView) ApiUtils(com.nextcloud.talk.utils.ApiUtils) BottomSheet(com.kennyc.bottomsheet.BottomSheet) Handler(android.os.Handler) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) VerticalChangeHandler(com.bluelinelabs.conductor.changehandler.VerticalChangeHandler) Participant(com.nextcloud.talk.models.json.participants.Participant) MenuItemCompat(android.support.v4.view.MenuItemCompat) HttpException(retrofit2.HttpException) InputType(android.text.InputType) FlexibleAdapter(eu.davidea.flexibleadapter.FlexibleAdapter) ThreadMode(org.greenrobot.eventbus.ThreadMode) ViewGroup(android.view.ViewGroup) NoOpControllerChangeHandler(com.bluelinelabs.conductor.internal.NoOpControllerChangeHandler) BundleKeys(com.nextcloud.talk.utils.bundle.BundleKeys) List(java.util.List) Disposable(io.reactivex.disposables.Disposable) Parcels(org.parceler.Parcels) FastScroller(eu.davidea.fastscroller.FastScroller) CallItem(com.nextcloud.talk.adapters.items.CallItem) Nullable(android.support.annotation.Nullable) SearchManager(android.app.SearchManager) EditorInfo(android.view.inputmethod.EditorInfo) Context(android.content.Context) MoreMenuClickEvent(com.nextcloud.talk.events.MoreMenuClickEvent) UserEntity(com.nextcloud.talk.models.database.UserEntity) SmoothScrollLinearLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager) Intent(android.content.Intent) NonNull(android.support.annotation.NonNull) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) BottomSheetLockEvent(com.nextcloud.talk.events.BottomSheetLockEvent) Inject(javax.inject.Inject) BaseController(com.nextcloud.talk.controllers.base.BaseController) MenuInflater(android.view.MenuInflater) EventBus(org.greenrobot.eventbus.EventBus) Menu(android.view.Menu) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) NcApi(com.nextcloud.talk.api.NcApi) BottomNavigationView(android.support.design.widget.BottomNavigationView) R(com.nextcloud.talk.R) Room(com.nextcloud.talk.models.json.rooms.Room) LayoutInflater(android.view.LayoutInflater) TextUtils(android.text.TextUtils) HorizontalChangeHandler(com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler) RecyclerView(android.support.v7.widget.RecyclerView) Subscribe(org.greenrobot.eventbus.Subscribe) KeyboardUtils(com.nextcloud.talk.utils.KeyboardUtils) CallActivity(com.nextcloud.talk.activities.CallActivity) ViewTreeObserver(android.view.ViewTreeObserver) Collections(java.util.Collections) NextcloudTalkApplication(com.nextcloud.talk.application.NextcloudTalkApplication) RouterTransaction(com.bluelinelabs.conductor.RouterTransaction) Handler(android.os.Handler) VerticalChangeHandler(com.bluelinelabs.conductor.changehandler.VerticalChangeHandler) NoOpControllerChangeHandler(com.bluelinelabs.conductor.internal.NoOpControllerChangeHandler) HorizontalChangeHandler(com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler) CallItem(com.nextcloud.talk.adapters.items.CallItem) HttpException(retrofit2.HttpException) VerticalChangeHandler(com.bluelinelabs.conductor.changehandler.VerticalChangeHandler)

Aggregations

Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 NoOpControllerChangeHandler (com.bluelinelabs.conductor.internal.NoOpControllerChangeHandler)2 CallItem (com.nextcloud.talk.adapters.items.CallItem)2 SearchManager (android.app.SearchManager)1 Context (android.content.Context)1 Handler (android.os.Handler)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 BottomNavigationView (android.support.design.widget.BottomNavigationView)1 MenuItemCompat (android.support.v4.view.MenuItemCompat)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)1 RecyclerView (android.support.v7.widget.RecyclerView)1 SearchView (android.support.v7.widget.SearchView)1 InputType (android.text.InputType)1 TextUtils (android.text.TextUtils)1 LayoutInflater (android.view.LayoutInflater)1 Menu (android.view.Menu)1 MenuInflater (android.view.MenuInflater)1