package com.sw_ss16.lc_app.ui.learning_center_one;

import android.os.Bundle;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.sw_ss16.lc_app.R;
import com.sw_ss16.lc_app.content.StudyRoomsContent;
import com.sw_ss16.lc_app.ui.base.BaseActivity;
import com.sw_ss16.lc_app.ui.base.BaseFragment;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * Shows the quote detail page.
 *
 * Created by Andreas Schrade on 14.12.2015.
 */
public class StudyRoomDetailFragment extends BaseFragment {

    /**
     * The argument represents the dummy item ID of this fragment.
     */
    public static final String ARG_ITEM_ID = "item_id";

    /**
     * The dummy lc_address of this fragment.
     */
    private StudyRoomsContent.DummyItem dummyItem;

    @Bind(R.id.quote)
    TextView quote;

    @Bind(R.id.author)
    TextView author;

    @Bind(R.id.backdrop)
    ImageView backdropImg;

    @Bind(R.id.collapsing_toolbar)
    CollapsingToolbarLayout collapsingToolbar;

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

        if (getArguments().containsKey(ARG_ITEM_ID)) {
            // load dummy item by using the passed item ID.
            dummyItem = StudyRoomsContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
        }

        setHasOptionsMenu(true);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflateAndBind(inflater, container, R.layout.fragment_article_detail);

        if (!((BaseActivity) getActivity()).providesActivityToolbar()) {
            // No Toolbar present. Set include_toolbar:
            ((BaseActivity) getActivity()).setToolbar((Toolbar) rootView.findViewById(R.id.toolbar));
        }

        if (dummyItem != null) {
            loadBackdrop();
            collapsingToolbar.setTitle(dummyItem.title);
            author.setText(dummyItem.content);
            quote.setText(dummyItem.author);
        }

        return rootView;
    }

    private void loadBackdrop() {
        // Glide.with(this).load(dummyItem.photoId).centerCrop().into(backdropImg);
        Glide.with(this).load(dummyItem.imageInUrl).centerCrop().into(backdropImg);
    }

    @OnClick(R.id.fav_fab_btn)
    public void onFabClicked(View view) {
        if(dummyItem.isFavLc)
        {
            dummyItem.isFavLc = false;
            StudyRoomsContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID)).isFavLc = false;
            //FavoriteStudyRoomsContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID)).isFavLc = false;
        }
        else{
            dummyItem.isFavLc = true;
            StudyRoomsContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID)).isFavLc = true;
            //FavoriteStudyRoomsContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID)).isFavLc = true;

        }

        //Snackbar.make(view, "Hello Snackbar!", Snackbar.LENGTH_LONG).setAction("Action", null).show();
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        inflater.inflate(R.menu.sample_actions, menu);
        super.onCreateOptionsMenu(menu, inflater);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.action_settings:
                // your logic
                return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public static StudyRoomDetailFragment newInstance(String itemID) {
        StudyRoomDetailFragment fragment = new StudyRoomDetailFragment();
        Bundle args = new Bundle();
        args.putString(StudyRoomDetailFragment.ARG_ITEM_ID, itemID);
        fragment.setArguments(args);
        return fragment;
    }

    public StudyRoomDetailFragment() {}
}

@@ -486,16 +486,123 @@
 _app.R;%0A
+import com.sw_ss16.lc_app.content.LearningCenter;%0Aimport com.sw_ss16.lc_app.content.LearningCenterContent;%0A
 import c
@@ -1164,45 +1164,116 @@
 ate 
-StudyRoomsContent.DummyItem dummyItem
+LearningCenter dummyItem;%0A%0A    private LearningCenterContent lc_contentmanager = new LearningCenterContent()
 ;%0A%0A 
@@ -1723,16 +1723,17 @@
 tem ID.%0A
+%0A
         
@@ -1728,32 +1728,220 @@
 D.%0A%0A            
+lc_contentmanager.setApplicationContext(getActivity().getApplicationContext());%0A            dummyItem = lc_contentmanager.getLcObject(getArguments().getString(ARG_ITEM_ID));%0A            //
 dummyItem = Stud
@@ -2669,23 +2669,23 @@
 mmyItem.
-content
+address
 );%0A     
@@ -2715,22 +2715,27 @@
 mmyItem.
-author
+description
 );%0A     
@@ -2939,11 +2939,13 @@
 mage
-InU
+_in_u
 rl).
@@ -3079,20 +3079,22 @@
 yItem.is
-FavL
+_fav_l
 c)%0A     
@@ -3102,32 +3102,34 @@
   %7B%0A            
+//
 dummyItem.isFavL
@@ -3120,28 +3120,30 @@
 dummyItem.is
-FavL
+_fav_l
 c = false;%0A 
@@ -3145,32 +3145,34 @@
 se;%0A            
+//
 StudyRoomsConten
@@ -3379,32 +3379,34 @@
 se%7B%0A            
+//
 dummyItem.isFavL
@@ -3401,20 +3401,22 @@
 yItem.is
-FavL
+_fav_l
 c = true
@@ -3421,32 +3421,34 @@
 ue;%0A            
+//
 StudyRoomsConten

Make StudyRoomContent unused