diff options
author | Deepanshu Gupta <deepanshu@google.com> | 2015-07-27 10:11:03 -0700 |
---|---|---|
committer | Deepanshu Gupta <deepanshu@google.com> | 2015-08-25 12:06:56 -0700 |
commit | 6b1b651fedc421265d328f1b74512e62ac8a2e13 (patch) | |
tree | 5c1c4fcab5c2525774e5f470887c54928b3d892c /tools | |
parent | 5ad4dae1578dd6823da93ee8382f07ec2814e3ba (diff) | |
download | frameworks_base-6b1b651fedc421265d328f1b74512e62ac8a2e13.zip frameworks_base-6b1b651fedc421265d328f1b74512e62ac8a2e13.tar.gz frameworks_base-6b1b651fedc421265d328f1b74512e62ac8a2e13.tar.bz2 |
Fix imports. [DO NOT MERGE]
Also remove null checks on return value of ReflectionUtils.getMethod()
as the method always return non null.
Change-Id: Ib476302c2cf0504a0f54db4e795955ad10e5df3f
(cherry picked from commit 671b7f9b99316f7224c1213d6923d449a2de9b62)
Diffstat (limited to 'tools')
3 files changed, 12 insertions, 23 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/support/DesignLibUtil.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/support/DesignLibUtil.java index 0426907..aa873a6 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/support/DesignLibUtil.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/support/DesignLibUtil.java @@ -18,14 +18,12 @@ package com.android.layoutlib.bridge.android.support; import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; +import com.android.layoutlib.bridge.util.ReflectionUtils.ReflectionException; import android.annotation.NonNull; import android.annotation.Nullable; import android.view.View; -import java.lang.reflect.Method; - -import static com.android.layoutlib.bridge.util.ReflectionUtils.ReflectionException; import static com.android.layoutlib.bridge.util.ReflectionUtils.getMethod; import static com.android.layoutlib.bridge.util.ReflectionUtils.invoke; @@ -53,10 +51,7 @@ public class DesignLibUtil { return; } try { - Method setTitle = getMethod(view.getClass(), "setTitle", CharSequence.class); - if (setTitle != null) { - invoke(setTitle, view, title); - } + invoke(getMethod(view.getClass(), "setTitle", CharSequence.class), view, title); } catch (ReflectionException e) { Bridge.getLog().warning(LayoutLog.TAG_INFO, "Error occurred while trying to set title.", e); diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/support/RecyclerViewUtil.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/support/RecyclerViewUtil.java index d14c80b..d432120 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/support/RecyclerViewUtil.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/support/RecyclerViewUtil.java @@ -21,16 +21,13 @@ import com.android.ide.common.rendering.api.LayoutlibCallback; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.android.BridgeContext; import com.android.layoutlib.bridge.android.RenderParamsFlags; -import com.android.layoutlib.bridge.util.ReflectionUtils; +import com.android.layoutlib.bridge.util.ReflectionUtils.ReflectionException; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; import android.view.View; -import java.lang.reflect.Method; - -import static com.android.layoutlib.bridge.util.ReflectionUtils.ReflectionException; import static com.android.layoutlib.bridge.util.ReflectionUtils.getCause; import static com.android.layoutlib.bridge.util.ReflectionUtils.getMethod; import static com.android.layoutlib.bridge.util.ReflectionUtils.invoke; @@ -98,8 +95,7 @@ public class RecyclerViewUtil { @Nullable private static Object getLayoutManager(View recyclerView) throws ReflectionException { - Method getLayoutManager = getMethod(recyclerView.getClass(), "getLayoutManager"); - return getLayoutManager != null ? invoke(getLayoutManager, recyclerView) : null; + return invoke(getMethod(recyclerView.getClass(), "getLayoutManager"), recyclerView); } @Nullable @@ -127,10 +123,7 @@ public class RecyclerViewUtil { private static void setProperty(@NonNull Object object, @NonNull Class<?> propertyClass, @Nullable Object propertyValue, @NonNull String propertySetter) throws ReflectionException { - Method setter = getMethod(object.getClass(), propertySetter, propertyClass); - if (setter != null) { - invoke(setter, object, propertyValue); - } + invoke(getMethod(object.getClass(), propertySetter, propertyClass), object, propertyValue); } /** diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java index d1c9f21..8c7ea8a 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java @@ -45,6 +45,7 @@ import android.widget.RelativeLayout; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.widget.LinearLayout.VERTICAL; +import static com.android.layoutlib.bridge.impl.ResourceHelper.getBooleanThemeValue; /** * The Layout used to create the system decor. @@ -325,7 +326,7 @@ class Layout extends RelativeLayout { mParams = params; mContext = context; mResources = mParams.getResources(); - mWindowIsFloating = ResourceHelper.getBooleanThemeValue(mResources, ATTR_WINDOW_FLOATING, true, true); + mWindowIsFloating = getBooleanThemeValue(mResources, ATTR_WINDOW_FLOATING, true, true); findBackground(); findStatusBar(); @@ -342,11 +343,11 @@ class Layout extends RelativeLayout { private void findStatusBar() { boolean windowFullScreen = - ResourceHelper.getBooleanThemeValue(mResources, ATTR_WINDOW_FULL_SCREEN, true, false); + getBooleanThemeValue(mResources, ATTR_WINDOW_FULL_SCREEN, true, false); if (!windowFullScreen && !mWindowIsFloating) { mStatusBarSize = getDimension(ATTR_STATUS_BAR_HEIGHT, true, DEFAULT_STATUS_BAR_HEIGHT); - mTranslucentStatus = ResourceHelper.getBooleanThemeValue(mResources, + mTranslucentStatus = getBooleanThemeValue(mResources, ATTR_WINDOW_TRANSLUCENT_STATUS, true, false); } } @@ -356,14 +357,14 @@ class Layout extends RelativeLayout { return; } // Check if an actionbar is needed - boolean windowActionBar = ResourceHelper.getBooleanThemeValue(mResources, ATTR_WINDOW_ACTION_BAR, + boolean windowActionBar = getBooleanThemeValue(mResources, ATTR_WINDOW_ACTION_BAR, !isThemeAppCompat(), true); if (windowActionBar) { mActionBarSize = getDimension(ATTR_ACTION_BAR_SIZE, true, DEFAULT_TITLE_BAR_HEIGHT); } else { // Maybe the gingerbread era title bar is needed boolean windowNoTitle = - ResourceHelper.getBooleanThemeValue(mResources, ATTR_WINDOW_NO_TITLE, true, false); + getBooleanThemeValue(mResources, ATTR_WINDOW_NO_TITLE, true, false); if (!windowNoTitle) { mTitleBarSize = getDimension(ATTR_WINDOW_TITLE_SIZE, true, DEFAULT_TITLE_BAR_HEIGHT); @@ -391,7 +392,7 @@ class Layout extends RelativeLayout { mNavBarOrientation = barOnBottom ? LinearLayout.HORIZONTAL : VERTICAL; mNavBarSize = getDimension(barOnBottom ? ATTR_NAV_BAR_HEIGHT : ATTR_NAV_BAR_WIDTH, true, DEFAULT_NAV_BAR_SIZE); - mTranslucentNav = ResourceHelper.getBooleanThemeValue(mResources, + mTranslucentNav = getBooleanThemeValue(mResources, ATTR_WINDOW_TRANSLUCENT_NAV, true, false); } } |