Search in sources :

Example 41 with Field

use of java.lang.reflect.Field in project Shuttle by timusus.

the class ThemeUtils method themeSearchView.

@SuppressLint("InlinedApi")
public static void themeSearchView(Context context, SearchView searchView) {
    FilterableStateListDrawable stateListDrawable = new FilterableStateListDrawable();
    NinePatchDrawable disabledDrawable = (NinePatchDrawable) CompatUtils.getDrawableCompat(context, R.drawable.abc_textfield_search_default_mtrl_alpha);
    NinePatchDrawable otherDrawable = (NinePatchDrawable) CompatUtils.getDrawableCompat(context, R.drawable.abc_textfield_search_activated_mtrl_alpha);
    int accentColor = ColorUtils.getAccentColor();
    ColorFilter colorFilter = new PorterDuffColorFilter(accentColor, PorterDuff.Mode.SRC_ATOP);
    stateListDrawable.addState(new int[] { android.R.attr.state_enabled, android.R.attr.state_activated }, otherDrawable, colorFilter);
    stateListDrawable.addState(new int[] { android.R.attr.state_enabled, android.R.attr.state_focused }, otherDrawable, colorFilter);
    stateListDrawable.addState(StateSet.WILD_CARD, disabledDrawable);
    View searchPlate = searchView.findViewById(android.support.v7.appcompat.R.id.search_plate);
    searchPlate.setBackground(stateListDrawable);
    EditText searchTextView = (EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
    try {
        Field mCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
        mCursorDrawableRes.setAccessible(true);
        mCursorDrawableRes.set(searchTextView, 0);
    } catch (final Exception | NoClassDefFoundError ignored) {
    }
}
Also used : FilterableStateListDrawable(com.simplecity.amp_library.ui.views.FilterableStateListDrawable) AppCompatEditText(android.support.v7.widget.AppCompatEditText) EditText(android.widget.EditText) Field(java.lang.reflect.Field) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) ColorFilter(android.graphics.ColorFilter) LightingColorFilter(android.graphics.LightingColorFilter) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) HmsView(com.doomonafireball.betterpickers.hmspicker.HmsView) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) ScrollView(android.widget.ScrollView) SuppressLint(android.annotation.SuppressLint) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable) SuppressLint(android.annotation.SuppressLint)

Example 42 with Field

use of java.lang.reflect.Field in project Shuttle by timusus.

the class PreferenceManagerCompat method setOnPreferenceTreeClickListener.

/**
     * Sets the callback to be invoked when a {@link Preference} in the
     * hierarchy rooted at this {@link PreferenceManager} is clicked.
     * 
     * @param listener The callback to be invoked.
     */
static void setOnPreferenceTreeClickListener(PreferenceManager manager, final OnPreferenceTreeClickListener listener) {
    try {
        Field onPreferenceTreeClickListener = PreferenceManager.class.getDeclaredField("mOnPreferenceTreeClickListener");
        onPreferenceTreeClickListener.setAccessible(true);
        if (listener != null) {
            Object proxy = Proxy.newProxyInstance(onPreferenceTreeClickListener.getType().getClassLoader(), new Class[] { onPreferenceTreeClickListener.getType() }, new InvocationHandler() {

                public Object invoke(Object proxy, Method method, Object[] args) {
                    if (method.getName().equals("onPreferenceTreeClick")) {
                        return Boolean.valueOf(listener.onPreferenceTreeClick((PreferenceScreen) args[0], (Preference) args[1]));
                    } else {
                        return null;
                    }
                }
            });
            onPreferenceTreeClickListener.set(manager, proxy);
        } else {
            onPreferenceTreeClickListener.set(manager, null);
        }
    } catch (Exception e) {
        Log.w(TAG, "Couldn't set PreferenceManager.mOnPreferenceTreeClickListener by reflection", e);
    }
}
Also used : Field(java.lang.reflect.Field) Method(java.lang.reflect.Method) InvocationHandler(java.lang.reflect.InvocationHandler)

Example 43 with Field

use of java.lang.reflect.Field in project torodb by torodb.

the class DescriptionFactoryWrapper method document.

private void document(JsonPointer propPointer, BeanProperty prop) {
    JavaType type = prop.getType();
    if (hasDescription(prop) && !isPrimitive(type) && !type.isEnumType() && !type.isMapLikeType()) {
        console.println("");
    } else if (isPrimitive(type) || type.isEnumType()) {
        printTabs();
        console.print(propPointer.toString());
        console.print("=");
    } else if (type.isMapLikeType()) {
        printTabs();
        console.print(propPointer.append(JsonPointer.compile("/<string>")).toString());
        console.print("=");
        type = type.getContentType();
    }
    if (isPrimitive(type)) {
        console.print("<");
        console.print(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, type.getRawClass().getSimpleName()));
        console.print(">");
    } else if (type.isEnumType()) {
        console.print("<enum:string>");
    }
    if (hasDescription(prop) && !isPrimitive(type) && !type.isEnumType()) {
        printTabs();
    }
    printDescription(prop);
    if (hasDescription(prop) || isPrimitive(type) || type.isEnumType()) {
        console.println("");
    }
    if (hasDescription(prop) && !isPrimitive(type) && !type.isEnumType()) {
        console.println("");
    }
    if (type.isEnumType()) {
        for (Field enumField : type.getRawClass().getDeclaredFields()) {
            if (!enumField.isEnumConstant()) {
                continue;
            }
            printTabs();
            console.print(" - ");
            console.print(enumField.getName());
            Description enumConstantConfigProperty = enumField.getAnnotation(Description.class);
            if (enumConstantConfigProperty != null && enumConstantConfigProperty.value() != null) {
                console.print(" # ");
                console.print(resourceBundle.getString(enumConstantConfigProperty.value()));
            }
            console.println("");
        }
    }
}
Also used : Field(java.lang.reflect.Field) JavaType(com.fasterxml.jackson.databind.JavaType) Description(com.torodb.packaging.config.annotation.Description)

Example 44 with Field

use of java.lang.reflect.Field in project bazel by bazelbuild.

the class IncrementalClassLoader method setParent.

private static void setParent(ClassLoader classLoader, ClassLoader newParent) {
    try {
        Field parent = ClassLoader.class.getDeclaredField("parent");
        parent.setAccessible(true);
        parent.set(classLoader, newParent);
    } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {
        throw new RuntimeException(e);
    }
}
Also used : Field(java.lang.reflect.Field)

Example 45 with Field

use of java.lang.reflect.Field in project BGABanner-Android by bingoogolapple.

the class BGAViewPager method getXVelocity.

private float getXVelocity() {
    float xVelocity = 0;
    Class viewpagerClass = ViewPager.class;
    try {
        Field velocityTrackerField = viewpagerClass.getDeclaredField("mVelocityTracker");
        velocityTrackerField.setAccessible(true);
        VelocityTracker velocityTracker = (VelocityTracker) velocityTrackerField.get(this);
        Field activePointerIdField = viewpagerClass.getDeclaredField("mActivePointerId");
        activePointerIdField.setAccessible(true);
        Field maximumVelocityField = viewpagerClass.getDeclaredField("mMaximumVelocity");
        maximumVelocityField.setAccessible(true);
        int maximumVelocity = maximumVelocityField.getInt(this);
        velocityTracker.computeCurrentVelocity(1000, maximumVelocity);
        xVelocity = VelocityTrackerCompat.getXVelocity(velocityTracker, activePointerIdField.getInt(this));
    } catch (Exception e) {
    }
    return xVelocity;
}
Also used : Field(java.lang.reflect.Field) VelocityTracker(android.view.VelocityTracker) ViewPager(android.support.v4.view.ViewPager)

Aggregations

Field (java.lang.reflect.Field)5144 Method (java.lang.reflect.Method)613 Test (org.junit.Test)538 ArrayList (java.util.ArrayList)490 IOException (java.io.IOException)318 HashMap (java.util.HashMap)318 Map (java.util.Map)296 InvocationTargetException (java.lang.reflect.InvocationTargetException)176 List (java.util.List)171 Pattern (java.util.regex.Pattern)122 Matcher (java.util.regex.Matcher)117 HashSet (java.util.HashSet)109 File (java.io.File)107 Annotation (java.lang.annotation.Annotation)98 Support_Field (tests.support.Support_Field)82 Collection (java.util.Collection)81 Test (org.testng.annotations.Test)68 Type (java.lang.reflect.Type)67 SienaException (siena.SienaException)65 Before (org.junit.Before)62