Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6b1b651f authored by Deepanshu Gupta's avatar Deepanshu Gupta
Browse files

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 671b7f9b)
parent 5ad4dae1
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -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);
+3 −10
Original line number Diff line number Diff line
@@ -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);
    }

    /**
+7 −6
Original line number Diff line number Diff line
@@ -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);
            }
        }