// Path: app/src/main/java/pt/passarola/utils/Utils.java
// public class Utils {
// 
//     /**
//      * Validate if device has GooglePlayServices app installed
//      */
//     public static boolean isGooglePlayServicesAvailable(Context context) {
//         return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) == SUCCESS;
//     }
// 
//     /**
//      * Normalize the value of a distance expressed in meters.
//      * 989 meters = 989 meters
//      * 1000 meters = 1.0 km
//      * 1500 meters = 1.5 km
//      *
//      * @param distanceInMeters distance number in meters
//      * @return distance normalized with distance units
//      */
//     public static String getNormalizedDistance(int distanceInMeters){
//         float distance = (float) distanceInMeters;
//         if(distance < 1000){
//             return distanceInMeters + " meters";
//         } else {
//             return String.format("%.02f", distance/1000) + " km";
//         }
//     }
// 
//     /**
//      * Generate a date object from a string
//      *
//      * @param date string date
//      * @return date object that follows the format "yyyy-mm-dd"
//      */
//     @Nullable
//     public static Date getDateFromString(String date){
//         Date result;
//         DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd", Locale.UK);
// 
//         try {
//             result = dateFormat.parse(date);
//         } catch (ParseException e){
//             result = null;
//         }
// 
//         return result;
//     }
// 
//     /**
//      * Open intent with data
//      *
//      * @param context used to start activity
//      * @param link intent's data
//      */
//     public static void openLink(Context context, String link) {
//         Intent intent = new Intent(Intent.ACTION_VIEW);
//         intent.setData(Uri.parse(link));
//         context.startActivity(intent);
//     }
// 
//     /**
//      * Open contact screen by providing a phone number
//      * @param context used to start activity
//      * @param phoneNumber data to show on contact screen
//      */
//     public static void openContact(Context context, String phoneNumber){
//         Intent intent = new Intent(Intent.ACTION_VIEW);
//         intent.setData(Uri.parse("tel:" + phoneNumber));
//         context.startActivity(intent);
//     }
// 
// }


import pt.passarola.utils.Utils;
import android.support.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
import java.util.Date;
    }

    public String getMediumDescription() {
        return mediumDescription;
    }

    public boolean isValid(){
        return id != null && name != null &&
                style != null && labelPicSmall != null &&
                seriesId != null && startDate != null;
    }

    @Override
    public int compareTo(@NonNull Beer another) {
        if (this.isValid() && another.isValid()) {
            int seriesIdL = Integer.valueOf(this.seriesId);
            int seriesIdR = Integer.valueOf(another.seriesId);
            if(seriesIdL > seriesIdR) {
                return 1;
            } else if(seriesIdL < seriesIdR){
                return -1;
            } else {
               return compareDates(this.getStartDate(), another.getStartDate());
            }
        } else {
            return 0;
        }
    }

    private int compareDates(String dateA, String dateB){
// Path: app/src/main/java/pt/passarola/utils/Utils.java
// public class Utils {
// 
//     /**
//      * Validate if device has GooglePlayServices app installed
//      */
//     public static boolean isGooglePlayServicesAvailable(Context context) {
//         return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) == SUCCESS;
//     }
// 
//     /**
//      * Normalize the value of a distance expressed in meters.
//      * 989 meters = 989 meters
//      * 1000 meters = 1.0 km
//      * 1500 meters = 1.5 km
//      *
//      * @param distanceInMeters distance number in meters
//      * @return distance normalized with distance units
//      */
//     public static String getNormalizedDistance(int distanceInMeters){
//         float distance = (float) distanceInMeters;
//         if(distance < 1000){
//             return distanceInMeters + " meters";
//         } else {
//             return String.format("%.02f", distance/1000) + " km";
//         }
//     }
// 
//     /**
//      * Generate a date object from a string
//      *
//      * @param date string date
//      * @return date object that follows the format "yyyy-mm-dd"
//      */
//     @Nullable
//     public static Date getDateFromString(String date){
//         Date result;
//         DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd", Locale.UK);
// 
//         try {
//             result = dateFormat.parse(date);
//         } catch (ParseException e){
//             result = null;
//         }
// 
//         return result;
//     }
// 
//     /**
//      * Open intent with data
//      *
//      * @param context used to start activity
//      * @param link intent's data
//      */
//     public static void openLink(Context context, String link) {
//         Intent intent = new Intent(Intent.ACTION_VIEW);
//         intent.setData(Uri.parse(link));
//         context.startActivity(intent);
//     }
// 
//     /**
//      * Open contact screen by providing a phone number
//      * @param context used to start activity
//      * @param phoneNumber data to show on contact screen
//      */
//     public static void openContact(Context context, String phoneNumber){
//         Intent intent = new Intent(Intent.ACTION_VIEW);
//         intent.setData(Uri.parse("tel:" + phoneNumber));
//         context.startActivity(intent);
//     }
// 
// }


// Path: app/src/main/java/pt/passarola/model/Beer.java
import pt.passarola.utils.Utils;
import android.support.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
import java.util.Date;

    }

    public String getMediumDescription() {
        return mediumDescription;
    }

    public boolean isValid(){
        return id != null && name != null &&
                style != null && labelPicSmall != null &&
                seriesId != null && startDate != null;
    }

    @Override
    public int compareTo(@NonNull Beer another) {
        if (this.isValid() && another.isValid()) {
            int seriesIdL = Integer.valueOf(this.seriesId);
            int seriesIdR = Integer.valueOf(another.seriesId);
            if(seriesIdL > seriesIdR) {
                return 1;
            } else if(seriesIdL < seriesIdR){
                return -1;
            } else {
               return compareDates(this.getStartDate(), another.getStartDate());
            }
        } else {
            return 0;
        }
    }

    private int compareDates(String dateA, String dateB){
        Date dateFormattedA = Utils.getDateFromString(dateA);