package org.stepic.droid.ui.fragments;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;

import com.squareup.otto.Subscribe;

import org.stepic.droid.R;
import org.stepic.droid.events.InternetIsEnabledEvent;
import org.stepic.droid.events.comments.NewCommentWasAddedOrUpdateEvent;
import org.stepic.droid.events.steps.StepWasUpdatedEvent;
import org.stepic.droid.model.Attempt;
import org.stepic.droid.model.Reply;

public class FillBlanksFragment extends StepAttemptFragment {


    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        View fillBlanksView = ((LayoutInflater) this.getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.view_fill_blanks, attemptContainer, false);
        attemptContainer.addView(fillBlanksView);
    }

    @Override
    protected void showAttempt(Attempt attempt) {

    }

    @Override
    protected Reply generateReply() {
        return null;
    }

    @Override
    protected void blockUIBeforeSubmit(boolean needBlock) {

    }

    @Override
    protected void onRestoreSubmission() {

    }

    @Subscribe
    @Override
    public void onInternetEnabled(InternetIsEnabledEvent enabledEvent) {
        super.onInternetEnabled(enabledEvent);
    }

    @Subscribe
    public void onNewCommentWasAdded(NewCommentWasAddedOrUpdateEvent event) {
        super.onNewCommentWasAdded(event);
    }

    @Subscribe
    public void onStepWasUpdated(StepWasUpdatedEvent event) {
        super.onStepWasUpdated(event);
    }

}

@@ -517,21 +517,123 @@
 d.model.
-Reply
+FillBlankComponent;%0Aimport org.stepic.droid.model.Reply;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List
 ;%0A%0Apubli
@@ -1144,87 +1144,504 @@
 ) %7B%0A
-%0A    %7D%0A%0A    @Override%0A    protected Reply generateReply() %7B%0A        return null
+        List%3CFillBlankComponent%3E list = attempt.getDataset().getFillBlankComponents();%0A        //// TODO: 20.01.17   show components from reply%0A%0A    %7D%0A%0A    @Override%0A    protected Reply generateReply() %7B%0A        //// TODO: 20.01.17 make it from user changing%0A        List%3CString%3E blanks = new ArrayList%3C%3E();%0A        blanks.add(%22First one%22);%0A        blanks.add(%22Second%22);%0A        blanks.add(%22    etc%22);%0A        return new Reply.Builder()%0A                .setBlanks(blanks)%0A                .build()
 ;%0A  
@@ -1715,24 +1715,62 @@
 eedBlock) %7B%0A
+        //// TODO: 20.01.17   block UI
 %0A    %7D%0A%0A    
@@ -1822,16 +1822,140 @@
 ion() %7B%0A
+        Reply reply = submission.getReply();%0A        //// TODO: 20.01.17   fill blanks from reply%0A        reply.getBlanks();
 %0A    %7D%0A%0A

mark as TODO main part of fill blanks