package com.almoturg.sprog.presenter;

import android.support.v7.widget.RecyclerView;

import com.almoturg.sprog.data.MarkdownConverter;
import com.almoturg.sprog.model.Poem;
import com.almoturg.sprog.ui.PoemsListAdapter;

import static com.almoturg.sprog.SprogApplication.filtered_poems;

public class MainListItemPresenter {
    private Poem poem;
    private PoemsListAdapter.ViewHolder view;
    private boolean expanded;

    private MainPresenter mainPresenter;


    public MainListItemPresenter(PoemsListAdapter.ViewHolder view, MainPresenter mainPresenter) {
        this.view = view;
        this.mainPresenter = mainPresenter;
    }

    public void setPoem(Poem poem){
        this.poem = poem;
        expanded = false;
    }

    public MarkdownConverter getMarkdownConverter() {
        return mainPresenter.markdownConverter;
    }

    public void onClick() {
        if (!expanded) {
            if (!poem.read) {
                poem.read = true;
                mainPresenter.addNewReadPoem(poem);
            }
            view.expand(mainPresenter.markdownConverter
                    .convertPoemMarkdown(poem.content, poem.timestamp));
        } else if (!mainPresenter.updating && !mainPresenter.processing){
            view.startPoemActivity(filtered_poems.indexOf(poem));
        }
    }
}

@@ -36,56 +36,8 @@
 r;%0A%0A
-import android.support.v7.widget.RecyclerView;%0A%0A
 impo
@@ -843,24 +843,53 @@
 expanded) %7B%0A
+            expanded = true;%0A
             

set expanded to true in presenter onClick