Search in sources :

Example 26 with Content

use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.

the class ContentTranslatorTest method testSetMemberVariableTags.

/**
 * Tests the {@link ContentTranslator#setMemberVariable(Content, String, Object)} method for
 * the tags member variable.
 */
@Test
public void testSetMemberVariableTags() throws Exception {
    String tags = "['tag1', 'tag2', 'tag3']";
    Content content = new Content();
    assertTrue(mContentTranslator.setMemberVariable(content, "mTags", tags));
    assertEquals(content.getTags().size(), 3);
}
Also used : Content(com.amazon.android.model.content.Content) Test(org.junit.Test)

Example 27 with Content

use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.

the class ContentTranslatorTest method testValidateModelFalseDescription.

/**
 * Tests the {@link ContentTranslator#validateModel(Content)} method for the false case where
 * the description is invalid.
 */
@Test
public void testValidateModelFalseDescription() throws Exception {
    Content content = createValidContent();
    // make good content bad
    content.setDescription("");
    assertFalse(mContentTranslator.validateModel(content));
}
Also used : Content(com.amazon.android.model.content.Content) Test(org.junit.Test)

Example 28 with Content

use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.

the class ContentTranslatorTest method testValidateModelNullValue.

/**
 * Tests the {@link ContentTranslator#validateModel(Content)} method for the false case where
 * the title is null.
 */
@Test
public void testValidateModelNullValue() throws Exception {
    Content content = createValidContent();
    // make good content bad
    content.setTitle(null);
    assertFalse(mContentTranslator.validateModel(content));
}
Also used : Content(com.amazon.android.model.content.Content) Test(org.junit.Test)

Example 29 with Content

use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.

the class ContentTranslatorTest method testValidateModelFalseTitleCase.

/**
 * Tests the {@link ContentTranslator#validateModel(Content)} method for the false case where
 * the title is invalid.
 */
@Test
public void testValidateModelFalseTitleCase() throws Exception {
    Content content = createValidContent();
    // make good content bad
    content.setTitle("");
    assertFalse(mContentTranslator.validateModel(content));
}
Also used : Content(com.amazon.android.model.content.Content) Test(org.junit.Test)

Example 30 with Content

use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.

the class ContentBrowseActivity method onItemSelected.

/**
 * {@inheritDoc}
 * Called by the browse fragment ({@link ContentBrowseFragment}. Switches the content
 * title, description, and image.
 */
@Override
public void onItemSelected(Object item, Row row, boolean isLastContentRow) {
    if (item != null) {
        lastRowSelected = isLastContentRow;
    }
    if (row != lastSelectedRow && item != null) {
        lastSelectedRow = row;
        lastSelectedRowChanged = true;
    } else {
        lastSelectedRowChanged = false;
    }
    lastSelectedItemIndex = ((ArrayObjectAdapter) ((ListRow) row).getAdapter()).indexOf(item);
    if (item instanceof Content) {
        Content content = (Content) item;
        callImageLoadSubscription(content.getTitle(), content.getDescription(), content.getBackgroundImageUrl());
    } else // Update screen background with selected playlist (category) image
    if (item instanceof ContentContainer) {
        ContentContainer contentContainer = (ContentContainer) item;
        callImageLoadSubscription(contentContainer.getName(), contentContainer.getExtraStringValue("description"), contentContainer.getExtraStringValue(Content.BACKGROUND_IMAGE_URL_FIELD_NAME));
    } else if (item instanceof Action) {
        Action settingsAction = (Action) item;
        // Terms of use action.
        if (ContentBrowser.TERMS.equals(settingsAction.getAction())) {
            callImageLoadSubscription(getString(R.string.terms_title), getString(R.string.terms_description), null);
        } else // Login and logout action.
        if (ContentBrowser.LOGIN_LOGOUT.equals(settingsAction.getAction())) {
            if (settingsAction.getState() == LogoutSettingsFragment.TYPE_LOGOUT) {
                callImageLoadSubscription(getString(R.string.logout_label), getString(R.string.logout_description), null);
            } else {
                callImageLoadSubscription(getString(R.string.login_label), getString(R.string.login_description), null);
            }
        }
    }
}
Also used : Action(com.amazon.android.model.Action) Content(com.amazon.android.model.content.Content) ContentContainer(com.amazon.android.model.content.ContentContainer) ListRow(androidx.leanback.widget.ListRow)

Aggregations

Content (com.amazon.android.model.content.Content)76 ContentContainer (com.amazon.android.model.content.ContentContainer)28 Test (org.junit.Test)26 ArrayObjectAdapter (androidx.leanback.widget.ArrayObjectAdapter)13 ListRow (androidx.leanback.widget.ListRow)13 ArrayList (java.util.ArrayList)11 Recipe (com.amazon.android.recipe.Recipe)10 Intent (android.content.Intent)8 RecentDatabaseHelper (com.amazon.android.contentbrowser.database.helpers.RecentDatabaseHelper)7 TextUtils (android.text.TextUtils)6 RecentRecord (com.amazon.android.contentbrowser.database.records.RecentRecord)6 CardPresenter (com.amazon.android.tv.tenfoot.presenter.CardPresenter)6 List (java.util.List)6 Context (android.content.Context)5 HeaderItem (androidx.leanback.widget.HeaderItem)5 Action (com.amazon.android.model.Action)5 NavigatorModel (com.amazon.android.navigator.NavigatorModel)5 AndroidSchedulers (rx.android.schedulers.AndroidSchedulers)5 Bundle (android.os.Bundle)4 Log (android.util.Log)4