package com.xtremelabs.droidsugar.fakes;

import android.content.Context;
import android.widget.Toast;
import com.xtremelabs.droidsugar.util.Implements;

import java.util.ArrayList;
import java.util.List;

@SuppressWarnings({"UnusedDeclaration"})
@Implements(Toast.class)
public class FakeToast {
    public static List<CharSequence> toastMessages = new ArrayList<CharSequence>();
    public static boolean wasShown;

    public static Toast makeText(Context context, int resId, int duration) {
        toastMessages.add(context.getResources().getString(resId));
        return new Toast(null);
    }

    public static Toast makeText(Context context, CharSequence text, int duration) {
        toastMessages.add(text);
        return new Toast(null);
    }

    public static boolean madeToast(CharSequence message) {
        return toastMessages.contains(message);
    }

    public void show() {
        wasShown = true;
    }

    public static void reset() {
        toastMessages.clear();
        wasShown = false;
    }
}

@@ -92,24 +92,81 @@
 dget.Toast;%0A
+import com.xtremelabs.droidsugar.ProxyDelegatingHandler;%0A
 import com.x
@@ -221,25 +221,23 @@
 va.util.
-ArrayList
+HashMap
 ;%0Aimport
@@ -247,20 +247,19 @@
 va.util.
-List
+Map
 ;%0A%0A@Supp
@@ -349,29 +349,30 @@
  %7B%0A    p
-ublic
+rivate
  static 
 List%3CCha
@@ -363,20 +363,19 @@
  static 
-List
+Map
 %3CCharSeq
@@ -383,39 +383,37 @@
 ence
-%3E toastMessages = new ArrayList
+, Toast%3E toasts = new HashMap
 %3CCha
@@ -425,30 +425,32 @@
 ence
+, Toast
 %3E();%0A
+%0A
     p
-ublic static
+rivate
  boo
@@ -462,16 +462,24 @@
 wasShown
+ = false
 ;%0A%0A    p
@@ -558,34 +558,41 @@
         
-toastMessages.add(
+return makeText(context, 
 context.
@@ -626,40 +626,18 @@
 sId)
-);%0A        return new Toast(null
+, duration
 );%0A 
@@ -739,29 +739,68 @@
     
-toastMessages.add(tex
+Toast toast = new Toast(null);%0A        toasts.put(text, toas
 t);%0A
@@ -814,31 +814,21 @@
  return 
-new Toast(null)
+toast
 ;%0A    %7D%0A
@@ -858,12 +858,14 @@
 ean 
-made
+showed
 Toas
@@ -914,91 +914,213 @@
 oast
-Messages.contains(message);%0A    %7D%0A%0A    public void show() %7B%0A        wasShown = true
+s.containsKey(message) && proxyFor(toasts.get(message)).wasShown;%0A    %7D%0A%0A    private static FakeToast proxyFor(Toast toast) %7B%0A        return (FakeToast) ProxyDelegatingHandler.getInstance().proxyFor(toast)
 ;%0A  
@@ -1174,15 +1174,8 @@
 oast
-Message
 s.cl
@@ -1181,16 +1181,48 @@
 lear();%0A
+    %7D%0A%0A    public void show() %7B%0A
         
@@ -1232,20 +1232,19 @@
 Shown = 
-fals
+tru
 e;%0A    %7D

Simplify checking toast showiness.