mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-08-03 06:38:49 +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.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
import com.panda3ds.pandroid.R;
|
import com.panda3ds.pandroid.R;
|
||||||
import com.panda3ds.pandroid.data.game.GameMetadata;
|
import com.panda3ds.pandroid.data.game.GameMetadata;
|
||||||
import com.panda3ds.pandroid.utils.FileUtils;
|
import com.panda3ds.pandroid.utils.FileUtils;
|
||||||
|
@ -19,15 +20,29 @@ import com.panda3ds.pandroid.utils.GameUtils;
|
||||||
import com.panda3ds.pandroid.view.gamesgrid.GamesGridView;
|
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 final ActivityResultContracts.OpenDocument openRomContract = new ActivityResultContracts.OpenDocument();
|
||||||
private ActivityResultLauncher<String[]> pickFileRequest;
|
private ActivityResultLauncher<String[]> pickFileRequest;
|
||||||
private GamesGridView gameListView;
|
private GamesGridView gameListView;
|
||||||
|
private SwipeRefreshLayout swipeRefreshLayout;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
return inflater.inflate(R.layout.fragment_games, container, false);
|
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
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue