I want to save data from the API in the RecyclerView so that when rotating the screen is not reloaded
I think I can use onSaveInstanceState but still don't really understand how to use it
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final RecyclerView rvTVShow = view.findViewById(R.id.rv_shows);
rvTVShow.setHasFixedSize(true);
rvTVShow.setLayoutManager(new LinearLayoutManager(getActivity()));
ApiInterface apiService =
ApiClient.getClient().create(ApiInterface.class);
Call<MovieResponse> call = apiService.getTVShow(API_KEY);
call.enqueue(new Callback<MovieResponse>() {
@Override
public void onResponse(@NonNull Call<MovieResponse> call, @NonNull Response<MovieResponse> response) {
final List<Movies> movies = Objects.requireNonNull(response.body()).getResults();
TvShowAdapter tvShowAdapter = new TvShowAdapter(movies , R.layout.list_movies);
rvTVShow.setAdapter(tvShowAdapter);
....
}