package com.cuongnd.wpibannerweb.helper;

import android.content.Context;
import android.util.Log;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

import java.util.Calendar;

/**
 * Created by Cuong Nguyen on 5/18/2015.
 */
public class Utils {
    public static void logError(String TAG, Exception e) {
        Log.e(TAG, "exception", e);
    }

    /**
     * Data structure for holding name and id of a term
     */
    public static class TermValue {
        private String mValue;
        private String mText;
        private boolean mMark;

        public TermValue(String value, String text) {
            mValue = value;
            mText = text;
            mMark = false;
        }

        public String getValue() {
            return mValue;
        }

        public String toString() {
            return mText;
        }

        public boolean isMark() { return mMark;}

        public void setMark(boolean mark) {
            mMark = mark;
        }
    }

    /**
     * Convert a string of days of week in WPI convention to an array of numbers representing the
     * corresponding days of week.
     * @param days The string of days of week in WPI convention.
     * @return An array of numbers representing the corresponding days of week. The numbers in this
     * array follow the constants for days of week in the Calendar class.
     */
    public static int[] fromWpiDays(String days) {
        int[] ret = new int[days.length()];
        for (int i = 0; i < days.length(); i++) {
            switch (days.charAt(i)) {
                case 'M': ret[i] = Calendar.MONDAY; break;
                case 'T': ret[i] = Calendar.TUESDAY; break;
                case 'W': ret[i] = Calendar.WEDNESDAY; break;
                case 'R': ret[i] = Calendar.THURSDAY; break;
                case 'F': ret[i] = Calendar.FRIDAY; break;
            }
        }
        return ret;
    }

    /**
     * Convert an array of days of week into a string of days of week in WPI convention.
     * @param days An array contains the days of week.
     * @return A string of days of week in WPI convention.
     */
    public static String toWpiDays(int[] days) {
        char[] wpiDays = {'?', '?', 'M', 'T', 'W', 'R', 'F'};
        String ret = "";
        for (int c : days) ret += wpiDays[c];
        return ret;
    }

}

@@ -35,16 +35,45 @@
 elper;%0A%0A
+import android.app.Activity;%0A
 import a
@@ -96,16 +96,16 @@
 ontext;%0A
-
 import a
@@ -219,16 +219,45 @@
 extView;
+%0Aimport android.widget.Toast;
 %0A%0Aimport
@@ -348,16 +348,17 @@
 Utils %7B%0A
+%0A
     publ
@@ -376,77 +376,565 @@
 oid 
-logError(String TAG, Exception e) %7B%0A        Log.e(TAG, %22exception%22, e
+showLongToast(final Activity activity, final String toast) %7B%0A        activity.runOnUiThread(new Runnable() %7B%0A            @Override%0A            public void run() %7B%0A                Toast.makeText(activity, toast, Toast.LENGTH_LONG).show();%0A            %7D%0A        %7D);%0A    %7D%0A%0A    public static void showShortToast(final Activity activity, final String toast) %7B%0A        activity.runOnUiThread(new Runnable() %7B%0A            @Override%0A            public void run() %7B%0A                Toast.makeText(activity, toast, Toast.LENGTH_SHORT).show();%0A            %7D%0A        %7D
 );%0A 

Add showToast methods