Android: Fix recreating main activity
4752ec8
broke this because I wasn't aware that a fragment
has to have a constructor with no parameters in order for
activity recreation to work.
This commit is contained in:
parent
72a6fff36c
commit
fcb19a228b
|
@ -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