Cleanup and usage of new ImageCardView

The Showcase app now makes use of the new
ImageCardView which is stylable through
XML and uses less Views.
Cleaned up DetailView.
Cleaned up styles and layouts.
Added Copyright notices.

Change-Id: Ib37485d5b57be6a0f4b5321ac61b41a0808eaf35
This commit is contained in:
Robert Hahn
2015-08-03 12:36:31 -07:00
parent 226bc5165f
commit 8dd090f514
71 changed files with 1106 additions and 1369 deletions

View File

@@ -39,6 +39,9 @@
<activity
android:name=".DialogExampleActivity"
android:theme="@style/Theme.Example.LeanbackDialog"></activity>
<activity
android:name=".DetailViewExampleActivity"
android:theme="@style/Theme.Example.LeanbackDetailView"></activity>
</application>
</manifest>

View File

@@ -70,7 +70,7 @@ public class CardExampleFragment extends BrowseFragment {
private void createRows() {
String json = Utils
.inputStreamToString(getResources().openRawResource(R.raw.cards_card_example));
.inputStreamToString(getResources().openRawResource(R.raw.cards_example));
CardRow[] rows = new Gson().fromJson(json, CardRow[].class);
for (CardRow row : rows) {
mRowsAdapter.add(createCardRow(row));

View File

@@ -0,0 +1,54 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package android.support.v17.leanback.supportleanbackshowcase;
import android.app.Activity;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v17.leanback.app.DetailsFragment;
import android.support.v17.leanback.app.GuidedStepFragment;
import android.support.v17.leanback.supportleanbackshowcase.cards.models.Card;
import android.support.v17.leanback.supportleanbackshowcase.cards.presenters.CardPresenterSelector;
import android.support.v17.leanback.widget.Action;
import android.support.v17.leanback.widget.ArrayObjectAdapter;
import android.support.v17.leanback.widget.ClassPresenterSelector;
import android.support.v17.leanback.widget.DetailsOverviewRow;
import android.support.v17.leanback.widget.FullWidthDetailsOverviewRowPresenter;
import android.support.v17.leanback.widget.HeaderItem;
import android.support.v17.leanback.widget.ListRow;
import android.support.v17.leanback.widget.ListRowPresenter;
import android.support.v17.leanback.widget.OnItemViewClickedListener;
import android.support.v17.leanback.widget.OnItemViewSelectedListener;
import android.support.v17.leanback.widget.Presenter;
import android.support.v17.leanback.widget.Row;
import android.support.v17.leanback.widget.RowPresenter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.google.gson.Gson;
/**
* Contains a {@link DetailsFragment} in order to display more details for a given card.
*/
public class DetailViewExampleActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail_example);
}
}

View File

@@ -38,39 +38,46 @@ import android.widget.Toast;
import com.google.gson.Gson;
/**
* Displays a card with more details.
* Displays a card with more details using a {@link DetailsFragment}.
*/
public class DetailViewExampleFragment extends DetailsFragment implements OnItemViewClickedListener,
OnItemViewSelectedListener {
private static final String TAG = "DetailViewExampleFragment";
private ArrayObjectAdapter mRowsAdapter;
@Override public void onActivityCreated(Bundle savedInstanceState) {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setupUi();
setupEventListeners();
}
private void setupUi() {
// Load the card we want to display from a JSON resource. This JSON data could come from
// anywhere in a real world app, e.g. a server.
String json = Utils
.inputStreamToString(getResources().openRawResource(R.raw.detail_example));
DetailedCard data = new Gson().fromJson(json, DetailedCard.class);
// Setup fragment
setTitle(getString(R.string.detail_view_title));
FullWidthDetailsOverviewRowPresenter rowPresenter = new FullWidthDetailsOverviewRowPresenter(
new DetailsDescriptionPresenter(getActivity())) {
@Override protected RowPresenter.ViewHolder createRowViewHolder(ViewGroup parent) {
@Override
protected RowPresenter.ViewHolder createRowViewHolder(ViewGroup parent) {
// Customize Actionbar and Content by using custom colors.
RowPresenter.ViewHolder viewHolder = super.createRowViewHolder(parent);
// TODO: hahnr@ replace with API calls (they don't exist yet)
View actionsView = viewHolder.view.findViewById(R.id.details_overview_actions);
actionsView.setBackgroundColor(getActivity().getResources().getColor(
R.color.detail_view_actionbar_background));
View actionsView = viewHolder.view.
findViewById(R.id.details_overview_actions_background);
actionsView.setBackgroundColor(getActivity().getResources().
getColor(R.color.detail_view_actionbar_background, null));
View detailsView = viewHolder.view.findViewById(R.id.details_frame);
detailsView.setBackgroundColor(
getActivity().getResources().getColor(R.color.detail_view_background));
getResources().getColor(R.color.detail_view_background, null));
return viewHolder;
}
};
@@ -112,26 +119,30 @@ public class DetailViewExampleFragment extends DetailsFragment implements OnItem
}
private void setupEventListeners() {
// FIXME: leanbackteam@ The item & itemViewHolder parameters in onItemSelected are null in the DetailsOverviewRow as long as the user navigates top or down. After navigating left or right it will be the actual item rather than null.
setOnItemViewSelectedListener(this);
setOnItemViewClickedListener(this);
}
@Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
RowPresenter.ViewHolder rowViewHolder, Row row) {
@Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
RowPresenter.ViewHolder rowViewHolder, Row row) {
if (!(item instanceof Action)) return;
Action action = (Action) item;
if (action.getId() == 3) {
setSelectedPosition(1);
} else Toast.makeText(getActivity(), getString(R.string.action_cicked), Toast.LENGTH_LONG)
} else {
Toast.makeText(getActivity(), getString(R.string.action_cicked), Toast.LENGTH_LONG)
.show();
}
}
@Override public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
RowPresenter.ViewHolder rowViewHolder, Row row) {
@Override
public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
RowPresenter.ViewHolder rowViewHolder, Row row) {
if (mRowsAdapter.indexOf(row) > 0) {
getView().setBackgroundColor(
getResources().getColor(R.color.detail_view_related_background));
int backgroundColor = getResources().getColor(R.color.detail_view_related_background,
null);
getView().setBackgroundColor(backgroundColor);
} else {
getView().setBackgroundResource(R.drawable.background_canyon);
}

View File

@@ -36,7 +36,7 @@ public class DetailsDescriptionPresenter extends Presenter {
}
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) {
View view = LayoutInflater.from(mContext).inflate(R.layout.detail_view, null);
View view = LayoutInflater.from(mContext).inflate(R.layout.detail_view_content, null);
return new ViewHolder(view);
}

View File

@@ -178,12 +178,9 @@ public class MainFragment extends BrowseFragment {
break;
}
case 3: {
updateBackgroundImage(
getResources().getDrawable(R.drawable.background_canyon, null));
Fragment fragment = new DetailViewExampleFragment();
getFragmentManager().beginTransaction()
.replace(R.id.fragmentContainer, fragment)
.addToBackStack(null).commit();
Intent intent = new Intent(getActivity().getBaseContext(),
DetailViewExampleActivity.class);
startActivity(intent);
break;
}
case 4: {

View File

@@ -1,3 +1,17 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package android.support.v17.leanback.supportleanbackshowcase;
import com.google.gson.annotations.SerializedName;

View File

@@ -1,3 +1,17 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package android.support.v17.leanback.supportleanbackshowcase;
import android.util.SparseArray;

View File

@@ -1,3 +1,17 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package android.support.v17.leanback.supportleanbackshowcase;
import android.app.Fragment;

View File

@@ -34,13 +34,11 @@ public class VideoConsumptionExampleFragment extends PlaybackOverlayFragment imp
OnItemViewClickedListener, MediaPlayerGlue.OnMediaFileFinishedPlayingListener {
private static final String URL = "http://techslides.com/demos/sample-videos/small.mp4";
private static final String TAG = "VideoConsumptionExampleFragment";
private ArrayObjectAdapter mRowsAdapter;
private MediaPlayerGlue mGlue;
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Constants.LOCAL_LOGD) Log.d(TAG, "onCreate");
mGlue = new VideoMediaPlayerGlue(getActivity(), this) {
@@ -61,7 +59,6 @@ public class VideoConsumptionExampleFragment extends PlaybackOverlayFragment imp
SurfaceView surface = (SurfaceView) videoSurfaceFragment.getView();
surface.getHolder().addCallback(new SurfaceHolder.Callback() {
@Override public void surfaceCreated(SurfaceHolder holder) {
Log.d(TAG, "surfaceCreated(SurfaceHolder)");
mGlue.setDisplay(holder);
}
@@ -71,7 +68,6 @@ public class VideoConsumptionExampleFragment extends PlaybackOverlayFragment imp
}
@Override public void surfaceDestroyed(SurfaceHolder holder) {
Log.d(TAG, "surfaceDestroyed(SurfaceHolder)");
}
});

View File

@@ -1,3 +1,17 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package android.support.v17.leanback.supportleanbackshowcase;
import android.graphics.Color;

View File

@@ -1,7 +1,19 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package android.support.v17.leanback.supportleanbackshowcase;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
@@ -9,11 +21,8 @@ import android.support.v17.leanback.app.GuidedStepFragment;
import android.support.v17.leanback.widget.GuidanceStylist;
import android.support.v17.leanback.widget.GuidedAction;
import android.support.v17.leanback.widget.GuidedActionsStylist;
import android.util.Log;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
/**
* TODO: JavaDoc

View File

@@ -1,3 +1,17 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package android.support.v17.leanback.supportleanbackshowcase;
import android.os.Bundle;

View File

@@ -0,0 +1,70 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package android.support.v17.leanback.supportleanbackshowcase.cards;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v17.leanback.supportleanbackshowcase.R;
import android.support.v17.leanback.supportleanbackshowcase.cards.models.Card;
import android.support.v17.leanback.widget.BaseCardView;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
public class CharacterCardView extends BaseCardView {
public CharacterCardView(Context context) {
super(context);
LayoutInflater.from(getContext()).inflate(R.layout.character_card, this);
setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
ImageView mainImage = (ImageView) findViewById(R.id.main_image);
View container = findViewById(R.id.container);
if (hasFocus) {
container.setBackgroundResource(R.drawable.character_focused);
mainImage.setBackgroundResource(R.drawable.character_focused);
} else {
container.setBackgroundResource(R.drawable.character_not_focused_padding);
mainImage.setBackgroundResource(R.drawable.character_not_focused);
}
}
});
setFocusable(true);
}
public void updateUi(Card card) {
TextView primaryText = (TextView) findViewById(R.id.primary_text);
final ImageView imageView = (ImageView) findViewById(R.id.main_image);
primaryText.setText(card.getTitle());
if (card.getLocalImageResourceName() != null) {
int resourceId = card.getLocalImageResourceId(getContext());
Bitmap bitmap = BitmapFactory
.decodeResource(getContext().getResources(), resourceId);
RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(getContext().getResources(), bitmap);
drawable.setAntiAlias(true);
drawable.setCornerRadius(Math.max(bitmap.getWidth(), bitmap.getHeight()) / 2.0f);
imageView.setImageDrawable(drawable);
}
}
}

View File

@@ -0,0 +1,57 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package android.support.v17.leanback.supportleanbackshowcase.cards;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v17.leanback.supportleanbackshowcase.R;
import android.support.v17.leanback.supportleanbackshowcase.cards.models.Card;
import android.support.v17.leanback.widget.BaseCardView;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
public class TextCardView extends BaseCardView {
public TextCardView(Context context) {
super(context);
LayoutInflater.from(getContext()).inflate(R.layout.text_icon_card, this);
setFocusable(true);
}
public void updateUi(Card card) {
TextView extraText = (TextView) findViewById(R.id.extra_text);
TextView primaryText = (TextView) findViewById(R.id.primary_text);
final ImageView imageView = (ImageView) findViewById(R.id.main_image);
extraText.setText(card.getExtraText());
primaryText.setText(card.getTitle());
// Create a rounded drawable.
int resourceId = card.getLocalImageResourceId(getContext());
Bitmap bitmap = BitmapFactory
.decodeResource(getContext().getResources(), resourceId);
RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(getContext().getResources(), bitmap);
drawable.setAntiAlias(true);
drawable.setCornerRadius(
Math.max(bitmap.getWidth(), bitmap.getHeight()) / 2.0f);
imageView.setImageDrawable(drawable);
}
}

View File

@@ -109,12 +109,13 @@ public class Card {
public enum Type {
THIN,
THIN_RATING,
MOVIE_COMPLETE,
MOVIE,
MOVIE_BASE,
ICON,
SQUARE_BIG,
SQUARE,
WIDE_SHORT,
SINGLE_LINE,
GAME,
SQUARE_SMALL,
DEFAULT,
SIDE_INFO,

View File

@@ -15,7 +15,6 @@ package android.support.v17.leanback.supportleanbackshowcase.cards.presenters;
import android.content.Context;
import android.support.v17.leanback.supportleanbackshowcase.cards.models.Card;
import android.support.v17.leanback.supportleanbackshowcase.cards.views.BaseCardViewEx;
import android.support.v17.leanback.widget.BaseCardView;
import android.support.v17.leanback.widget.Presenter;
import android.view.ViewGroup;

View File

@@ -1,95 +0,0 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package android.support.v17.leanback.supportleanbackshowcase.cards.presenters;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.support.v17.leanback.supportleanbackshowcase.R;
import android.support.v17.leanback.supportleanbackshowcase.Utils;
import android.support.v17.leanback.supportleanbackshowcase.cards.models.Card;
import android.support.v17.leanback.supportleanbackshowcase.cards.views.FooterLayoutCardView;
import android.support.v17.leanback.widget.Presenter;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.squareup.picasso.Picasso;
/**
* A custom and abstract card {@link Presenter} which allows to create a card consisting of an image
* and a custom footer. The footer is passed as a layout and will be inflated automatically.
*/
public abstract class AbstractFooterCardPresenter extends
AbstractCardPresenter<FooterLayoutCardView> {
private static final String TAG = "AbstractFooterCardPresenter";
private final Drawable mLoadingErrorDrawable;
private final int mFooterLayoutd;
private final int mImageWidth;
private final int mImageHeight;
/**
* @param context Used to retrieve default values such as error drawables.
* @param footerLayoutId The layout which represents the footer.
* @param imageWidth The width of the card's main image. This width defines the card's width
* too.
* @param imageHeight The height of the card's main image. The card's height will be
* <code>imageHeight + footerHeight</code>
*/
public AbstractFooterCardPresenter(Context context, int footerLayoutId, int imageWidth,
int imageHeight) {
super(context);
mFooterLayoutd = footerLayoutId;
mImageWidth = imageWidth;
mImageHeight = imageHeight;
// In case the image could not be fetched from the server we want to make sure something is show. In this case, a solid color.
int color = context.getResources().getColor(R.color.loading_error_card_background);
mLoadingErrorDrawable = new ColorDrawable(color);
}
@Override public final FooterLayoutCardView onCreateView() {
FooterLayoutCardView cardView = new FooterLayoutCardView(getContext(), mFooterLayoutd,
mImageWidth, mImageHeight);
onViewCreated(cardView);
return cardView;
}
@Override public void onBindViewHolder(Card card, FooterLayoutCardView cardView) {
// Load the card's image. This can be either an image on a remote server or a local one stored in the resources.
ImageView imageView = cardView.getImageView();
if (card.getImageURI() != null) {
Utils.loadImageFromUri(getContext(), card.getImageURI(), imageView, mImageWidth,
mImageHeight, true, mLoadingErrorDrawable);
} else if (card.getLocalImageResourceName() != null) {
int resourceId = getContext().getResources()
.getIdentifier(card.getLocalImageResourceName(),
"drawable", getContext().getPackageName());
Picasso.with(getContext()).load(resourceId).resize(mImageWidth, mImageHeight)
.centerCrop().into(imageView);
}
}
/**
* Override this method to react to creations of new card views.
*
* @param cardView The view which has been created.
* @see Presenter#onCreateViewHolder(ViewGroup)
*/
public void onViewCreated(FooterLayoutCardView cardView) {
// Nothing to clean up. Override if necessary.
}
}

View File

@@ -25,9 +25,6 @@ import java.util.HashMap;
/**
* This PresenterSelector will decide what Presenter to use depending on a given card's type.
* <p/>
* TODO: leanbackteam@ Discuss whether leanback's PresenterSelector should be renamed to
* AbstractPresenterSelector.
*/
public class CardPresenterSelector extends PresenterSelector {
@@ -38,68 +35,55 @@ public class CardPresenterSelector extends PresenterSelector {
mContext = context;
}
@Override public Presenter getPresenter(Object item) {
@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.class.getName()));
Card card = (Card) item;
Presenter presenter = presenters.get(card.getType());
if (presenter == null) switch (card.getType()) {
case SQUARE:
presenter = new SingleLineCardPresenter(mContext);
break;
case THIN_RATING:
presenter = new MovieRatingCardPresenter(mContext);
break;
case SIDE_INFO:
presenter = new SideInfoCardPresenter(mContext);
break;
case SIDE_INFO_TEST_1:
presenter = new LauncherCardPresenter(mContext);
break;
case TEXT:
presenter = new TextCardPresenter(mContext);
break;
case ICON:
presenter = new IconCardPresenter(mContext);
break;
case CHARACTER:
presenter = new CharacterCardPresenter(mContext);
break;
case THIN: {
int width = (int) mContext.getResources()
.getDimension(R.dimen.thin_image_card_width);
int height = (int) mContext.getResources()
.getDimension(R.dimen.thin_image_card_height);
presenter = new ImageCardViewPresenter1(mContext, width, height);
if (presenter == null) {
switch (card.getType()) {
case SINGLE_LINE:
presenter = new SingleLineCardPresenter(mContext);
break;
case MOVIE:
case MOVIE_BASE:
case MOVIE_COMPLETE:
case SQUARE_BIG:
case GRID_SQUARE:
case GAME: {
int style = R.style.MovieCardSimpleStyle;
if (card.getType() == Card.Type.MOVIE_BASE) {
style = R.style.MovieCardBasicStyle;
} else if (card.getType() == Card.Type.MOVIE_COMPLETE) {
style = R.style.MovieCardCompleteStyle;
} else if (card.getType() == Card.Type.SQUARE_BIG) {
style = R.style.SquareBigCard;
} else if (card.getType() == Card.Type.GRID_SQUARE) {
style = R.style.GridCardStyle;
} else if (card.getType() == Card.Type.GAME) {
style = R.style.GameCardStyle;
}
presenter = new ImageCardViewPresenter(mContext, style);
break;
}
case SIDE_INFO:
presenter = new SideInfoCardPresenter(mContext);
break;
case TEXT:
presenter = new TextCardPresenter(mContext);
break;
case ICON:
presenter = new IconCardPresenter(mContext);
break;
case CHARACTER:
presenter = new CharacterCardPresenter(mContext);
break;
default:
presenter = new ImageCardViewPresenter(mContext);
break;
}
break;
case SQUARE_BIG: {
int width = (int) mContext.getResources()
.getDimension(R.dimen.big_square_image_card_width);
int height = (int) mContext.getResources()
.getDimension(R.dimen.big_square_image_card_height);
presenter = new ImageCardViewPresenter(mContext, width, height);
}
break;
case GRID_SQUARE: {
int width = (int) mContext.getResources().getDimension(R.dimen.grid_card_width);
int height = (int) mContext.getResources().getDimension(R.dimen.grid_card_height);
presenter = new ImageCardViewPresenter(mContext, width, height);
}
break;
case WIDE_SHORT: {
presenter = new GameBannerCardPresenter(mContext);
}
break;
default: {
int width = (int) mContext.getResources()
.getDimension(R.dimen.default_image_card_width);
int height = (int) mContext.getResources()
.getDimension(R.dimen.default_image_card_height);
presenter = new ImageCardViewPresenter(mContext, width, height);
}
break;
}
presenters.put(card.getType(), presenter);
return presenter;

View File

@@ -15,73 +15,26 @@
package android.support.v17.leanback.supportleanbackshowcase.cards.presenters;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v17.leanback.supportleanbackshowcase.Constants;
import android.support.v17.leanback.supportleanbackshowcase.R;
import android.support.v17.leanback.supportleanbackshowcase.cards.CharacterCardView;
import android.support.v17.leanback.supportleanbackshowcase.cards.models.Card;
import android.support.v17.leanback.supportleanbackshowcase.cards.views.BaseCardViewEx;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import android.util.Log;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
/**
* This Presenter is used to display the characters card row in the DetailView examples.
*/
public class CharacterCardPresenter extends AbstractCardPresenter<BaseCardViewEx> {
private static final String TAG = "CharacterCardPresenter";
private final SparseArray<RoundedBitmapDrawable> mImageCache = new SparseArray<RoundedBitmapDrawable>();
public class CharacterCardPresenter extends AbstractCardPresenter<CharacterCardView> {
public CharacterCardPresenter(Context context) {
super(context);
}
@Override protected BaseCardViewEx onCreateView() {
final BaseCardViewEx cardView = new BaseCardViewEx(getContext());
LayoutInflater.from(getContext()).inflate(R.layout.character_card, cardView);
cardView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override public void onFocusChange(View v, boolean hasFocus) {
if (Constants.LOCAL_LOGD) Log.d(TAG, "onFocusChanged(" + hasFocus + ")");
ImageView mainImage = cardView.getViewById(R.id.main_image);
View container = cardView.getViewById(R.id.container);
if (hasFocus) {
container.setBackgroundResource(R.drawable.character_focused);
mainImage.setBackgroundResource(R.drawable.character_focused);
} else {
container.setBackgroundResource(R.drawable.character_not_focused_padding);
mainImage.setBackgroundResource(R.drawable.character_not_focused);
}
}
});
return cardView;
@Override
protected CharacterCardView onCreateView() {
return new CharacterCardView(getContext());
}
@Override public void onBindViewHolder(Card card, BaseCardViewEx cardView) {
if (Constants.LOCAL_LOGD) Log.d(TAG, "onBindViewHolder");
TextView primaryText = cardView.getViewById(R.id.primary_text);
final ImageView imageView = cardView.getViewById(R.id.main_image);
primaryText.setText(card.getTitle());
if (card.getLocalImageResourceName() != null) {
int resourceId = card.getLocalImageResourceId(getContext());
RoundedBitmapDrawable drawable = mImageCache.get(resourceId, null);
if (drawable == null) {
Bitmap bitmap = BitmapFactory
.decodeResource(getContext().getResources(), resourceId);
drawable = RoundedBitmapDrawableFactory.create(getContext().getResources(), bitmap);
drawable.setAntiAlias(true);
drawable.setCornerRadius(Math.max(bitmap.getWidth(), bitmap.getHeight()) / 2.0f);
mImageCache.put(resourceId, drawable);
}
imageView.setImageDrawable(drawable);
if (Constants.LOCAL_LOGD) Log.d(TAG, "Round image created and set.");
}
@Override
public void onBindViewHolder(Card card, CharacterCardView cardView) {
cardView.updateUi(card);
}
}

View File

@@ -1,44 +0,0 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package android.support.v17.leanback.supportleanbackshowcase.cards.presenters;
import android.content.Context;
import android.graphics.Color;
import android.support.v17.leanback.supportleanbackshowcase.R;
import android.support.v17.leanback.supportleanbackshowcase.cards.views.ImageCardViewReplacement;
import android.widget.TextView;
/**
* This presenter will display the cards representing a gamer banners. It inherits from {@link
* ImageCardViewPresenter} and will set a footer icon as well as a secondary text color.
*/
public class GameBannerCardPresenter extends ImageCardViewPresenter {
private static final String TAG = "GameBannerCardPresenter";
public GameBannerCardPresenter(Context context) {
super(context,
(int) context.getResources().getDimension(R.dimen.wide_short_image_card_width),
(int) context.getResources().getDimension(R.dimen.wide_short_image_card_height));
}
@Override protected ImageCardViewReplacement onCreateView() {
ImageCardViewReplacement cardView = super.onCreateView();
TextView secondaryText = cardView.getSecondaryTextView();
secondaryText.setTextColor(Color.parseColor("#80c349"));
return cardView;
}
}

View File

@@ -16,51 +16,36 @@ package android.support.v17.leanback.supportleanbackshowcase.cards.presenters;
import android.content.Context;
import android.support.v17.leanback.supportleanbackshowcase.R;
import android.support.v17.leanback.supportleanbackshowcase.cards.models.Card;
import android.support.v17.leanback.supportleanbackshowcase.cards.views.BaseCardViewEx;
import android.view.LayoutInflater;
import android.support.v17.leanback.widget.ImageCardView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
/**
* This Presenter will display cards which consists of a single icon which will be highlighted by a
* surrounding circle when the card is focused. AndroidTV uses these cards for entering settings
* menu.
*/
public class IconCardPresenter extends AbstractCardPresenter<BaseCardViewEx> {
private static final String TAG = "IconCardPresenter";
public class IconCardPresenter extends ImageCardViewPresenter {
public IconCardPresenter(Context context) {
super(context);
super(context, R.style.IconCardStyle);
}
@Override protected BaseCardViewEx onCreateView() {
final BaseCardViewEx cardView = new BaseCardViewEx(getContext());
LayoutInflater.from(getContext()).inflate(R.layout.icon_card, cardView);
LayoutInflater.from(getContext()).inflate(R.layout.icon_card_footer, cardView);
cardView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) cardView.getViewById(R.id.container)
.setBackgroundResource(R.drawable.icon_focused);
else cardView.getViewById(R.id.container).setBackground(null);
@Override
protected ImageCardView onCreateView() {
final ImageCardView imageCardView = super.onCreateView();
final ImageView image = imageCardView.getMainImageView();
imageCardView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
image.setBackgroundResource(R.drawable.icon_focused);
} else {
image.setBackground(null);
}
}
});
return cardView;
}
@Override public void onBindViewHolder(Card card, BaseCardViewEx cardView) {
TextView primaryText = cardView.getViewById(R.id.primary_text);
ImageView imageView = cardView.getViewById(R.id.main_image);
primaryText.setText(card.getTitle());
if (card.getLocalImageResourceName() != null) {
int resourceId = card.getLocalImageResourceId(getContext());
Picasso.with(getContext()).load(resourceId).into(imageView);
}
return imageCardView;
}
}

View File

@@ -15,127 +15,45 @@
package android.support.v17.leanback.supportleanbackshowcase.cards.presenters;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.support.v17.leanback.supportleanbackshowcase.Constants;
import android.support.v17.leanback.supportleanbackshowcase.R;
import android.support.v17.leanback.supportleanbackshowcase.Utils;
import android.support.v17.leanback.supportleanbackshowcase.cards.models.Card;
import android.support.v17.leanback.supportleanbackshowcase.cards.views.ImageCardViewReplacement;
import android.util.Log;
import android.view.View;
import com.squareup.picasso.Picasso;
import java.util.HashMap;
import android.support.v17.leanback.widget.ImageCardView;
/**
* A ImageCardViewPresenter is used to generate Views and bind Objects to them on demand. It
* contains an {@link ImageCardViewReplacement}.
* A very basic {@link ImageCardView} {@link android.support.v17.leanback.widget.Presenter}.You can
* pass a custom style for the ImageCardView in the constructor. Use the default constructor to
* create a Presenter with a default ImageCardView style.
*/
public class ImageCardViewPresenter extends AbstractCardPresenter<ImageCardViewReplacement> {
public class ImageCardViewPresenter extends AbstractCardPresenter<ImageCardView> {
private static final String TAG = "ImageCardViewPresenter";
private final int mImageWidthInDp;
private final int mImageHeightDp;
private final Drawable mLoadingErrorDrawable;
private final HashMap<Object, Integer> mSelectedColors = new HashMap<Object, Integer>();
private int mDefaultFooterColor;
private final int mCardStyleResId;
public ImageCardViewPresenter(Context context, int imageWidthInDp, int imageHeightInDp) {
public ImageCardViewPresenter(Context context, int cardStyleResId) {
super(context);
int color = context.getResources().getColor(R.color.loading_error_card_background);
mLoadingErrorDrawable = new ColorDrawable(color);
mDefaultFooterColor = context.getResources()
.getColor(R.color.default_card_footer_background_color);
mImageWidthInDp = imageWidthInDp;
mImageHeightDp = imageHeightInDp;
mCardStyleResId = cardStyleResId;
}
@Override protected ImageCardViewReplacement onCreateView() {
if (Constants.LOCAL_LOGD) Log.d(TAG, "onCreateView()");
final ImageCardViewReplacement cardView = new ImageCardViewReplacement(getContext(),
mImageWidthInDp,
mImageHeightDp);
cardView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override public void onFocusChange(View v, boolean hasFocus) {
udateCardUi(cardView);
}
});
return cardView;
public ImageCardViewPresenter(Context context) {
super(context);
mCardStyleResId = R.style.DefaultCardStyle;
}
@Override public void onBindViewHolder(Card card, ImageCardViewReplacement cardView) {
if (Constants.LOCAL_LOGD) Log.d(TAG, "onBindViewHolder(Card,ImageCardViewReplacement)");
@Override
protected ImageCardView onCreateView() {
return new ImageCardView(getContext(), mCardStyleResId);
}
@Override
public void onBindViewHolder(Card card, final ImageCardView cardView) {
cardView.setTag(card);
// Display description iff there is one.
if (card.getDescription() == null || card.getDescription().length() == 0) {
cardView.getSecondaryTextView().setVisibility(View.GONE);
cardView.getPrimaryTextView().setLines(2);
cardView.getPrimaryTextView().setMaxLines(2);
} else {
cardView.getPrimaryTextView().setLines(1);
cardView.getPrimaryTextView().setMaxLines(1);
cardView.getSecondaryTextView().setText(card.getDescription());
cardView.getSecondaryTextView().setVisibility(View.VISIBLE);
}
// Display title iff there is one.
if (card.getTitle() == null || card.getTitle().length() == 0) {
cardView.getPrimaryTextView().setVisibility(View.GONE);
cardView.getSecondaryTextView().setLines(2);
cardView.getSecondaryTextView().setMaxLines(2);
} else {
cardView.getSecondaryTextView().setLines(1);
cardView.getSecondaryTextView().setMaxLines(1);
cardView.getPrimaryTextView().setText(card.getTitle());
cardView.getPrimaryTextView().setVisibility(View.VISIBLE);
}
// Load main image from an URI or a local resource.
if (card.getImageURI() != null) {
Utils.loadImageFromUri(getContext(), card.getImageURI(), cardView.getImageView(),
mImageWidthInDp, mImageHeightDp, true, mLoadingErrorDrawable);
} else if (card.getLocalImageResourceName() != null) {
cardView.setTitleText(card.getTitle());
cardView.setContentText(card.getDescription());
if (card.getLocalImageResourceName() != null) {
int resourceId = getContext().getResources()
.getIdentifier(card.getLocalImageResourceName(),
"drawable", getContext().getPackageName());
Picasso.with(getContext()).load(resourceId).resize(mImageWidthInDp, mImageHeightDp)
.centerCrop().into(cardView.getImageView());
.getIdentifier(card.getLocalImageResourceName(),
"drawable", getContext().getPackageName());
cardView.getMainImageView().setImageResource(resourceId);
}
// Load footer icon from a local resource or hide it.
cardView.getViewById(R.id.container).setVisibility(View.VISIBLE);
if (card.getFooterLocalImageResourceName() != null) {
int resourceId = getContext().getResources()
.getIdentifier(card.getFooterLocalImageResourceName(),
"drawable", getContext().getPackageName());
Picasso.with(getContext()).load(resourceId).into(cardView.getIconView());
cardView.getIconView().setVisibility(View.VISIBLE);
} else {
if (card.getDescription() == null || card.getDescription().isEmpty()) {
cardView.getViewById(R.id.container).setVisibility(View.GONE);
}
cardView.getIconView().setVisibility(View.GONE);
}
// Update background color depending on the card's focused state.
udateCardUi(cardView);
}
private void udateCardUi(ImageCardViewReplacement view) {
int color = mDefaultFooterColor;
if (view.getTag() != null) {
Card card = (Card) view.getTag();
if (card.getSelectedColor() != -1 && view.isSelected()) {
color = card.getSelectedColor();
}
if (card.getFooterColor() != -1) {
color = card.getFooterColor();
}
}
view.getInfoBoxView().setBackgroundColor(color);
}
}

View File

@@ -1,64 +0,0 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package android.support.v17.leanback.supportleanbackshowcase.cards.presenters;
import android.content.Context;
import android.support.v17.leanback.supportleanbackshowcase.Constants;
import android.support.v17.leanback.supportleanbackshowcase.R;
import android.support.v17.leanback.supportleanbackshowcase.cards.models.Card;
import android.support.v17.leanback.supportleanbackshowcase.cards.views.ImageCardViewReplacement;
import android.support.v17.leanback.widget.ImageCardView;
import android.util.Log;
/**
* A ImageCardViewPresenter is used to generate Views and bind Objects to them on demand. It
* contains an {@link ImageCardViewReplacement}.
*/
public class ImageCardViewPresenter1 extends AbstractCardPresenter<ImageCardView> {
private static final String TAG = "ImageCardViewPresenter";
private final int mImageWidthInDp;
private final int mImageHeightDp;
public ImageCardViewPresenter1(Context context, int imageWidthInDp, int imageHeightInDp) {
super(context);
mImageWidthInDp = imageWidthInDp;
mImageHeightDp = imageHeightInDp;
}
@Override protected ImageCardView onCreateView() {
if (Constants.LOCAL_LOGD) Log.d(TAG, "onCreateView()");
final ImageCardView cardView = new ImageCardView(getContext(), R.style.ImageCardViewColoredTextStyle);
cardView.setMainImageDimensions(mImageWidthInDp, mImageHeightDp);
cardView.setFocusable(true);
return cardView;
}
@Override public void onBindViewHolder(Card card, final ImageCardView cardView) {
if (Constants.LOCAL_LOGD) Log.d(TAG, "onBindViewHolder(Card,ImageCardViewReplacement)");
cardView.setTag(card);
cardView.setTitleText(card.getTitle());
//cardView.setContentText("Hello");
if (card.getLocalImageResourceName() != null) {
int resourceId = getContext().getResources()
.getIdentifier(card.getLocalImageResourceName(),
"drawable", getContext().getPackageName());
cardView.getMainImageView().setImageResource(resourceId);
}
}
}

View File

@@ -1,97 +0,0 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package android.support.v17.leanback.supportleanbackshowcase.cards.presenters;
import android.animation.ValueAnimator;
import android.content.Context;
import android.support.v17.leanback.supportleanbackshowcase.R;
import android.support.v17.leanback.supportleanbackshowcase.Utils;
import android.support.v17.leanback.supportleanbackshowcase.cards.models.Card;
import android.support.v17.leanback.supportleanbackshowcase.cards.views.ImageCardViewReplacement;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.ImageView;
import com.squareup.picasso.Picasso;
/**
* THis Presenter displays an expandable card which is used e.g. in the AndroidTV launcher. Once
* such a card gets focused it expands and will show more details of the image.
*/
public class LauncherCardPresenter extends ImageCardViewPresenter {
private static final String TAG = "LauncherCardPresenter";
public LauncherCardPresenter(Context context) {
super(context, 1 /* val > 0 required by Picasso */,
(int) context.getResources().getDimension(R.dimen.default_image_card_height));
}
@Override protected ImageCardViewReplacement onCreateView() {
ImageCardViewReplacement cardView = super.onCreateView();
final ImageView imageView = cardView.getImageView();
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
cardView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override public void onFocusChange(View v, final boolean hasFocus) {
int expandedWidth = (int) getContext().getResources().getDimension(
R.dimen.default_image_card_width);
int collapsedWidth = (int) getContext().getResources().getDimension(
R.dimen.default_image_card_height);
expandedWidth = collapsedWidth;
ValueAnimator animator = new ValueAnimator();
animator.setInterpolator(new AccelerateDecelerateInterpolator());
animator.setIntValues(hasFocus ? collapsedWidth : expandedWidth,
hasFocus ? expandedWidth : collapsedWidth);
animator.setDuration(500);
animator.setStartDelay(0);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override public void onAnimationUpdate(ValueAnimator animation) {
ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams();
layoutParams.width = (Integer) animation.getAnimatedValue();
imageView.setLayoutParams(layoutParams);
}
});
animator.start();
}
});
return cardView;
}
@Override public void onBindViewHolder(Card card, ImageCardViewReplacement cardView) {
super.onBindViewHolder(card, cardView);
ImageView imageView = cardView.getImageView();
cardView.setTag(card);
int width = (int) getContext().getResources()
.getDimension(R.dimen.default_image_card_height);
ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams();
layoutParams.width = Utils.convertDpToPixel(getContext(), width);
imageView.setLayoutParams(layoutParams);
if (card.getLocalImageResourceName() != null) {
int height = (int) getContext().getResources()
.getDimension(R.dimen.sidetext_image_card_height);
int resourceId = getContext().getResources()
.getIdentifier(card.getLocalImageResourceName(),
"drawable", getContext().getPackageName());
Picasso.with(getContext()).load(resourceId).into(imageView);
}
}
}

View File

@@ -1,42 +0,0 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package android.support.v17.leanback.supportleanbackshowcase.cards.presenters;
import android.content.Context;
import android.support.v17.leanback.supportleanbackshowcase.R;
import android.support.v17.leanback.supportleanbackshowcase.cards.models.Card;
import android.support.v17.leanback.supportleanbackshowcase.cards.views.ImageCardViewReplacement;
import android.view.Gravity;
/**
* This Presenter inherits from ImageCardViewPresenter and will set the secondary text alignment as
* well as a footer icon to display the movie's rating.
*/
public class MovieRatingCardPresenter extends ImageCardViewPresenter {
private static final String TAG = "MovieRatingCardPresenter";
public MovieRatingCardPresenter(Context context) {
super(context, (int) context.getResources().getDimension(R.dimen.thin_image_card_width),
(int) context.getResources().getDimension(R.dimen.thin_image_card_height));
}
@Override public void onBindViewHolder(Card card, ImageCardViewReplacement cardView) {
super.onBindViewHolder(card, cardView);
cardView.getPrimaryTextView().setLines(2);
cardView.getPrimaryTextView().setMaxLines(2);
cardView.getSecondaryTextView().setGravity(Gravity.RIGHT);
}
}

View File

@@ -17,8 +17,6 @@ package android.support.v17.leanback.supportleanbackshowcase.cards.presenters;
import android.content.Context;
import android.support.v17.leanback.supportleanbackshowcase.R;
import android.support.v17.leanback.supportleanbackshowcase.cards.models.Card;
import android.support.v17.leanback.supportleanbackshowcase.cards.views.BaseCardViewEx;
import android.support.v17.leanback.supportleanbackshowcase.cards.views.OnActivateStateChangeHandler;
import android.support.v17.leanback.widget.BaseCardView;
import android.view.LayoutInflater;
import android.view.View;
@@ -33,49 +31,55 @@ import com.squareup.picasso.Picasso;
* box, thus it will be hidden if the parent row is inactive. This behavior is unique to this card
* and requires a special focus handler.
*/
public class SideInfoCardPresenter extends AbstractCardPresenter<BaseCardViewEx> implements
OnActivateStateChangeHandler {
private static final String TAG = "SideInfoCardPresenter";
public class SideInfoCardPresenter extends AbstractCardPresenter<BaseCardView> {
public SideInfoCardPresenter(Context context) {
super(context);
}
@Override protected BaseCardViewEx onCreateView() {
BaseCardViewEx cardView = new BaseCardViewEx(getContext());
@Override
protected BaseCardView onCreateView() {
final BaseCardView cardView = new BaseCardView(getContext()) {
@Override
public void setActivated(boolean activated) {
super.setActivated(activated);
onActivateStateChanged(this, activated);
}
};
cardView.setFocusable(true);
cardView.setCardType(BaseCardView.CARD_TYPE_MAIN_ONLY);
cardView.addView(LayoutInflater.from(getContext()).inflate(R.layout.side_info_card, null));
cardView.setOnActivateStateChangeHandler(this);
onActivateStateChanged(cardView, cardView.isActivated());
return cardView;
}
@Override public void onBindViewHolder(Card card, BaseCardViewEx cardView) {
ImageView imageView = cardView.getViewById(R.id.main_image);
@Override
public void onBindViewHolder(Card card, BaseCardView cardView) {
ImageView imageView = (ImageView) cardView.findViewById(R.id.main_image);
if (card.getLocalImageResourceName() != null) {
int width = (int) getContext().getResources()
.getDimension(R.dimen.sidetext_image_card_width);
.getDimension(R.dimen.sidetext_image_card_width);
int height = (int) getContext().getResources()
.getDimension(R.dimen.sidetext_image_card_height);
.getDimension(R.dimen.sidetext_image_card_height);
int resourceId = getContext().getResources()
.getIdentifier(card.getLocalImageResourceName(),
"drawable", getContext().getPackageName());
.getIdentifier(card.getLocalImageResourceName(),
"drawable", getContext().getPackageName());
Picasso.with(getContext()).load(resourceId).resize(width, height).centerCrop()
.into(imageView);
.into(imageView);
}
TextView primaryText = cardView.getViewById(R.id.primary_text);
TextView primaryText = (TextView) cardView.findViewById(R.id.primary_text);
primaryText.setText(card.getTitle());
TextView secondaryText = cardView.getViewById(R.id.secondary_text);
TextView secondaryText = (TextView) cardView.findViewById(R.id.secondary_text);
secondaryText.setText(card.getDescription());
TextView extraText = cardView.getViewById(R.id.extra_text);
TextView extraText = (TextView) cardView.findViewById(R.id.extra_text);
extraText.setText(card.getExtraText());
}
@Override public void onActivateStateChanged(final BaseCardViewEx cardView, boolean activated) {
cardView.getViewById(R.id.info).setVisibility(activated ? View.VISIBLE : View.GONE);
public void onActivateStateChanged(final BaseCardView cardView, boolean activated) {
cardView.findViewById(R.id.info).setVisibility(activated ? View.VISIBLE : View.GONE);
}
}

View File

@@ -17,44 +17,22 @@ package android.support.v17.leanback.supportleanbackshowcase.cards.presenters;
import android.content.Context;
import android.support.v17.leanback.supportleanbackshowcase.R;
import android.support.v17.leanback.supportleanbackshowcase.cards.models.Card;
import android.support.v17.leanback.supportleanbackshowcase.cards.views.BaseCardViewEx;
import android.support.v17.leanback.widget.BaseCardView;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.TextView;
import android.support.v17.leanback.widget.ImageCardView;
/**
* This Presenter will display a card which consists of a big image followed by a colored footer.
* Not only the colored footer is unique to this card, but also it's footer (info) will be visible
* even when its parent row is inactive.
*/
public class SingleLineCardPresenter extends AbstractCardPresenter<BaseCardViewEx> {
private static final String TAG = "SingleLineCardPresenter";
public class SingleLineCardPresenter extends ImageCardViewPresenter {
public SingleLineCardPresenter(Context context) {
super(context);
super(context, R.style.SingleLineCardStyle);
}
@Override protected BaseCardViewEx onCreateView() {
BaseCardViewEx cardView = new BaseCardViewEx(getContext());
cardView.setCardType(BaseCardView.CARD_TYPE_MAIN_ONLY);
cardView.addView(
LayoutInflater.from(getContext()).inflate(R.layout.single_line_card_footer, null));
return cardView;
}
@Override public void onBindViewHolder(Card card, BaseCardViewEx cardView) {
TextView primaryText = cardView.getViewById(R.id.primary_text);
primaryText.setText(card.getTitle());
int resourceId = getContext().getResources()
.getIdentifier(card.getLocalImageResourceName(), "drawable",
getContext().getPackageName());
ImageView mainImage = cardView.getViewById(R.id.main_image);
mainImage.setImageResource(resourceId);
cardView.getViewById(R.id.container).setBackgroundColor(card.getFooterColor());
@Override public void onBindViewHolder(Card card, ImageCardView cardView) {
super.onBindViewHolder(card, cardView);
cardView.setInfoAreaBackgroundColor(card.getFooterColor());
}
}

View File

@@ -1,44 +0,0 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
*/
package android.support.v17.leanback.supportleanbackshowcase.cards.presenters;
import android.support.v17.leanback.supportleanbackshowcase.R;
import android.support.v17.leanback.widget.Presenter;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.TextView;
public class StringPresenter extends Presenter {
private static final String TAG = "StringPresenter";
public ViewHolder onCreateViewHolder(ViewGroup parent) {
Log.d(TAG, "onCreateViewHolder");
TextView tv = new TextView(parent.getContext());
tv.setFocusable(true);
tv.setFocusableInTouchMode(true);
tv.setBackground(parent.getContext().getResources().getDrawable(R.drawable.icon_focused));
return new ViewHolder(tv);
}
public void onBindViewHolder(ViewHolder viewHolder, Object item) {
Log.d(TAG, "onBindViewHolder for " + item.toString());
((TextView) viewHolder.view).setText(item.toString());
}
public void onUnbindViewHolder(ViewHolder viewHolder) {
Log.d(TAG, "onUnbindViewHolder");
}
}

View File

@@ -15,74 +15,27 @@
package android.support.v17.leanback.supportleanbackshowcase.cards.presenters;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.support.v17.leanback.supportleanbackshowcase.R;
import android.support.v17.leanback.supportleanbackshowcase.cards.TextCardView;
import android.support.v17.leanback.supportleanbackshowcase.cards.models.Card;
import android.support.v17.leanback.supportleanbackshowcase.cards.views.BaseCardViewEx;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Target;
/**
* The Presenter displays a card consisting of text as a replacement for a big image. The footer is
* also quite unique since it does contain two images rather than one or non.
*/
public class TextCardPresenter extends AbstractCardPresenter<BaseCardViewEx> {
private static final String TAG = "AbstractFooterCardPresenter";
public class TextCardPresenter extends AbstractCardPresenter<TextCardView> {
public TextCardPresenter(Context context) {
super(context);
}
@Override protected BaseCardViewEx onCreateView() {
BaseCardViewEx cardView = new BaseCardViewEx(getContext());
LayoutInflater.from(getContext()).inflate(R.layout.text_icon_card, cardView);
LayoutInflater.from(getContext()).inflate(R.layout.text_icon_card_footer, cardView);
return cardView;
@Override
protected TextCardView onCreateView() {
return new TextCardView(getContext());
}
@Override public void onBindViewHolder(Card card, BaseCardViewEx cardView) {
TextView extraText = cardView.getViewById(R.id.extra_text);
TextView primaryText = cardView.getViewById(R.id.primary_text);
ImageView footerIcon = cardView.getViewById(R.id.footer_icon);
final ImageView imageView = cardView.getViewById(R.id.main_image);
extraText.setText(card.getExtraText());
primaryText.setText(card.getTitle());
if (card.getLocalImageResourceName() != null) {
int width = (int) getContext().getResources()
.getDimension(R.dimen.sidetext_image_card_width);
int height = (int) getContext().getResources()
.getDimension(R.dimen.sidetext_image_card_height);
int resourceId = card.getLocalImageResourceId(getContext());
// TODO: hahnr@ load the image without Picasso
Picasso.with(getContext()).load(resourceId).resize(width, height).centerCrop()
.into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory
.create(getContext().getResources(), bitmap);
drawable.setCornerRadius(
Math.max(bitmap.getWidth(), bitmap.getHeight()) / 2.0f);
imageView.setImageDrawable(drawable);
}
@Override public void onBitmapFailed(Drawable errorDrawable) {
}
@Override public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
}
footerIcon.setImageResource(R.drawable.stars_white);
@Override
public void onBindViewHolder(Card card, TextCardView cardView) {
cardView.updateUi(card);
}
}

View File

@@ -1,54 +0,0 @@
/*
* Copyright (c) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
package android.support.v17.leanback.supportleanbackshowcase.cards.views;
import android.content.Context;
import android.support.v17.leanback.supportleanbackshowcase.ResourceCache;
import android.support.v17.leanback.widget.BaseCardView;
import android.view.View;
/**
* This class is an extension for the BaseCardView which is focusable by default. This behavior has
* to be merged into the original BaseCardView at some point in the development. After merging those
* two classes, this one, the BaseCardViewEx, can be removed.
*/
public class BaseCardViewEx extends BaseCardView {
protected Context mContext;
private ResourceCache mResourceCache = new ResourceCache();
private OnActivateStateChangeHandler mActivationCallback;
public BaseCardViewEx(Context context) {
super(context);
mContext = context;
setCardType(BaseCardView.CARD_TYPE_INFO_UNDER);
// TODO: @hahnr BaseCardView should be focusable by default. Merge!
setFocusable(true);
setFocusableInTouchMode(true);
}
@Override public void setActivated(boolean activated) {
super.setActivated(activated);
if (mActivationCallback != null)
mActivationCallback.onActivateStateChanged(this, activated);
}
public void setOnActivateStateChangeHandler(OnActivateStateChangeHandler handler) {
mActivationCallback = handler;
}
public <ViewType extends View> ViewType getViewById(int resId) {
return mResourceCache.getViewById(this, resId);
}
}

View File

@@ -1,70 +0,0 @@
/*
* Copyright (c) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
package android.support.v17.leanback.supportleanbackshowcase.cards.views;
import android.content.Context;
import android.support.v17.leanback.supportleanbackshowcase.R;
import android.view.LayoutInflater;
import android.widget.ImageView;
/**
* The FooterLayoutCardView creates a card view consisting of a big image followed by a footer
* passed as a layout resource.
*/
public class FooterLayoutCardView extends BaseCardViewEx {
private final ImageView mImageView;
/**
* The footer passed as a layout resource id will be inflated and added automatically to this
* view.
* <p/>
* <u>Note:</u> If you want your footer to expand/collapse when its parent row is
* activated/deactivated, you have to add the <code>layout_viewType="info"</code> property to
* your footers root view.
* <p/>
* <u>Example footer layout:</u>
* <pre>{@code <?xml version="1.0" encoding="utf-8"?>
* <FrameLayout
* xmlns:android="http://schemas.android.com/apk/res/android"
* xmlns:lb="http://schemas.android.com/apk/res-auto"
* lb:layout_viewType="info"
* android:layout_width="match_parent"
* android:layout_height="match_parent">
* <TextView
* android:id="@+id/primary_text"
* android:layout_width="match_parent"
* android:layout_height="wrap_content"/>
* </FrameLayout>}</pre>
*
* @param context The current context.
* @param layoutId The footers layout resource id.
* @param imageWidthInDp The width of the ImageView used in this card. The card's width always
* equals the image's width.
* @param imageHeightInDp The height of the ImageView used in this card.
* @see android.support.v17.leanback.widget.BaseCardView.LayoutParams
*/
public FooterLayoutCardView(Context context, int layoutId, int imageWidthInDp,
int imageHeightInDp) {
super(context);
setCardType(CARD_TYPE_INFO_UNDER);
setBackgroundColor(context.getResources().getColor(R.color.default_card_background_color));
LayoutInflater.from(context).inflate(R.layout.image_card, this);
mImageView = getViewById(R.id.image_card_view_main_image);
LayoutInflater.from(context).inflate(layoutId, this);
}
public ImageView getImageView() {
return mImageView;
}
}

View File

@@ -1,63 +0,0 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
*/
package android.support.v17.leanback.supportleanbackshowcase.cards.views;
import android.content.Context;
import android.support.v17.leanback.supportleanbackshowcase.R;
import android.support.v17.leanback.widget.ImageCardView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
/**
* Leanback's {@link ImageCardView} will need some layout changes to fit all design requirements
* from the specs. This class is a temporary implementation of the "new" {@link ImageCardView} and
* will replace the existing one at some point in the development process. The original
* implementation also requires some refactoring to be more flexible in order to be used for various
* card types.
* <p/>
* Besides from the refactoring of the ImageCardView I suggest to change not only the BaseCardView
* but also to add at least one additional CardView, the "FooterLayoutCardView". More about this
* topic can be discussed later in the development process.
*/
public class ImageCardViewReplacement extends FooterLayoutCardView {
public static final int PRIMARY_TEXTVIEW_ID = R.id.primary_text;
public static final int SECONDARY_TEXTVIEW_ID = R.id.secondary_text;
public static final int FOOTER_ICON_ID = R.id.footer_icon;
public static final int INFO_BOX_ID = R.id.info_field;
public ImageCardViewReplacement(Context context, int widthInDp, int heightInDp) {
super(context, R.layout.image_card_footer, widthInDp, heightInDp);
setBackgroundColor(context.getResources().getColor(R.color.default_card_background_color));
}
public TextView getPrimaryTextView() {
return getViewById(PRIMARY_TEXTVIEW_ID);
}
public TextView getSecondaryTextView() {
return getViewById(SECONDARY_TEXTVIEW_ID);
}
public ImageView getIconView() {
return getViewById(FOOTER_ICON_ID);
}
public View getInfoBoxView() {
return getViewById(INFO_BOX_ID);
}
}

View File

@@ -1,17 +0,0 @@
/*
* Copyright (c) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
package android.support.v17.leanback.supportleanbackshowcase.cards.views;
public interface OnActivateStateChangeHandler {
void onActivateStateChanged(BaseCardViewEx cardView, boolean activated);
}

View File

@@ -1,7 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp"></padding>
<padding
android:bottom="4dp"
android:left="4dp"
android:right="4dp"
android:top="4dp"></padding>
<solid android:color="#FFEEEEEE"></solid>
</shape>

View File

@@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">

View File

@@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">

View File

@@ -1,9 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="@color/background_gradient_start"
android:endColor="@color/background_gradient_end"
android:angle="-270" />
android:angle="-270"
android:endColor="@color/background_gradient_end"
android:startColor="@color/background_gradient_start"/>
</shape>

View File

@@ -1,7 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#4DEEEEEE"></solid>
<size
android:width="96dp"

View File

@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/icon_not_focused"></item>
<item android:drawable="@drawable/icon_focused" android:state_focused="true"></item>
</selector>

View File

@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software distributed under the License
~ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
~ or implied. See the License for the specific language governing permissions and limitations under
~ the License.
~
-->
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#00EEEEEE"></solid>
</shape>

View File

@@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#E6000000"></solid>
</shape>

View File

@@ -1,6 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="@drawable/song_row_background_focused"></item>
<item android:drawable="@drawable/song_row_background_focused" android:state_focused="true"></item>
<item>
<color android:color="#384248"></color>
</item>

View File

@@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="#384248"></color>

View File

@@ -1,5 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/background_canyon"></item>
<item android:drawable="@drawable/overlay_black"></item>
<item android:drawable="@drawable/background_canyon"></item>
<item android:drawable="@drawable/overlay_black"></item>
</layer-list>

View File

@@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/wizard_important_action_item_background_focused" android:state_focused="true"></item>
<item android:drawable="@drawable/wizard_important_action_item_background_not_focused"></item>

View File

@@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

View File

@@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/detailsFragment"
android:name="android.support.v17.leanback.supportleanbackshowcase.DetailViewExampleFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"></fragment>
</RelativeLayout>

View File

@@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<RelativeLayout
android:id="@+id/fragmentContainer"
xmlns:android="http://schemas.android.com/apk/res/android"

View File

@@ -1,8 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/settingsFragment"
android:name="android.support.v17.leanback.supportleanbackshowcase.SettingsExampleFragment"

View File

@@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lb="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
@@ -26,7 +41,7 @@
<TextView
android:id="@+id/primary_text"
style="@style/StandardCardPrimaryText"
style="@style/Widget.Leanback.ImageCardView.TitleStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"

View File

@@ -1,5 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lb="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
lb:layout_viewType="main">
<LinearLayout
android:id="@+id/container"
android:layout_width="96dp"
android:layout_height="96dp"
android:background="@drawable/icon_focused_selector"
android:orientation="vertical">
<ImageView
android:id="@+id/main_image"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"/>
</LinearLayout>
</FrameLayout>

View File

@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lb="http://schemas.android.com/apk/res-auto"
lb:layout_viewType="info"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/primary_text"
style="@style/StandardCardPrimaryText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="sans-serif-condensed"
android:gravity="center"
android:lines="2"
android:maxLines="2"
/>
</FrameLayout>

View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lb="http://schemas.android.com/apk/res-auto"
lb:layout_viewType="main"
android:layout_width="match_parent"
android:id="@+id/image_card_view_main_image"
android:layout_height="match_parent">
</ImageView>

View File

@@ -1,53 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lb="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/default_card_footer_background_color"
lb:layout_viewType="info">
<RelativeLayout
android:id="@+id/info_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="7dp"
android:paddingLeft="11dp"
android:paddingRight="11dp"
android:paddingTop="7dp">
<TextView
android:id="@+id/primary_text"
style="@style/StandardCardPrimaryText"
android:layout_width="match_parent"
android:fontFamily="sans-serif-condensed"
android:maxLines="1"/>
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="16sp"
android:layout_below="@+id/primary_text"
android:layout_gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/footer_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="8dp"
android:gravity="center_vertical"
android:src="@drawable/category_drama"/>
<TextView
android:id="@+id/secondary_text"
style="@style/StandardCardSecondaryText"
android:layout_gravity="center_vertical"
android:fontFamily="sans-serif-condensed"
android:maxLines="1"
android:text="Purchased"
/>
</LinearLayout>
</RelativeLayout>
</FrameLayout>

View File

@@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lb="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"

View File

@@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lb="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"

View File

@@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lb="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
@@ -29,14 +44,14 @@
<TextView
android:id="@+id/primary_text"
style="@style/StandardCardPrimaryText"
style="@style/Widget.Leanback.ImageCardView.TitleStyle"
android:fontFamily="sans-serif-condensed"
android:maxLines="2"
android:textSize="16sp"/>
<TextView
android:id="@+id/secondary_text"
style="@style/StandardCardSecondaryText"
style="@style/Widget.Leanback.ImageCardView.ContentStyle"
android:layout_marginTop="4dp"
android:fontFamily="sans-serif-condensed"
android:maxLines="1"
@@ -44,7 +59,7 @@
<TextView
android:id="@+id/extra_text"
style="@style/StandardCardSecondaryText"
style="@style/Widget.Leanback.ImageCardView.ContentStyle"
android:layout_marginTop="6dp"
android:fontFamily="sans-serif-condensed"
android:maxLines="5"/>

View File

@@ -1,33 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/default_card_footer_background_color">
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical"
android:paddingLeft="11dp"
android:paddingRight="11dp"
android:paddingTop="7dp">
<ImageView
android:id="@+id/main_image"
android:layout_width="@dimen/square_image_card_width"
android:layout_height="@dimen/square_image_card_height"/>
<TextView
android:id="@+id/primary_text"
style="@style/StandardCardPrimaryText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-condensed"
android:gravity="center"
android:maxLines="2"
android:paddingBottom="7dp"
android:paddingTop="7dp"/>
</LinearLayout>
</FrameLayout>

View File

@@ -1,29 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lb="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/default_card_footer_background_color"
lb:layout_viewType="main">
<!--
Copyright (C) 2015 The Android Open Source Project
<LinearLayout
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lb="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/extra_text"
style="@style/Widget.Leanback.ImageCardView.ContentStyle"
android:layout_width="256dp"
android:layout_height="wrap_content"
android:background="@color/default_card_background_color"
android:orientation="vertical">
android:fontFamily="sans-serif-condensed"
android:lines="7"
android:maxLines="7"
android:paddingBottom="14dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="12dp"
lb:layout_viewType="main"/>
<android.support.v17.leanback.widget.NonOverlappingRelativeLayout
android:layout_width="256dp"
android:layout_height="36dp"
android:background="@color/default_card_footer_background_color"
android:gravity="left"
android:orientation="horizontal"
android:paddingBottom="7dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="7dp">
<ImageView
android:id="@+id/main_image"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:layout_marginRight="8dp"
android:adjustViewBounds="true"/>
<TextView
android:id="@+id/extra_text"
style="@style/StandardCardSecondaryText"
android:id="@+id/primary_text"
style="@style/Widget.Leanback.ImageCardView.TitleStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="left"
android:layout_toRightOf="@+id/main_image"
android:fontFamily="sans-serif-condensed"
android:lines="7"
android:maxLines="7"
android:paddingBottom="14dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="12dp"/>
android:maxLines="1"
/>
</LinearLayout>
</FrameLayout>
<ImageView
android:id="@+id/footer_icon"
android:layout_width="wrap_content"
android:layout_height="32dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:adjustViewBounds="true"
android:src="@drawable/stars_white"/>
</android.support.v17.leanback.widget.NonOverlappingRelativeLayout>
</merge>

View File

@@ -1,56 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lb="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
lb:layout_viewType="info">
<LinearLayout
android:layout_width="256dp"
android:layout_height="wrap_content"
android:layout_below="@+id/primary_text"
android:background="@color/default_card_footer_background_color"
android:gravity="left"
android:orientation="horizontal"
android:paddingBottom="7dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="7dp">
<ImageView
android:id="@+id/main_image"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="8dp"
android:adjustViewBounds="true"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="32dp"
android:orientation="vertical">
<TextView
android:id="@+id/primary_text"
style="@style/StandardCardPrimaryText"
android:layout_width="match_parent"
android:layout_gravity="left"
android:layout_marginTop="1dp"
android:fontFamily="sans-serif-condensed"
android:maxLines="1"
/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="16sp">
<ImageView
android:id="@+id/footer_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>

View File

@@ -1,6 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<SurfaceView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</SurfaceView>

View File

@@ -3,55 +3,55 @@
"title": "Standard",
"cards": [
{
"type": "THIN",
"title": "The Amazing Spuder-Man",
"type": "MOVIE",
"title": "The Amazing Spider-Man",
"description": "$3.99",
"localImageResource": "card_image_movie_01"
},
{
"type": "THIN",
"type": "MOVIE",
"title": "American Psycho",
"description": "$3.99",
"localImageResource": "card_image_movie_02"
},
{
"type": "THIN",
"type": "MOVIE",
"title": "Big Hero 6",
"description": "$3.99",
"localImageResource": "card_image_movie_03"
},
{
"type": "THIN",
"type": "MOVIE",
"title": "Edge of Tomorrow",
"description": "$3.99",
"localImageResource": "card_image_movie_04"
},
{
"type": "THIN",
"type": "MOVIE",
"title": "The Hobbit: The Desolation of Smaug",
"description": "$3.99",
"localImageResource": "card_image_movie_05"
},
{
"type": "THIN",
"type": "MOVIE",
"title": "Interstellar",
"description": "$3.99",
"localImageResource": "card_image_movie_06"
},
{
"type": "THIN",
"type": "MOVIE",
"title": "Jurassic Park",
"description": "$3.99",
"localImageResource": "card_image_movie_07"
},
{
"type": "THIN",
"type": "MOVIE",
"title": "The Hunger Games: Mockingjay Part I",
"description": "$3.99",
"localImageResource": "card_image_movie_08"
},
{
"type": "THIN",
"type": "MOVIE",
"title": "Planes",
"description": "$3.99",
"localImageResource": "card_image_movie_09"
@@ -62,47 +62,47 @@
"title": "Two Line Title",
"cards": [
{
"type": "THIN_RATING",
"title": "The Amazing Spuder-Man",
"type": "MOVIE_BASE",
"title": "The Amazing Spider-Man",
"localImageResource": "card_image_movie_01"
},
{
"type": "THIN_RATING",
"type": "MOVIE_BASE",
"title": "American Psycho",
"localImageResource": "card_image_movie_02"
},
{
"type": "THIN_RATING",
"type": "MOVIE_BASE",
"title": "Big Hero 6",
"localImageResource": "card_image_movie_03"
},
{
"type": "THIN_RATING",
"type": "MOVIE_BASE",
"title": "Edge of Tomorrow",
"localImageResource": "card_image_movie_04"
},
{
"type": "THIN_RATING",
"type": "MOVIE_BASE",
"title": "The Hobbit: The Desolation of Smaug",
"localImageResource": "card_image_movie_05"
},
{
"type": "THIN_RATING",
"type": "MOVIE_BASE",
"title": "Interstellar",
"localImageResource": "card_image_movie_06"
},
{
"type": "THIN_RATING",
"type": "MOVIE_BASE",
"title": "Jurassic Park",
"localImageResource": "card_image_movie_07"
},
{
"type": "THIN_RATING",
"type": "MOVIE_BASE",
"title": "The Hunger Games: Mockingjay Part I",
"localImageResource": "card_image_movie_08"
},
{
"type": "THIN_RATING",
"type": "MOVIE_BASE",
"title": "Planes",
"localImageResource": "card_image_movie_09"
}
@@ -112,63 +112,63 @@
"title": "Two Line Title + Icon",
"cards": [
{
"type": "THIN_RATING",
"type": "MOVIE_COMPLETE",
"description": "$3.99",
"title": "The Amazing Spider-Man",
"footerIconLocalImageResource": "stars_red",
"localImageResource": "card_image_movie_01"
},
{
"type": "THIN_RATING",
"type": "MOVIE_COMPLETE",
"title": "American Psycho",
"description": "$3.99",
"footerIconLocalImageResource": "stars_red",
"localImageResource": "card_image_movie_02"
},
{
"type": "THIN_RATING",
"type": "MOVIE_COMPLETE",
"title": "Big Hero 6",
"description": "$3.99",
"footerIconLocalImageResource": "stars_red",
"localImageResource": "card_image_movie_03"
},
{
"type": "THIN_RATING",
"type": "MOVIE_COMPLETE",
"title": "Edge of Tomorrow",
"description": "$3.99",
"footerIconLocalImageResource": "stars_red",
"localImageResource": "card_image_movie_04"
},
{
"type": "THIN_RATING",
"type": "MOVIE_COMPLETE",
"title": "The Hobbit: The Desolation of Smaug",
"description": "$3.99",
"footerIconLocalImageResource": "stars_red",
"localImageResource": "card_image_movie_05"
},
{
"type": "THIN_RATING",
"type": "MOVIE_COMPLETE",
"title": "Interstellar",
"description": "$3.99",
"footerIconLocalImageResource": "stars_red",
"localImageResource": "card_image_movie_06"
},
{
"type": "THIN_RATING",
"type": "MOVIE_COMPLETE",
"title": "Jurassic Park",
"description": "$3.99",
"footerIconLocalImageResource": "stars_red",
"localImageResource": "card_image_movie_07"
},
{
"type": "THIN_RATING",
"type": "MOVIE_COMPLETE",
"description": "$3.99",
"title": "The Hunger Games: Mockingjay Part I",
"footerIconLocalImageResource": "stars_red",
"localImageResource": "card_image_movie_08"
},
{
"type": "THIN_RATING",
"type": "MOVIE_COMPLETE",
"title": "Planes",
"description": "$3.99",
"footerIconLocalImageResource": "stars_red",
@@ -288,35 +288,35 @@
"title": "Wide (Games)",
"cards": [
{
"type": "WIDE_SHORT",
"type": "GAME",
"title": "Angry Birds",
"description": "Purchased",
"localImageResource": "game_angry_bird_w",
"footerIconLocalImageResource": "ic_installed"
},
{
"type": "WIDE_SHORT",
"type": "GAME",
"title": "Badland",
"description": "Purchased",
"localImageResource": "game_badland_w",
"footerIconLocalImageResource": "ic_installed"
},
{
"type": "WIDE_SHORT",
"type": "GAME",
"title": "Leo's Fortune",
"description": "Purchased",
"localImageResource": "game_leos_fortune_w",
"footerIconLocalImageResource": "ic_installed"
},
{
"type": "WIDE_SHORT",
"type": "GAME",
"title": "Minion Rush",
"description": "Purchased",
"localImageResource": "game_minion_rush_w",
"footerIconLocalImageResource": "ic_installed"
},
{
"type": "WIDE_SHORT",
"type": "GAME",
"title": "Monument Valley",
"description": "Purchased",
"localImageResource": "game_monument_valley_w",
@@ -430,100 +430,47 @@
}
]
},
{
"title": "Launcher",
"cards": [
{
"type": "SIDE_INFO_TEST_1",
"title": "Harry Potter",
"description": "$3.99",
"localImageResource": "coffee_and_tea_01"
},
{
"type": "SIDE_INFO_TEST_1",
"title": "Harry Potter",
"description": "$3.99",
"localImageResource": "coffee_and_tea_02"
},
{
"type": "SIDE_INFO_TEST_1",
"title": "Harry Potter",
"description": "$3.99",
"localImageResource": "coffee_and_tea_03"
},
{
"type": "SIDE_INFO_TEST_1",
"title": "Harry Potter",
"description": "$3.99",
"localImageResource": "coffee_and_tea_04"
},
{
"type": "SIDE_INFO_TEST_1",
"title": "Harry Potter",
"description": "$3.99",
"localImageResource": "coffee_and_tea_05"
},
{
"type": "SIDE_INFO_TEST_1",
"title": "Harry Potter",
"description": "$3.99",
"localImageResource": "coffee_and_tea_06"
},
{
"type": "SIDE_INFO_TEST_1",
"title": "Harry Potter",
"description": "$3.99",
"localImageResource": "coffee_and_tea_07"
},
{
"type": "SIDE_INFO_TEST_1",
"title": "Harry Potter",
"description": "$3.99",
"localImageResource": "coffee_and_tea_08"
}
]
},
{
"title": "Single Line",
"cards": [
{
"type": "SQUARE",
"type": "SINGLE_LINE",
"title": "Action & Adventure",
"footerColor": "#dd004e",
"localImageResource": "category_action"
},
{
"type": "SQUARE",
"type": "SINGLE_LINE",
"title": "Animation",
"footerColor": "#c51162",
"localImageResource": "category_animation"
},
{
"type": "SQUARE",
"type": "SINGLE_LINE",
"title": "Classics",
"footerColor": "#9c27b0",
"localImageResource": "category_classics"
},
{
"type": "SQUARE",
"type": "SINGLE_LINE",
"title": "Comedy",
"footerColor": "#cf4900",
"localImageResource": "category_comedy"
},
{
"type": "SQUARE",
"type": "SINGLE_LINE",
"title": "Crime",
"footerColor": "#3f51b5",
"localImageResource": "category_crime"
},
{
"type": "SQUARE",
"type": "SINGLE_LINE",
"title": "Documentary",
"footerColor": "#02639b",
"localImageResource": "category_documentary"
},
{
"type": "SQUARE",
"type": "SINGLE_LINE",
"title": "Drama",
"footerColor": "#2a56c6",
"localImageResource": "category_drama"

View File

@@ -49,55 +49,55 @@
],
"recommended": [
{
"type": "THIN",
"type": "MOVIE",
"title": "The Amazing Spuder-Man",
"description": "$3.99",
"localImageResource": "card_image_movie_01"
},
{
"type": "THIN",
"type": "MOVIE",
"title": "American Psycho",
"description": "$3.99",
"localImageResource": "card_image_movie_02"
},
{
"type": "THIN",
"type": "MOVIE",
"title": "Big Hero 6",
"description": "$3.99",
"localImageResource": "card_image_movie_03"
},
{
"type": "THIN",
"type": "MOVIE",
"title": "Edge of Tomorrow",
"description": "$3.99",
"localImageResource": "card_image_movie_04"
},
{
"type": "THIN",
"type": "MOVIE",
"title": "The Hobbit: The Desolation of Smaug",
"description": "$3.99",
"localImageResource": "card_image_movie_05"
},
{
"type": "THIN",
"type": "MOVIE",
"title": "Interstellar",
"description": "$3.99",
"localImageResource": "card_image_movie_06"
},
{
"type": "THIN",
"type": "MOVIE",
"title": "Jurassic Park",
"description": "$3.99",
"localImageResource": "card_image_movie_07"
},
{
"type": "THIN",
"type": "MOVIE",
"title": "The Hunger Games: Mockingjay Part I",
"description": "$3.99",
"localImageResource": "card_image_movie_08"
},
{
"type": "THIN",
"type": "MOVIE",
"title": "Planes",
"description": "$3.99",
"localImageResource": "card_image_movie_09"

View File

@@ -1,3 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software distributed under the License
~ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
~ or implied. See the License for the specific language governing permissions and limitations under
~ the License.
~
-->
<resources>
<color name="background_gradient_start">#FFFFFF</color>
<color name="background_gradient_end">#DDDDDD</color>

View File

@@ -1,10 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software distributed under the License
~ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
~ or implied. See the License for the specific language governing permissions and limitations under
~ the License.
~
-->
<resources>
<dimen name="default_image_card_width">224dp</dimen>
<dimen name="default_image_card_height">126dp</dimen>
<dimen name="thin_image_card_width">120dp</dimen>
<dimen name="thin_image_card_height">172dp</dimen>
<dimen name="movie_image_card_width">120dp</dimen>
<dimen name="movie_image_card_height">172dp</dimen>
<dimen name="icon_image_card_width">224dp</dimen>
<dimen name="icon_image_card_height">109dp</dimen>

View File

@@ -1,3 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software distributed under the License
~ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
~ or implied. See the License for the specific language governing permissions and limitations under
~ the License.
~
-->
<resources>
<string name="app_name">ShowcaseApp</string>
<string name="browse_title"><![CDATA[androidTV]]></string>

View File

@@ -1,31 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software distributed under the License
~ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
~ or implied. See the License for the specific language governing permissions and limitations under
~ the License.
~
-->
<resources>
<style name="AppTheme" parent="@style/Theme.Leanback">
</style>
<style name="StandardCardPrimaryText">
<item name="android:ellipsize">end</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">@color/card_primary_text</item>
<item name="android:lineSpacingMultiplier">1.09</item>
</style>
<style name="StandardCardSecondaryText">
<item name="android:ellipsize">end</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">12sp</item>
<item name="android:textColor">@color/card_secondary_text</item>
<item name="android:lineSpacingMultiplier">1.13</item>
</style>
<style name="ImageCardViewColoredTextStyle" parent="Widget.Leanback.ImageCardViewStyle">
<item name="titleStyle">@style/ImageCardViewColoredTitle</item>
<item name="infoAreaBackground">#F00</item>
</style>
<style name="WizardActionsContainerStyle" parent="Widget.Leanback.GuidedActionsContainerStyle">
<item name="android:background">#C03800</item>
</style>
@@ -34,8 +26,137 @@
<item name="android:background">#263238</item>
</style>
<style name="ImageCardViewColoredTitle" parent="Widget.Leanback.ImageCardView.TitleStyle">
<item name="android:textColor">#F0F</item>
<!-- Various movie card styles. Used in cards example. -->
<style name="MovieCardBadgeStyle" parent="Widget.Leanback.ImageCardView.BadgeStyle">
<item name="android:src">@drawable/stars_red</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:scaleType">center</item>
</style>
<style name="MovieCardTitleTwoLineStyle" parent="Widget.Leanback.ImageCardView.TitleStyle">
<item name="android:maxLines">2</item>
<item name="android:minLines">2</item>
</style>
<style name="MovieCardContentGoneStyle" parent="Widget.Leanback.ImageCardView.ContentStyle">
<item name="android:visibility">invisible</item>
</style>
<style name="MovieCardImageStyle" parent="Widget.Leanback.ImageCardView.ImageStyle">
<item name="android:layout_width">@dimen/movie_image_card_width</item>
<item name="android:layout_height">@dimen/movie_image_card_height</item>
</style>
<style name="MovieCardSimpleStyle" parent="Widget.Leanback.ImageCardViewStyle">
<item name="lbImageCardViewType">Title</item>
<item name="lbImageCardViewImageStyle">@style/MovieCardImageStyle</item>
</style>
<style name="MovieCardCompleteStyle" parent="MovieCardSimpleStyle">
<item name="lbImageCardViewTitleStyle">@style/MovieCardTitleTwoLineStyle</item>
<item name="lbImageCardViewBadgeStyle">@style/MovieCardBadgeStyle</item>
<item name="lbImageCardViewType">Title|Content|IconOnLeft</item>
</style>
<style name="MovieCardBasicStyle" parent="MovieCardCompleteStyle">
<item name="lbImageCardViewContentStyle">@style/MovieCardContentGoneStyle</item>
</style>
<!-- Squared Title/Content card style. Used in cards example. -->
<style name="SquareBigCardImageStyle" parent="Widget.Leanback.ImageCardView.ImageStyle">
<item name="android:layout_width">@dimen/big_square_image_card_width</item>
<item name="android:layout_height">@dimen/big_square_image_card_height</item>
</style>
<style name="SquareBigCard" parent="Widget.Leanback.ImageCardViewStyle">
<item name="lbImageCardViewImageStyle">@style/SquareBigCardImageStyle</item>
</style>
<!-- Grid card style. Used by Grid example. -->
<style name="GridCardImageStyle" parent="Widget.Leanback.ImageCardView.ImageStyle">
<item name="android:layout_width">@dimen/grid_card_width</item>
<item name="android:layout_height">@dimen/grid_card_height</item>
</style>
<style name="GridCardStyle" parent="Widget.Leanback.ImageCardViewStyle">
<item name="lbImageCardViewImageStyle">@style/GridCardImageStyle</item>
</style>
<!-- A default card style. Used in cards example. -->
<style name="DefaultCardImageStyle" parent="Widget.Leanback.ImageCardView.ImageStyle">
<item name="android:layout_width">@dimen/default_image_card_width</item>
<item name="android:layout_height">@dimen/default_image_card_height</item>
</style>
<style name="DefaultCardStyle" parent="Widget.Leanback.ImageCardViewStyle">
<item name="lbImageCardViewImageStyle">@style/DefaultCardImageStyle</item>
</style>
<!-- Game card styles with custom Badge icon. Used in cards example. -->
<style name="GameCardContentStyle" parent="Widget.Leanback.ImageCardView.ContentStyle">
<item name="android:textColor">#80c349</item>
</style>
<style name="GameCardBadgeStyle" parent="Widget.Leanback.ImageCardView.BadgeStyle">
<item name="android:src">@drawable/ic_installed</item>
</style>
<style name="GameCardStyle" parent="DefaultCardStyle">
<item name="lbImageCardViewContentStyle">@style/GameCardContentStyle</item>
<item name="lbImageCardViewType">Title|Content|IconOnLeft</item>
<item name="lbImageCardViewBadgeStyle">@style/GameCardBadgeStyle</item>
</style>
<!-- Squared single line card with colored footer style. Used in cards example. -->
<style name="SingleLineCardTitleStyle" parent="Widget.Leanback.ImageCardView.TitleStyle">
<item name="android:textAlignment">center</item>
<item name="android:gravity">center</item>
</style>
<style name="SingleLineCardInfoAreaStyle" parent="Widget.Leanback.ImageCardView.InfoAreaStyle">
<item name="android:layout_width">@dimen/square_image_card_width</item>
<item name="layout_viewType">main</item>
</style>
<style name="SingleLineCardImageStyle" parent="Widget.Leanback.ImageCardView.ImageStyle">
<item name="android:layout_width">@dimen/square_image_card_width</item>
<item name="android:layout_height">@dimen/square_image_card_height</item>
</style>
<style name="SingleLineCardStyle" parent="DefaultCardStyle">
<item name="lbImageCardViewTitleStyle">@style/SingleLineCardTitleStyle</item>
<item name="lbImageCardViewType">Title</item>
<item name="lbImageCardViewImageStyle">@style/SingleLineCardImageStyle</item>
<item name="lbImageCardViewInfoAreaStyle">@style/SingleLineCardInfoAreaStyle</item>
</style>
<!-- Icon card style with custom focus handler. Used in cards example. -->
<style name="IconCardImageStyle" parent="Widget.Leanback.ImageCardView.ImageStyle">
<item name="android:layout_width">96dp</item>
<item name="android:layout_height">96dp</item>
<item name="android:padding">16dp</item>
</style>
<style name="IconCardTitleStyle" parent="Widget.Leanback.ImageCardView.TitleStyle">
<item name="android:maxLines">2</item>
<item name="android:minLines">2</item>
<item name="android:gravity">center</item>
</style>
<style name="IconCardInfoAreaStyle" parent="Widget.Leanback.ImageCardView.InfoAreaStyle">
<item name="android:layout_width">96dp</item>
<item name="android:background">@null</item>
<item name="layout_viewType">main</item>
</style>
<style name="IconCardStyle" parent="DefaultCardStyle">
<item name="android:background">@null</item>
<item name="android:layout_width">96dp</item>
<item name="android:layout_height">wrap_content</item>
<item name="lbImageCardViewTitleStyle">@style/IconCardTitleStyle</item>
<item name="lbImageCardViewType">Title</item>
<item name="lbImageCardViewImageStyle">@style/IconCardImageStyle</item>
<item name="lbImageCardViewInfoAreaStyle">@style/IconCardInfoAreaStyle</item>
</style>
</resources>

View File

@@ -1,3 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software distributed under the License
~ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
~ or implied. See the License for the specific language governing permissions and limitations under
~ the License.
~
-->
<resources>
<style name="Theme.Example.Leanback" parent="Theme.Leanback">
@@ -11,7 +26,6 @@
<item name="android:colorPrimary">@color/search_color</item>
<item name="android:colorAccent">@color/accent</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14</item>
<!-- <item name="imageCardViewStyle">@style/ImageCardViewColoredTextStyle</item> -->
</style>
<style name="Theme.Example.LeanbackWizard" parent="Theme.Leanback.GuidedStep">
@@ -29,4 +43,8 @@
<item name="android:backgroundDimEnabled">true</item>
<item name="android:colorPrimary">@color/settings_background</item>
</style>
<style name="Theme.Example.LeanbackDetailView" parent="Theme.Leanback">
<item name="android:colorPrimary">@color/detail_view_actionbar_background</item>
</style>
</resources>