package com.bernard.mcqinator.view.activities;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;

import com.bernard.mcqinator.R;
import com.bernard.mcqinator.controller.QuizMetadataManager;
import com.bernard.mcqinator.view.QuizAdapter;
import com.bernard.mcqinator.view.TextBackgroundManager;

public class ChoosingQuizActivity extends ListActivity {

    TextBackgroundManager tbm;
    QuizAdapter qa;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_choosing_quiz);
        tbm = new TextBackgroundManager(this);

        qa = new QuizAdapter(QuizMetadataManager.getAll(this),this);
        setListAdapter(qa);
    }

    @Override
    protected void onStart() {
        super.onStart();
        tbm.stopTexts();
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        tbm.restartTexts();
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        Intent i = new Intent(this,ConfiguringQuizActivity.class);
        i.putExtra(ConfiguringQuizActivity.QUIZID,qa.getItem(position).getFileID());
        startActivity(i);
    }
}
