/*
 * Copyright 2016 Farbod Salamat-Zadeh
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.satsumasoftware.flashcards.object;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.Html;
import android.text.Spanned;

public class FlashCard implements Parcelable {

    private int mId, mPageRef;
    private String mQuestion, mAnswer;
    private Topic mTopic;


    public FlashCard(int id, String question, String answer, int pageRef, Topic topic) {
        mId = id;
        mQuestion = question;
        mAnswer = answer;
        mPageRef = pageRef;
        mTopic = topic;
    }


    public int getId() {
        return mId;
    }

    public Spanned getQuestion() {
        return Html.fromHtml(mQuestion);
    }

    public Spanned getAnswer() {
        if (mAnswer.equals("#see-guide")) {
            return Html.fromHtml("This answer is too long to fit on a flashcard, but you can " +
                    "check <b>page " + mPageRef + "</b> for details.");
        } else {
            return Html.fromHtml(mAnswer);
        }
    }

    public Topic getTopic() {
        return mTopic;
    }

    public int getPageReference() {
        return mPageRef;
    }


    protected FlashCard(Parcel in) {
        mId = in.readInt();
        mPageRef = in.readInt();
        mQuestion = in.readString();
        mAnswer = in.readString();
        mTopic = in.readParcelable(Topic.class.getClassLoader());
    }

    public static final Creator<FlashCard> CREATOR = new Creator<FlashCard>() {
        @Override
        public FlashCard createFromParcel(Parcel in) {
            return new FlashCard(in);
        }

        @Override
        public FlashCard[] newArray(int size) {
            return new FlashCard[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(mId);
        dest.writeInt(mPageRef);
        dest.writeString(mQuestion);
        dest.writeString(mAnswer);
        dest.writeParcelable(mTopic, flags);
    }
}

@@ -670,16 +670,20 @@
 s.Parcel
+able
 ;%0Aimport
@@ -695,47 +695,36 @@
 oid.
-os.Parcelable;%0Aim
+sup
 port
- android.text.Html
+.annotation.StringDef
 ;%0Aim
@@ -755,1860 +755,442 @@
 d;%0A%0A
-public class FlashCard implements Parcelable %7B%0A%0A    private int mId, mPageRef;%0A    private String mQuestion, mAnswer;%0A    private Topic mTop
+import java.lang.annotation.Retention;%0Aimport java.lang.annotation.RetentionPol
 ic
+y
 ;%0A%0A
-%0A    
 public 
-FlashCard(int id, String question, String answer, int pageRef, Topic topic) %7B%0A        mId = id;%0A        mQuestion = question;%0A        mAnswer = answer;%0A        mPageRef = pageRef;%0A        mTopic = topic;%0A    %7D%0A%0A%0A    public int getId() %7B%0A        return mId;%0A    %7D%0A%0A    public Spanned getQuestion() %7B%0A        return Html.fromHtml(mQuestion);%0A    %7D%0A%0A    public Spanned getAnswer() %7B%0A        if (mAnswer.equals(%22#see-guide%22)) %7B%0A            return Html.fromHtml(%22This answer is too long to fit on a flashcard, but you can %22 +%0A                    %22check %3Cb%3Epage %22 + mPageRef + %22%3C/b%3E for details.%22);%0A        %7D else %7B%0A            return Html.fromHtml(mAnswer);%0A        %7D%0A    %7D%0A%0A    public Topic getTopic() %7B%0A        return mTopic;%0A    %7D%0A%0A    public int getPageReference() %7B%0A        return mPageRef;%0A    %7D%0A%0A%0A    protected FlashCard(Parcel in) %7B%0A        mId = in.readInt();%0A        mPageRef = in.readInt();%0A        mQuestion = in.readString();%0A        mAnswer = in.readString();%0A        mTopic = in.readParcelable(Topic.class.getClassLoader());%0A    %7D%0A%0A    public static final Creator%3CFlashCard%3E CREATOR = new Creator%3CFlashCard%3E() %7B%0A        @Override%0A        public FlashCard createFromParcel(Parcel in)
+interface FlashCard extends Parcelable %7B%0A%0A    int getId();%0A%0A    Spanned getQuestion();%0A%0A    Spanned getAnswer();%0A%0A    Topic getTopic();%0A%0A    @StringDef(%7BSTANDARD, LANGUAGE%7D)%0A    @Retention(RetentionPolicy.SOURCE)%0A    @interface CourseType
  %7B
+%7D
 %0A    
-        return new FlashCard(in);%0A        %7D%0A%0A        @Override%0A        public FlashCard%5B%5D newArray(int size) %7B%0A            return new FlashCard%5Bsize%5D;%0A        %7D%0A    %7D;%0A%0A    @Override%0A    public int describeContents() %7B%0A        return 0;%0A    %7D%0A%0A    @Override%0A    public void writeToParcel(Parcel dest, int flags) %7B%0A        dest.writeInt(mId);%0A        dest.writeInt(mPageRef);%0A        dest.writeString(mQuestion);%0A        dest.writeString(mAnswer);%0A        dest.writeParcelable(mTopic, flags);%0A    %7D
+String STANDARD = %22standard%22, LANGUAGE = %22language%22;%0A%0A    @CourseType String getFlashCardType();%0A
 %0A%7D%0A

Make 'FlashCard' an interface