package cn.bjtu.nourriture.fragments;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.design.widget.TextInputLayout;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import java.util.List;

import cn.bjtu.nourriture.R;
import cn.bjtu.nourriture.UserActivity;
import cn.bjtu.nourriture.api.ErrorUtils;
import cn.bjtu.nourriture.api.NourritureService;
import cn.bjtu.nourriture.api.ServiceFactory;
import cn.bjtu.nourriture.model.ErrorLogin;
import cn.bjtu.nourriture.model.Ingredients;
import cn.bjtu.nourriture.model.Token;
import retrofit.HttpException;
import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Author : juliengenoud
 * 30/11/15
 **/
public class IngredientFragment extends Fragment {

    public static IngredientFragment newInstance() {
        IngredientFragment fragment = new IngredientFragment();
        return fragment;
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.dummy_fragment,container,false);
        ((TextView)v.findViewById(R.id.dummy)).setText("Ingredients");
        Log.d("Debug Ingredients", "Enter in Ingredients");
        NourritureService service = ServiceFactory.createRetrofitService(NourritureService.class);
        Observable<List<Ingredients>> observable = service.getIngredients();
        Log.d("Debug Ingredients", "After request to API");

        //Request to API

        observable
                .subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<List <Ingredients>>() {
                    @Override
                    public void onCompleted() {
                        //Do nothing
                    }

                    @Override
                    public void onError(Throwable e) {
                                /*e.printStackTrace();
                                Log.e(TAG, e.getMessage());*/
                        if (e instanceof HttpException) {
                            ErrorLogin error = ErrorUtils.parseError(((HttpException) e).response().errorBody(), ServiceFactory.getRestAdapter());
                        }
                    }

                    @Override
                    public void onNext(List <Ingredients> ingredient) {
                        for (int i = 0; i < ingredient.size(); i++) {
                            Log.d("Nom de l'ingredient", "onNext: " + ingredient.get(i).getName());
                            Log.d("Desc Ingredient", "onNext: " + ingredient.get(i).getDescription());
                        }
                    }
                });

        return v;
    }
}

@@ -3012,24 +3012,323 @@
 ription());%0A
+                            Log.d(%22Fat Ingredient%22, %22onNext: %22 + ingredient.get(i).getFat());%0A                            Log.d(%22Prot Ingredient%22, %22onNext: %22 + ingredient.get(i).getProteins());%0A                            Log.d(%22Carb Ingredient%22, %22onNext: %22 + ingredient.get(i).getCarbohydrates());%0A
             

Modify Ingredient Model