Search in sources :

Example 1 with Theme

use of com.google.samples.apps.topeka.model.Theme in project android-topeka by googlesamples.

the class QuizFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    // Create a themed Context and custom LayoutInflater
    // to get nicely themed views in this Fragment.
    final Theme theme = mCategory.getTheme();
    final ContextThemeWrapper context = new ContextThemeWrapper(getActivity(), theme.getStyleId());
    final LayoutInflater themedInflater = LayoutInflater.from(context);
    return themedInflater.inflate(R.layout.fragment_quiz, container, false);
}
Also used : ContextThemeWrapper(android.view.ContextThemeWrapper) LayoutInflater(android.view.LayoutInflater) Theme(com.google.samples.apps.topeka.model.Theme)

Example 2 with Theme

use of com.google.samples.apps.topeka.model.Theme in project android-topeka by googlesamples.

the class TopekaDatabaseHelper method getCategory.

/**
     * Gets a category from the given position of the cursor provided.
     *
     * @param cursor The Cursor containing the data.
     * @param readableDatabase The database that contains the quizzes.
     * @return The found category.
     */
private static Category getCategory(Cursor cursor, SQLiteDatabase readableDatabase) {
    // "magic numbers" based on CategoryTable#PROJECTION
    final String id = cursor.getString(0);
    final String name = cursor.getString(1);
    final String themeName = cursor.getString(2);
    final Theme theme = Theme.valueOf(themeName);
    final String isSolved = cursor.getString(3);
    final boolean solved = getBooleanFromDatabase(isSolved);
    final int[] scores = JsonHelper.jsonArrayToIntArray(cursor.getString(4));
    final List<Quiz> quizzes = getQuizzes(id, readableDatabase);
    return new Category(name, id, theme, quizzes, scores, solved);
}
Also used : AlphaPickerQuiz(com.google.samples.apps.topeka.model.quiz.AlphaPickerQuiz) Quiz(com.google.samples.apps.topeka.model.quiz.Quiz) MultiSelectQuiz(com.google.samples.apps.topeka.model.quiz.MultiSelectQuiz) FillTwoBlanksQuiz(com.google.samples.apps.topeka.model.quiz.FillTwoBlanksQuiz) FillBlankQuiz(com.google.samples.apps.topeka.model.quiz.FillBlankQuiz) TrueFalseQuiz(com.google.samples.apps.topeka.model.quiz.TrueFalseQuiz) SelectItemQuiz(com.google.samples.apps.topeka.model.quiz.SelectItemQuiz) ToggleTranslateQuiz(com.google.samples.apps.topeka.model.quiz.ToggleTranslateQuiz) PickerQuiz(com.google.samples.apps.topeka.model.quiz.PickerQuiz) FourQuarterQuiz(com.google.samples.apps.topeka.model.quiz.FourQuarterQuiz) Category(com.google.samples.apps.topeka.model.Category) Theme(com.google.samples.apps.topeka.model.Theme)

Aggregations

Theme (com.google.samples.apps.topeka.model.Theme)2 ContextThemeWrapper (android.view.ContextThemeWrapper)1 LayoutInflater (android.view.LayoutInflater)1 Category (com.google.samples.apps.topeka.model.Category)1 AlphaPickerQuiz (com.google.samples.apps.topeka.model.quiz.AlphaPickerQuiz)1 FillBlankQuiz (com.google.samples.apps.topeka.model.quiz.FillBlankQuiz)1 FillTwoBlanksQuiz (com.google.samples.apps.topeka.model.quiz.FillTwoBlanksQuiz)1 FourQuarterQuiz (com.google.samples.apps.topeka.model.quiz.FourQuarterQuiz)1 MultiSelectQuiz (com.google.samples.apps.topeka.model.quiz.MultiSelectQuiz)1 PickerQuiz (com.google.samples.apps.topeka.model.quiz.PickerQuiz)1 Quiz (com.google.samples.apps.topeka.model.quiz.Quiz)1 SelectItemQuiz (com.google.samples.apps.topeka.model.quiz.SelectItemQuiz)1 ToggleTranslateQuiz (com.google.samples.apps.topeka.model.quiz.ToggleTranslateQuiz)1 TrueFalseQuiz (com.google.samples.apps.topeka.model.quiz.TrueFalseQuiz)1