Search in sources :

Example 36 with WindowManager

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);
}
Also used : PopupWindow(android.widget.PopupWindow) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageView(android.widget.ImageView) View(android.view.View) WindowManager(android.view.WindowManager)

Example 37 with WindowManager

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;
}
Also used : Point(android.graphics.Point) WindowManager(android.view.WindowManager)

Example 38 with WindowManager

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;
}
Also used : Point(android.graphics.Point) Point(android.graphics.Point) WindowManager(android.view.WindowManager) Display(android.view.Display) TargetApi(android.annotation.TargetApi)

Example 39 with WindowManager

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;
}
Also used : DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager)

Example 40 with WindowManager

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);
}
Also used : ConnectivityManager(android.net.ConnectivityManager) Bundle(android.os.Bundle) TestHnItem(io.github.hidroh.materialistic.data.TestHnItem) WindowManager(android.view.WindowManager) TestItem(io.github.hidroh.materialistic.test.TestItem) Before(org.junit.Before)

Aggregations

WindowManager (android.view.WindowManager)411 Display (android.view.Display)186 Point (android.graphics.Point)129 DisplayMetrics (android.util.DisplayMetrics)104 View (android.view.View)43 IWindowManager (android.view.IWindowManager)37 Context (android.content.Context)36 Resources (android.content.res.Resources)25 ImageView (android.widget.ImageView)24 SuppressLint (android.annotation.SuppressLint)20 Configuration (android.content.res.Configuration)20 Camera (android.hardware.Camera)17 Intent (android.content.Intent)16 Rect (android.graphics.Rect)16 RemoteException (android.os.RemoteException)15 LayoutParams (android.view.WindowManager.LayoutParams)15 TextView (android.widget.TextView)15 Dialog (android.app.Dialog)14 Method (java.lang.reflect.Method)12 PackageManager (android.content.pm.PackageManager)11