Example usage for java.lang NoSuchFieldException printStackTrace

List of usage examples for java.lang NoSuchFieldException printStackTrace

Introduction

In this page you can find the example usage for java.lang NoSuchFieldException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.grottworkshop.gwsspringindicator.viewpager.ScrollerViewPager.java

/**
 *
 *///from  w  w w .j  a  v a2s . c o  m
public void fixScrollSpeed() {
    try {
        fixScrollSpeed(duration);
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    }
}

From source file:com.xperia64.timidityae.Globals.java

@SuppressLint("NewApi")
public static int getBackgroundColor(TextView textView) {
    Drawable drawable = textView.getBackground();
    if (drawable instanceof ColorDrawable) {
        ColorDrawable colorDrawable = (ColorDrawable) drawable;
        if (Build.VERSION.SDK_INT >= 11) {
            return colorDrawable.getColor();
        }/*from w w w.j a v  a 2  s.c o  m*/
        try {
            Field field = colorDrawable.getClass().getDeclaredField("mState");
            field.setAccessible(true);
            Object object = field.get(colorDrawable);
            field = object.getClass().getDeclaredField("mUseColor");
            field.setAccessible(true);
            return field.getInt(object);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
    return 0;
}

From source file:com.jungle.widgets.layout.FixedSpeedViewPager.java

private void initFixedSpeed() {
    try {/*  w ww.  j a v  a 2 s  .c  o  m*/
        Field scroller = ViewPager.class.getDeclaredField("mScroller");
        Field interpolator = ViewPager.class.getDeclaredField("sInterpolator");
        if (scroller != null && interpolator != null) {
            scroller.setAccessible(true);
            interpolator.setAccessible(true);

            mScroller = new FixedSpeedScroller(getContext(), (Interpolator) interpolator.get(null));
            scroller.set(this, mScroller);
        }
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.jivesoftware.os.jive.utils.http.client.ApacheHttpClient31BackedHttpClientOAuthTest.java

private void mockResponse(byte[] body, int statusCode, String reason) throws IOException {
    final InputStream bodyInputStream = new ByteArrayInputStream(body);
    final StatusLine statusLine = new StatusLine("HTTP/1.1 " + statusCode + " " + reason + "\n");

    when(httpClient.executeMethod(argThat(new ArgumentMatcher<HttpMethod>() {
        @Override/*w  w w  .  ja v  a2 s .  c  om*/
        public boolean matches(Object o) {
            if (o instanceof HttpMethodBase) {
                HttpMethodBase methodBase = (HttpMethodBase) o;

                try {
                    Field responseStreamField = HttpMethodBase.class.getDeclaredField("responseStream");
                    responseStreamField.setAccessible(true);
                    responseStreamField.set(methodBase, bodyInputStream);
                    responseStreamField.setAccessible(false);

                    Field statusLineField = HttpMethodBase.class.getDeclaredField("statusLine");
                    statusLineField.setAccessible(true);
                    statusLineField.set(methodBase, statusLine);
                    statusLineField.setAccessible(false);

                } catch (NoSuchFieldException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }

                return true;
            }
            return false;
        }
    }))).thenReturn(200);
}

From source file:com.rukiasoft.androidapps.cocinaconroll.ui.ToolbarAndRefreshActivity.java

public void setToolbar(Toolbar toolbar) {
    setSupportActionBar(toolbar);/*from  w  w w  .j  av  a2  s . com*/
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    try {
        if (toolbar.getClass() != null) {
            Field f = toolbar.getClass().getDeclaredField("mTitleTextView");
            f.setAccessible(true);
            TextView titleTextView = (TextView) f.get(toolbar);
            titleTextView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
            titleTextView.setFocusable(true);
            titleTextView.setFocusableInTouchMode(true);
            titleTextView.requestFocus();
            titleTextView.setSingleLine(true);
            titleTextView.setSelected(true);
            titleTextView.setMarqueeRepeatLimit(-1);
        }
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}

From source file:hochschuledarmstadt.photostream_tools.ImageCacher.java

private void injectImageFilePath(Photo photo, String imageFilePath) {
    try {/*from   w w  w  .j  a v a2s  . c o  m*/
        Field f = photo.getClass().getDeclaredField("imageFilePath");
        f.setAccessible(true);
        f.set(photo, imageFilePath);
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}

From source file:org.essencemc.essencecore.nms.v1_8R3.SkullUtil_1_8_R3.java

/**
 * {@inheritDoc}/*from  w ww  . jav a2 s  .c o  m*/
 */
@Override
public SkullMeta setSkullUrl(String skinUrl, SkullMeta meta) {
    if (meta == null) {
        return meta;
    }

    GameProfile profile = new GameProfile(UUID.randomUUID(), null);
    profile.getProperties().put("textures",
            new Property("textures", new String(Util.getSkullTexture(skinUrl))));
    Field profileField;

    try {
        profileField = meta.getClass().getDeclaredField("profile");
        profileField.setAccessible(true);
        profileField.set(meta, profile);

    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return meta;
}

From source file:com.caseybrooks.scripturememory.activities.DetailActivity.java

private void setTheme() {
    try {/*from   w w w .  j av a2s  .  c o  m*/
        setTheme(R.style.class.getDeclaredField(MetaSettings.getAppTheme(context)).getInt(null));
    } catch (NoSuchFieldException nsfe) {
        nsfe.printStackTrace();
    } catch (IllegalAccessException iae) {
        iae.printStackTrace();
    }
}

From source file:org.essencemc.essencecore.nms.v1_8R3.SkullUtil_1_8_R3.java

/**
 * {@inheritDoc}/*  w w w .  j a  va  2  s  . co m*/
 */
@Override
public String getSkullUrl(SkullMeta meta) {
    if (meta == null) {
        return null;
    }

    String skinUrl = null;
    try {
        //Get the profile properties.
        Field profileField = meta.getClass().getDeclaredField("profile");
        profileField.setAccessible(true);
        Collection<Property> properties = ((GameProfile) profileField.get(meta)).getProperties()
                .get("textures");

        //Get the texture property.
        for (Property prop : properties) {
            if (prop.getName().equalsIgnoreCase("textures")) {
                //Convert the encoded texture string to json.
                String jsonString = new String(Base64.decodeBase64(prop.getValue()));
                JSONObject json = (JSONObject) new JSONParser().parse(jsonString);

                //Get the texture code from JSON.
                json = (JSONObject) json.get("textures");
                json = (JSONObject) json.get("SKIN");
                skinUrl = (String) json.get("url");

                //Get the last bit of the url to get the short code.
                String[] split = skinUrl.split("/");
                skinUrl = split[split.length - 1];
            }
        }
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return skinUrl;
}

From source file:hochschuledarmstadt.photostream_tools.adapter.BaseFragmentPagerAdapter.java

public void updateCommentCount(int photoId, int commentCount) {
    for (Photo photo : photos) {
        if (photo.getId() == photoId) {
            try {
                Field f = photo.getClass().getDeclaredField("commentCount");
                f.setAccessible(true);/*from ww w  .  j ava  2  s  .  c  o  m*/
                f.set(photo, commentCount);
            } catch (NoSuchFieldException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } finally {
                notifyDataSetChanged();
            }
        }
    }
}