package com.bastienleonard.tomate.ui.tasks;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.Loader;
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 com.bastienleonard.tomate.R;
import com.bastienleonard.tomate.trello.loaders.CardsLoader;
import com.bastienleonard.tomate.trello.models.Card;

import java.util.List;

public final class TasksFragment extends Fragment implements LoaderManager.LoaderCallbacks<List<Card>> {
    private static final String ARG_LIST_ID = "listId";
    private static final int CARDS_LOADER_ID = 1;

    private TasksRecyclerViewAdapter mAdapter;

    public static TasksFragment newInstance(String listId) {
        TasksFragment f = new TasksFragment();
        Bundle args = new Bundle();
        args.putString(ARG_LIST_ID, listId);
        f.setArguments(args);
        return f;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.tasks_fragment, container, false);
        RecyclerView list = (RecyclerView) view.findViewById(R.id.list);
        mAdapter = new TasksRecyclerViewAdapter();
        list.setAdapter(mAdapter);
        list.setLayoutManager(new LinearLayoutManager(getContext()));
        getLoaderManager().initLoader(CARDS_LOADER_ID, null, this);
        return view;
    }

    @Override
    public Loader<List<Card>> onCreateLoader(int i, Bundle bundle) {
        return new CardsLoader(getContext(), getArguments().getString(ARG_LIST_ID));
    }

    @Override
    public void onLoadFinished(Loader<List<Card>> loader, List<Card> cards) {
        if (cards == null) {
            // TODO
        } else if (cards.size() == 0) {
            // TODO
        } else {
            mAdapter.setCard(cards);
            mAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void onLoaderReset(Loader<List<Card>> loader) {

    }
}

@@ -1489,24 +1489,182 @@
 ontext()));%0A
+        return view;%0A    %7D%0A%0A    @Override%0A    public void onActivityCreated(Bundle savedInstanceState) %7B%0A        super.onActivityCreated(savedInstanceState);%0A
         getL
@@ -1719,37 +1719,16 @@
  this);%0A
-        return view;%0A
     %7D%0A%0A 

Call initLoader() in onActivityCreated()