Example usage for android.widget RelativeLayout requestLayout

List of usage examples for android.widget RelativeLayout requestLayout

Introduction

In this page you can find the example usage for android.widget RelativeLayout requestLayout.

Prototype

@Override
    public void requestLayout() 

Source Link

Usage

From source file:com.hybris.mobile.lib.ui.view.Alert.java

/**
 * Show the alert/*from  www. ja  v  a2 s  .com*/
 *
 * @param context                 application-specific resources
 * @param configuration           describes all device configuration information
 * @param text                    message to be displayed
 * @param forceClearPreviousAlert true will clear previous alert else keep it
 */
@SuppressLint("NewApi")
private static void showAlertOnScreen(final Activity context, final Configuration configuration,
        final String text, boolean forceClearPreviousAlert) {

    final ViewGroup mainView = ((ViewGroup) context.findViewById(android.R.id.content));
    boolean currentlyDisplayed = false;
    int viewId = R.id.alert_view_top;
    final TextView textView;
    boolean alertAlreadyExists = false;

    if (configuration.getOrientation().equals(Configuration.Orientation.BOTTOM)) {
        viewId = R.id.alert_view_bottom;
    }

    // Retrieving the view
    RelativeLayout relativeLayout = (RelativeLayout) mainView.findViewById(viewId);

    if (forceClearPreviousAlert) {
        mainView.removeView(relativeLayout);
        relativeLayout = null;
    }

    // Creating the view
    if (relativeLayout == null) {

        // Main layout
        relativeLayout = new RelativeLayout(context);
        relativeLayout.setId(viewId);
        relativeLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, configuration.getHeight()));
        relativeLayout.setGravity(Gravity.CENTER);

        // Textview
        textView = new TextView(context);
        textView.setId(R.id.alert_view_text);
        textView.setGravity(Gravity.CENTER);
        textView.setLayoutParams(
                new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        relativeLayout.addView(textView);

        setIcon(context, configuration, relativeLayout, textView);

        if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) {
            relativeLayout.setY(-configuration.getHeight());
        } else {
            relativeLayout.setY(mainView.getHeight());
        }

        // Adding the view to the global layout
        mainView.addView(relativeLayout, 0);
        relativeLayout.bringToFront();
        relativeLayout.requestLayout();
        relativeLayout.invalidate();
    }
    // View already exists
    else {
        alertAlreadyExists = true;
        textView = (TextView) relativeLayout.findViewById(R.id.alert_view_text);

        if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) {
            if (relativeLayout.getY() == 0) {
                currentlyDisplayed = true;
            }
        } else {
            if (relativeLayout.getY() < mainView.getHeight()) {
                currentlyDisplayed = true;
            }
        }

        // The view is currently shown to the user
        if (currentlyDisplayed) {

            // If the message is not the same, we hide the current message and display the new one
            if (!StringUtils.equals(text, textView.getText())) {
                // Anim out the current message
                ViewPropertyAnimator viewPropertyAnimator = animOut(configuration, mainView, relativeLayout);

                final RelativeLayout relativeLayoutFinal = relativeLayout;

                if (viewPropertyAnimator != null) {
                    // Anim in the new message after the animation out has finished
                    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
                        viewPropertyAnimator.setListener(new AnimatorListenerAdapter() {
                            @Override
                            public void onAnimationEnd(Animator animation) {
                                setIcon(context, configuration, relativeLayoutFinal, textView);
                                animIn(configuration, relativeLayoutFinal, textView, mainView, text);
                            }
                        });
                    } else {
                        viewPropertyAnimator.withEndAction(new Runnable() {
                            @Override
                            public void run() {
                                setIcon(context, configuration, relativeLayoutFinal, textView);
                                animIn(configuration, relativeLayoutFinal, textView, mainView, text);
                            }
                        });
                    }
                } else {
                    setIcon(context, configuration, relativeLayoutFinal, textView);
                    animIn(configuration, relativeLayoutFinal, textView, mainView, text);
                }
            }
        }
    }

    final RelativeLayout relativeLayoutFinal = relativeLayout;

    // Close the alert by clicking the layout
    if (configuration.isCloseable()) {
        relativeLayout.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                animOut(configuration, mainView, relativeLayoutFinal);
                v.performClick();
                return true;
            }
        });
    }

    if (!currentlyDisplayed) {
        // Set the icon in case the alert already exists but it's not currently displayed
        if (alertAlreadyExists) {
            setIcon(context, configuration, relativeLayoutFinal, textView);
        }

        // We anim in the alert
        animIn(configuration, relativeLayoutFinal, textView, mainView, text);
    }
}

From source file:ac.robinson.paperchains.PaperChainsActivity.java

private void animateRecordingInterface(int direction, View keyView) {
    mPlayButton.setVisibility(View.VISIBLE);
    mDeleteButton.setVisibility(View.VISIBLE);
    mSaveButton.setVisibility(View.VISIBLE);

    // animate the control buttons out to be equally spaced around the record button
    float buttonOffset = -mPlayButton.getWidth();
    PointF centre = new PointF(0, 0);
    PointF startingPoint = new PointF(0, buttonOffset);
    double radRot = Math.toRadians(-120);
    double cosRot = Math.cos(radRot);
    double sinRot = Math.sin(radRot);
    QRImageParser.rotatePoint(startingPoint, centre, cosRot, sinRot);
    float leftX = startingPoint.x;
    float leftY = startingPoint.y;
    QRImageParser.rotatePoint(startingPoint, centre, cosRot, sinRot);
    float rightX = startingPoint.x;
    float rightY = startingPoint.y;

    RelativeLayout parent;
    AnimatorSet buttonAnimator = new AnimatorSet();
    switch (direction) {
    case 1: // out
        // on an outward animation, we want the three minor buttons to have priority so the record button's
        // larger click area doesn't capture their clicks
        mPlayButton.bringToFront();/*  ww  w . j  a  va2s .  c  o  m*/
        mDeleteButton.bringToFront();
        mSaveButton.bringToFront();
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
            // need to manually re-layout before KitKat
            parent = (RelativeLayout) mPlayButton.getParent();
            parent.requestLayout();
            parent.invalidate();
        }

        buttonAnimator.playTogether(ObjectAnimator.ofFloat(mDeleteButton, "translationX", 0, leftX),
                ObjectAnimator.ofFloat(mDeleteButton, "translationY", 0, leftY),
                ObjectAnimator.ofFloat(mSaveButton, "translationX", 0, rightX),
                ObjectAnimator.ofFloat(mSaveButton, "translationY", 0, rightY),
                ObjectAnimator.ofFloat(mPlayButton, "translationY", 0, buttonOffset));
        buttonAnimator.setInterpolator(new OvershootInterpolator());
        break;
    case -1: // in
        // keyView is the view we want to be at the front after an inward animation
        if (keyView != null) {
            keyView.bringToFront();
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
                // need to manually re-layout before KitKat
                parent = (RelativeLayout) keyView.getParent();
                parent.requestLayout();
                parent.invalidate();
            }
        }

        buttonAnimator.playTogether(ObjectAnimator.ofFloat(mDeleteButton, "translationX", leftX, 0),
                ObjectAnimator.ofFloat(mDeleteButton, "translationY", leftY, 0),
                ObjectAnimator.ofFloat(mSaveButton, "translationX", rightX, 0),
                ObjectAnimator.ofFloat(mSaveButton, "translationY", rightY, 0),
                ObjectAnimator.ofFloat(mPlayButton, "translationY", buttonOffset, 0));
        buttonAnimator.setInterpolator(new AnticipateInterpolator());
        break;
    }
    buttonAnimator.setDuration(BUTTON_ANIMATION_DURATION);
    buttonAnimator.start();
}

From source file:com.almalence.opencam.PluginManagerBase.java

@Override
public void onPreviewFrame(byte[] data) {
    // prevents plugin's views to disappear
    if (isRestarting) {
        RelativeLayout pluginsLayout = (RelativeLayout) ApplicationScreen.instance
                .findViewById(R.id.mainLayout1);
        pluginsLayout.requestLayout();
        isRestarting = false;/*  w w w  .  ja  v  a2s .c o m*/
    }

    for (int i = 0; i < activeVF.size(); i++)
        pluginList.get(activeVF.get(i)).onPreviewFrame(data);

    if (null != pluginList.get(activeCapture))
        pluginList.get(activeCapture).onPreviewFrame(data);
}

From source file:com.cerema.cloud2.ui.dialog.SamlWebViewDialog.java

@SuppressWarnings("deprecation")
@SuppressLint("SetJavaScriptEnabled")
@Override/*from w w w  .j a  va2s  . c o  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log_OC.v(TAG, "onCreateView, savedInsanceState is " + savedInstanceState);

    // Inflate layout of the dialog  
    RelativeLayout ssoRootView = (RelativeLayout) inflater.inflate(R.layout.sso_dialog, container, false); // null parent view because it will go in the dialog layout

    if (mSsoWebView == null) {
        // initialize the WebView
        mSsoWebView = new SsoWebView(getActivity().getApplicationContext());
        mSsoWebView.setFocusable(true);
        mSsoWebView.setFocusableInTouchMode(true);
        mSsoWebView.setClickable(true);

        WebSettings webSettings = mSsoWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setBuiltInZoomControls(false);
        webSettings.setLoadWithOverviewMode(false);
        webSettings.setSavePassword(false);
        webSettings.setUserAgentString(MainApp.getUserAgent());
        webSettings.setSaveFormData(false);

        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setAcceptCookie(true);
        cookieManager.removeAllCookie();

        mSsoWebView.loadUrl(mInitialUrl);
    }

    mWebViewClient.setTargetUrl(mTargetUrl);
    mSsoWebView.setWebViewClient(mWebViewClient);

    // add the webview into the layout
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    ssoRootView.addView(mSsoWebView, layoutParams);
    ssoRootView.requestLayout();

    return ssoRootView;
}

From source file:com.digitalarx.android.ui.dialog.SamlWebViewDialog.java

@SuppressWarnings("deprecation")
@SuppressLint("SetJavaScriptEnabled")
@Override/*  w ww.j  a v  a 2 s.  co  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log_OC.d(TAG, "onCreateView, savedInsanceState is " + savedInstanceState);

    // Inflate layout of the dialog  
    RelativeLayout ssoRootView = (RelativeLayout) inflater.inflate(R.layout.sso_dialog, container, false); // null parent view because it will go in the dialog layout

    if (mSsoWebView == null) {
        // initialize the WebView
        mSsoWebView = new SsoWebView(getSherlockActivity().getApplicationContext());
        mSsoWebView.setFocusable(true);
        mSsoWebView.setFocusableInTouchMode(true);
        mSsoWebView.setClickable(true);

        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setAcceptCookie(true);
        cookieManager.removeAllCookie();
        mSsoWebView.loadUrl(mInitialUrl);

        WebSettings webSettings = mSsoWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setBuiltInZoomControls(false);
        webSettings.setLoadWithOverviewMode(false);
        webSettings.setSavePassword(false);
        webSettings.setUserAgentString(OwnCloudClient.USER_AGENT);
        webSettings.setSaveFormData(false);
    }

    mWebViewClient.setTargetUrl(mTargetUrl);
    mSsoWebView.setWebViewClient(mWebViewClient);

    // add the webview into the layout
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    ssoRootView.addView(mSsoWebView, layoutParams);
    ssoRootView.requestLayout();

    return ssoRootView;
}

From source file:com.owncloud.android.ui.dialog.LoginWebViewDialog.java

@SuppressWarnings("deprecation")
@SuppressLint("SetJavaScriptEnabled")
@Override/*from   w w w.ja v a 2s.c  o m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log_OC.v(TAG, "onCreateView, savedInsanceState is " + savedInstanceState);

    // Inflate layout of the dialog  
    RelativeLayout ssoRootView = (RelativeLayout) inflater.inflate(R.layout.webview_dialog, container, false); // null parent view because it will go in the dialog layout

    if (mWebView == null) {
        // initialize the WebView
        mWebView = new SsoWebView(getActivity().getApplicationContext());
        mWebView.setFocusable(true);
        mWebView.setFocusableInTouchMode(true);
        mWebView.setClickable(true);

        WebSettings webSettings = mWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setSavePassword(false);
        webSettings.setUserAgentString(MainApp.getUserAgent());
        webSettings.setSaveFormData(false);
        // next two settings grant that non-responsive webs are zoomed out when loaded
        webSettings.setUseWideViewPort(true);
        webSettings.setLoadWithOverviewMode(true);
        // next three settings allow the user use pinch gesture to zoom in / out
        webSettings.setSupportZoom(true);
        webSettings.setBuiltInZoomControls(true);
        webSettings.setDisplayZoomControls(false);
        webSettings.setAllowFileAccess(false);

        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setAcceptCookie(true);
        cookieManager.removeAllCookie();

        mWebView.loadUrl(mInitialUrl);
    }

    mWebViewClient.addTargetUrls(mTargetUrls);
    mWebView.setWebViewClient(mWebViewClient);

    // add the webview into the layout
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    ssoRootView.addView(mWebView, layoutParams);
    ssoRootView.requestLayout();

    return ssoRootView;
}

From source file:com.zoffcc.applications.zanavi.Navit.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    if (last_orientation != newConfig.orientation) {
        // Checks the orientation of the screen
        if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            // setContentView(R.layout.main_layout);

            // -- bottom bar --
            int h = NavitGraphics.mCanvasHeight;
            try {
                int h001;
                android.view.ViewGroup.LayoutParams lp001;

                View v003 = (View) findViewById(R.id.osd_nextturn_new);
                h001 = getResources().getDimensionPixelSize(R.dimen.osd_nextturn_new_height);
                lp001 = v003.getLayoutParams();
                lp001.height = h001;/*from   www .  j  a va 2s . c  o  m*/
                v003.requestLayout();

                v003 = (View) findViewById(R.id.bottom_bar);
                h001 = getResources().getDimensionPixelSize(R.dimen.bottom_bar_height);
                lp001 = v003.getLayoutParams();
                lp001.height = h001;
                v003.requestLayout();

                LinearLayout v002 = (LinearLayout) findViewById(R.id.bottom_slide_view);
                h001 = getResources().getDimensionPixelSize(R.dimen.bottom_slide_view_height);
                lp001 = v002.getLayoutParams();
                lp001.height = h001;
                v002.requestLayout();

                v003 = (View) findViewById(R.id.osd_timetodest_new);
                h001 = getResources().getDimensionPixelSize(R.dimen.osd_timetodest_new_height);
                lp001 = v003.getLayoutParams();
                lp001.height = h001;
                v003.requestLayout();

                v002 = (LinearLayout) findViewById(R.id.bottom_line_container);
                h001 = getResources().getDimensionPixelSize(R.dimen.bottom_line_container_height);
                lp001 = v002.getLayoutParams();
                lp001.height = h001;
                v002.requestLayout();

                RelativeLayout v001 = (RelativeLayout) findViewById(R.id.gui_top_container);
                h001 = getResources().getDimensionPixelSize(R.dimen.gui_top_container_height);
                lp001 = v001.getLayoutParams();
                lp001.height = h001;
                v001.requestLayout();

                int ml = getResources().getDimensionPixelSize(R.dimen.margin_left_speeding);
                int mb = getResources().getDimensionPixelSize(R.dimen.margin_bottom_speeding);
                v003 = (View) findViewById(R.id.view_speeding);
                RelativeLayout.LayoutParams relativeParams_001 = (RelativeLayout.LayoutParams) v003
                        .getLayoutParams();
                relativeParams_001.setMargins(ml, 0, 0, mb); // left, top, right, bottom
                v003.setLayoutParams(relativeParams_001);
                v003.requestLayout();

                smaller_top_bar(true);

                // Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();

                bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height);
                bottom_bar_slider_shadow_px = (int) getResources()
                        .getDimension(R.dimen.bottom_slide_view_shadow_compat_height);

                Navit.cur_y_margin_bottom_bar_touch = h + Navit.actionBarHeight + bottom_bar_px
                        - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom
            } catch (Exception e) {
                Navit.cur_y_margin_bottom_bar_touch = h + Navit.actionBarHeight + bottom_bar_px
                        - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom
            }
            Navit.bottom_y_margin_bottom_bar_touch = Navit.cur_y_margin_bottom_bar_touch;
            // -- bottom bar --
        } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
            // setContentView(R.layout.main_layout);

            // -- bottom bar --
            int h = NavitGraphics.mCanvasHeight;
            try {
                int h001;
                android.view.ViewGroup.LayoutParams lp001;

                View v003 = (View) findViewById(R.id.osd_nextturn_new);
                h001 = getResources().getDimensionPixelSize(R.dimen.osd_nextturn_new_height);
                lp001 = v003.getLayoutParams();
                lp001.height = h001;
                v003.requestLayout();

                v003 = (View) findViewById(R.id.bottom_bar);
                h001 = getResources().getDimensionPixelSize(R.dimen.bottom_bar_height);
                lp001 = v003.getLayoutParams();
                lp001.height = h001;
                v003.requestLayout();

                LinearLayout v002 = (LinearLayout) findViewById(R.id.bottom_slide_view);
                h001 = getResources().getDimensionPixelSize(R.dimen.bottom_slide_view_height);
                lp001 = v002.getLayoutParams();
                lp001.height = h001;
                v002.requestLayout();

                v003 = (View) findViewById(R.id.osd_timetodest_new);
                h001 = getResources().getDimensionPixelSize(R.dimen.osd_timetodest_new_height);
                lp001 = v003.getLayoutParams();
                lp001.height = h001;
                v003.requestLayout();

                v002 = (LinearLayout) findViewById(R.id.bottom_line_container);
                h001 = getResources().getDimensionPixelSize(R.dimen.bottom_line_container_height);
                lp001 = v002.getLayoutParams();
                lp001.height = h001;
                v002.requestLayout();

                RelativeLayout v001 = (RelativeLayout) findViewById(R.id.gui_top_container);
                h001 = getResources().getDimensionPixelSize(R.dimen.gui_top_container_height);
                lp001 = v001.getLayoutParams();
                lp001.height = h001;
                v001.requestLayout();

                int ml = getResources().getDimensionPixelSize(R.dimen.margin_left_speeding);
                int mb = getResources().getDimensionPixelSize(R.dimen.margin_bottom_speeding);
                v003 = (View) findViewById(R.id.view_speeding);
                RelativeLayout.LayoutParams relativeParams_001 = (RelativeLayout.LayoutParams) v003
                        .getLayoutParams();
                relativeParams_001.setMargins(ml, 0, 0, mb); // left, top, right, bottom
                v003.setLayoutParams(relativeParams_001);
                v003.requestLayout();

                smaller_top_bar(false);

                // Toast.makeText(this, "protrait", Toast.LENGTH_SHORT).show();

                bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height);
                bottom_bar_slider_shadow_px = (int) getResources()
                        .getDimension(R.dimen.bottom_slide_view_shadow_compat_height);

                Navit.cur_y_margin_bottom_bar_touch = h + Navit.actionBarHeight + bottom_bar_px
                        - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom
            } catch (Exception e) {
                Navit.cur_y_margin_bottom_bar_touch = h + Navit.actionBarHeight + bottom_bar_px
                        - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom
            }
            Navit.bottom_y_margin_bottom_bar_touch = Navit.cur_y_margin_bottom_bar_touch;
            // -- bottom bar --
        }

        last_orientation = newConfig.orientation;
    }
}

From source file:com.zoffcc.applications.zanavi.Navit.java

void smaller_top_bar(boolean horizonzal) {
    // not working properly, deactivate for now ----------------
    if (2 == (1 + 1) * 1) {
        return;//  ww w. j  av a 2  s .co m
    }
    // not working properly, deactivate for now ----------------

    // -------------------------------------------------------------
    // -------------------------- smaller top bar  -----------------
    // -------------------------------------------------------------
    RelativeLayout v11 = (RelativeLayout) findViewById(R.id.gui_top_container);
    int h11 = getResources().getDimensionPixelSize(R.dimen.gui_top_container_height);
    if (horizonzal) {
        // h11 = (int) ((float) h11 * 0.8f);
        h11 = h11 * 1;
    } else {
        h11 = (int) ((float) h11 * 0.7f);
    }
    android.view.ViewGroup.LayoutParams lp11 = v11.getLayoutParams();
    lp11.height = h11;
    v11.requestLayout();
    // -------------------------------------------------------------
    // -------------------------- smaller top bar  -----------------
    // -------------------------------------------------------------
}