content: package com.androidavanzado.offlinemovies.ui;
  
  import android.content.Context;
  import android.os.Bundle;
  
  import androidx.fragment.app.Fragment;
  import androidx.recyclerview.widget.GridLayoutManager;
  import androidx.recyclerview.widget.LinearLayoutManager;
  import androidx.recyclerview.widget.RecyclerView;
  
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  import com.androidavanzado.offlinemovies.R;
  import com.androidavanzado.offlinemovies.data.MovieEntity;
  
  import java.util.List;
  
  public class MovieFragment extends Fragment {
  
      private static final String ARG_COLUMN_COUNT = "column-count";
      private int mColumnCount = 1;
      List<MovieEntity> movieList;
      MyMovieRecyclerViewAdapter adapter;
  
  
      public MovieFragment() {
      }
  
  
      public static MovieFragment newInstance(int columnCount) {
          MovieFragment fragment = new MovieFragment();
          Bundle args = new Bundle();
          args.putInt(ARG_COLUMN_COUNT, columnCount);
          fragment.setArguments(args);
          return fragment;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          if (getArguments() != null) {
              mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT);
          }
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.fragment_movie_list, container, false);
  
          // Set the adapter
          if (view instanceof RecyclerView) {
              Context context = view.getContext();
              RecyclerView recyclerView = (RecyclerView) view;
              if (mColumnCount <= 1) {
                  recyclerView.setLayoutManager(new LinearLayoutManager(context));
              } else {
                  recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
              }
  
              adapter = new MyMovieRecyclerViewAdapter(
                      getActivity(),
                      movieList
              );
  
              recyclerView.setAdapter(adapter);
          }
          return view;
      }
  
  }
  