use of android.view.WindowManager in project android-app by eoecn.
the class PopupWindowUtil method showActionWindow.
public void showActionWindow(View parent, Context context, List<T> tabs) {
// final RingtoneclipModel currentData = model;
// final int res_id = currentData.getId();
int[] location = new int[2];
int popWidth = context.getResources().getDimensionPixelOffset(R.dimen.popupWindow_width);
parent.getLocationOnScreen(location);
View view = getView(context, tabs);
popupWindow = new PopupWindow(view, popWidth, // new
LayoutParams.WRAP_CONTENT);
// PopupWindow(view,
// popWidth,
// LayoutParams.WRAP_CONTENT);
popupWindow.setFocusable(true);
popupWindow.setOutsideTouchable(true);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// 显示的位置为:屏幕的最右端
int xPos = (int) (windowManager.getDefaultDisplay().getWidth() - popupWindow.getWidth() - context.getResources().getDimension(R.dimen.popupWindow_margin));
// popupWindow.showAsDropDown(parent, -10,0);
popupWindow.showAtLocation(parent, Gravity.NO_GRAVITY, xPos, location[1] + parent.getHeight() - 20);
}
use of android.view.WindowManager in project Onboarding by eoinfogarty.
the class ViewHelper method getDisplaySize.
public static Point getDisplaySize(@NonNull Context context) {
Point point = new Point();
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
manager.getDefaultDisplay().getSize(point);
return point;
}
use of android.view.WindowManager in project glide by bumptech.
the class RecyclerAdapter method getScreenWidth.
// Display#getSize(Point)
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
@SuppressWarnings("deprecation")
private static int getScreenWidth(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
final int result;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
Point size = new Point();
display.getSize(size);
result = size.x;
} else {
result = display.getWidth();
}
return result;
}
use of android.view.WindowManager in project Launcher3 by chislon.
the class TiledImageRenderer method isHighResolution.
private static boolean isHighResolution(Context context) {
DisplayMetrics metrics = new DisplayMetrics();
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
wm.getDefaultDisplay().getMetrics(metrics);
return metrics.heightPixels > 2048 || metrics.widthPixels > 2048;
}
use of android.view.WindowManager in project materialistic by hidroh.
the class ItemFragmentSinglePageTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
TestApplication.applicationGraph.inject(this);
reset(hackerNewsClient);
reset(userServices);
shadowOf(((WindowManager) RuntimeEnvironment.application.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay()).setHeight(// no preload
0);
shadowOf((ConnectivityManager) RuntimeEnvironment.application.getSystemService(Context.CONNECTIVITY_SERVICE)).setActiveNetworkInfo(ShadowNetworkInfo.newInstance(null, ConnectivityManager.TYPE_WIFI, 0, true, true));
final TestHnItem item0 = new TestHnItem(1, 1) {
@Override
public long getNeighbour(int direction) {
if (direction == Navigable.DIRECTION_DOWN) {
return 4L;
}
return super.getNeighbour(direction);
}
};
item0.populate(new // level 0
TestItem() {
@Override
public String getId() {
return "1";
}
@Override
public String getText() {
return "text";
}
@Override
public int getDescendants() {
return 1;
}
@Override
public long[] getKids() {
return new long[] { 2L };
}
});
final TestHnItem item1 = new TestHnItem(2, 2);
item1.populate(new // level 1
TestItem() {
@Override
public String getId() {
return "2";
}
@Override
public String getParent() {
return "1";
}
@Override
public boolean isDeleted() {
return true;
}
@Override
public String getText() {
return "text";
}
@Override
public int getDescendants() {
return 1;
}
@Override
public long[] getKids() {
return new long[] { 3L };
}
});
item0.getKidItems()[0] = item1;
final TestHnItem item2 = new TestHnItem(3, 3);
item2.populate(new // level 2
TestItem() {
@Override
public String getId() {
return "3";
}
@Override
public long[] getKids() {
return new long[0];
}
@Override
public int getDescendants() {
return 0;
}
@Override
public String getParent() {
return "2";
}
@Override
public boolean isDead() {
return true;
}
});
item1.getKidItems()[0] = item2;
TestHnItem item3 = new TestHnItem(4, 4) {
@Override
public long getNeighbour(int direction) {
if (direction == Navigable.DIRECTION_UP) {
return 1L;
}
return super.getNeighbour(direction);
}
};
item3.populate(new // level 0
TestItem() {
@Override
public String getId() {
return "4";
}
@Override
public String getText() {
return "text";
}
@Override
public int getDescendants() {
return 0;
}
@Override
public long[] getKids() {
return new long[0];
}
});
TestHnItem story = new TestHnItem(0);
story.populate(new TestItem() {
@Override
public long[] getKids() {
return new long[] { 1L, 4L };
}
@Override
public int getDescendants() {
return 4;
}
});
story.getKidItems()[0] = item0;
story.getKidItems()[1] = item3;
Bundle args = new Bundle();
args.putParcelable(ItemFragment.EXTRA_ITEM, story);
fragment = (ItemFragment) Fragment.instantiate(RuntimeEnvironment.application, ItemFragment.class.getName(), args);
controller = Robolectric.buildActivity(ItemFragmentMultiPageTest.TestItemActivity.class);
activity = controller.create().start().resume().visible().get();
PreferenceManager.getDefaultSharedPreferences(activity).edit().putBoolean(activity.getString(R.string.pref_lazy_load), false).apply();
activity.getSupportFragmentManager().beginTransaction().add(R.id.content_frame, fragment, ItemFragment.class.getName()).commit();
recyclerView = (RecyclerView) fragment.getView().findViewById(R.id.recycler_view);
adapter = (SinglePageItemRecyclerViewAdapter) recyclerView.getAdapter();
// auto expand all
viewHolder = (ToggleItemViewHolder) customShadowOf(adapter).getViewHolder(0);
viewHolder1 = (ToggleItemViewHolder) customShadowOf(adapter).getViewHolder(1);
viewHolder2 = (ToggleItemViewHolder) customShadowOf(adapter).getViewHolder(2);
}
Aggregations