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

The following are Jave code examples for showing how to use bringToFront() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: FreeStreams-TVLauncher   File: AllApp.java   Source Code and License Vote up 7 votes
@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(
                    mContext, focus);
            mAnimation.setBackgroundColor(Color.TRANSPARENT);
            mAnimation.setFillAfter(hasFocus);
            v.startAnimation(mAnimation);
            mAnimation.start();
            v.bringToFront();
        }
 
Example 2
Project: Closet   File: BasicSearchBarFragment.java   Source Code and License Vote up 7 votes
/**
 * 点击搜索
 */
protected void reactionToClickSearchAction() {
    mShowSearchToolbar = true;

    View childView = mRevealFrameLayout.getChildAt(0);
    childView.setVisibility(View.VISIBLE);
    childView.bringToFront();

    int centerX = childView.getRight();
    int centerY = childView.getBottom() / 2;
    Animator circularReveal = ViewAnimationUtils.createCircularReveal(childView, centerX, centerY, 0, childView.getWidth());
    circularReveal.setDuration(300).setInterpolator(new LinearInterpolator());
    circularReveal.start();

    circularReveal.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);

            reactionToCover(true);

            mEdSearch.requestFocus();
            KeyboardUtils.showSoftInput(mEdSearch, getContext());
        }
    });
}
 
Example 3
Project: duo-navigation-drawer   File: DuoMenuView.java   Source Code and License Vote up 7 votes
/**
 * 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 4
Project: FreeStreams-TVLauncher   File: WoDouGameBaseFragment.java   Source Code and License Vote up 7 votes
@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 5
Project: JavaUniverse   File: AndroidGuiWrapper.java   Source Code and License Vote up 7 votes
private void applyWindowSize() {
    int n = mContainer.getChildCount();
    View[] children = new View[n];
    for (int i = 0; i < n; i++) {
        children[i] = mContainer.getChildAt(i);
    }
    Arrays.sort(children, new Comparator<View>() {
        @Override
        public int compare(final View v1, final View v2) {
            Window w1 = (Window) v1.getTag();
            Window w2 = (Window) v2.getTag();
            return w1.getZ_index() - w2.getZ_index();
        }
    });

    for (View child : children) {
        Window window = (Window) child.getTag();
        FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) child.getLayoutParams();
        params.width = getSize(mContainerWidth, window.getWidth());
        params.height = getSize(mContainerHeight, window.getHeight());
        params.leftMargin = getSize(mContainerWidth, window.getLeft());
        params.topMargin = getSize(mContainerHeight, window.getTop());
        child.setLayoutParams(params);
        child.bringToFront();
    }
}
 
Example 6
Project: GxIconDIY   File: BottomNavigationBehavior.java   Source Code and License Vote up 7 votes
@Override
public void updateSnackbar(CoordinatorLayout parent, View dependency, View child) {
    if (dependency instanceof Snackbar.SnackbarLayout) {
        if (mSnackbarHeight == -1) {
            mSnackbarHeight = dependency.getHeight();
        }

        int targetPadding = child.getMeasuredHeight();

        int shadow = (int) ViewCompat.getElevation(child);
        ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) dependency.getLayoutParams();
        layoutParams.bottomMargin = targetPadding - shadow;
        child.bringToFront();
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
            child.getParent().requestLayout();
            ((View) child.getParent()).invalidate();
        }

    }
}
 
Example 7
Project: FragmentCapsulation   File: BasicSearchBarFragment.java   Source Code and License Vote up 7 votes
/**
 * 点击搜索
 */
protected void reactionToClickSearchAction() {
    mShowSearchToolbar = true;

    View childView = mRevealFrameLayout.getChildAt(0);
    childView.setVisibility(View.VISIBLE);
    childView.bringToFront();

    int centerX = childView.getRight();
    int centerY = childView.getBottom() / 2;
    Animator circularReveal = ViewAnimationUtils.createCircularReveal(childView, centerX, centerY, 0, childView.getWidth());
    circularReveal.setDuration(300).setInterpolator(new LinearInterpolator());
    circularReveal.start();

    circularReveal.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);

            reactionToCover(true);

            mEdSearch.requestFocus();
            KeyboardUtils.showSoftInput(mEdSearch, getContext());
        }
    });
}
 
Example 8
Project: QiangHongBao   File: BottomNavigationBehavior.java   Source Code and License Vote up 7 votes
@Override
public void updateSnackbar(CoordinatorLayout parent, View dependency, View child) {
    if (!isTablet && dependency instanceof Snackbar.SnackbarLayout) {
        if (mSnackbarHeight == -1) {
            mSnackbarHeight = dependency.getHeight();
        }
        if (ViewCompat.getTranslationY(child) != 0) return;
        int targetPadding = bottomNavHeight + mSnackbarHeight - defaultOffset;

        ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) dependency.getLayoutParams();
        layoutParams.bottomMargin = targetPadding;
        child.bringToFront();
        child.getParent().requestLayout();
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
            ((View) child.getParent()).invalidate();
        }

    }
}
 
Example 9
Project: FragmentCapsulation   File: BasicSearchBarFragment.java   Source Code and License Vote up 6 votes
/**
 * 搜索栏的回退逻辑
 *
 * @return
 */
private boolean reactionToSearchBack() {
    if (mShowSearchToolbar) {
        mShowSearchToolbar = false;
        KeyboardUtils.hideSoftInput(mEdSearch, getContext());

        View childView = mRevealFrameLayout.getChildAt(0);
        childView.bringToFront();

        int centerX = childView.getLeft();
        int centerY = childView.getBottom() / 2;
        Animator circularReveal = ViewAnimationUtils.createCircularReveal(childView, centerX, centerY, 0, childView.getWidth());
        circularReveal.setDuration(300).setInterpolator(new DecelerateInterpolator());

        circularReveal.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                reactionToCover(false);
            }
        });
        circularReveal.start();

        if (mEdSearch != null) {
            mEdSearch.setText("");
            mSearchWord = "";
            fetchSearchData(mSearchWord);
        }

        return true;
    }
    return false;
}
 
Example 10
Project: LuaViewPlayground   File: UDView.java   Source Code and License Vote up 6 votes
/**
 * bring a view to front
 *
 * @return
 */
public UDView bringToFront() {
    final View view = getView();
    if (view != null) {
        view.bringToFront();
    }
    return this;
}
 
Example 11
Project: AssistantBySDK   File: LingjuSwipeUpLoadRefreshLayout.java   Source Code and License Vote up 6 votes
private void setTargetOffsetTopAndBottom(View target, int offset, boolean requiresUpdate) {
    target.bringToFront();
    //Log.e(TAG, "setTargetOffsetTopAndBottom>>target.getTop="+target.getTop());
    target.offsetTopAndBottom(offset);
        // Log.e(TAG,"setTargetOffsetTopAndBottom>>bCircleView,offset="+offset+",top="+target.getTop());
        bCurrentTargetOffsetTop = target.getTop();
    if (requiresUpdate && android.os.Build.VERSION.SDK_INT < 11) {
        invalidate();
    }
}
 
Example 12
Project: Closet   File: BasicSearchBarFragment.java   Source Code and License Vote up 6 votes
/**
 * 搜索栏的回退逻辑
 *
 * @return
 */
private boolean reactionToSearchBack() {
    if (mShowSearchToolbar) {
        mShowSearchToolbar = false;
        KeyboardUtils.hideSoftInput(mEdSearch, getContext());

        View childView = mRevealFrameLayout.getChildAt(0);
        childView.bringToFront();

        int centerX = childView.getLeft();
        int centerY = childView.getBottom() / 2;
        Animator circularReveal = ViewAnimationUtils.createCircularReveal(childView, centerX, centerY, 0, childView.getWidth());
        circularReveal.setDuration(300).setInterpolator(new DecelerateInterpolator());

        circularReveal.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                reactionToCover(false);
            }
        });
        circularReveal.start();

        if (mEdSearch != null) {
            mEdSearch.setText("");
            mSearchWord = "";
            fetchSearchData(mSearchWord);
        }

        return true;
    }
    return false;
}
 
Example 13
Project: ucar-weex-core   File: StickyHeaderHelper.java   Source Code and License Vote up 6 votes
/**
 * Bring component with bigest pos to Front
 */
private void showSticky() {
  if(mCurrentStickyRef==null){
    WXLogUtils.e("Current Sticky ref is null.");
    return;
  }

  WXCell headComponent = mHeaderComps.get(mCurrentStickyRef);
  final View headerView = headComponent.getRealView();
  if (headerView == null) {
    WXLogUtils.e("Sticky header's real view is null.");
    return;
  }
  View header = mHeaderViews.get(headComponent.getRef());
  if( header != null){
    //already there
    header.bringToFront();
  }else {
    mHeaderViews.put(headComponent.getRef(), headerView);
    //record translation, it should not change after transformation
    final float translationX = headerView.getTranslationX();
    final float translationY = headerView.getTranslationY();
    headComponent.removeSticky();

    ViewGroup existedParent;
    if ((existedParent = (ViewGroup) headerView.getParent()) != null) {
      existedParent.removeView(headerView);
    }
    mParent.addView(headerView);
    //recover translation, sometimes it will be changed on fling
    headerView.setTranslationX(translationX);
    headerView.setTranslationY(translationY);

  }
  if (headComponent.getDomObject().getEvents().contains("sticky")) {
    headComponent.fireEvent("sticky");
  }
}
 
Example 14
Project: JewelryUI   File: JazzyViewPager.java   Source Code and License Vote up 6 votes
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 15
Project: StickyScrollView   File: PropertySetter.java   Source Code and License Vote up 6 votes
public static void setTranslationZ(View view, float translationZ) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ViewCompat.setTranslationZ(view, translationZ);
    } else if (translationZ != 0) {
        view.bringToFront();
        if (view.getParent() != null) {
            ((View) view.getParent()).invalidate();
        }
    }
}
 
Example 16
Project: Library-System-Android   File: Log.java   Source Code and License Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.inventory);

    TextView main = (TextView) findViewById(R.id.maininventory);

    View mainButton = findViewById(R.id.main_button);
    mainButton.setOnClickListener(this);
    mainButton.bringToFront();

    ArrayList<Transaction> transactions = new ArrayList<>(db.getAllTransactions());

    for(Transaction transaction: transactions){

        if(transaction.getTypeNumber()==1||transaction.getTypeNumber()==2) {
            main.append("\n\nTransaction Number: " + transaction.getId());
            main.append("\n     Reservation Number: " + transaction.getReservation());
            main.append("\n     Username: " + transaction.getUsername());
            main.append("\n     Transaction Type: " + transaction.getType());
            main.append("\n     Book Title: " + transaction.getTitle());
            main.append("\n     Pick Up: " + transaction.getPickUpDate());
            main.append("\n     Return: " + transaction.getDropOffDate());
            main.append("\n     Transaction Date: " + transaction.getDate());
            main.append("\n     Transaction Time: " + transaction.getTime());
        }
        else{
            main.append("\n\nTransaction Number: " + transaction.getId());
            main.append("\n     Username: " + transaction.getUsername());
            main.append("\n     Transaction Type: " + transaction.getType());
            main.append("\n     Transaction Date: " + transaction.getDate());
            main.append("\n     Transaction Time: " + transaction.getTime());
        }
    }
    db.getAllBooks();
}
 
Example 17
Project: AdaptiveTableLayout   File: AdaptiveTableLayout.java   Source Code and License Vote up 5 votes
/**
 * 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 18
Project: ShortcutMenu   File: ShortMenuAnimator.java   Source Code and License Vote up 5 votes
@Override
public boolean animateAdd(final RecyclerView.ViewHolder holder) {
    if (adapter == null) {
        adapter = (ChannelAdapter) rv.getAdapter();
    }
    int adapterPosition=holder.getAdapterPosition();
    int type=adapter.getItemViewType(adapterPosition);
    int position=0;
    ShortcutMenuBean shortcutMenuBean;
    switch (type) {
        case ChannelAdapter.TYPE_MY:
        case ChannelAdapter.TYPE_OTHER:
            if (type == ChannelAdapter.TYPE_MY) {
                position = adapterPosition - ChannelAdapter.getCountPreMyHeader();
                shortcutMenuBean = adapter.getMyChannelItems().get(position);
            } else {
                position = adapterPosition - ChannelAdapter.getCountPreOtherHeader() - adapter.getMyChannelItems().size();
                shortcutMenuBean = adapter.getOtherChannelItems().get(position);
            }
            if (shortcutMenuBean.isMove()) {
                View view=holder.itemView;
                if (type == ChannelAdapter.TYPE_MY) {
                    view.bringToFront();
                }
                int toX=view.getLeft();
                int toY=holder.itemView.getTop();
                ShortcutMenuBean.MoveInfo moveInfo=shortcutMenuBean.getMoveInfo();
                int fromX=moveInfo.getFromX();
                int fromY = moveInfo.getFromY();
                fromX += ViewCompat.getTranslationX(holder.itemView);
                fromY += ViewCompat.getTranslationY(holder.itemView);
                resetAnimation(holder);
                int deltaX = toX - fromX;
                int deltaY = toY - fromY;
                if (deltaX == 0 && deltaY == 0) {
                    dispatchMoveFinished(holder);
                    return false;
                }
                if (deltaX != 0) {
                    ViewCompat.setTranslationX(view, -deltaX);
                }
                if (deltaY != 0) {
                    ViewCompat.setTranslationY(view, -deltaY);
                }
                mPendingMoves.add(new MoveInfo(holder, fromX, fromY, toX, toY));
                shortcutMenuBean.setMoveInfo(null);
                return true;
            }
            break;
    }
    resetAnimation(holder);
    ViewCompat.setAlpha(holder.itemView, 0);
    mPendingAdditions.add(holder);
    return true;
}
 
Example 19
Project: photo-editor-android   File: MultiTouchListener.java   Source Code and License Vote up 5 votes
@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;
}
 
Example 20
Project: Library-System-Android   File: Inventory.java   Source Code and License Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.inventory);

    View mainButton = findViewById(R.id.main_button);
    mainButton.setOnClickListener(this);
    mainButton.bringToFront();

    TextView main = (TextView) findViewById(R.id.maininventory);

    ArrayList<Book> books = new ArrayList<>(db.getAllBooks());

    for(Book book: books){
        main.append(book.toString()+" \n");
    }

    db.getAllBooks();


}