// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/FactAboutNumber.java
// public class FactAboutNumber {
// 
//     public String number;
//     public String fact;
// 
//     private FactAboutNumber(String number, String fact) {
//         this.number = number;
//         this.fact = fact;
//     }
// 
//     public static FactAboutNumber of(String number, String fact) {
//         return new FactAboutNumber(number, fact);
//     }
// }
// 
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/ComposedWithSpannedStyles.java
// public class ComposedWithSpannedStyles implements FactViewModel {
// 
//     private String number;
//     private String fact;
//     private ForegroundColorSpan numberColor;
// 
// 
//     private ComposedWithSpannedStyles(String number,
//                                       String fact,
//                                       ForegroundColorSpan numberColor) {
//         this.number = number;
//         this.fact = fact;
//         this.numberColor = numberColor;
//     }
// 
//     public static ComposedWithSpannedStyles with(String number,
//                                                  String fact,
//                                                  ForegroundColorSpan numberColor) {
// 
//         return new ComposedWithSpannedStyles(number, fact, numberColor);
//     }
// 
//     @Override public CharSequence formattedFact() {
// 
//         return new Spanny()
//                 .append(number, new StyleSpan(Typeface.BOLD), numberColor)
//                 .append(fact);
//     }
// 
//     @Override public int viewType() {
//         return TYPE_SINGLE_LABEL;
//     }
// 
// }
// 
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
// 
//     int TYPE_TWO_LABELS = 0;
//     int TYPE_SINGLE_LABEL = 1;
// 
//     CharSequence formattedFact();
// 
//     int viewType();
// 
// }
// 
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/NumberAndFact.java
// public class NumberAndFact implements FactViewModel {
// 
//     private String number;
//     private String fact;
// 
//     public NumberAndFact(String number, String fact) {
//         this.number = number;
//         this.fact = fact;
//     }
//     
//     @Override public CharSequence formattedFact() {
//         return fact;
//     }
// 
//     @Override public int viewType() {
//         return TYPE_TWO_LABELS;
//     }
// 
//     public String relatedNumber() {
//         return number;
//     }
// 
// }
// 
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/DomainToViewModel.java
// public interface DomainToViewModel<Data, ViewModel> {
// 
//     ViewModel translate(Data data);
// 
// }


import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.text.style.ForegroundColorSpan;
import br.ufs.demos.rxmvp.playground.R;
import br.ufs.demos.rxmvp.playground.trivia.domain.FactAboutNumber;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.ComposedWithSpannedStyles;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.NumberAndFact;
import br.ufs.demos.rxmvp.playground.util.DomainToViewModel;
package br.ufs.demos.rxmvp.playground.trivia.presentation;



/**
 * Created by bira on 7/1/17.
 */

public class FactsViewModelMapper implements DomainToViewModel<FactAboutNumber, FactViewModel> {

    private static final int MAX_CHARS_FOR_SMALL_FACT = 50;
    private Context context;

    public FactsViewModelMapper(Context context) {
        this.context = context;
    }

    @Override public FactViewModel translate(FactAboutNumber fact) {
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/domain/FactAboutNumber.java
// public class FactAboutNumber {
// 
//     public String number;
//     public String fact;
// 
//     private FactAboutNumber(String number, String fact) {
//         this.number = number;
//         this.fact = fact;
//     }
// 
//     public static FactAboutNumber of(String number, String fact) {
//         return new FactAboutNumber(number, fact);
//     }
// }
// 
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/ComposedWithSpannedStyles.java
// public class ComposedWithSpannedStyles implements FactViewModel {
// 
//     private String number;
//     private String fact;
//     private ForegroundColorSpan numberColor;
// 
// 
//     private ComposedWithSpannedStyles(String number,
//                                       String fact,
//                                       ForegroundColorSpan numberColor) {
//         this.number = number;
//         this.fact = fact;
//         this.numberColor = numberColor;
//     }
// 
//     public static ComposedWithSpannedStyles with(String number,
//                                                  String fact,
//                                                  ForegroundColorSpan numberColor) {
// 
//         return new ComposedWithSpannedStyles(number, fact, numberColor);
//     }
// 
//     @Override public CharSequence formattedFact() {
// 
//         return new Spanny()
//                 .append(number, new StyleSpan(Typeface.BOLD), numberColor)
//                 .append(fact);
//     }
// 
//     @Override public int viewType() {
//         return TYPE_SINGLE_LABEL;
//     }
// 
// }
// 
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/FactViewModel.java
// public interface FactViewModel {
// 
//     int TYPE_TWO_LABELS = 0;
//     int TYPE_SINGLE_LABEL = 1;
// 
//     CharSequence formattedFact();
// 
//     int viewType();
// 
// }
// 
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/models/NumberAndFact.java
// public class NumberAndFact implements FactViewModel {
// 
//     private String number;
//     private String fact;
// 
//     public NumberAndFact(String number, String fact) {
//         this.number = number;
//         this.fact = fact;
//     }
//     
//     @Override public CharSequence formattedFact() {
//         return fact;
//     }
// 
//     @Override public int viewType() {
//         return TYPE_TWO_LABELS;
//     }
// 
//     public String relatedNumber() {
//         return number;
//     }
// 
// }
// 
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/util/DomainToViewModel.java
// public interface DomainToViewModel<Data, ViewModel> {
// 
//     ViewModel translate(Data data);
// 
// }


// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/trivia/presentation/FactsViewModelMapper.java
import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.text.style.ForegroundColorSpan;
import br.ufs.demos.rxmvp.playground.R;
import br.ufs.demos.rxmvp.playground.trivia.domain.FactAboutNumber;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.ComposedWithSpannedStyles;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.FactViewModel;
import br.ufs.demos.rxmvp.playground.trivia.presentation.models.NumberAndFact;
import br.ufs.demos.rxmvp.playground.util.DomainToViewModel;

package br.ufs.demos.rxmvp.playground.trivia.presentation;



/**
 * Created by bira on 7/1/17.
 */

public class FactsViewModelMapper implements DomainToViewModel<FactAboutNumber, FactViewModel> {

    private static final int MAX_CHARS_FOR_SMALL_FACT = 50;
    private Context context;

    public FactsViewModelMapper(Context context) {
        this.context = context;
    }

    @Override public FactViewModel translate(FactAboutNumber fact) {
        if (isFactTooLarge(fact)) return composedWithSpans(fact);