Example usage for android.view Window getDecorView

List of usage examples for android.view Window getDecorView

Introduction

In this page you can find the example usage for android.view Window getDecorView.

Prototype

public abstract View getDecorView();

Source Link

Document

Retrieve the top-level window decor view (containing the standard window frame/decorations and the client's content inside of that), which can be added as a window to the window manager.

Usage

From source file:org.catrobat.paintroid.test.integration.BaseIntegrationTestClass.java

protected int getStatusbarHeight() {
    Rect rectangle = new Rect();
    Window window = mSolo.getCurrentActivity().getWindow();
    window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
    return (rectangle.top);
}

From source file:org.zywx.wbpalmstar.plugin.uexiconlist.EUExIconList.java

/**
 * @param jsonData//from  ww w.j a va  2  s  .c  om
 * @return
 */
private String openIconList(final String jsonData) {
    String errorMsg = "";
    if (!isIconListOpened) {
        ((Activity) mContext).runOnUiThread(new Runnable() {

            @Override
            public void run() {
                Rect outRect = new Rect();
                ((Activity) mContext).getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect);
                try {
                    JSONObject json = new JSONObject();
                    json.put(JK_WIDGET_PATH, mWWidgetData.getWidgetPath());
                    json.put(JK_WIDGET_TYPE, mWWidgetData.m_wgtType);
                    Intent intent = new Intent(mContext, IconListActivity.class);
                    intent.putExtra(WIDGET_INFO, json.toString());
                    intent.putExtra(ITEM_INFO, jsonData);
                    if (mgr == null) {
                        mgr = new LocalActivityManager((Activity) mContext, false);
                        mgr.dispatchCreate(null);
                    }
                    Window window = mgr.startActivity(IconListActivity.TAG, intent);
                    View marketDecorView = window.getDecorView();
                    if (IconListOption.isFollowWebRoll()) {
                        AbsoluteLayout.LayoutParams lp = new AbsoluteLayout.LayoutParams(
                                (int) UIConfig.getWidth(), (int) UIConfig.getHight(), (int) UIConfig.getX(),
                                (int) UIConfig.getY());
                        ViewGroup viewGroup = (ViewGroup) marketDecorView.getParent();
                        if (viewGroup != null) {
                            viewGroup.removeView(marketDecorView);
                        }
                        addViewToWebView(marketDecorView, lp, IconListActivity.TAG);
                    } else {
                        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                                (int) UIConfig.getWidth(), (int) UIConfig.getHight());
                        lp.leftMargin = (int) UIConfig.getX();
                        lp.topMargin = (int) UIConfig.getY();
                        addViewToCurrentWindow(marketDecorView, lp);
                    }
                    isIconListOpened = true;
                    mIconListActivity = (IconListActivity) mgr.getActivity(IconListActivity.TAG);
                    mIconListActivity.initView(EUExIconList.this);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }// end run()
        });
    } // end if
    else {
        errorMsg = ERROR_MSG_ALREADY_OPEN;
    }
    return errorMsg;
}

From source file:com.wojtechnology.sunami.OuterLayout.java

private void updateScreenHeight() {
    Display display = mContext.getWindowManager().getDefaultDisplay();
    Window window = mContext.getWindow();
    Point size = new Point();
    Rect rectangle = new Rect();
    display.getSize(size);/*  w  ww  .ja v  a 2s.  co  m*/
    window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
    mScreenHeight = size.y - rectangle.top;
}

From source file:org.kaaproject.kaa.demo.photoframe.MainActivity.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void setLightsOutMode(boolean enabled) {
    final Window window = getWindow();
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        if (enabled) {
            window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
            window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        } else {/*from w  w  w  . java 2 s. c o m*/
            window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        }
    } else {
        window.getDecorView().setSystemUiVisibility(enabled ? View.SYSTEM_UI_FLAG_FULLSCREEN : 0);
    }
}

From source file:org.kaaproject.kaa.demo.photoframe.activities.SlideshowActivity.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void setLightsOutMode(boolean enabled) {
    final Window window = getWindow();
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        if (enabled) {
            window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
            window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        } else {//from w  w w. j  av a 2 s  .c o m
            window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        }
    } else {
        window.getDecorView().setSystemUiVisibility(enabled ? View.SYSTEM_UI_FLAG_FULLSCREEN : 0);
    }
}

From source file:com.hellofyc.base.app.activity.BaseActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setStatusBarColorTransparent() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
        window.setNavigationBarColor(Color.TRANSPARENT);
    }//ww  w. jav a 2 s . co  m
}

From source file:com.github.piasy.dialogfragmentanywhere.BaseDialogFragment.java

void anchorDialog() {
    final Bundle args = getArguments();
    if (args == null || getDialog() == null) {
        return;//from  ww w  .  jav a  2s  .co  m
    }

    final Window window = getDialog().getWindow();
    final WindowManager.LayoutParams params = window.getAttributes();

    int anchorX = args.getInt(ANCHOR_VIEW_X);
    int anchorY = args.getInt(ANCHOR_VIEW_Y);
    int anchorWidth = args.getInt(ANCHOR_VIEW_WIDTH);
    int anchorHeight = args.getInt(ANCHOR_VIEW_HEIGHT);
    int dialogWidth = window.getDecorView().getWidth();
    int dialogHeight = window.getDecorView().getHeight();
    int locate = args.getInt(LOCATE_TO_ANCHOR);
    int offsetX = args.getInt(OFFSET_X);
    int offsetY = args.getInt(OFFSET_Y);

    switch (locate) {
    case LOCATE_LEFT:
        params.x = anchorX - dialogWidth + offsetX;
        params.y = anchorY - Math.abs(dialogHeight - anchorHeight) / 2 - getStatusBarHeight() + offsetY;
        break;
    case LOCATE_RIGHT:
        params.x = anchorX + anchorWidth + offsetX;
        params.y = anchorY - Math.abs(dialogHeight - anchorHeight) / 2 - getStatusBarHeight() + offsetY;
        break;
    case LOCATE_BELOW:
        params.x = anchorX - Math.abs(dialogWidth - anchorWidth) / 2 + offsetX;
        params.y = anchorY + anchorHeight - getStatusBarHeight() + offsetY;
        break;
    case LOCATE_ABOVE:
        params.x = anchorX - Math.abs(dialogWidth - anchorWidth) / 2 + offsetX;
        params.y = anchorY - dialogHeight - getStatusBarHeight() + offsetY;
    default:
        break;
    }
    window.setAttributes(params);
}

From source file:io.flutter.embedding.android.FlutterActivity.java

private void configureStatusBarForFullscreenFlutterExperience() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(0x40000000);
        window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI);
    }/* w w  w. j a va2s.  c o  m*/
}

From source file:org.mariotaku.twidere.fragment.ActivityHostFragment.java

@SuppressWarnings({ "deprecation", "unchecked" })
@Override/*from ww  w .j a v a2 s  .  com*/
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final Intent intent = new Intent(getActivity(), getActivityClass());
    final Bundle args = getArguments();
    if (args != null) {
        intent.putExtras(args);
    }

    final Window w = getLocalActivityManager().startActivity(ACTIVITY_TAG, intent);
    mAttachedActivity = null;
    final Context context = w.getContext();
    if (context instanceof Activity) {
        try {
            mAttachedActivity = (A) context;
            if (context instanceof FragmentCallback) {
                ((FragmentCallback<A>) context).setCallbackFragment(this);
            }
        } catch (final ClassCastException e) {
            // This should't happen.
            e.printStackTrace();
        }
    }
    final View wd = w != null ? w.getDecorView() : null;

    if (wd != null) {
        final ViewParent parent = wd.getParent();
        if (parent != null) {
            final ViewGroup v = (ViewGroup) parent;
            v.removeView(wd);
        }

        wd.setVisibility(View.VISIBLE);
        wd.setFocusableInTouchMode(true);
        if (wd instanceof ViewGroup) {
            ((ViewGroup) wd).setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
        }
    }
    return wd;
}

From source file:com.facebook.litho.LayoutState.java

private static boolean canCollectDisplayListsSync(Activity activity) {
    // If we have no window or the hierarchy has never been drawn before we cannot guarantee that
    // a valid GL context exists. In this case just bail.
    final Window window = activity.getWindow();
    if (window == null) {
        return false;
    }// w ww  . jav a2  s  .c om

    final View decorView = window.getDecorView();
    if (decorView == null || decorView.getDrawingTime() == 0) {
        return false;
    }

    return true;
}