package com.blstream.studybox.exam_view.fragment;


import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.blstream.studybox.R;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ResultDialogFragment extends DialogFragment implements DialogInterface.OnShowListener{

    @Bind(R.id.total_score)
    public TextView totalScore;

    private int correctAnswers;
    private int noOfQuestions;

    public static ResultDialogFragment newInstance(int correctAnswers, int noOfQuestions) {
        ResultDialogFragment resultFragment = new ResultDialogFragment();
        Bundle args = new Bundle();
        args.putInt("correctAnswers", correctAnswers);
        args.putInt("noOfQuestions", noOfQuestions);
        resultFragment.setArguments(args);
        return resultFragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        correctAnswers = getArguments().getInt("correctAnswers");
        noOfQuestions = getArguments().getInt("noOfQuestions");
        setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Light);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.dialog_result, container, false);
        initView(view);
        return view;
    }

    private void initView(View view){
        ButterKnife.bind(this, view);
        totalScore.setText(getString(R.string.correct_answers, correctAnswers, noOfQuestions));
    }

    @OnClick(R.id.improve_result)
    public void onClick(View view) {
        dismiss();
    }

    @Override
    public void onShow(DialogInterface dialog) {
        ((OnResultShow) getActivity()).onResultShow();
    }

    public interface OnResultShow {
        void onResultShow();
    }

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

        Dialog result = new Dialog(getActivity(), getTheme()) {
            @Override
            public void onBackPressed() {
                dismiss();
                getActivity().finish();
            }
        };
        result.setOnShowListener(this);
        return result;
    }
}

@@ -112,16 +112,47 @@
 erface;%0A
+import android.content.Intent;%0A
 import a
@@ -415,16 +415,71 @@
 dybox.R;
+%0Aimport com.blstream.studybox.activities.DecksActivity;
 %0A%0Aimport
@@ -2049,32 +2049,180 @@
 smiss();%0A    %7D%0A%0A
+    @OnClick(R.id.my_decks)%0A    public void backToMyDecks(View view) %7B%0A        startActivity(new Intent(getContext(), DecksActivity.class));%0A    %7D%0A%0A
     @Override%0A  

Add handling for backing to DecksActivity from result fragment