Example usage for android.view Gravity RIGHT

List of usage examples for android.view Gravity RIGHT

Introduction

In this page you can find the example usage for android.view Gravity RIGHT.

Prototype

int RIGHT

To view the source code for android.view Gravity RIGHT.

Click Source Link

Document

Push object to the right of its container, not changing its size.

Usage

From source file:com.jecelyin.editor.v2.ui.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        if (mDrawerLayout != null) {
            if (mDrawerLayout.isDrawerOpen(Gravity.LEFT)) {
                mDrawerLayout.closeDrawer(Gravity.LEFT);
                return true;
            }/*  w w  w  .j a  v  a  2s . co m*/
            if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
                mDrawerLayout.closeDrawer(Gravity.RIGHT);
                return true;
            }
        }
        if ((System.currentTimeMillis() - mExitTime) > 2000) {
            UIUtils.toast(getContext(), R.string.press_again_will_exit);
            mExitTime = System.currentTimeMillis();
            return true;
        } else {
            return tabManager == null || tabManager.closeAllTabAndExitApp();
        }
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.dwdesign.tweetings.activity.HomeActivity.java

@Override
public boolean onPrepareOptionsMenu(final Menu menu) {
    final boolean bottom_actions = mPreferences.getBoolean(PREFERENCE_KEY_COMPOSE_BUTTON, false);
    final boolean leftside_compose_button = mPreferences.getBoolean(PREFERENCE_KEY_LEFTSIDE_COMPOSE_BUTTON,
            false);//from   w  w w .j av  a 2  s  . c  om
    int icon = R.drawable.ic_menu_tweet, title = R.string.compose;
    if (mViewPager != null && mAdapter != null) {
        final int position = mViewPager.getCurrentItem();
        int messagesPosition = TAB_POSITION_MESSAGES;
        if (mShowHomeTab == false) {
            messagesPosition--;
        }
        if (mShowMentionsTab == false) {
            messagesPosition--;
        }
        if (position == mAdapter.getCount() - 1 && mShowAccountsTab) {
            icon = R.drawable.ic_menu_add;
            title = R.string.add_account;
        } else {
            title = R.string.compose;
            if (mShowMessagesTab && position == messagesPosition) {
                icon = R.drawable.ic_menu_compose;
            } else {
                icon = R.drawable.ic_menu_tweet;
            }
        }
        final MenuItem composeItem = menu.findItem(MENU_COMPOSE);
        if (composeItem != null) {
            composeItem.setIcon(icon);
            composeItem.setTitle(title);
            composeItem.setVisible(!bottom_actions && mViewPager.getVisibility() == View.VISIBLE);
        }
        if (mComposeButton != null) {
            mComposeButton.setImageResource(icon);
            mComposeButton.setVisibility(
                    bottom_actions && mViewPager.getVisibility() == View.VISIBLE ? View.VISIBLE : View.GONE);
            if (bottom_actions) {
                final FrameLayout.LayoutParams compose_lp = (FrameLayout.LayoutParams) mComposeButton
                        .getLayoutParams();
                compose_lp.gravity = Gravity.BOTTOM | (leftside_compose_button ? Gravity.LEFT : Gravity.RIGHT);
                mComposeButton.setLayoutParams(compose_lp);
            }
        }
    }
    return super.onPrepareOptionsMenu(menu);
}

From source file:com.hippo.nimingban.ui.ListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_list, menu);
    mRule = menu.findItem(R.id.action_rule);
    mCreatePost = menu.findItem(R.id.action_create_post);
    mRefresh = menu.findItem(R.id.action_refresh);
    mSortForumsMenu = menu.findItem(R.id.action_sort_forums);

    if (mSlidingDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
        mRule.setVisible(false);// w w  w  .  j  ava 2s. c o m
        mCreatePost.setVisible(false);
        mRefresh.setVisible(false);
        mSortForumsMenu.setVisible(true);
    } else {
        mRule.setVisible(true);
        mCreatePost.setVisible(true);
        mRefresh.setVisible(true);
        mSortForumsMenu.setVisible(false);
    }

    return true;
}

From source file:com.aidy.bottomdrawerlayout.AllDrawerLayout.java

void moveDrawerToOffset(View drawerView, float slideOffset) {
    Log.i(TAG, "BottomDrawerLayout -- moveDrawerToOffset() -- slideOffset = " + slideOffset);
    final int absGravity = getDrawerViewAbsoluteGravity(drawerView);
    final float oldOffset = getDrawerViewOffset(drawerView);
    final int width = drawerView.getWidth();
    final int height = drawerView.getHeight();
    final int xoldPos = (int) (width * oldOffset);
    final int xnewPos = (int) (width * slideOffset);
    final int yoldPos = (int) (height * oldOffset);
    final int ynewPos = (int) (height * slideOffset);
    int dx = xnewPos - xoldPos;
    int dy = ynewPos - yoldPos;

    if (absGravity == Gravity.LEFT || absGravity == Gravity.RIGHT) {
        drawerView.offsetLeftAndRight(checkDrawerViewAbsoluteGravity(drawerView, Gravity.LEFT) ? dx : -dx);
    }//from w ww. ja v a 2  s.  com
    if (absGravity == Gravity.TOP || absGravity == Gravity.BOTTOM) {
        drawerView.offsetTopAndBottom(checkDrawerViewAbsoluteGravity(drawerView, Gravity.TOP) ? dy : -dy);
    }
    setDrawerViewOffset(drawerView, slideOffset);
}

From source file:com.hippo.ehviewer.ui.scene.GalleryListScene.java

@Override
public View onCreateDrawerView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.drawer_list, container, false);
    Toolbar toolbar = (Toolbar) ViewUtils.$$(view, R.id.toolbar);
    final TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
    final ListView listView = (ListView) ViewUtils.$$(view, R.id.list_view);

    Context context = getContext2();
    Assert.assertNotNull(context);/*from  www.  jav  a  2 s .  c o m*/

    final List<QuickSearch> list = EhDB.getAllQuickSearch();
    final ArrayAdapter<QuickSearch> adapter = new ArrayAdapter<>(context, R.layout.item_simple_list, list);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (null == mHelper || null == mUrlBuilder) {
                return;
            }

            mUrlBuilder.set(list.get(position));
            mUrlBuilder.setPageIndex(0);
            onUpdateUrlBuilder();
            mHelper.refresh();
            setState(STATE_NORMAL);
            closeDrawer(Gravity.RIGHT);
        }
    });

    tip.setText(R.string.quick_search_tip);
    toolbar.setTitle(R.string.quick_search);
    toolbar.inflateMenu(R.menu.drawer_gallery_list);
    toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            int id = item.getItemId();
            switch (id) {
            case R.id.action_add:
                if (Settings.getQuickSearchTip()) {
                    showQuickSearchTipDialog(list, adapter, listView, tip);
                } else {
                    showAddQuickSearchDialog(list, adapter, listView, tip);
                }
                break;
            case R.id.action_settings:
                startScene(new Announcer(QuickSearchScene.class));
                break;
            }
            return true;
        }
    });

    if (0 == list.size()) {
        tip.setVisibility(View.VISIBLE);
        listView.setVisibility(View.GONE);
    } else {
        tip.setVisibility(View.GONE);
        listView.setVisibility(View.VISIBLE);
    }

    return view;
}

From source file:com.initialxy.cordova.themeablebrowser.ThemeableBrowser.java

/**
 * Display a new browser with the specified URL.
 *
 * @param url//  w  w  w  .  j  a  v  a2  s. c  om
 * @param features
 * @return
 */
public String showWebPage(final String url, final Options features) {
    final CordovaWebView thatWebView = this.webView;

    // Create dialog in new thread
    Runnable runnable = new Runnable() {
        @SuppressLint("NewApi")
        public void run() {
            // Let's create the main dialog
            dialog = new ThemeableBrowserDialog(cordova.getActivity(), android.R.style.Theme_Black_NoTitleBar,
                    features.hardwareback);
            if (!features.disableAnimation) {
                dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
            }
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCancelable(true);
            dialog.setThemeableBrowser(getThemeableBrowser());

            // Main container layout
            ViewGroup main = null;

            if (features.fullscreen) {
                main = new FrameLayout(cordova.getActivity());
            } else {
                main = new LinearLayout(cordova.getActivity());
                ((LinearLayout) main).setOrientation(LinearLayout.VERTICAL);
            }

            // Toolbar layout
            Toolbar toolbarDef = features.toolbar;
            FrameLayout toolbar = new FrameLayout(cordova.getActivity());
            toolbar.setBackgroundColor(hexStringToColor(
                    toolbarDef != null && toolbarDef.color != null ? toolbarDef.color : "#ffffffff"));
            toolbar.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT,
                    dpToPixels(toolbarDef != null ? toolbarDef.height : TOOLBAR_DEF_HEIGHT)));

            if (toolbarDef != null && (toolbarDef.image != null || toolbarDef.wwwImage != null)) {
                try {
                    Drawable background = getImage(toolbarDef.image, toolbarDef.wwwImage,
                            toolbarDef.wwwImageDensity);
                    setBackground(toolbar, background);
                } catch (Resources.NotFoundException e) {
                    emitError(ERR_LOADFAIL,
                            String.format("Image for toolbar, %s, failed to load", toolbarDef.image));
                } catch (IOException ioe) {
                    emitError(ERR_LOADFAIL,
                            String.format("Image for toolbar, %s, failed to load", toolbarDef.wwwImage));
                }
            }

            // Left Button Container layout
            LinearLayout leftButtonContainer = new LinearLayout(cordova.getActivity());
            FrameLayout.LayoutParams leftButtonContainerParams = new FrameLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            leftButtonContainerParams.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;
            leftButtonContainer.setLayoutParams(leftButtonContainerParams);
            leftButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL);

            // Right Button Container layout
            LinearLayout rightButtonContainer = new LinearLayout(cordova.getActivity());
            FrameLayout.LayoutParams rightButtonContainerParams = new FrameLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            rightButtonContainerParams.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL;
            rightButtonContainer.setLayoutParams(rightButtonContainerParams);
            rightButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL);

            // Edit Text Box
            edittext = new EditText(cordova.getActivity());
            RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1);
            textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5);
            edittext.setLayoutParams(textLayoutParams);
            edittext.setSingleLine(true);
            edittext.setText(url);
            edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
            edittext.setImeOptions(EditorInfo.IME_ACTION_GO);
            edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE
            edittext.setOnKeyListener(new View.OnKeyListener() {
                public boolean onKey(View v, int keyCode, KeyEvent event) {
                    // If the event is a key-down event on the "enter" button
                    if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                        navigate(edittext.getText().toString());
                        return true;
                    }
                    return false;
                }
            });

            // Back button
            final Button back = createButton(features.backButton, "back button", new View.OnClickListener() {
                public void onClick(View v) {
                    emitButtonEvent(features.backButton, inAppWebView.getUrl());

                    if (features.backButtonCanClose && !canGoBack()) {
                        closeDialog();
                    } else {
                        goBack();
                    }
                }
            });

            if (back != null) {
                back.setEnabled(features.backButtonCanClose);
            }

            // Forward button
            final Button forward = createButton(features.forwardButton, "forward button",
                    new View.OnClickListener() {
                        public void onClick(View v) {
                            emitButtonEvent(features.forwardButton, inAppWebView.getUrl());

                            goForward();
                        }
                    });

            if (forward != null) {
                forward.setEnabled(false);
            }

            // Close/Done button
            Button close = createButton(features.closeButton, "close button", new View.OnClickListener() {
                public void onClick(View v) {
                    emitButtonEvent(features.closeButton, inAppWebView.getUrl());
                    closeDialog();
                }
            });

            // Menu button
            Spinner menu = features.menu != null ? new MenuSpinner(cordova.getActivity()) : null;
            if (menu != null) {
                menu.setLayoutParams(
                        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
                menu.setContentDescription("menu button");
                setButtonImages(menu, features.menu, DISABLED_ALPHA);

                // We are not allowed to use onClickListener for Spinner, so we will use
                // onTouchListener as a fallback.
                menu.setOnTouchListener(new View.OnTouchListener() {
                    @Override
                    public boolean onTouch(View v, MotionEvent event) {
                        if (event.getAction() == MotionEvent.ACTION_UP) {
                            emitButtonEvent(features.menu, inAppWebView.getUrl());
                        }
                        return false;
                    }
                });

                if (features.menu.items != null) {
                    HideSelectedAdapter<EventLabel> adapter = new HideSelectedAdapter<EventLabel>(
                            cordova.getActivity(), android.R.layout.simple_spinner_item, features.menu.items);
                    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                    menu.setAdapter(adapter);
                    menu.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                        @Override
                        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                            if (inAppWebView != null && i < features.menu.items.length) {
                                emitButtonEvent(features.menu.items[i], inAppWebView.getUrl(), i);
                            }
                        }

                        @Override
                        public void onNothingSelected(AdapterView<?> adapterView) {
                        }
                    });
                }
            }

            // Title
            final TextView title = features.title != null ? new TextView(cordova.getActivity()) : null;
            final TextView subtitle = features.title != null ? new TextView(cordova.getActivity()) : null;
            if (title != null) {
                FrameLayout.LayoutParams titleParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                        LayoutParams.FILL_PARENT);
                titleParams.gravity = Gravity.CENTER;
                title.setLayoutParams(titleParams);
                title.setSingleLine();
                title.setEllipsize(TextUtils.TruncateAt.END);
                title.setGravity(Gravity.CENTER | Gravity.TOP);
                title.setTextColor(
                        hexStringToColor(features.title.color != null ? features.title.color : "#000000ff"));
                title.setTypeface(title.getTypeface(), Typeface.BOLD);
                title.setTextSize(TypedValue.COMPLEX_UNIT_PT, 8);

                FrameLayout.LayoutParams subtitleParams = new FrameLayout.LayoutParams(
                        LayoutParams.MATCH_PARENT, LayoutParams.FILL_PARENT);
                titleParams.gravity = Gravity.CENTER;
                subtitle.setLayoutParams(subtitleParams);
                subtitle.setSingleLine();
                subtitle.setEllipsize(TextUtils.TruncateAt.END);
                subtitle.setGravity(Gravity.CENTER | Gravity.BOTTOM);
                subtitle.setTextColor(hexStringToColor(
                        features.title.subColor != null ? features.title.subColor : "#000000ff"));
                subtitle.setTextSize(TypedValue.COMPLEX_UNIT_PT, 6);
                subtitle.setVisibility(View.GONE);

                if (features.title.staticText != null) {
                    title.setGravity(Gravity.CENTER);
                    title.setText(features.title.staticText);
                } else {
                    subtitle.setVisibility(View.VISIBLE);
                }
            }

            // WebView
            inAppWebView = new WebView(cordova.getActivity());
            final ViewGroup.LayoutParams inAppWebViewParams = features.fullscreen
                    ? new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
                    : new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0);
            if (!features.fullscreen) {
                ((LinearLayout.LayoutParams) inAppWebViewParams).weight = 1;
            }
            inAppWebView.setLayoutParams(inAppWebViewParams);
            inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView));
            WebViewClient client = new ThemeableBrowserClient(thatWebView, new PageLoadListener() {

                @Override
                public void onPageStarted(String url) {
                    if (inAppWebView != null && title != null && features.title != null
                            && features.title.staticText == null && features.title.showPageTitle
                            && features.title.loadingText != null) {
                        title.setText(features.title.loadingText);
                        subtitle.setText(url);
                    }
                }

                @Override
                public void onPageFinished(String url, boolean canGoBack, boolean canGoForward) {
                    if (inAppWebView != null && title != null && features.title != null
                            && features.title.staticText == null && features.title.showPageTitle) {
                        title.setText(inAppWebView.getTitle());
                        subtitle.setText(inAppWebView.getUrl());
                    }

                    if (back != null) {
                        back.setEnabled(canGoBack || features.backButtonCanClose);
                    }

                    if (forward != null) {
                        forward.setEnabled(canGoForward);
                    }
                }
            });
            inAppWebView.setWebViewClient(client);
            WebSettings settings = inAppWebView.getSettings();
            settings.setJavaScriptEnabled(true);
            settings.setJavaScriptCanOpenWindowsAutomatically(true);
            settings.setBuiltInZoomControls(features.zoom);
            settings.setDisplayZoomControls(false);
            settings.setPluginState(android.webkit.WebSettings.PluginState.ON);

            //Toggle whether this is enabled or not!
            Bundle appSettings = cordova.getActivity().getIntent().getExtras();
            boolean enableDatabase = appSettings == null
                    || appSettings.getBoolean("ThemeableBrowserStorageEnabled", true);
            if (enableDatabase) {
                String databasePath = cordova.getActivity().getApplicationContext()
                        .getDir("themeableBrowserDB", Context.MODE_PRIVATE).getPath();
                settings.setDatabasePath(databasePath);
                settings.setDatabaseEnabled(true);
            }
            settings.setDomStorageEnabled(true);

            if (features.clearcache) {
                CookieManager.getInstance().removeAllCookie();
            } else if (features.clearsessioncache) {
                CookieManager.getInstance().removeSessionCookie();
            }

            inAppWebView.loadUrl(url);
            inAppWebView.getSettings().setLoadWithOverviewMode(true);
            inAppWebView.getSettings().setUseWideViewPort(true);
            inAppWebView.requestFocus();
            inAppWebView.requestFocusFromTouch();

            // Add buttons to either leftButtonsContainer or
            // rightButtonsContainer according to user's alignment
            // configuration.
            int leftContainerWidth = 0;
            int rightContainerWidth = 0;

            if (features.customButtons != null) {
                for (int i = 0; i < features.customButtons.length; i++) {
                    final BrowserButton buttonProps = features.customButtons[i];
                    final int index = i;
                    Button button = createButton(buttonProps, String.format("custom button at %d", i),
                            new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    if (inAppWebView != null) {
                                        emitButtonEvent(buttonProps, inAppWebView.getUrl(), index);
                                    }
                                }
                            });

                    if (ALIGN_RIGHT.equals(buttonProps.align)) {
                        rightButtonContainer.addView(button);
                        rightContainerWidth += button.getLayoutParams().width;
                    } else {
                        leftButtonContainer.addView(button, 0);
                        leftContainerWidth += button.getLayoutParams().width;
                    }
                }
            }

            // Back and forward buttons must be added with special ordering logic such
            // that back button is always on the left of forward button if both buttons
            // are on the same side.
            if (forward != null && features.forwardButton != null
                    && !ALIGN_RIGHT.equals(features.forwardButton.align)) {
                leftButtonContainer.addView(forward, 0);
                leftContainerWidth += forward.getLayoutParams().width;
            }

            if (back != null && features.backButton != null && ALIGN_RIGHT.equals(features.backButton.align)) {
                rightButtonContainer.addView(back);
                rightContainerWidth += back.getLayoutParams().width;
            }

            if (back != null && features.backButton != null && !ALIGN_RIGHT.equals(features.backButton.align)) {
                leftButtonContainer.addView(back, 0);
                leftContainerWidth += back.getLayoutParams().width;
            }

            if (forward != null && features.forwardButton != null
                    && ALIGN_RIGHT.equals(features.forwardButton.align)) {
                rightButtonContainer.addView(forward);
                rightContainerWidth += forward.getLayoutParams().width;
            }

            if (menu != null) {
                if (features.menu != null && ALIGN_RIGHT.equals(features.menu.align)) {
                    rightButtonContainer.addView(menu);
                    rightContainerWidth += menu.getLayoutParams().width;
                } else {
                    leftButtonContainer.addView(menu, 0);
                    leftContainerWidth += menu.getLayoutParams().width;
                }
            }

            if (close != null) {
                if (features.closeButton != null && ALIGN_RIGHT.equals(features.closeButton.align)) {
                    rightButtonContainer.addView(close);
                    rightContainerWidth += close.getLayoutParams().width;
                } else {
                    leftButtonContainer.addView(close, 0);
                    leftContainerWidth += close.getLayoutParams().width;
                }
            }

            // Add the views to our toolbar
            toolbar.addView(leftButtonContainer);
            // Don't show address bar.
            // toolbar.addView(edittext);
            toolbar.addView(rightButtonContainer);

            if (title != null) {
                int titleMargin = Math.max(leftContainerWidth, rightContainerWidth);

                FrameLayout.LayoutParams titleParams = (FrameLayout.LayoutParams) title.getLayoutParams();
                titleParams.setMargins(titleMargin, 8, titleMargin, 0);
                toolbar.addView(title);
            }

            if (subtitle != null) {
                int subtitleMargin = Math.max(leftContainerWidth, rightContainerWidth);

                FrameLayout.LayoutParams subtitleParams = (FrameLayout.LayoutParams) subtitle.getLayoutParams();
                subtitleParams.setMargins(subtitleMargin, 0, subtitleMargin, 8);
                toolbar.addView(subtitle);
            }

            if (features.fullscreen) {
                // If full screen mode, we have to add inAppWebView before adding toolbar.
                main.addView(inAppWebView);
            }

            // Don't add the toolbar if its been disabled
            if (features.location) {
                // Add our toolbar to our main view/layout
                main.addView(toolbar);
            }

            if (!features.fullscreen) {
                // If not full screen, we add inAppWebView after adding toolbar.
                main.addView(inAppWebView);
            }

            WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
            lp.copyFrom(dialog.getWindow().getAttributes());
            lp.width = WindowManager.LayoutParams.MATCH_PARENT;
            lp.height = WindowManager.LayoutParams.MATCH_PARENT;

            dialog.setContentView(main);
            dialog.show();
            dialog.getWindow().setAttributes(lp);
            // the goal of openhidden is to load the url and not display it
            // Show() needs to be called to cause the URL to be loaded
            if (features.hidden) {
                dialog.hide();
            }
        }
    };
    this.cordova.getActivity().runOnUiThread(runnable);
    return "";
}

From source file:com.huangj.huangjlibrary.widget.drawerlayout.DrawerLayout.java

/**
 * Enable or disable interaction with the given drawer.
 *
 * <p>This allows the application to restrict the user's ability to open or close
 * the given drawer. DrawerLayout will still respond to calls to {@link #openDrawer(int)},
 * {@link #closeDrawer(int)} and friends if a drawer is locked.</p>
 *
 * <p>Locking a drawer open or closed will implicitly open or close
 * that drawer as appropriate.</p>
 *
 * @param lockMode The new lock mode for the given drawer. One of {@link #LOCK_MODE_UNLOCKED},
 *                 {@link #LOCK_MODE_LOCKED_CLOSED} or {@link #LOCK_MODE_LOCKED_OPEN}.
 * @param edgeGravity Gravity.LEFT, RIGHT, START or END.
 *                    Expresses which drawer to change the mode for.
 *
 * @see #LOCK_MODE_UNLOCKED/*from ww  w  .j a va2  s. c o m*/
 * @see #LOCK_MODE_LOCKED_CLOSED
 * @see #LOCK_MODE_LOCKED_OPEN
 */
public void setDrawerLockMode(@LockMode int lockMode, @EdgeGravity int edgeGravity) {
    final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this));

    switch (edgeGravity) {
    case Gravity.LEFT:
        mLockModeLeft = lockMode;
        break;
    case Gravity.RIGHT:
        mLockModeRight = lockMode;
        break;
    case GravityCompat.START:
        mLockModeStart = lockMode;
        break;
    case GravityCompat.END:
        mLockModeEnd = lockMode;
        break;
    }

    if (lockMode != LOCK_MODE_UNLOCKED) {
        // Cancel interaction in progress
        final ViewDragHelper helper = absGravity == Gravity.LEFT ? mLeftDragger : mRightDragger;
        helper.cancel();
    }
    switch (lockMode) {
    case LOCK_MODE_LOCKED_OPEN:
        final View toOpen = findDrawerWithGravity(absGravity);
        if (toOpen != null) {
            openDrawer(toOpen);
        }
        break;
    case LOCK_MODE_LOCKED_CLOSED:
        final View toClose = findDrawerWithGravity(absGravity);
        if (toClose != null) {
            closeDrawer(toClose);
        }
        break;
    // default: do nothing
    }
}

From source file:com.aidy.bottomdrawerlayout.AllDrawerLayout.java

/**
 * Simple gravity to string - only supports LEFT and RIGHT for debugging
 * output.//from  w  w w .  j a  v  a 2  s  .co  m
 * 
 * @param gravity
 *            Absolute gravity value
 * @return LEFT or RIGHT as appropriate, or a hex string
 */
static String gravityToString(int gravity) {
    if ((gravity & Gravity.LEFT) == Gravity.LEFT) {
        return "LEFT";
    }
    if ((gravity & Gravity.RIGHT) == Gravity.RIGHT) {
        return "RIGHT";
    }
    if ((gravity & Gravity.TOP) == Gravity.TOP) {
        return "TOP";
    }
    if ((gravity & Gravity.BOTTOM) == Gravity.BOTTOM) {
        return "BOTTOM";
    }
    return Integer.toHexString(gravity);
}

From source file:com.jecelyin.editor.v2.widget.AnyDrawerLayout.java

/**
 * Enable or disable interaction with the given drawer.
 *
 * <p>This allows the application to restrict the user's ability to open or close
 * the given drawer. DrawerLayout will still respond to calls to {@link #openDrawer(int)},
 * {@link #closeDrawer(int)} and friends if a drawer is locked.</p>
 *
 * <p>Locking a drawer open or closed will implicitly open or close
 * that drawer as appropriate.</p>
 *
 * @param lockMode The new lock mode for the given drawer. One of {@link #LOCK_MODE_UNLOCKED},
 *                 {@link #LOCK_MODE_LOCKED_CLOSED} or {@link #LOCK_MODE_LOCKED_OPEN}.
 * @param edgeGravity Gravity.LEFT, RIGHT, START or END.
 *                    Expresses which drawer to change the mode for.
 *
 * @see #LOCK_MODE_UNLOCKED// w  ww .  j a  va  2  s . c om
 * @see #LOCK_MODE_LOCKED_CLOSED
 * @see #LOCK_MODE_LOCKED_OPEN
 */
public void setDrawerLockMode(@LockMode int lockMode, @EdgeGravity int edgeGravity) {
    final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this));

    switch (edgeGravity) {
    case Gravity.LEFT:
        mLockModeLeft = lockMode;
        break;
    case Gravity.RIGHT:
        mLockModeRight = lockMode;
        break;
    case GravityCompat.START:
        mLockModeStart = lockMode;
        break;
    case GravityCompat.END:
        mLockModeEnd = lockMode;
        break;
    }

    if (lockMode != LOCK_MODE_UNLOCKED) {
        // Cancel interaction in progress
        final ViewDragHelper helper = absGravity == Gravity.LEFT ? mLeftDragger
                : (absGravity == Gravity.RIGHT ? mRightDragger : mBottomDragger);
        helper.cancel();
    }
    switch (lockMode) {
    case LOCK_MODE_LOCKED_OPEN:
        final View toOpen = findDrawerWithGravity(absGravity);
        if (toOpen != null) {
            openDrawer(toOpen);
        }
        break;
    case LOCK_MODE_LOCKED_CLOSED:
        final View toClose = findDrawerWithGravity(absGravity);
        if (toClose != null) {
            closeDrawer(toClose);
        }
        break;
    // default: do nothing
    }
}

From source file:com.aidy.bottomdrawerlayout.BottomDrawerLayout.java

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    Log.i(TAG, "onLayout()");
    mInLayout = true;/*from  w w w. jav a  2  s  .c  om*/
    final int width = r - l;
    final int height = b - t;
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == GONE) {
            continue;
        }
        final LayoutParams lp = (LayoutParams) child.getLayoutParams();
        if (isContentView(child)) {
            child.layout(lp.leftMargin, lp.topMargin, lp.leftMargin + child.getMeasuredWidth(),
                    lp.topMargin + child.getMeasuredHeight());
        } else {
            final int childWidth = child.getMeasuredWidth();
            final int childHeight = child.getMeasuredHeight();
            int childTop;

            final float newOffset;
            if (checkDrawerViewAbsoluteGravity(child, Gravity.BOTTOM)) {
                childTop = height - (int) (childHeight * lp.onScreen);
                newOffset = (float) (height - childTop) / childWidth;
            } else {
                childTop = -childHeight + (int) (childHeight * lp.onScreen);
                newOffset = (float) (childHeight + childTop) / childHeight;
            }
            final boolean changeOffset = newOffset != lp.onScreen;
            final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK;
            switch (vgrav) {
            default:
            case Gravity.LEFT: {
                child.layout(lp.leftMargin, childTop, lp.leftMargin + childWidth, childTop + childHeight);
                break;
            }
            case Gravity.RIGHT: {
                child.layout(width - lp.rightMargin, childTop, width - lp.rightMargin, childTop + childHeight);
                break;
            }
            case Gravity.CENTER_HORIZONTAL: {
                int childLeft = (width - childWidth) / 2;
                if (childLeft < lp.leftMargin) {
                    childLeft = lp.leftMargin;
                } else if (childLeft + childWidth > width - lp.rightMargin) {
                    childLeft = width - lp.rightMargin - childWidth;
                }
                child.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
                break;
            }
            }

            if (changeOffset) {
                setDrawerViewOffset(child, newOffset);
            }

            final int newVisibility = lp.onScreen > 0 ? VISIBLE : INVISIBLE;
            if (child.getVisibility() != newVisibility) {
                child.setVisibility(newVisibility);
            }
        }
    }
    mInLayout = false;
    mFirstLayout = false;
}