Merge pull request #9590 from JosJuice/android-recreate-main
Android: Fix recreating main activity
This commit is contained in:
commit
064a00634e
|
@ -40,7 +40,11 @@ public class PlatformPagerAdapter extends FragmentPagerAdapter
|
|||
@Override
|
||||
public Fragment getItem(int position)
|
||||
{
|
||||
return PlatformGamesFragment.newInstance(Platform.fromPosition(position), mOnRefreshListener);
|
||||
Platform platform = Platform.fromPosition(position);
|
||||
|
||||
PlatformGamesFragment fragment = PlatformGamesFragment.newInstance(platform);
|
||||
fragment.setOnRefreshListener(mOnRefreshListener);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,10 +26,9 @@ public final class PlatformGamesFragment extends Fragment implements PlatformGam
|
|||
private SwipeRefreshLayout mSwipeRefresh;
|
||||
private SwipeRefreshLayout.OnRefreshListener mOnRefreshListener;
|
||||
|
||||
public static PlatformGamesFragment newInstance(Platform platform,
|
||||
SwipeRefreshLayout.OnRefreshListener onRefreshListener)
|
||||
public static PlatformGamesFragment newInstance(Platform platform)
|
||||
{
|
||||
PlatformGamesFragment fragment = new PlatformGamesFragment(onRefreshListener);
|
||||
PlatformGamesFragment fragment = new PlatformGamesFragment();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(ARG_PLATFORM, platform);
|
||||
|
@ -38,11 +37,6 @@ public final class PlatformGamesFragment extends Fragment implements PlatformGam
|
|||
return fragment;
|
||||
}
|
||||
|
||||
public PlatformGamesFragment(SwipeRefreshLayout.OnRefreshListener onRefreshListener)
|
||||
{
|
||||
mOnRefreshListener = onRefreshListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
|
@ -110,6 +104,14 @@ public final class PlatformGamesFragment extends Fragment implements PlatformGam
|
|||
mAdapter.refetchMetadata();
|
||||
}
|
||||
|
||||
public void setOnRefreshListener(@Nullable SwipeRefreshLayout.OnRefreshListener listener)
|
||||
{
|
||||
mOnRefreshListener = listener;
|
||||
|
||||
if (mSwipeRefresh != null)
|
||||
mSwipeRefresh.setOnRefreshListener(listener);
|
||||
}
|
||||
|
||||
public void setRefreshing(boolean refreshing)
|
||||
{
|
||||
mSwipeRefresh.setRefreshing(refreshing);
|
||||
|
|
Loading…
Reference in New Issue