Merge "Update more implementations of findViewById()" into oc-dev

This commit is contained in:
TreeHugger Robot
2017-04-14 16:26:20 +00:00
committed by Android (Google) Code Review
12 changed files with 22 additions and 22 deletions

View File

@@ -4700,7 +4700,7 @@ package android.app {
public abstract class FragmentContainer {
ctor public FragmentContainer();
method public android.app.Fragment instantiate(android.content.Context, java.lang.String, android.os.Bundle);
method public abstract android.view.View onFindViewById(int);
method public abstract <T extends android.view.View> T onFindViewById(int);
method public abstract boolean onHasView();
}
@@ -4751,7 +4751,7 @@ package android.app {
ctor public FragmentHostCallback(android.content.Context, android.os.Handler, int);
method public void onAttachFragment(android.app.Fragment);
method public void onDump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]);
method public android.view.View onFindViewById(int);
method public <T extends android.view.View> T onFindViewById(int);
method public abstract E onGetHost();
method public android.view.LayoutInflater onGetLayoutInflater();
method public int onGetWindowAnimations();
@@ -37210,7 +37210,7 @@ package android.service.dreams {
method public boolean dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent);
method public boolean dispatchTouchEvent(android.view.MotionEvent);
method public boolean dispatchTrackballEvent(android.view.MotionEvent);
method public android.view.View findViewById(int);
method public <T extends android.view.View> T findViewById(int);
method public final void finish();
method public android.view.Window getWindow();
method public android.view.WindowManager getWindowManager();

View File

@@ -4865,7 +4865,7 @@ package android.app {
public abstract class FragmentContainer {
ctor public FragmentContainer();
method public android.app.Fragment instantiate(android.content.Context, java.lang.String, android.os.Bundle);
method public abstract android.view.View onFindViewById(int);
method public abstract <T extends android.view.View> T onFindViewById(int);
method public abstract boolean onHasView();
}
@@ -4916,7 +4916,7 @@ package android.app {
ctor public FragmentHostCallback(android.content.Context, android.os.Handler, int);
method public void onAttachFragment(android.app.Fragment);
method public void onDump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]);
method public android.view.View onFindViewById(int);
method public <T extends android.view.View> T onFindViewById(int);
method public abstract E onGetHost();
method public android.view.LayoutInflater onGetLayoutInflater();
method public int onGetWindowAnimations();
@@ -40326,7 +40326,7 @@ package android.service.dreams {
method public boolean dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent);
method public boolean dispatchTouchEvent(android.view.MotionEvent);
method public boolean dispatchTrackballEvent(android.view.MotionEvent);
method public android.view.View findViewById(int);
method public <T extends android.view.View> T findViewById(int);
method public final void finish();
method public android.view.Window getWindow();
method public android.view.WindowManager getWindowManager();

View File

@@ -4713,7 +4713,7 @@ package android.app {
public abstract class FragmentContainer {
ctor public FragmentContainer();
method public android.app.Fragment instantiate(android.content.Context, java.lang.String, android.os.Bundle);
method public abstract android.view.View onFindViewById(int);
method public abstract <T extends android.view.View> T onFindViewById(int);
method public abstract boolean onHasView();
}
@@ -4764,7 +4764,7 @@ package android.app {
ctor public FragmentHostCallback(android.content.Context, android.os.Handler, int);
method public void onAttachFragment(android.app.Fragment);
method public void onDump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]);
method public android.view.View onFindViewById(int);
method public <T extends android.view.View> T onFindViewById(int);
method public abstract E onGetHost();
method public android.view.LayoutInflater onGetLayoutInflater();
method public int onGetWindowAnimations();
@@ -37363,7 +37363,7 @@ package android.service.dreams {
method public boolean dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent);
method public boolean dispatchTouchEvent(android.view.MotionEvent);
method public boolean dispatchTrackballEvent(android.view.MotionEvent);
method public android.view.View findViewById(int);
method public <T extends android.view.View> T findViewById(int);
method public final void finish();
method public android.view.Window getWindow();
method public android.view.WindowManager getWindowManager();

View File

@@ -7526,7 +7526,7 @@ public class Activity extends ContextThemeWrapper
@Nullable
@Override
public View onFindViewById(int id) {
public <T extends View> T onFindViewById(int id) {
return Activity.this.findViewById(id);
}

View File

@@ -2527,7 +2527,7 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
mChildFragmentManager.attachController(mHost, new FragmentContainer() {
@Override
@Nullable
public View onFindViewById(int id) {
public <T extends View> T onFindViewById(int id) {
if (mView == null) {
throw new IllegalStateException("Fragment does not have a view");
}

View File

@@ -31,7 +31,7 @@ public abstract class FragmentContainer {
* view is not a child of this container.
*/
@Nullable
public abstract View onFindViewById(@IdRes int id);
public abstract <T extends View> T onFindViewById(@IdRes int id);
/**
* Return {@code true} if the container holds any view.

View File

@@ -207,7 +207,7 @@ public abstract class FragmentHostCallback<E> extends FragmentContainer {
@Nullable
@Override
public View onFindViewById(int id) {
public <T extends View> T onFindViewById(int id) {
return null;
}

View File

@@ -1243,7 +1243,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
+ f
+ " for a container view with no id"));
}
container = (ViewGroup) mContainer.onFindViewById(f.mContainerId);
container = mContainer.onFindViewById(f.mContainerId);
if (container == null && !f.mRestored) {
String resName;
try {

View File

@@ -193,7 +193,7 @@ class FragmentTransition {
View nonExistentView, ArrayMap<String, String> nameOverrides) {
ViewGroup sceneRoot = null;
if (fragmentManager.mContainer.onHasView()) {
sceneRoot = (ViewGroup) fragmentManager.mContainer.onFindViewById(containerId);
sceneRoot = fragmentManager.mContainer.onFindViewById(containerId);
}
if (sceneRoot == null) {
return;
@@ -265,7 +265,7 @@ class FragmentTransition {
View nonExistentView, ArrayMap<String, String> nameOverrides) {
ViewGroup sceneRoot = null;
if (fragmentManager.mContainer.onHasView()) {
sceneRoot = (ViewGroup) fragmentManager.mContainer.onFindViewById(containerId);
sceneRoot = fragmentManager.mContainer.onFindViewById(containerId);
}
if (sceneRoot == null) {
return;

View File

@@ -462,7 +462,7 @@ public class DreamService extends Service implements Window.Callback {
* @return The view if found or null otherwise.
*/
@Nullable
public View findViewById(@IdRes int id) {
public <T extends View> T findViewById(@IdRes int id) {
return getWindow().findViewById(id);
}

View File

@@ -1787,7 +1787,7 @@ public class RemoteViews implements Parcelable, Filter {
@Override
public Action initActionAsync(ViewTree root, ViewGroup rootParent, OnClickHandler handler) {
final TextView target = (TextView) root.findViewById(viewId);
final TextView target = root.findViewById(viewId);
if (target == null) return ACTION_NOOP;
TextViewDrawableAction copy = useIcons ?
@@ -3688,12 +3688,12 @@ public class RemoteViews implements Parcelable, Filter {
createTree();
}
public View findViewById(int id) {
public <T extends View> T findViewById(int id) {
if (mChildren == null) {
return mRoot.findViewById(id);
}
ViewTree tree = findViewTreeById(id);
return tree == null ? null : tree.mRoot;
return tree == null ? null : (T) tree.mRoot;
}
public void addChild(ViewTree child) {

View File

@@ -157,7 +157,7 @@ public class FragmentHostManager {
// TODO: Do something?
}
private View findViewById(int id) {
private <T extends View> T findViewById(int id) {
return mRootView.findViewById(id);
}
@@ -245,7 +245,7 @@ public class FragmentHostManager {
@Override
@Nullable
public View onFindViewById(int id) {
public <T extends View> T onFindViewById(int id) {
return FragmentHostManager.this.findViewById(id);
}