package manager.efidroid.org.efidroidmanager.fragments;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import manager.efidroid.org.efidroidmanager.R;
import manager.efidroid.org.efidroidmanager.models.OperatingSystem;

import java.util.ArrayList;
import java.util.List;

/**
 * A fragment representing a list of Items.
 * <p/>
 * Activities containing this fragment MUST implement the {@link OnListFragmentInteractionListener}
 * interface.
 */
public class OperatingSystemFragment extends Fragment {
    private OnListFragmentInteractionListener mListener;

    /**
     * Mandatory empty constructor for the fragment manager to instantiate the
     * fragment (e.g. upon screen orientation changes).
     */
    public OperatingSystemFragment() {
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_operatingsystem_list, container, false);

        ArrayList<OperatingSystem> list = new ArrayList<>();
        OperatingSystem s;

        s = new OperatingSystem();
        s.setName("OS1");
        list.add(s);

        s = new OperatingSystem();
        s.setName("OS1");
        list.add(s);

        s = new OperatingSystem();
        s.setName("OS1");
        list.add(s);

        s = new OperatingSystem();
        s.setName("OS1");
        list.add(s);

        s = new OperatingSystem();
        s.setName("OS1");
        list.add(s);

        s = new OperatingSystem();
        s.setName("OS1");
        list.add(s);

        // Set the adapter
        if (view instanceof RecyclerView) {
            Context context = view.getContext();
            RecyclerView recyclerView = (RecyclerView) view;
            recyclerView.setLayoutManager(new LinearLayoutManager(context));
            recyclerView.setAdapter(new OperatingSystemRecyclerViewAdapter(list, mListener));
        }
        return view;
    }


    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if (activity instanceof OnListFragmentInteractionListener) {
            mListener = (OnListFragmentInteractionListener) activity;
        } else {
            throw new RuntimeException(activity.toString()
                    + " must implement OnListFragmentInteractionListener");
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        mListener = null;
    }

    /**
     * This interface must be implemented by activities that contain this
     * fragment to allow an interaction in this fragment to be communicated
     * to the activity and potentially other fragments contained in that
     * activity.
     * <p/>
     * See the Android Training lesson <a href=
     * "http://developer.android.com/training/basics/fragments/communicating.html"
     * >Communicating with Other Fragments</a> for more information.
     */
    public interface OnListFragmentInteractionListener {
        void onListFragmentInteraction(OperatingSystem item);
    }
}

@@ -2462,25 +2462,23 @@
 ach(
-Activity activity
+Context context
 ) %7B%0A
@@ -2500,24 +2500,23 @@
 nAttach(
-activity
+context
 );%0A     
@@ -2522,24 +2522,23 @@
     if (
-activity
+context
  instanc
@@ -2638,24 +2638,23 @@
 stener) 
-activity
+context
 ;%0A      
@@ -2703,24 +2703,23 @@
 ception(
-activity
+context
 .toStrin

replace usage of deprecated function