Merge pull request #5338 from mahdihijazi/fix_fragment_life_cycle

[Android] Fix crash on the Android TV
This commit is contained in:
Markus Wick 2017-05-04 00:06:08 +02:00 committed by GitHub
commit d9d8ed6497
2 changed files with 6 additions and 9 deletions

View File

@ -46,8 +46,11 @@ public final class TvMainActivity extends Activity implements MainView
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);
@ -55,7 +58,6 @@ public final class TvMainActivity extends Activity implements MainView
mBrowseFragment.setBadgeDrawable(getResources().getDrawable(
R.drawable.ic_launcher, null));
mBrowseFragment.setBrandColor(getResources().getColor(R.color.dolphin_blue_dark));
buildRowsAdapter();
mPresenter.onCreate();

View File

@ -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>