fixing warnings in LoginBackgrop

This commit is contained in:
Axel Uhl committed 2015-08-12 20:28:20 +02:00
1 parent 4b6cdaa724
commit 6484bfa5fe
1 file changed
+3 -9
@@ -89,32 +89,26 @@ public class LoginBackdrop extends Fragment {
// Try to force some vertical offset
try {
Object menuHelper;
Class[] argTypes;
Field fMenuHelper = PopupMenu.class.getDeclaredField("mPopup");
fMenuHelper.setAccessible(true);
menuHelper = fMenuHelper.get(popupMenu);
Field fListPopup = menuHelper.getClass().getDeclaredField("mPopup");
fListPopup.setAccessible(true);
Object listPopup = fListPopup.get(menuHelper);
argTypes = new Class[] { int.class };
Class listPopupClass = listPopup.getClass();
Class<?> listPopupClass = listPopup.getClass();
int height = view.getHeight();
// Invoke setVerticalOffset() with the negative height to move up by that distance
@SuppressWarnings("unchecked")
Method setVerticalOffset = listPopupClass.getDeclaredMethod("setVerticalOffset", argTypes);
Method setVerticalOffset = listPopupClass.getDeclaredMethod("setVerticalOffset", int.class);
setVerticalOffset.invoke(listPopup, -height);
@SuppressWarnings("unchecked")
int width = (Integer) listPopupClass.getDeclaredMethod("getWidth").invoke(listPopup);
width -= view.getWidth();
// Invoke setHorizontalOffset() with the negative height to move up by that distance
@SuppressWarnings("unchecked")
Method setHorizontalOffset = listPopupClass.getDeclaredMethod("setHorizontalOffset", argTypes);
Method setHorizontalOffset = listPopupClass.getDeclaredMethod("setHorizontalOffset", int.class);
setHorizontalOffset.invoke(listPopup, -width);
// Invoke show() to update the window's position
@SuppressWarnings("unchecked")
Method show = listPopupClass.getDeclaredMethod("show");
show.invoke(listPopup);
} catch (Exception e) {