This file contains hidden or 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
<!-- Add this INSIDE the application tag --> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN"/> | |
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/> | |
</intent-filter> |
This file contains hidden or 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 { | |
public static String TRANSITION_NAME = "poster_transition"; | |
// Injects the API using Dagger | |
@Inject | |
TheMovieDbAPI mDbAPI; | |
private Movie movie; | |
private MovieDetails movieDetails; |
This file contains hidden or 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 Config { | |
public static final String API_KEY_URL = "YOUR API KEY HERE!!"; | |
} |
This file contains hidden or 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 MovieDetailsActivity extends BaseTvActivity { | |
GlideBackgroundManager mBackgroundManager; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
// Retrieve the movie through the intent | |
Movie movie = getIntent().getExtras().getParcelable(Movie.class.getSimpleName()); |
This file contains hidden or 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 MainFragment extends BrowseFragment implements OnItemViewSelectedListener { | |
private void createRows() { | |
... | |
setOnItemViewSelectedListener(this); | |
} | |
@Override | |
public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { | |
// Check if the item is a movie |
This file contains hidden or 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.gabilheri.moviestmdb"> | |
<uses-permission android:name="android.permission.INTERNET"/> | |
<uses-permission android:name="android.permission.RECORD_AUDIO"/> | |
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | |
<uses-feature | |
android:name="android.hardware.touchscreen" | |
android:required="false"/> |
This file contains hidden or 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
package com.gabilheri.moviestmdb.ui.main; | |
import android.os.Bundle; | |
import android.support.v17.leanback.app.BrowseFragment; | |
import android.support.v17.leanback.widget.ArrayObjectAdapter; | |
import android.support.v17.leanback.widget.HeaderItem; | |
import android.support.v17.leanback.widget.ListRow; | |
import android.support.v17.leanback.widget.ListRowPresenter; | |
import android.support.v4.content.ContextCompat; | |
import android.util.SparseArray; |
This file contains hidden or 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
/** | |
* Creates the rows and sets up the adapter of the fragment | |
*/ | |
private void createRows() { | |
// Creates the RowsAdapter for the Fragment | |
// The ListRowPresenter tells to render ListRow objects | |
ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); | |
for (int i = 0; i < mRows.size(); i++) { | |
MovieRow row = mRows.get(i); | |
// Adds a new ListRow to the adapter. Each row will contain a collection of Movies |
This file contains hidden or 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
import android.support.v17.leanback.widget.Presenter; | |
import android.view.ViewGroup; | |
public class MoviePresenter extends Presenter { | |
public MoviePresenter() { | |
} | |
@Override | |
public ViewHolder onCreateViewHolder(ViewGroup parent) { |
This file contains hidden or 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 MovieCardView extends BindableCardView<Movie> { | |
@BindView(R.id.poster_iv) | |
ImageView mPosterIV; | |
@BindView(R.id.vote_average_tv) | |
TextView mVoteAverageTV; | |
public MovieCardView(Context context) { | |
super(context); |