Java Code Examples for android.view.View#bringToFront()

The following examples show how to use android.view.View#bringToFront() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Handles the header view.
 */
private void handleHeader() {
    if (mHeaderViewId == DEFAULT_LAYOUT_ATTRIBUTE_VALUE || mMenuViewHolder.mMenuHeader == null) {
        return;
    }

    View view = mLayoutInflater.inflate(mHeaderViewId, null, false);

    if (view != null) {
        if (mMenuViewHolder.mMenuHeader.getChildCount() > 0) {
            mMenuViewHolder.mMenuHeader.removeAllViews();
        }

        mMenuViewHolder.mMenuHeader.addView(view);
        view.setTag(TAG_HEADER);
        view.bringToFront();
        view.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mOnMenuClickListener != null) {
                    mOnMenuClickListener.onHeaderClicked();
                }
            }
        });
    }
}
 
Example 2
Source Project: licodeAndroidClient   File: VideoGridLayout.java    License: MIT License 6 votes vote down vote up
/**
 * selects a child to be displayed in a zoomed way, unsets if null is passed
 * as parameter
 */
public void setZoomedChild(View v) {
	synchronized (this) {
		mZoomedChild = v;

		if (v != null) {
			v.bringToFront();
			if (mControlElements != null) {
				mControlElements.bringToFront();
			}

			int gridpos = ((LayoutParams) v.getLayoutParams()).gridPosition;
			mZoomedPosition = gridpos % mColumns;
			if (mZoomedPosition >= mColumns / 2) {
				// move left if in right half
				mZoomedPosition = mZoomedPosition - 1;
			}

			// move up one row if in lower half
			mZoomedPosition += mColumns
					* (gridpos / mColumns + (gridpos / mColumns >= mRows / 2 ? -1
							: 0));
		}
	}
}
 
Example 3
@Override
public void onFocusChange(View v, boolean hasFocus) {

    int focus = 0;
    if (hasFocus) {
        focus = R.anim.enlarge;
    } else {
        focus = R.anim.decrease;
    }
    //如果有焦点就放大,没有焦点就缩小
    Animation mAnimation = AnimationUtils.loadAnimation(
            getActivity().getApplication(), focus);
    mAnimation.setBackgroundColor(Color.TRANSPARENT);
    mAnimation.setFillAfter(hasFocus);
    v.startAnimation(mAnimation);
    mAnimation.start();
    v.bringToFront();
}
 
Example 4
private View addTipsViewToContainer(View target, ViewGroup tipContainer, int tipsId) {
    View tipsView = TipsUtils.findChildViewById(tipContainer, tipsId);
    if (tipsView != null) {
        tipsView.bringToFront();
        return tipsView;
    } else {
        mView.setId(tipsId);
        FrameLayout.LayoutParams targetViewLayoutParams = new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        if (mHideTarget) {
            target.setVisibility(View.INVISIBLE);
        }
        if (tipContainer.indexOfChild(target) == -1) {
            tipContainer.addView(target, targetViewLayoutParams);
        } else {
            target.setLayoutParams(targetViewLayoutParams);
        }
        tipContainer.addView(mView, mLayoutParams);
        return mView;
    }
}
 
Example 5
Source Project: UltimateAndroid   File: JazzyViewPager.java    License: Apache License 2.0 5 votes vote down vote up
protected void animateStack(View left, View right, float positionOffset, int positionOffsetPixels) {
    if (mState != State.IDLE) {
        if (right != null) {
            manageLayer(right, true);
            mScale = (1 - SCALE_MAX) * positionOffset + SCALE_MAX;
            mTrans = -getWidth() - getPageMargin() + positionOffsetPixels;
            ViewHelper.setScaleX(right, mScale);
            ViewHelper.setScaleY(right, mScale);
            ViewHelper.setTranslationX(right, mTrans);
        }
        if (left != null) {
            left.bringToFront();
        }
    }
}
 
Example 6
/**
 * Handles the footer view.
 */
private void handleFooter() {
    if (mFooterViewId == DEFAULT_LAYOUT_ATTRIBUTE_VALUE || mMenuViewHolder.mMenuFooter == null) {
        return;
    }

    View view = mLayoutInflater.inflate(mFooterViewId, null, false);

    if (view != null) {
        if (mMenuViewHolder.mMenuFooter.getChildCount() > 0) {
            mMenuViewHolder.mMenuFooter.removeAllViews();
        }

        mMenuViewHolder.mMenuFooter.addView(view);
        view.setTag(TAG_FOOTER);
        view.bringToFront();

        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;

            for (int i = 0; i < viewGroup.getChildCount(); i++) {
                if (viewGroup.getChildAt(i) instanceof Button) {
                    viewGroup.getChildAt(i).setOnClickListener(new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            if (mOnMenuClickListener != null) {
                                mOnMenuClickListener.onFooterClicked();
                            }
                        }
                    });
                    return;
                }
            }
        }
    }
}
 
Example 7
Source Project: SmartSwipe   File: SlidingConsumer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void orderChildren() {
    View contentView = mWrapper.getContentView();
    if (contentView != null) {
        contentView.bringToFront();
    }
    if (mScrimView != null) {
        mScrimView.bringToFront();
    }
}
 
Example 8
Source Project: ChannelView   File: ChannelView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void handleMessage(Message msg) {
    View v = (View) msg.obj;
    v.bringToFront();
    styleAdapter.setFocusedStyle(getViewHolder(v));
    isAccessDrag = true;
}
 
Example 9
protected void animateStack(View left, View right, float positionOffset, int positionOffsetPixels) {		
	if (mState != State.IDLE) {
		if (right != null) {
			manageLayer(right, true);
			mScale = (1-SCALE_MAX) * positionOffset + SCALE_MAX;
			mTrans = -getWidth()-getPageMargin()+positionOffsetPixels;
			ViewHelper.setScaleX(right, mScale);
			ViewHelper.setScaleY(right, mScale);
			ViewHelper.setTranslationX(right, mTrans);
		}
		if (left != null) {
			left.bringToFront();
		}
	}
}
 
Example 10
private void initNavigationDrawer(){
    mDrawerToggle = new ActionBarDrawerToggle(
            this,                  /* host Activity */
            mDrawerLayout,         /* DrawerLayout object */
            R.drawable.ic_drawer,  /* nav drawer icon */
            0, /* "open drawer" description */
            0  /* "close drawer" description */
    ) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            supportInvalidateOptionsMenu();
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            drawerView.bringToFront();
            supportInvalidateOptionsMenu();
        }
    };


    ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this,
            R.layout.list_item, new String[]{getString(R.string.action_about), getString(R.string.action_send)});

    mDrawerOptions.setAdapter(adapter);
    mDrawerOptions.setOnItemClickListener(MainActivity.this);

    mDrawerToggle.setDrawerIndicatorEnabled(true);
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.LEFT);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
}
 
Example 11
Source Project: FamilyChat   File: ParallaxTransformer.java    License: Apache License 2.0 5 votes vote down vote up
private void bringViewToFront(View view) {
    ViewGroup group = (ViewGroup) view.getParent();
    int index = group.indexOfChild(view);
    if (index != group.getChildCount() - 1) {
        view.bringToFront();
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
            view.requestLayout();
            group.invalidate();
        }
    }
}
 
Example 12
/**
 * bring a view to front
 *
 * @return
 */
public UDView bringToFront() {
    View view = getView();
    if (view != null) {
        view.bringToFront();
    }
    return this;
}
 
Example 13
Source Project: Paginize   File: ContainerPageManager.java    License: MIT License 5 votes vote down vote up
public void setPage(InnerPage newPage, Object data) {
    InnerPage oldPage = getCurrentInnerPage();
    if (newPage == oldPage) {
        return;
    }

    if (oldPage != null) {
        oldPage.onHide();
        oldPage.onHidden();
        oldPage.getView().setVisibility(View.GONE);

        if (mInnerPageEventNotifier != null) {
            mInnerPageEventNotifier.onInnerPageHidden(oldPage);
        }
    }

    if (newPage != null) {
        View newPageView = newPage.getView();

        if (getContainerView().indexOfChild(newPageView) == -1) {
            getContainerView().addView(newPageView);
        }

        newPageView.bringToFront();
        newPageView.setVisibility(View.VISIBLE);
        newPage.onShow(data);
        newPage.onShown(data);

        if (mInnerPageEventNotifier != null) {
            mInnerPageEventNotifier.onInnerPageShown(newPage);
        }
    } else {
        getContainerView().setVisibility(View.GONE);
    }

    setCurrentInnerPage(newPage);
}
 
Example 14
Source Project: letv   File: JazzyViewPager.java    License: Apache License 2.0 5 votes vote down vote up
protected void animateStack(View left, View right, float positionOffset, int positionOffsetPixels) {
    if (this.mState != State.IDLE) {
        if (right != null) {
            manageLayer(right, true);
            this.mScale = (0.5f * positionOffset) + 0.5f;
            this.mTrans = (float) (((-getWidth()) - getPageMargin()) + positionOffsetPixels);
            ViewHelper.setScaleX(right, this.mScale);
            ViewHelper.setScaleY(right, this.mScale);
            ViewHelper.setTranslationX(right, this.mTrans);
        }
        if (left != null) {
            left.bringToFront();
        }
    }
}
 
Example 15
private void setTargetOffsetTopAndBottom(View target, int offset, boolean requiresUpdate) {
    target.bringToFront();
    //Log.e(TAG, "setTargetOffsetTopAndBottom>>target.getTop="+target.getTop());
    target.offsetTopAndBottom(offset);
    if (target == tCircleView) {
        // Log.e(TAG,"setTargetOffsetTopAndBottom>>tCircleView,offset="+offset+",top="+target.getTop());
        tCurrentTargetOffsetTop = target.getTop();
    } else {
        // Log.e(TAG,"setTargetOffsetTopAndBottom>>bCircleView,offset="+offset+",top="+target.getTop());
        bCurrentTargetOffsetTop = target.getTop();
    }
    if (requiresUpdate && android.os.Build.VERSION.SDK_INT < 11) {
        invalidate();
    }
}
 
Example 16
Source Project: Paginize   File: ContainerPageManager.java    License: MIT License 4 votes vote down vote up
void setPage(InnerPage newPage) {
  InnerPage oldPage = getCurrentInnerPage();
  if (newPage == oldPage) {
    return;
  }

  if (oldPage != null) {
    oldPage.onHide();
    oldPage.onHidden();
    oldPage.getView().setVisibility(View.GONE);

    if (mInnerPageEventNotifier != null) {
      mInnerPageEventNotifier.onInnerPageHidden(oldPage);
    }
  }

  if (newPage != null) {
    View newPageView = newPage.getView();

    if (getContainerView().indexOfChild(newPageView) == -1) {
      getContainerView().addView(newPageView);
    }

    newPageView.bringToFront();
    newPageView.setVisibility(View.VISIBLE);
    newPage.onShow();
    newPage.onShown();

    if (mInnerPageEventNotifier != null) {
      mInnerPageEventNotifier.onInnerPageShown(newPage);
    }
  } else {
    getContainerView().setVisibility(View.GONE);
  }

  setCurrentInnerPage(newPage);

  if (newPage != null && !mInnerPageSet.contains(newPage)) {
    mInnerPageSet.add(newPage);
  }
}
 
Example 17
Source Project: Gloading   File: Gloading.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Show specific status UI
 * @param status status
 * @see #showLoading()
 * @see #showLoadFailed()
 * @see #showLoadSuccess()
 * @see #showEmpty()
 */
public void showLoadingStatus(int status) {
    if (curState == status || !validate()) {
        return;
    }
    curState = status;
    //first try to reuse status view
    View convertView = mStatusViews.get(status);
    if (convertView == null) {
        //secondly try to reuse current status view
        convertView = mCurStatusView;
    }
    try {
        //call customer adapter to get UI for specific status. convertView can be reused
        View view = mAdapter.getView(this, convertView, status);
        if (view == null) {
            printLog(mAdapter.getClass().getName() + ".getView returns null");
            return;
        }
        if (view != mCurStatusView || mWrapper.indexOfChild(view) < 0) {
            if (mCurStatusView != null) {
                mWrapper.removeView(mCurStatusView);
            }
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                view.setElevation(Float.MAX_VALUE);
            }
            mWrapper.addView(view);
            ViewGroup.LayoutParams lp = view.getLayoutParams();
            if (lp != null) {
                lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
                lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
            }
        } else if (mWrapper.indexOfChild(view) != mWrapper.getChildCount() - 1) {
            // make sure loading status view at the front
            view.bringToFront();
        }
        mCurStatusView = view;
        mStatusViews.put(status, view);
    } catch(Exception e) {
        if (DEBUG) {
            e.printStackTrace();
        }
    }
}
 
Example 18
private void bringDraggedToFront() {
    View draggedView = getChildAt(dragged);
    draggedView.bringToFront();
}
 
Example 19
/**
 * Refresh current row header view holder.
 *
 * @param holder current view holder
 */
private void refreshHeaderRowViewHolder(ViewHolder holder) {
    int top = mManager.getRowsHeight(0, Math.max(0, holder.getRowIndex())) + mManager.getHeaderColumnHeight();
    int left = calculateRowHeadersLeft();
    if (isRTL()) {
        left += mSettings.getCellMargin();
    }
    View view = holder.getItemView();

    int leftMargin = holder.getColumnIndex() * mSettings.getCellMargin() + mSettings.getCellMargin();
    int topMargin = holder.getRowIndex() * mSettings.getCellMargin() + mSettings.getCellMargin();

    if (holder.isDragging() && mDragAndDropPoints.getOffset().y > 0) {
        top = mState.getScrollY() + mDragAndDropPoints.getOffset().y - view.getHeight() / 2;
        view.bringToFront();
    }
    if (holder.isDragging()) {
        View topShadow = mShadowHelper.getTopShadow();
        View bottomShadow = mShadowHelper.getBottomShadow();

        if (topShadow != null) {
            int shadowTop = top - mState.getScrollY();
            topShadow.layout(0,
                    Math.max(mManager.getHeaderColumnHeight() - mState.getScrollY(), shadowTop - SHADOW_THICK) + topMargin,
                    mSettings.getLayoutWidth(),
                    shadowTop + topMargin);
            topShadow.bringToFront();
        }

        if (bottomShadow != null) {
            int shadowBottom = top - mState.getScrollY() + mManager.getRowHeight(holder.getRowIndex());
            bottomShadow.layout(
                    0,
                    Math.max(mManager.getHeaderColumnHeight() - mState.getScrollY(), shadowBottom) + topMargin,
                    mSettings.getLayoutWidth(),
                    shadowBottom + SHADOW_THICK + topMargin);

            bottomShadow.bringToFront();
        }
    }

    //noinspection ResourceType
    view.layout(left + leftMargin * (isRTL() ? 0 : 1),
            top - mState.getScrollY() + topMargin,
            left + mManager.getHeaderRowWidth() + leftMargin * (isRTL() ? 1 : 0),
            top + mManager.getRowHeight(holder.getRowIndex()) - mState.getScrollY() + topMargin);

    if (mState.isColumnDragging()) {
        view.bringToFront();
    }

    if (!mState.isRowDragging()) {
        View shadow = mShadowHelper.getRowsHeadersShadow();

        if (shadow == null) {
            shadow = mShadowHelper.addRowsHeadersShadow(this);
        }

        int shadowStart, shadowEnd;
        shadowStart = !isRTL() ? view.getRight() : view.getLeft() - SHADOW_HEADERS_THICK;
        shadowEnd = shadowStart + SHADOW_HEADERS_THICK;

        shadow.layout(shadowStart,
                mState.isColumnDragging() ? 0 :
                        mSettings.isHeaderFixed() ? 0 : -mState.getScrollY(),
                shadowEnd,
                mSettings.getLayoutHeight());

        shadow.bringToFront();
    }
}
 
Example 20
@Override
public boolean onTouch(View view, MotionEvent event) {
    mScaleGestureDetector.onTouchEvent(view, event);

    if (!isTranslateEnabled) {
        return true;
    }

    int action = event.getAction();

    int x = (int) event.getRawX();
    int y = (int) event.getRawY();

    switch (action & event.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
            mPrevX = event.getX();
            mPrevY = event.getY();
            mPrevRawX = event.getRawX();
            mPrevRawY = event.getRawY();
            mActivePointerId = event.getPointerId(0);
            deleteView.setVisibility(View.VISIBLE);
            view.bringToFront();
            firePhotoEditorSDKListener(view, true);
            break;
        case MotionEvent.ACTION_MOVE:
            int pointerIndexMove = event.findPointerIndex(mActivePointerId);
            if (pointerIndexMove != -1) {
                float currX = event.getX(pointerIndexMove);
                float currY = event.getY(pointerIndexMove);
                if (!mScaleGestureDetector.isInProgress()) {
                    adjustTranslation(view, currX - mPrevX, currY - mPrevY);
                }
            }
            break;
        case MotionEvent.ACTION_CANCEL:
            mActivePointerId = INVALID_POINTER_ID;
            break;
        case MotionEvent.ACTION_UP:
            mActivePointerId = INVALID_POINTER_ID;
            if (isViewInBounds(deleteView, x, y)) {
                if (onMultiTouchListener != null)
                    onMultiTouchListener.onRemoveViewListener(view);
            } else if (!isViewInBounds(photoEditImageView, x, y)) {
                view.animate().translationY(0).translationY(0);
            }
            deleteView.setVisibility(View.GONE);
            firePhotoEditorSDKListener(view, false);
            float mCurrentCancelX = event.getRawX();
            float mCurrentCancelY = event.getRawY();
            if (mCurrentCancelX == mPrevRawX || mCurrentCancelY == mPrevRawY) {
                if (view instanceof TextView) {
                    if (onMultiTouchListener != null) {
                        onMultiTouchListener.onEditTextClickListener(
                                ((TextView) view).getText().toString(), ((TextView) view).getCurrentTextColor());
                    }
                    if (onPhotoEditorSDKListener != null) {
                        onPhotoEditorSDKListener.onEditTextChangeListener(
                                ((TextView) view).getText().toString(), ((TextView) view).getCurrentTextColor());
                    }
                }
            }
            break;
        case MotionEvent.ACTION_POINTER_UP:
            int pointerIndexPointerUp = (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
            int pointerId = event.getPointerId(pointerIndexPointerUp);
            if (pointerId == mActivePointerId) {
                int newPointerIndex = pointerIndexPointerUp == 0 ? 1 : 0;
                mPrevX = event.getX(newPointerIndex);
                mPrevY = event.getY(newPointerIndex);
                mActivePointerId = event.getPointerId(newPointerIndex);
            }
            break;
    }

    return true;
}