This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android"> | |
<shortcut | |
android:shortcutId="leaderboard" | |
android:enabled="true" | |
android:icon="@drawable/ic_leaderboard_primary" | |
<!-- --> | |
<!-- Note this needs to be a string resource, it can NOT be a string --> | |
<!-- If you try to use a literal string here will cause an error --> | |
android:shortcutShortLabel="@string/leaderboard" | |
android:shortcutLongLabel="@string/leaderboard"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Somewhere inside your app... | |
if (isUserLoggedIn() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { | |
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); | |
// NOTE: You MUST specify an Action on the intents. Otherwise it will crash | |
Intent home = new Intent(this, HomeActivity.class); | |
home.setAction(Intent.ACTION_VIEW); | |
Intent profile = new Intent(this, UserProfileActivity.class); | |
profile.setAction(Intent.ACTION_VIEW); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.myapp"> | |
<application | |
android:name=".MyApp" | |
android:icon="@mipmap/ic_launcher" | |
android:label="@string/app_name" | |
android:theme="@style/Theme"> | |
<activity | |
android:name=".ui.home.HomeActivity"> | |
<intent-filter> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomMovieDetailsPresenter extends FullWidthDetailsOverviewRowPresenter { | |
private int mPreviousState = STATE_FULL; | |
public CustomMovieDetailsPresenter(Presenter detailsPresenter, DetailsOverviewLogoPresenter logoPresenter) { | |
super(detailsPresenter, logoPresenter); | |
// Setting the initial state to FULL prevents the OverviewRow from starting in a weird position | |
// It ensures consistency and avoids a bug that makes the poster start off the screen. | |
setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_FULL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void onLayoutLogo(ViewHolder viewHolder, int oldState, boolean logoChanged) { | |
View v = viewHolder.getLogoViewHolder().view; | |
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) | |
v.getLayoutParams(); | |
switch (mAlignmentMode) { | |
case ALIGN_MODE_START: | |
default: | |
lp.setMarginStart(v.getResources().getDimensionPixelSize( | |
R.dimen.lb_details_v2_logo_margin_start)); | |
break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MovieDetailsFragment extends DetailsFragment implements Palette.PaletteAsyncListener { | |
... | |
ArrayObjectAdapter mRecommendationsAdapter = new ArrayObjectAdapter(new MoviePresenter()); | |
... | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MovieDetailsFragment extends DetailsFragment implements Palette.PaletteAsyncListener { | |
// Add the adapter and use the newly created Presenter to define how to render the objects | |
ArrayObjectAdapter mCastAdapter = new ArrayObjectAdapter(new PersonPresenter()); | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
// Adds the adapter and fetches the data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PersonPresenter extends Presenter { | |
Context mContext; | |
@Override | |
public ViewHolder onCreateViewHolder(ViewGroup parent) { | |
if (mContext == null) { | |
// We do this to avoid creating a new ContextThemeWrapper for each one of the cards | |
// If we look inside the ImageCardView they warn us about the same this. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
... | |
<style name="PersonCardTheme" parent="Theme.Leanback"> | |
<item name="imageCardViewImageStyle">@style/PersonCardViewStyle</item> | |
</style> | |
<style name="PersonCardViewStyle" parent="Widget.Leanback.ImageCardView.ImageStyle"> | |
<item name="android:layout_width">180dp</item> | |
<item name="android:layout_height">250dp</item> |