public void setAboveOffset(int i) { // RelativeLayout.LayoutParams params = // ((RelativeLayout.LayoutParams)mContent.getLayoutParams()); // params.setMargins(i, params.topMargin, params.rightMargin, params.bottomMargin); mContent.setPadding( i, mContent.getPaddingTop(), mContent.getPaddingRight(), mContent.getPaddingBottom()); }
private boolean isInIgnoredView(MotionEvent ev) { Rect rect = new Rect(); for (View v : mIgnoredViews) { v.getHitRect(rect); if (rect.contains((int) ev.getX(), (int) ev.getY())) return true; } return false; }
private void setScrollingCacheEnabled(boolean enabled) { if (mScrollingCacheEnabled != enabled) { mScrollingCacheEnabled = enabled; if (USE_CACHE) { final int size = getChildCount(); for (int i = 0; i < size; ++i) { final View child = getChildAt(i); if (child.getVisibility() != GONE) { child.setDrawingCacheEnabled(enabled); } } } } }
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); if (weChatUtils.getIWXAPI().isWXAppInstalled()) { inflater.inflate(R.menu.main_wechat, menu); } else { inflater.inflate(R.menu.main, menu); } MenuItem shareItem = menu.findItem(R.id.action_share); android.support.v4.view.ActionProvider actionProvider = MenuItemCompat.getActionProvider(shareItem); if (null != actionProvider && actionProvider instanceof ShareActionProvider) { mShareActionProvider.setShareHistoryFileName( ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME); // mShareActionProvider.setShareIntent(Utils.getShareRawIntent(this)); mShareActionProvider.setOnShareTargetSelectedListener( new ShareActionProvider.OnShareTargetSelectedListener() { @Override public boolean onShareTargetSelected( ShareActionProvider shareActionProvider, Intent intent) { updateShareIntent(); return false; } }); updateShareIntent(); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (item.getItemId() == R.id.action_share) { View itemChooser = MenuItemCompat.getActionView(item); if (itemChooser != null) { itemChooser.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { EFLogger.i(TAG, "onClick"); ScreenshotUtils.shotBitmap(MainActivity.this, shareFileName); } }); } } } } return super.onCreateOptionsMenu(menu); }
@Override public void onClick(View v) { int id = v.getId(); switch (id) { case R.id.user_icon: case R.id.user_info: { showGameBoardFragment(); break; } case R.id.button_sign_in: // start the sign-in flow beginUserInitiatedSignInImpl(); break; case R.id.button_sign_out: // sign out. signOutImpl(); showSignInBar(); break; case R.id.share_textview: { showShare(); break; } } }
public int getChildWidth(int i) { switch (i) { case 0: return getBehindWidth(); case 1: return mContent.getWidth(); default: return 0; } }
public int getDestScrollX(int page) { switch (page) { case 0: case 2: return mViewBehind.getMenuLeft(mContent, page); case 1: return mContent.getLeft(); } return 0; }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int width = getDefaultSize(0, widthMeasureSpec); int height = getDefaultSize(0, heightMeasureSpec); setMeasuredDimension(width, height); final int contentWidth = getChildMeasureSpec(widthMeasureSpec, 0, width); final int contentHeight = getChildMeasureSpec(heightMeasureSpec, 0, height); mContent.measure(contentWidth, contentHeight); }
public boolean arrowScroll(int direction) { View currentFocused = findFocus(); if (currentFocused == this) currentFocused = null; boolean handled = false; View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction); if (nextFocused != null && nextFocused != currentFocused) { if (direction == View.FOCUS_LEFT) { handled = nextFocused.requestFocus(); } else if (direction == View.FOCUS_RIGHT) { // If there is nothing to the right, or this is causing us to // jump to the left, then what we really want to do is page right. if (currentFocused != null && nextFocused.getLeft() <= currentFocused.getLeft()) { handled = pageRight(); } else { handled = nextFocused.requestFocus(); } } } else if (direction == FOCUS_LEFT || direction == FOCUS_BACKWARD) { // Trying to move left and nothing there; try to page. handled = pageLeft(); } else if (direction == FOCUS_RIGHT || direction == FOCUS_FORWARD) { // Trying to move right and nothing there; try to page. handled = pageRight(); } if (handled) { playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction)); } return handled; }
/** * Tests scrollability within child views of v given a delta of dx. * * @param v View to test for horizontal scrollability * @param checkV Whether the view v passed should itself be checked for scrollability (true), or * just its children (false). * @param dx Delta scrolled in pixels * @param x X coordinate of the active touch point * @param y Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. */ protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance first. for (int i = count - 1; i >= 0; i--) { final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll( child, true, dx, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && ViewCompat.canScrollHorizontally(v, -dx); }
protected float getPercentOpen() { return Math.abs(mScrollX - mContent.getLeft()) / getBehindWidth(); }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final int width = r - l; final int height = b - t; mContent.layout(0, 0, width, height); }
public int getContentLeft() { return mContent.getLeft() + mContent.getPaddingLeft(); }