Search in sources :

Example 1 with SelectedUserDestinationParams

use of com.voipgrid.vialer.api.models.SelectedUserDestinationParams in project vialer-android by VoIPGRID.

the class NavigationDrawerActivity method onItemSelected.

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    if (mFirstTimeOnItemSelected) {
        mFirstTimeOnItemSelected = false;
    } else {
        if (parent.getCount() - 1 == position) {
            startWebActivity(getString(R.string.add_destination_title), getString(R.string.web_add_destination), getString(R.string.analytics_add_destination_title));
        } else {
            Destination destination = (Destination) parent.getAdapter().getItem(position);
            if (destination.getDescription().equals(getString(R.string.not_available))) {
                MiddlewareHelper.unregister(this);
            }
            SelectedUserDestinationParams params = new SelectedUserDestinationParams();
            params.fixedDestination = destination instanceof FixedDestination ? destination.getId() : null;
            params.phoneAccount = destination instanceof PhoneAccount ? destination.getId() : null;
            Call<Object> call = mApi.setSelectedUserDestination(mSelectedUserDestinationId, params);
            call.enqueue(this);
            if (!MiddlewareHelper.isRegistered(this)) {
                // If the previous destination was not available, or if we're not registered
                // for another reason, register again.
                MiddlewareHelper.registerAtMiddleware(this);
            }
        }
    }
}
Also used : FixedDestination(com.voipgrid.vialer.api.models.FixedDestination) Destination(com.voipgrid.vialer.api.models.Destination) UserDestination(com.voipgrid.vialer.api.models.UserDestination) PhoneAccount(com.voipgrid.vialer.api.models.PhoneAccount) SelectedUserDestinationParams(com.voipgrid.vialer.api.models.SelectedUserDestinationParams) FixedDestination(com.voipgrid.vialer.api.models.FixedDestination)

Aggregations

Destination (com.voipgrid.vialer.api.models.Destination)1 FixedDestination (com.voipgrid.vialer.api.models.FixedDestination)1 PhoneAccount (com.voipgrid.vialer.api.models.PhoneAccount)1 SelectedUserDestinationParams (com.voipgrid.vialer.api.models.SelectedUserDestinationParams)1 UserDestination (com.voipgrid.vialer.api.models.UserDestination)1