Example usage for android.view Gravity BOTTOM

List of usage examples for android.view Gravity BOTTOM

Introduction

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

Prototype

int BOTTOM

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

Click Source Link

Document

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

Usage

From source file:com.sonvp.tooltip.Tooltip.java

private Tooltip(Builder builder) {
    this.builder = builder;
    this.anchorView = builder.anchorView;
    this.gravity = builder.tooltipGravity;

    if (builder.dismissOutsideTouch) {

        rootView = (ViewGroup) anchorView.getRootView();
        overlay = new View(builder.context);
        overlay.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        //        overlay.setBackgroundColor(builder.context.getResources().getColor(android.R.color.holo_green_light));
        overlay.setOnTouchListener(this);
        rootView.addView(overlay);// w ww.j  a v  a2 s  .  co m
    }

    // TODO container should NOT capture all events
    container = new LinearLayout(builder.context);
    container.setOnClickListener(this);

    int backgroundColor = builder.backgroundColor;

    viewTooltip = getViewTooltip(builder, backgroundColor);

    rectAnchorView = getRectView(anchorView);
    changeGravityToolTip();
    if (builder.arrowDrawable == null) {
        builder.arrowDrawable = new ArrowDrawable(backgroundColor, gravity);
    }

    arrow = new ImageView(builder.context);
    // TODO supports Gravity.NO_GRAVITY
    switch (gravity) {
    case Gravity.LEFT:
        container.setOrientation(LinearLayout.HORIZONTAL);
        container.addView(viewTooltip, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        arrow.setImageDrawable(builder.arrowDrawable);
        container.addView(arrow,
                new LinearLayout.LayoutParams((int) builder.arrowWidth, (int) builder.arrowHeight));
        break;
    case Gravity.RIGHT:
        container.setOrientation(LinearLayout.HORIZONTAL);
        arrow.setImageDrawable(builder.arrowDrawable);
        container.addView(arrow,
                new LinearLayout.LayoutParams((int) builder.arrowWidth, (int) builder.arrowHeight));
        container.addView(viewTooltip, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        break;
    case Gravity.TOP:
        container.setOrientation(LinearLayout.VERTICAL);
        container.addView(viewTooltip, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        arrow.setImageDrawable(builder.arrowDrawable);
        container.addView(arrow,
                new LinearLayout.LayoutParams((int) builder.arrowWidth, (int) builder.arrowHeight));
        break;
    case Gravity.BOTTOM:
        container.setOrientation(LinearLayout.VERTICAL);
        arrow.setImageDrawable(builder.arrowDrawable);
        container.addView(arrow,
                new LinearLayout.LayoutParams((int) builder.arrowWidth, (int) builder.arrowHeight));
        container.addView(viewTooltip, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        break;
    }

    popupWindow = new PopupWindow(container, ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    popupWindow.setOnDismissListener(this);
    popupWindow.setClippingEnabled(false);
    popupWindow.setAnimationStyle(android.R.style.Animation);
    //        popupWindow.setBackgroundDrawable(builder.context.getResources().getDrawable(android.R.color.holo_blue_bright));

}

From source file:android.support.transition.Slide.java

/**
 * Change the edge that Views appear and disappear from.
 *
 * @param slideEdge The edge of the scene to use for Views appearing and disappearing. One of
 *                  {@link android.view.Gravity#LEFT}, {@link android.view.Gravity#TOP},
 *                  {@link android.view.Gravity#RIGHT}, {@link android.view.Gravity#BOTTOM},
 *                  {@link android.view.Gravity#START}, {@link android.view.Gravity#END}.
 *///  www .  j a v a2 s.  c  om
public void setSlideEdge(@GravityFlag int slideEdge) {
    switch (slideEdge) {
    case Gravity.LEFT:
        mSlideCalculator = sCalculateLeft;
        break;
    case Gravity.TOP:
        mSlideCalculator = sCalculateTop;
        break;
    case Gravity.RIGHT:
        mSlideCalculator = sCalculateRight;
        break;
    case Gravity.BOTTOM:
        mSlideCalculator = sCalculateBottom;
        break;
    case Gravity.START:
        mSlideCalculator = sCalculateStart;
        break;
    case Gravity.END:
        mSlideCalculator = sCalculateEnd;
        break;
    default:
        throw new IllegalArgumentException("Invalid slide direction");
    }
    mSlideEdge = slideEdge;
    SidePropagation propagation = new SidePropagation();
    propagation.setSide(slideEdge);
    setPropagation(propagation);
}

From source file:com.aosijia.dragonbutler.ui.widget.ActionSheet.java

private View createView() {
    FrameLayout parent = new FrameLayout(getActivity());
    parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg = new View(getActivity());
    mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg.setBackgroundColor(Color.argb(136, 0, 0, 0));
    mBg.setId(ActionSheet.BG_VIEW_ID);/*from ww w  .  j a  va  2s  .co m*/
    mBg.setOnClickListener(this);

    mPanel = new LinearLayout(getActivity());
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.BOTTOM;
    mPanel.setLayoutParams(params);
    mPanel.setOrientation(LinearLayout.VERTICAL);
    if (checkDeviceHasNavigationBar(getActivity())) {
        parent.setPadding(0, 0, 0, getNavBarHeight(getActivity()));
    } else {
        parent.setPadding(0, 0, 0, 0);
    }

    parent.addView(mBg);
    parent.addView(mPanel);
    return parent;
}

From source file:com.shenzhen.elson.selectordialoglib.SelectorDialog.java

private View createView() {
    FrameLayout parent = new FrameLayout(getActivity());
    parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg = new View(getActivity());
    mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg.setBackgroundColor(Color.argb(136, 0, 0, 0));
    mBg.setId(SelectorDialog.BG_VIEW_ID);
    mBg.setOnClickListener(this);

    mPanel = new LinearLayout(getActivity());
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.BOTTOM;
    mPanel.setLayoutParams(params);//from  w  ww  .  j  a v  a 2  s  .c  o  m
    mPanel.setOrientation(LinearLayout.VERTICAL);
    parent.setPadding(0, 0, 0, getNavBarHeight(getActivity()));
    parent.addView(mBg);
    parent.addView(mPanel);
    return parent;
}

From source file:com.farmerbb.taskbar.service.StartMenuService.java

@SuppressLint("RtlHardcoded")
private void drawStartMenu() {
    IconCache.getInstance(this).clearCache();

    final SharedPreferences pref = U.getSharedPreferences(this);
    final boolean hasHardwareKeyboard = getResources()
            .getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS;

    switch (pref.getString("show_search_bar", "keyboard")) {
    case "always":
        shouldShowSearchBox = true;/* ww w .j ava 2  s  .co m*/
        break;
    case "keyboard":
        shouldShowSearchBox = hasHardwareKeyboard;
        break;
    case "never":
        shouldShowSearchBox = false;
        break;
    }

    // Initialize layout params
    windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
    U.setCachedRotation(windowManager.getDefaultDisplay().getRotation());

    final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_PHONE,
            shouldShowSearchBox ? 0
                    : WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                            | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
            PixelFormat.TRANSLUCENT);

    // Determine where to show the start menu on screen
    switch (U.getTaskbarPosition(this)) {
    case "bottom_left":
        layoutId = R.layout.start_menu_left;
        params.gravity = Gravity.BOTTOM | Gravity.LEFT;
        break;
    case "bottom_vertical_left":
        layoutId = R.layout.start_menu_vertical_left;
        params.gravity = Gravity.BOTTOM | Gravity.LEFT;
        break;
    case "bottom_right":
        layoutId = R.layout.start_menu_right;
        params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
        break;
    case "bottom_vertical_right":
        layoutId = R.layout.start_menu_vertical_right;
        params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
        break;
    case "top_left":
        layoutId = R.layout.start_menu_top_left;
        params.gravity = Gravity.TOP | Gravity.LEFT;
        break;
    case "top_vertical_left":
        layoutId = R.layout.start_menu_vertical_left;
        params.gravity = Gravity.TOP | Gravity.LEFT;
        break;
    case "top_right":
        layoutId = R.layout.start_menu_top_right;
        params.gravity = Gravity.TOP | Gravity.RIGHT;
        break;
    case "top_vertical_right":
        layoutId = R.layout.start_menu_vertical_right;
        params.gravity = Gravity.TOP | Gravity.RIGHT;
        break;
    }

    // Initialize views
    int theme = 0;

    switch (pref.getString("theme", "light")) {
    case "light":
        theme = R.style.AppTheme;
        break;
    case "dark":
        theme = R.style.AppTheme_Dark;
        break;
    }

    ContextThemeWrapper wrapper = new ContextThemeWrapper(this, theme);
    layout = (StartMenuLayout) LayoutInflater.from(wrapper).inflate(layoutId, null);
    startMenu = (GridView) layout.findViewById(R.id.start_menu);

    if ((shouldShowSearchBox && !hasHardwareKeyboard)
            || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1)
        layout.viewHandlesBackButton();

    boolean scrollbar = pref.getBoolean("scrollbar", false);
    startMenu.setFastScrollEnabled(scrollbar);
    startMenu.setFastScrollAlwaysVisible(scrollbar);
    startMenu.setScrollBarStyle(scrollbar ? View.SCROLLBARS_OUTSIDE_INSET : View.SCROLLBARS_INSIDE_OVERLAY);

    if (pref.getBoolean("transparent_start_menu", false))
        startMenu.setBackgroundColor(0);

    searchView = (SearchView) layout.findViewById(R.id.search);

    int backgroundTint = U.getBackgroundTint(this);

    FrameLayout startMenuFrame = (FrameLayout) layout.findViewById(R.id.start_menu_frame);
    FrameLayout searchViewLayout = (FrameLayout) layout.findViewById(R.id.search_view_layout);
    startMenuFrame.setBackgroundColor(backgroundTint);
    searchViewLayout.setBackgroundColor(backgroundTint);

    if (shouldShowSearchBox) {
        if (!hasHardwareKeyboard)
            searchView.setIconifiedByDefault(true);

        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String query) {
                if (!hasSubmittedQuery) {
                    ListAdapter adapter = startMenu.getAdapter();
                    if (adapter != null) {
                        hasSubmittedQuery = true;

                        if (adapter.getCount() > 0) {
                            View view = adapter.getView(0, null, startMenu);
                            LinearLayout layout = (LinearLayout) view.findViewById(R.id.entry);
                            layout.performClick();
                        } else {
                            if (pref.getBoolean("hide_taskbar", true)
                                    && !FreeformHackHelper.getInstance().isInFreeformWorkspace())
                                LocalBroadcastManager.getInstance(StartMenuService.this)
                                        .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_TASKBAR"));
                            else
                                LocalBroadcastManager.getInstance(StartMenuService.this)
                                        .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU"));

                            Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
                            intent.putExtra(SearchManager.QUERY, query);
                            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            if (intent.resolveActivity(getPackageManager()) != null)
                                startActivity(intent);
                            else {
                                Uri uri = new Uri.Builder().scheme("https").authority("www.google.com")
                                        .path("search").appendQueryParameter("q", query).build();

                                intent = new Intent(Intent.ACTION_VIEW);
                                intent.setData(uri);
                                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

                                try {
                                    startActivity(intent);
                                } catch (ActivityNotFoundException e) {
                                    /* Gracefully fail */ }
                            }
                        }
                    }
                }
                return true;
            }

            @Override
            public boolean onQueryTextChange(String newText) {
                searchView.setIconified(false);

                View closeButton = searchView.findViewById(R.id.search_close_btn);
                if (closeButton != null)
                    closeButton.setVisibility(View.GONE);

                refreshApps(newText, false);

                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) {
                    new Handler().postDelayed(() -> {
                        EditText editText = (EditText) searchView.findViewById(R.id.search_src_text);
                        if (editText != null) {
                            editText.requestFocus();
                            editText.setSelection(editText.getText().length());
                        }
                    }, 50);
                }

                return true;
            }
        });

        searchView.setOnQueryTextFocusChangeListener((view, b) -> {
            if (!hasHardwareKeyboard) {
                ViewGroup.LayoutParams params1 = startMenu.getLayoutParams();
                params1.height = getResources().getDimensionPixelSize(b
                        && !U.isServiceRunning(this, "com.farmerbb.secondscreen.service.DisableKeyboardService")
                                ? R.dimen.start_menu_height_half
                                : R.dimen.start_menu_height);
                startMenu.setLayoutParams(params1);
            }

            if (!b) {
                if (hasHardwareKeyboard && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1)
                    LocalBroadcastManager.getInstance(StartMenuService.this)
                            .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU"));
                else {
                    InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
                    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
                }
            }
        });

        searchView.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);

        LinearLayout powerButton = (LinearLayout) layout.findViewById(R.id.power_button);
        powerButton.setOnClickListener(view -> {
            int[] location = new int[2];
            view.getLocationOnScreen(location);
            openContextMenu(location);
        });

        powerButton.setOnGenericMotionListener((view, motionEvent) -> {
            if (motionEvent.getAction() == MotionEvent.ACTION_BUTTON_PRESS
                    && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) {
                int[] location = new int[2];
                view.getLocationOnScreen(location);
                openContextMenu(location);
            }
            return false;
        });

        searchViewLayout.setOnClickListener(view -> searchView.setIconified(false));

        startMenu.setOnItemClickListener((parent, view, position, id) -> {
            hideStartMenu();

            AppEntry entry = (AppEntry) parent.getAdapter().getItem(position);
            U.launchApp(StartMenuService.this, entry.getPackageName(), entry.getComponentName(),
                    entry.getUserId(StartMenuService.this), null, false, false);
        });

        if (pref.getBoolean("transparent_start_menu", false))
            layout.findViewById(R.id.search_view_child_layout).setBackgroundColor(0);
    } else
        searchViewLayout.setVisibility(View.GONE);

    textView = (TextView) layout.findViewById(R.id.no_apps_found);

    LocalBroadcastManager.getInstance(this).unregisterReceiver(toggleReceiver);
    LocalBroadcastManager.getInstance(this).unregisterReceiver(toggleReceiverAlt);
    LocalBroadcastManager.getInstance(this).unregisterReceiver(hideReceiver);

    LocalBroadcastManager.getInstance(this).registerReceiver(toggleReceiver,
            new IntentFilter("com.farmerbb.taskbar.TOGGLE_START_MENU"));
    LocalBroadcastManager.getInstance(this).registerReceiver(toggleReceiverAlt,
            new IntentFilter("com.farmerbb.taskbar.TOGGLE_START_MENU_ALT"));
    LocalBroadcastManager.getInstance(this).registerReceiver(hideReceiver,
            new IntentFilter("com.farmerbb.taskbar.HIDE_START_MENU"));

    handler = new Handler();
    refreshApps(true);

    windowManager.addView(layout, params);
}

From source file:android.support.design.widget.CollapsingToolbarLayout.java

public CollapsingToolbarLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    ThemeUtils.checkAppCompatTheme(context);

    mCollapsingTextHelper = new CollapsingTextHelper(this);
    mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.DECELERATE_INTERPOLATOR);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingToolbarLayout, defStyleAttr,
            R.style.Widget_Design_CollapsingToolbar);

    mCollapsingTextHelper.setExpandedTextGravity(a.getInt(
            R.styleable.CollapsingToolbarLayout_expandedTitleGravity, GravityCompat.START | Gravity.BOTTOM));
    mCollapsingTextHelper/*from  ww  w  .j a  v a  2s .  c  om*/
            .setCollapsedTextGravity(a.getInt(R.styleable.CollapsingToolbarLayout_collapsedTitleGravity,
                    GravityCompat.START | Gravity.CENTER_VERTICAL));

    mExpandedMarginStart = mExpandedMarginTop = mExpandedMarginEnd = mExpandedMarginBottom = a
            .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMargin, 0);

    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart)) {
        mExpandedMarginStart = a
                .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart, 0);
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd)) {
        mExpandedMarginEnd = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd,
                0);
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop)) {
        mExpandedMarginTop = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop,
                0);
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom)) {
        mExpandedMarginBottom = a
                .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom, 0);
    }

    mCollapsingTitleEnabled = a.getBoolean(R.styleable.CollapsingToolbarLayout_titleEnabled, true);
    setTitle(a.getText(R.styleable.CollapsingToolbarLayout_title));

    // First load the default text appearances
    mCollapsingTextHelper.setExpandedTextAppearance(R.style.TextAppearance_Design_CollapsingToolbar_Expanded);
    mCollapsingTextHelper.setCollapsedTextAppearance(
            android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Widget_ActionBar_Title);

    // Now overlay any custom text appearances
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance)) {
        mCollapsingTextHelper.setExpandedTextAppearance(
                a.getResourceId(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance, 0));
    }
    if (a.hasValue(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance)) {
        mCollapsingTextHelper.setCollapsedTextAppearance(
                a.getResourceId(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance, 0));
    }

    mScrimVisibleHeightTrigger = a
            .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_scrimVisibleHeightTrigger, -1);

    mScrimAnimationDuration = a.getInt(R.styleable.CollapsingToolbarLayout_scrimAnimationDuration,
            DEFAULT_SCRIM_ANIMATION_DURATION);

    setContentScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_contentScrim));
    setStatusBarScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_statusBarScrim));

    mToolbarId = a.getResourceId(R.styleable.CollapsingToolbarLayout_toolbarId, -1);

    a.recycle();

    setWillNotDraw(false);

    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            return onWindowInsetChanged(insets);
        }
    });
}

From source file:com.instiwork.RegistrationActivity.java

public void dialogTermsUse() {
    View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.dialog_terms_use, null);
    mBottomSheetDialogTermsUse = new Dialog(RegistrationActivity.this, R.style.MaterialDialogSheet);
    mBottomSheetDialogTermsUse.setContentView(view);
    mBottomSheetDialogTermsUse.setCancelable(false);
    mBottomSheetDialogTermsUse.getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mBottomSheetDialogTermsUse.getWindow()
                .addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        mBottomSheetDialogTermsUse.getWindow().setStatusBarColor(Color.parseColor("#536942"));
    }/*  w  w  w .  j a  v  a2 s  . c o m*/
    mBottomSheetDialogTermsUse.getWindow().setGravity(Gravity.BOTTOM);
    mBottomSheetDialogTermsUse.show();

    view.findViewById(R.id.back_me_dlog_payment).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mBottomSheetDialogTermsUse.dismiss();
        }
    });

    pBarTermsUse = (ProgressBar) view.findViewById(R.id.pbar_terms_use);
    //        txtTermsUse = (RobotoLight) view.findViewById(R.id.txt_terms_use);

    webViewTermsUse = (WebView) view.findViewById(R.id.webv);
    webViewTermsUse.getSettings().setJavaScriptEnabled(true);
    webViewTermsUse.setVisibility(View.GONE);

    getTermsUse(InstiworkConstants.URL_DOMAIN + "Privacy_control");

    mBottomSheetDialogTermsUse.setOnKeyListener(new DialogInterface.OnKeyListener() {

        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN)
                if ((keyCode == KeyEvent.KEYCODE_BACK)) {
                    mBottomSheetDialogTermsUse.dismiss();
                    return true;
                }
            return false;
        }
    });
}

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

public BottomDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final float density = getResources().getDisplayMetrics().density;
    mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * density + 0.5f);
    final float minVel = MIN_FLING_VELOCITY * density;

    mBottomCallback = new ViewDragCallback(Gravity.BOTTOM);

    mBottomDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mBottomCallback);
    mBottomDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_BOTTOM);
    mBottomDragger.setMinVelocity(minVel);
    mBottomCallback.setDragger(mBottomDragger);

    setFocusableInTouchMode(true);//w  ww  .  jav  a2 s .  c  om

    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
    ViewGroupCompat.setMotionEventSplittingEnabled(this, false);
}

From source file:com.nokia.example.capturetheflag.Controller.java

@Override
public void onUpdatePlayerMessage(UpdatePlayerResponse update) {
    if (mCurrentGame == null) {
        return;//  www. j  a va 2  s. c o  m
    }

    Player updatedPlayer = update.getUpdatedPlayer();

    if (!mCurrentGame.getPlayers().contains(update.getUpdatedPlayer())) {
        Log.d(TAG, "onUpdatePlayerMessage(): New player");
        mCurrentGame.getPlayers().add(updatedPlayer);

        /* Show a toast message informing the user that a new player has
         * joined the game.
         */
        final String playerName = updatedPlayer.getName();

        mUIHandler.post(new Runnable() {
            @Override
            public void run() {
                String text = getString(R.string.new_player_joined, playerName);
                Toast toast = Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT);
                toast.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
                toast.show();
            }
        });
    } else {
        Log.d(TAG, "onUpdatePlayerMessage(): Existing player");
        int i = mCurrentGame.getPlayers().indexOf(updatedPlayer);
        Player old = mCurrentGame.getPlayers().get(i);
        mMap.updateMarkerForPlayer(updatedPlayer, old);
        mCurrentGame.getPlayers().set(i, updatedPlayer);
    }

    mMap.updatePlayerMarkerPosition(updatedPlayer);
}

From source file:android.support.v7ox.view.menu.ActionMenuItemView.java

@Override
public boolean onLongClick(View v) {
    if (hasText()) {
        // Don't show the cheat sheet for items that already show text.
        return false;
    }/*from   w w w. jav a2s . c  om*/

    final int[] screenPos = new int[2];
    final Rect displayFrame = new Rect();
    getLocationOnScreen(screenPos);
    getWindowVisibleDisplayFrame(displayFrame);

    final Context context = getContext();
    final int width = getWidth();
    final int height = getHeight();
    final int midy = screenPos[1] + height / 2;
    int referenceX = screenPos[0] + width / 2;
    if (ViewCompat.getLayoutDirection(v) == ViewCompat.LAYOUT_DIRECTION_LTR) {
        final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
        referenceX = screenWidth - referenceX; // mirror
    }
    Toast cheatSheet = Toast.makeText(context, mItemData.getTitle(), Toast.LENGTH_SHORT);
    if (midy < displayFrame.height()) {
        // Show along the top; follow action buttons
        cheatSheet.setGravity(Gravity.TOP | GravityCompat.END, referenceX,
                screenPos[1] + height - displayFrame.top);
    } else {
        // Show along the bottom center
        cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height);
    }
    cheatSheet.show();
    return true;
}