diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/PlatformPagerAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/PlatformPagerAdapter.java index eef3c5b77d..c032073888 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/PlatformPagerAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/PlatformPagerAdapter.java @@ -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 diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesFragment.java index a3f67613c0..c55e3c1fd7 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesFragment.java @@ -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);