diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/main/GamesFragment.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/main/GamesFragment.java index ff6e4dca..ee4e06c1 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/main/GamesFragment.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/main/GamesFragment.java @@ -12,6 +12,7 @@ import androidx.activity.result.contract.ActivityResultContracts; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import com.panda3ds.pandroid.R; import com.panda3ds.pandroid.data.game.GameMetadata; import com.panda3ds.pandroid.utils.FileUtils; @@ -19,15 +20,29 @@ import com.panda3ds.pandroid.utils.GameUtils; import com.panda3ds.pandroid.view.gamesgrid.GamesGridView; -public class GamesFragment extends Fragment implements ActivityResultCallback { +public class GamesFragment extends Fragment implements ActivityResultCallback, SwipeRefreshLayout.OnRefreshListener { private final ActivityResultContracts.OpenDocument openRomContract = new ActivityResultContracts.OpenDocument(); private ActivityResultLauncher pickFileRequest; private GamesGridView gameListView; + private SwipeRefreshLayout swipeRefreshLayout; @Nullable @Override - public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_games, container, false); + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_games, container, false); + swipeRefreshLayout = rootView.findViewById(R.id.swipe_refresh_layout); + swipeRefreshLayout.setOnRefreshListener(this); + return rootView; + } + + public void onRefresh() { + refreshGameList(); + } + + private void refreshGameList() { + // Refresh the game list + gameListView.setGameList(GameUtils.getGames()); + swipeRefreshLayout.setRefreshing(false); } @Override