mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-20 19:44:58 +00:00
add swipe refresh functions
This commit is contained in:
parent
80ff2ec648
commit
978652f39a
1 changed files with 18 additions and 3 deletions
|
@ -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<Uri> {
|
||||
public class GamesFragment extends Fragment implements ActivityResultCallback<Uri>, SwipeRefreshLayout.OnRefreshListener {
|
||||
private final ActivityResultContracts.OpenDocument openRomContract = new ActivityResultContracts.OpenDocument();
|
||||
private ActivityResultLauncher<String[]> 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
|
||||
|
|
Loading…
Add table
Reference in a new issue