@Test public void findTarget() { screen.setActivity(mock(Activity.class)); assertNull(screen.findTarget(1)); }
@Nullable public View findTarget(int id) { View resultView = null; for (WeakReference<View> weakRefView : scopes.values()) { View scopeView = weakRefView.get(); if (scopeView != null) { resultView = scopeView.findViewById(id); } if (resultView != null) { return resultView; } } if (activity != null) { resultView = activity.findViewById(id); } return resultView; }
Screen { @Nullable public View findTarget(int id) { View resultView = null; for (WeakReference<View> weakRefView : scopes.values()) { View scopeView = weakRefView.get(); if (scopeView != null) { resultView = scopeView.findViewById(id); } if (resultView != null) { return resultView; } } if (activity != null) { resultView = activity.findViewById(id); } return resultView; } }
Screen { @Nullable public View findTarget(int id) { View resultView = null; for (WeakReference<View> weakRefView : scopes.values()) { View scopeView = weakRefView.get(); if (scopeView != null) { resultView = scopeView.findViewById(id); } if (resultView != null) { return resultView; } } if (activity != null) { resultView = activity.findViewById(id); } return resultView; } Screen(Activity activity, String scopeName); }
Screen { @Nullable public View findTarget(int id) { View resultView = null; for (WeakReference<View> weakRefView : scopes.values()) { View scopeView = weakRefView.get(); if (scopeView != null) { resultView = scopeView.findViewById(id); } if (resultView != null) { return resultView; } } if (activity != null) { resultView = activity.findViewById(id); } return resultView; } Screen(Activity activity, String scopeName); boolean matches(TargetScreen screen); boolean matchesAny(Collection<TargetScreen> screens); @Nullable View findTarget(int id); }
Screen { @Nullable public View findTarget(int id) { View resultView = null; for (WeakReference<View> weakRefView : scopes.values()) { View scopeView = weakRefView.get(); if (scopeView != null) { resultView = scopeView.findViewById(id); } if (resultView != null) { return resultView; } } if (activity != null) { resultView = activity.findViewById(id); } return resultView; } Screen(Activity activity, String scopeName); boolean matches(TargetScreen screen); boolean matchesAny(Collection<TargetScreen> screens); @Nullable View findTarget(int id);  }