Search in sources :

Example 1 with ContactsController

use of com.nextcloud.talk.controllers.ContactsController in project talk-android by nextcloud.

the class CallMenuController method onItemClick.

@Override
public boolean onItemClick(View view, int position) {
    Bundle bundle = new Bundle();
    bundle.putParcelable(BundleKeys.KEY_ROOM, Parcels.wrap(room));
    if (menuType.equals(MenuType.REGULAR)) {
        MenuItem menuItem = (MenuItem) adapter.getItem(position);
        if (menuItem != null) {
            int tag = menuItem.getTag();
            if (tag == 5) {
                room.setPassword("");
            }
            if (tag > 0 && tag < 10) {
                bundle.putInt(BundleKeys.KEY_OPERATION_CODE, tag);
                if (tag != 2 && tag != 4 && tag != 6 && tag != 7) {
                    eventBus.post(new BottomSheetLockEvent(false, 0, false, false));
                    getRouter().pushController(RouterTransaction.with(new OperationsMenuController(bundle)).pushChangeHandler(new HorizontalChangeHandler()).popChangeHandler(new HorizontalChangeHandler()));
                } else if (tag != 7) {
                    getRouter().pushController(RouterTransaction.with(new EntryMenuController(bundle)).pushChangeHandler(new HorizontalChangeHandler()).popChangeHandler(new HorizontalChangeHandler()));
                } else {
                    bundle.putParcelable(BundleKeys.KEY_MENU_TYPE, Parcels.wrap(MenuType.SHARE));
                    getRouter().pushController(RouterTransaction.with(new CallMenuController(bundle)).pushChangeHandler(new HorizontalChangeHandler()).popChangeHandler(new HorizontalChangeHandler()));
                }
            }
        }
    } else if (menuType.equals(MenuType.SHARE) && position != 0) {
        AppItem appItem = (AppItem) adapter.getItem(position);
        if (appItem != null && getActivity() != null) {
            if (!room.hasPassword) {
                shareIntent.putExtra(Intent.EXTRA_TEXT, ShareUtils.getStringForIntent(getActivity(), null, userUtils, room));
                Intent intent = new Intent(shareIntent);
                intent.setComponent(new ComponentName(appItem.getPackageName(), appItem.getName()));
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                eventBus.post(new BottomSheetLockEvent(true, 0, false, true));
                getActivity().startActivity(intent);
            } else {
                bundle.putInt(BundleKeys.KEY_OPERATION_CODE, 7);
                bundle.putParcelable(BundleKeys.KEY_SHARE_INTENT, Parcels.wrap(shareIntent));
                bundle.putString(BundleKeys.KEY_APP_ITEM_PACKAGE_NAME, appItem.getPackageName());
                bundle.putString(BundleKeys.KEY_APP_ITEM_NAME, appItem.getName());
                getRouter().pushController(RouterTransaction.with(new EntryMenuController(bundle)).pushChangeHandler(new HorizontalChangeHandler()).popChangeHandler(new HorizontalChangeHandler()));
            }
        }
    } else if (menuType.equals(MenuType.NEW_CONVERSATION) && position != 0) {
        MenuItem menuItem = (MenuItem) adapter.getItem(position);
        if (menuItem != null) {
            if (menuItem.getTag() == 1) {
                eventBus.post(new BottomSheetLockEvent(true, 0, false, true));
                bundle = new Bundle();
                bundle.putBoolean(BundleKeys.KEY_NEW_CONVERSATION, true);
                getParentController().getParentController().getRouter().pushController((RouterTransaction.with(new ContactsController(bundle)).pushChangeHandler(new VerticalChangeHandler()).popChangeHandler(new VerticalChangeHandler())));
            } else {
                bundle = new Bundle();
                bundle.putInt(BundleKeys.KEY_OPERATION_CODE, 10);
                getRouter().pushController(RouterTransaction.with(new EntryMenuController(bundle)).pushChangeHandler(new HorizontalChangeHandler()).popChangeHandler(new HorizontalChangeHandler()));
            }
        }
    }
    return true;
}
Also used : ContactsController(com.nextcloud.talk.controllers.ContactsController) Bundle(android.os.Bundle) MenuItem(com.nextcloud.talk.adapters.items.MenuItem) Intent(android.content.Intent) VerticalChangeHandler(com.bluelinelabs.conductor.changehandler.VerticalChangeHandler) HorizontalChangeHandler(com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler) BottomSheetLockEvent(com.nextcloud.talk.events.BottomSheetLockEvent) AppItem(com.nextcloud.talk.adapters.items.AppItem) ComponentName(android.content.ComponentName)

Aggregations

ComponentName (android.content.ComponentName)1 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 HorizontalChangeHandler (com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler)1 VerticalChangeHandler (com.bluelinelabs.conductor.changehandler.VerticalChangeHandler)1 AppItem (com.nextcloud.talk.adapters.items.AppItem)1 MenuItem (com.nextcloud.talk.adapters.items.MenuItem)1 ContactsController (com.nextcloud.talk.controllers.ContactsController)1 BottomSheetLockEvent (com.nextcloud.talk.events.BottomSheetLockEvent)1