// Path: phial-overlay/src/main/java/com/mindcoders/phial/TargetScreen.java
// public class TargetScreen {
//     private final Class<? extends Activity> target;
//     private final String scope;
// 
// 
//     TargetScreen(Class<? extends Activity> target, String scope) {
//         this.target = target;
//         this.scope = scope;
//     }
// 
//     /**
//      * Creates a {@link TargetScreen} with activity as a target.
//      * @param target activity.
//      */
//     public static TargetScreen forActivity(Class<? extends Activity> target) {
//         return new TargetScreen(target, null);
//     }
// 
//     /**
//      * Creates a {@link TargetScreen} with custom scope as a target.
//      * @param scope scope name.
//      */
//     public static TargetScreen forScope(String scope) {
//         return new TargetScreen(null, scope);
//     }
// 
//     public Class<? extends Activity> getTargetActivity() {
//         return target;
//     }
// 
//     public String getScopeName() {
//         return scope;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         TargetScreen that = (TargetScreen) o;
// 
//         if (target != null ? !target.equals(that.target) : that.target != null) return false;
//         return scope != null ? scope.equals(that.scope) : that.scope == null;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = target != null ? target.hashCode() : 0;
//         result = 31 * result + (scope != null ? scope.hashCode() : 0);
//         return result;
//     }
// 
//     /**
//      * Returns either activity name or custom scope name.
//      * @return target name.
//      */
//     public String getName() {
//         if (target != null) {
//             return target.getSimpleName();
//         }
// 
//         return scope;
//     }
// }
// 
// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/util/ObjectUtil.java
// public final class ObjectUtil {
//     private ObjectUtil() {
//         //to hide
//     }
// 
//     public static <T> boolean equals(T a, T b) {
//         return (a == b) || (a != null && a.equals(b));
//     }
// }
// 
// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/util/SimpleActivityLifecycleCallbacks.java
// public class SimpleActivityLifecycleCallbacks implements Application.ActivityLifecycleCallbacks {
//     @Override
//     public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
//         //optional
//     }
// 
//     @Override
//     public void onActivityStarted(Activity activity) {
//         //optional
//     }
// 
//     @Override
//     public void onActivityResumed(Activity activity) {
//         //optional
//     }
// 
//     @Override
//     public void onActivityPaused(Activity activity) {
//         //optional
//     }
// 
//     @Override
//     public void onActivityStopped(Activity activity) {
//         //optional
//     }
// 
//     @Override
//     public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
//         //optional
//     }
// 
//     @Override
//     public void onActivityDestroyed(Activity activity) {
//         //optional
//     }
// }


import android.app.Activity;
import android.view.View;
import com.mindcoders.phial.TargetScreen;
import com.mindcoders.phial.internal.util.ObjectUtil;
import com.mindcoders.phial.internal.util.SimpleActivityLifecycleCallbacks;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
    public void onActivityPaused(Activity activity) {
        if (ObjectUtil.equals(activity, currentScreen.getActivity())) {
            currentScreen.clearActivity();
            fireOnScreenChanged();
        }
    }

    private void fireOnScreenChanged() {
        for (ScreenListener listener : listeners) {
            listener.onScreenChanged(currentScreen);
        }
    }

    @Override
    public void onEnterScope(String scopeName, View view) {
        currentScreen.enterScope(scopeName, view);
        fireOnScreenChanged();
    }

    @Override
    public void onExitScope(String scopeName) {
        currentScreen.exitScope(scopeName);
        fireOnScreenChanged();
    }

    void destroy() {
        listeners.clear();
        currentScreen.clearActivity();
    }

// Path: phial-overlay/src/main/java/com/mindcoders/phial/TargetScreen.java
// public class TargetScreen {
//     private final Class<? extends Activity> target;
//     private final String scope;
// 
// 
//     TargetScreen(Class<? extends Activity> target, String scope) {
//         this.target = target;
//         this.scope = scope;
//     }
// 
//     /**
//      * Creates a {@link TargetScreen} with activity as a target.
//      * @param target activity.
//      */
//     public static TargetScreen forActivity(Class<? extends Activity> target) {
//         return new TargetScreen(target, null);
//     }
// 
//     /**
//      * Creates a {@link TargetScreen} with custom scope as a target.
//      * @param scope scope name.
//      */
//     public static TargetScreen forScope(String scope) {
//         return new TargetScreen(null, scope);
//     }
// 
//     public Class<? extends Activity> getTargetActivity() {
//         return target;
//     }
// 
//     public String getScopeName() {
//         return scope;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         TargetScreen that = (TargetScreen) o;
// 
//         if (target != null ? !target.equals(that.target) : that.target != null) return false;
//         return scope != null ? scope.equals(that.scope) : that.scope == null;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = target != null ? target.hashCode() : 0;
//         result = 31 * result + (scope != null ? scope.hashCode() : 0);
//         return result;
//     }
// 
//     /**
//      * Returns either activity name or custom scope name.
//      * @return target name.
//      */
//     public String getName() {
//         if (target != null) {
//             return target.getSimpleName();
//         }
// 
//         return scope;
//     }
// }
// 
// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/util/ObjectUtil.java
// public final class ObjectUtil {
//     private ObjectUtil() {
//         //to hide
//     }
// 
//     public static <T> boolean equals(T a, T b) {
//         return (a == b) || (a != null && a.equals(b));
//     }
// }
// 
// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/util/SimpleActivityLifecycleCallbacks.java
// public class SimpleActivityLifecycleCallbacks implements Application.ActivityLifecycleCallbacks {
//     @Override
//     public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
//         //optional
//     }
// 
//     @Override
//     public void onActivityStarted(Activity activity) {
//         //optional
//     }
// 
//     @Override
//     public void onActivityResumed(Activity activity) {
//         //optional
//     }
// 
//     @Override
//     public void onActivityPaused(Activity activity) {
//         //optional
//     }
// 
//     @Override
//     public void onActivityStopped(Activity activity) {
//         //optional
//     }
// 
//     @Override
//     public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
//         //optional
//     }
// 
//     @Override
//     public void onActivityDestroyed(Activity activity) {
//         //optional
//     }
// }


// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/ScreenTracker.java
import android.app.Activity;
import android.view.View;
import com.mindcoders.phial.TargetScreen;
import com.mindcoders.phial.internal.util.ObjectUtil;
import com.mindcoders.phial.internal.util.SimpleActivityLifecycleCallbacks;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;

    public void onActivityPaused(Activity activity) {
        if (ObjectUtil.equals(activity, currentScreen.getActivity())) {
            currentScreen.clearActivity();
            fireOnScreenChanged();
        }
    }

    private void fireOnScreenChanged() {
        for (ScreenListener listener : listeners) {
            listener.onScreenChanged(currentScreen);
        }
    }

    @Override
    public void onEnterScope(String scopeName, View view) {
        currentScreen.enterScope(scopeName, view);
        fireOnScreenChanged();
    }

    @Override
    public void onExitScope(String scopeName) {
        currentScreen.exitScope(scopeName);
        fireOnScreenChanged();
    }

    void destroy() {
        listeners.clear();
        currentScreen.clearActivity();
    }

    public boolean matchesAny(Set<TargetScreen> targetScreen) {