Skip to content

Commit

Permalink
Merge pull request #5338 from mahdihijazi/fix_fragment_life_cycle
Browse files Browse the repository at this point in the history
[Android] Fix crash on the Android TV
  • Loading branch information
degasus committed May 3, 2017
2 parents eaa4565 + ed30caa commit d9d8ed6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@ protected void onCreate(Bundle savedInstanceState)
setContentView(R.layout.activity_tv_main);

final FragmentManager fragmentManager = getFragmentManager();
mBrowseFragment = (BrowseFragment) fragmentManager.findFragmentById(
R.id.fragment_game_list);
mBrowseFragment = new BrowseFragment();
fragmentManager
.beginTransaction()
.add(R.id.content, mBrowseFragment, "BrowseFragment")
.commit();

// Set display parameters for the BrowseFragment
mBrowseFragment.setHeadersState(BrowseFragment.HEADERS_ENABLED);
mBrowseFragment.setTitle(getString(R.string.app_name));
mBrowseFragment.setBadgeDrawable(getResources().getDrawable(
R.drawable.ic_launcher, null));
mBrowseFragment.setBrandColor(getResources().getColor(R.color.dolphin_blue_dark));

buildRowsAdapter();

mPresenter.onCreate();
Expand Down
7 changes: 1 addition & 6 deletions Source/Android/app/src/main/res/layout/activity_tv_main.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent">

<fragment
android:name="android.support.v17.leanback.app.BrowseFragment"
android:id="@+id/fragment_game_list"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

</FrameLayout>

0 comments on commit d9d8ed6

Please sign in to comment.