Search in sources :

Example 1 with IconCardPresenter

use of cx.ring.tv.cards.iconcards.IconCardPresenter in project ring-client-android by savoirfairelinux.

the class CardPresenterSelector method getPresenter.

@Override
public Presenter getPresenter(Object item) {
    if (!(item instanceof Card))
        throw new RuntimeException(String.format("The PresenterSelector only supports data items of type '%s'", Card.class.getName()));
    Card card = (Card) item;
    Presenter presenter = presenters.get(card.getType());
    if (presenter == null) {
        switch(card.getType()) {
            case ABOUT_VERSION:
            case ABOUT_CONTRIBUTOR:
            case ABOUT_LICENCES:
            case ACCOUNT_ADD_DEVICE:
            case ACCOUNT_EDIT_PROFILE:
            case ACCOUNT_SETTINGS:
                presenter = new IconCardPresenter(mContext);
                break;
            case SEARCH_RESULT:
                presenter = new ContactCardPresenter(mContext, R.style.SearchCardTheme);
                break;
            case CONTACT:
                presenter = new ContactCardPresenter(mContext, R.style.ContactCardTheme);
                break;
            case CONTACT_ONLINE:
                presenter = new ContactCardPresenter(mContext, R.style.ContactCardOnlineTheme);
                break;
            case CONTACT_WITH_USERNAME:
                presenter = new ContactCardPresenter(mContext, R.style.ContactCompleteCardTheme);
                break;
            case CONTACT_WITH_USERNAME_ONLINE:
                presenter = new ContactCardPresenter(mContext, R.style.ContactCompleteCardOnlineTheme);
                break;
            case CONTACT_REQUEST:
                presenter = new ContactRequestCardPresenter(mContext, R.style.ContactCardTheme);
                break;
            case CONTACT_REQUEST_WITH_USERNAME:
                presenter = new ContactRequestCardPresenter(mContext, R.style.ContactCompleteCardTheme);
                break;
            default:
                throw new InvalidParameterException("Uncatched card type");
        }
    }
    presenters.put(card.getType(), presenter);
    return presenter;
}
Also used : InvalidParameterException(java.security.InvalidParameterException) ContactRequestCardPresenter(cx.ring.tv.cards.contactrequests.ContactRequestCardPresenter) ContactCardPresenter(cx.ring.tv.cards.contacts.ContactCardPresenter) IconCardPresenter(cx.ring.tv.cards.iconcards.IconCardPresenter) Presenter(android.support.v17.leanback.widget.Presenter) ContactRequestCardPresenter(cx.ring.tv.cards.contactrequests.ContactRequestCardPresenter) IconCardPresenter(cx.ring.tv.cards.iconcards.IconCardPresenter) ContactCardPresenter(cx.ring.tv.cards.contacts.ContactCardPresenter)

Aggregations

Presenter (android.support.v17.leanback.widget.Presenter)1 ContactRequestCardPresenter (cx.ring.tv.cards.contactrequests.ContactRequestCardPresenter)1 ContactCardPresenter (cx.ring.tv.cards.contacts.ContactCardPresenter)1 IconCardPresenter (cx.ring.tv.cards.iconcards.IconCardPresenter)1 InvalidParameterException (java.security.InvalidParameterException)1