@Override public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what) { case SHOW_LOADING_LAYOUT: loadingView.bringToFront(); loadingView.setVisibility(View.VISIBLE); Log.d("koo", "loading page start"); break; case END_LOADING_LAYOUT: loadingView.setVisibility(View.GONE); Log.d("koo", "loading page end"); break; case START_SET_DATA: setData(); break; case START_DOWNLOAD_PROFILE_IMG: getUserProfileImg(downloadedUserView.getPicturePath()); break; /* * case SEND_THREAD_STOP_MESSAGE: mCountThread.stopThread(); * tv_Count.setText("Count Thread가 중지 되었습니다."); break; */ default: break; } }
/** Sets the visibility of the search bar */ public void setSearchBarVisibility(int visibility) { if (mSearchBar != null) { mSearchBar.setVisibility(visibility); // Always bring the search bar to the top mSearchBar.bringToFront(); } }
private void pushPageInternal( final Page newPage, final Page oldPage, final Object arg, boolean animated, PageAnimator.AnimationDirection animationDirection) { if (animated) { mAnimating = true; } newPage.onShow(arg); if (oldPage != null) { if (animated) { // when a new page is being pushed, ensures the oldPage always be visible during the // animation // transition if animated is true oldPage.getView().bringToFront(); } oldPage.onCover(); } mCurPage = newPage; mPageStack.addLast(newPage); mContainerView.addView(newPage.getView()); newPage.onAttached(); mViewTransparentMask.bringToFront(); if (mEnableDebug) { Log.d( TAG, String.format( ">>>> pushPage, pagestack=%d, %s, arg=%s", mPageStack.size(), newPage, arg)); } if (animated && mPageAnimator != null && !newPage.onPushPageAnimation(oldPage, newPage, animationDirection)) { mPageAnimator.onPushPageAnimation(oldPage, newPage, animationDirection); } int animationDuration = newPage.getAnimationDuration(); if (animationDuration == -1 && mPageAnimator != null) { animationDuration = mPageAnimator.getAnimationDuration(); } if (animated && animationDuration != -1) { newPage.postDelayed( new Runnable() { @Override public void run() { doFinalWorkForPushPage(oldPage, newPage, arg); } }, animationDuration); } else { doFinalWorkForPushPage(oldPage, newPage, arg); } }
/** * 设置加载界面 * * @param rootView 你所要放置的加载动画的根布局 */ public static void setAutoLoadingView(ViewGroup rootView) { if (rootView != null) { AutoLoadingUtil.rootView = rootView; view = LayoutInflater.from(rootView.getContext()).inflate(R.layout.autoloading, rootView, false); saveView = new ArrayList<View>(); ImageView image = (ImageView) view.findViewById(R.id.imageView_autoLoading); image.setBackgroundResource(R.anim.autoloading); AnimationDrawable anim = (AnimationDrawable) image.getBackground(); anim.start(); rootView.setOnHierarchyChangeListener( new OnHierarchyChangeListener() { @Override public void onChildViewRemoved(View parent, View child) { // TODO Auto-generated method stub saveView.add(child); } @Override public void onChildViewAdded(View parent, View child) { // TODO Auto-generated method stub } }); rootView.removeAllViews(); rootView.addView(view); view.bringToFront(); } }
@Override protected void onFinishInflate() { final int childCount = getChildCount(); if (childCount > 2) { throw new IllegalStateException("PtrFrameLayout only can host 2 elements"); } else if (childCount == 2) { if (mHeaderId != 0 && mHeaderView == null) { mHeaderView = findViewById(mHeaderId); } if (mContainerId != 0 && mContent == null) { mContent = findViewById(mContainerId); } // not specify header or content if (mContent == null || mHeaderView == null) { View child1 = getChildAt(0); View child2 = getChildAt(1); if (child1 instanceof PtrUIHandler) { mHeaderView = child1; mContent = child2; } else if (child2 instanceof PtrUIHandler) { mHeaderView = child2; mContent = child1; } else { // both are not specified if (mContent == null && mHeaderView == null) { mHeaderView = child1; mContent = child2; } // only one is specified else { if (mHeaderView == null) { mHeaderView = mContent == child1 ? child2 : child1; } else { mContent = mHeaderView == child1 ? child2 : child1; } } } } } else if (childCount == 1) { mContent = getChildAt(0); } else { TextView errorView = new TextView(getContext()); errorView.setClickable(true); errorView.setTextColor(0xffff6600); errorView.setGravity(Gravity.CENTER); errorView.setTextSize(20); errorView.setText( "The content view in PtrFrameLayout is empty. Do you forget to specify its id in xml layout file?"); mContent = errorView; addView(mContent); } // 检测mContent 是否是ILoadMoreView 也就是可以添加加载更多 onContentViewFinishInflate(mContent); if (mHeaderView != null) { mHeaderView.bringToFront(); } super.onFinishInflate(); }
/** * 显示底部View * * @param belowView 要操作的底部View */ private void showBelowView(View belowView) { if (belowView.getVisibility() != View.VISIBLE) { Animation animation = new TranslateAnimation(0, 0, belowView.getHeight(), 0); animation.setDuration(animatonDurationTime); belowView.startAnimation(animation); belowView.setVisibility(View.VISIBLE); belowView.bringToFront(); } }
public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view; view = inflater.inflate(R.layout.apie_telsius, container, false); View shadow = view.findViewById(R.id.shadow); shadow.bringToFront(); return view; }
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(); } } }
public void setTiles(Collection<QSTile<?>> tiles) { for (TileRecord record : mRecords) { removeView(record.tileView); } mRecords.clear(); for (QSTile<?> tile : tiles) { addTile(tile); } if (isShowingDetail()) { mDetail.bringToFront(); } }
private void popPageInternal( final Page removedPage, boolean animated, PageAnimator.AnimationDirection animationDirection) { if (mEnableDebug) { Log.d(TAG, String.format(">>>> popPage, pagestack=%d, %s", mPageStack.size(), removedPage)); } removedPage.onHide(); final Page prevPage; if (mPageStack.size() > 0) { // this check is always necessary prevPage = mPageStack.getLast(); prevPage.onUncover(removedPage.getReturnData()); if (animated && mPageAnimator != null && !removedPage.onPopPageAnimation(removedPage, prevPage, animationDirection)) { mPageAnimator.onPopPageAnimation(removedPage, prevPage, animationDirection); } prevPage.getView().setVisibility(View.VISIBLE); } else { prevPage = null; if (animated && mPageAnimator != null && !removedPage.onPopPageAnimation(removedPage, null, animationDirection)) { mPageAnimator.onPopPageAnimation(removedPage, null, animationDirection); } } mViewTransparentMask.bringToFront(); mCurPage = prevPage; int animationDuration = removedPage.getAnimationDuration(); if (animationDuration == -1 && mPageAnimator != null) { animationDuration = mPageAnimator.getAnimationDuration(); } if (animated && animationDuration != -1) { removedPage.postDelayed( new Runnable() { @Override public void run() { doFinalWorkForPopPageInternal(removedPage, prevPage); } }, animationDuration); } else { doFinalWorkForPopPageInternal(removedPage, prevPage); } }
protected void animateStack(View left, View right, float effectOffset, int positionOffsetPixels) { if (right != null) { mScale = (1 - SCALE_MAX) * effectOffset + SCALE_MAX; mTrans = -getWidth() - getPageMargin() + positionOffsetPixels; ViewHelper.setScaleX(right, mScale); ViewHelper.setScaleY(right, mScale); ViewHelper.setTranslationX(right, mTrans); } if (left != null) { left.bringToFront(); } }
@Override public void transformPage(View page, float position) { page.setTranslationX(0); switch (mMode) { case LEFT_OVERLAY: if (position > 0) { transform(page, position); } else if (position < 0) { page.bringToFront(); } break; case RIGHT_OVERLAY: if (position < 0) { transform(page, position); } else if (position > 0) { page.bringToFront(); } break; case NONE: break; } }
private void handleShowDetailImpl(Record r, boolean show, int x, int y) { if ((mDetailRecord != null) == show) return; // already in right state DetailAdapter detailAdapter = null; AnimatorListener listener = null; if (show) { detailAdapter = r.detailAdapter; r.detailView = detailAdapter.createDetailView(mContext, r.detailView, mDetailContent); if (r.detailView == null) throw new IllegalStateException("Must return detail view"); final Intent settingsIntent = detailAdapter.getSettingsIntent(); mDetailSettingsButton.setVisibility(settingsIntent != null ? VISIBLE : GONE); mDetailSettingsButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { mHost.startSettingsActivity(settingsIntent); } }); // Do not display remove tile button for dynamic tiles final StatusBarPanelCustomTile customTile = detailAdapter.getCustomTile(); mDetailRemoveButton.setVisibility( customTile != null && !(customTile.getPackage().equals(mContext.getPackageName()) || customTile.getUid() == Process.SYSTEM_UID) ? VISIBLE : GONE); mDetailRemoveButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { mHost.collapsePanels(); mHost.removeCustomTile(customTile); } }); mDetailContent.removeAllViews(); mDetail.bringToFront(); mDetailContent.addView(r.detailView); setDetailRecord(r); listener = mHideGridContentWhenDone; } else { mClosingDetail = true; setGridContentVisibility(true); listener = mTeardownDetailWhenDone; fireScanStateChanged(false); } sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); fireShowingDetail(show ? detailAdapter : null); mClipper.animateCircularClip(x, y, show, listener); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setTitle("Active Tournaments"); listAdapter = new tournamentListAdapter(this, data.tournaments); View addTournamentButton = (View) findViewById(R.id.addTournament); addTournamentButton.bringToFront(); ListView tournamentList = (ListView) findViewById(R.id.tournamentList); tournamentList.setAdapter(listAdapter); // Click on element in tournament list tournamentList.setOnItemClickListener( new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, final View view, int position, long id) { final String item = (String) parent.getItemAtPosition(position).toString(); if (!data.tournaments.get(position).getTournamentStatus()) { Intent intent = new Intent( getApplicationContext(), EditTournament.class); // Application Context and Activity intent.putExtra("tournament", position); startActivityForResult(intent, 0); } else if (data.tournaments.get(position).getFinished()) { String[] info = { data.tournaments.get(position).getWinner().getTeamName(), Integer.toString(data.tournaments.get(position).getWinner().getWins()), Integer.toString(data.tournaments.get(position).getWinner().getLosses()), data.tournaments.get(position).getWinner().getTeamLogo() }; Intent intent = new Intent( getApplicationContext(), winner.class); // Application Context and Activity intent.putExtra("info", info); startActivityForResult(intent, 0); } else { Intent intent = new Intent( getApplicationContext(), Schedule.class); // Application Context and Activity intent.putExtra("tournament", position); startActivityForResult(intent, 0); } } }); registerForContextMenu(tournamentList); }
/** 对View重新排序 */ private void orderViewStack() { synchronized (obj1) { if (releasedViewList.size() == 0) { return; } CardItemView changedView = (CardItemView) releasedViewList.get(0); if (changedView.getLeft() == initCenterViewX) { return; } // 1. 消失的卡片View位置重置 changedView.offsetLeftAndRight(initCenterViewX - changedView.getLeft()); changedView.offsetTopAndBottom(initCenterViewY - changedView.getTop() + yOffsetStep * 2); float scale = 1.0f - SCALE_STEP * 2; changedView.setScaleX(scale); changedView.setScaleY(scale); // 2. 卡片View在ViewGroup中的顺次调整 int num = viewList.size(); for (int i = num - 1; i > 0; i--) { View tempView = viewList.get(i); tempView.bringToFront(); } // 3. changedView填充新数据 int newIndex = isShowing + 4; if (newIndex < dataList.size()) { CardDataItem dataItem = dataList.get(newIndex); changedView.fillData(dataItem); } else { changedView.setVisibility(View.INVISIBLE); } // 4. viewList中的卡片view的位次调整 viewList.remove(changedView); viewList.add(changedView); releasedViewList.remove(0); // 5. 更新showIndex、接口回调 if (isShowing + 1 < dataList.size()) { isShowing++; } if (null != cardSwitchListener) { cardSwitchListener.onShow(isShowing); } } }
@Override protected void onCreate(Bundle savedInstanceState) { TestFlight.log("Main Activity Log Test"); super.onCreate(savedInstanceState); ((OBSApplication) getApplication()).inject(this); setContentView(R.layout.main_activity); if (savedInstanceState == null) { mainNav = MainNavigation.newInstance(1); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.add(R.id.nav_holder, mainNav); ft.commit(); } View navHolder = findViewById(R.id.nav_holder); navHolder.bringToFront(); }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // mOverlay.setTranslationY(800); Log.d("mPaintSeekInfo", "draw with mPaintSeekInfo => " + mPaintSeekInfo); if (isInEditMode()) { return; } if (mPaintSeekInfo) { Log.d("PlayerSeekbar", "Draw seekinfo"); if (params.height == 0) { mOverlay.setVisibility(INVISIBLE); params.height = mOverlay.getHeight(); params.width = mOverlay.getWidth(); mOverlay.bringToFront(); } mBackwards.setText(mBackwardsText); mCurrent.setText(mCurrentText); mForwards.setText(mForwardText); this.getLocationOnScreen(loc); int offset = loc[1] - (int) UIUtils.convertDpToPixel(200, getContext()); // FIXME this.getHeight()*4; int translationY = (int) ((View) this.getParent()).getTranslationY(); Log.d("PlayerSeekbar", "trans => " + translationY); Log.d("PlayerSeekbar", "loc0 => " + loc[0] + " loc0 => " + loc[1]); params.setMargins(mSideMargin, offset, mSideMargin, 0); if (mOverlay != null) { mOverlay.setLayoutParams(params); mOverlay.setVisibility(VISIBLE); } } else { Log.d("PlayerSeekbar", "Remove seekinfo"); if (mOverlay != null) { mOverlay.setVisibility(GONE); } } }
/** * 判断是否在当前触摸位置存在View * * @param x * @param y * @return */ private boolean hasView(int x, int y) { // 循环获取子view,判断xy是否在子view上,即判断是否按住了子view for (int index = 0; index < this.getChildCount(); index++) { View view = this.getChildAt(index); int left = (int) view.getX(); int top = (int) view.getY(); int right = view.getRight(); int bottom = view.getBottom(); Rect rect = new Rect(left, top, right, bottom); boolean contains = rect.contains(x, y); // 如果是与子view重叠则返回真,表示已经有了view不需要添加新view了 if (contains) { touchView = view; touchView.bringToFront(); return true; } } touchView = null; return false; }
// @Override // protected void onFocusChanged(boolean gainFocus, int direction, Rect // previouslyFocusedRect) { // super.onFocusChanged(gainFocus, direction, previouslyFocusedRect); // Log.i(TAG, "Focus changed: " + gainFocus); // if (gainFocus) { // Got focus // collapseExpand(false); // } // } // public void collapseExpand(boolean collapse) { if (!collapsible) { // Not supported if (!collapse) { // Request focus requestFocus(); } return; } collapsed = collapse; // RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) // pager.getLayoutParams(); if (collapse) { // Collapse // params.leftMargin = 0; clearAnimation(); pager.bringToFront(); } else { // params.leftMargin = listWidth; startAnimation(listShowAnimation); requestFocus(); bringToFront(); } // pager.setLayoutParams(params); }
public synchronized void place(View v, Point pt, boolean animate) { final int i = pt.x; final int j = pt.y; final float rnd = frand(); if (v.getTag(TAG_POS) != null) { for (final Point oc : getOccupied(v)) { mFreeList.add(oc); mCells[oc.y * mColumns + oc.x] = null; } } int scale = 1; if (rnd < PROB_4X) { if (!(i >= mColumns - 3 || j >= mRows - 3)) { scale = 4; } } else if (rnd < PROB_3X) { if (!(i >= mColumns - 2 || j >= mRows - 2)) { scale = 3; } } else if (rnd < PROB_2X) { if (!(i == mColumns - 1 || j == mRows - 1)) { scale = 2; } } v.setTag(TAG_POS, pt); v.setTag(TAG_SPAN, scale); tmpSet.clear(); final Point[] occupied = getOccupied(v); for (final Point oc : occupied) { final View squatter = mCells[oc.y * mColumns + oc.x]; if (squatter != null) { tmpSet.add(squatter); } } for (final View squatter : tmpSet) { for (final Point sq : getOccupied(squatter)) { mFreeList.add(sq); mCells[sq.y * mColumns + sq.x] = null; } if (squatter != v) { squatter.setTag(TAG_POS, null); if (animate) { squatter .animate() .withLayer() .scaleX(0.5f) .scaleY(0.5f) .alpha(0) .setDuration(DURATION) .setInterpolator(new AccelerateInterpolator()) .setListener( new Animator.AnimatorListener() { public void onAnimationStart(Animator animator) {} public void onAnimationEnd(Animator animator) { removeView(squatter); } public void onAnimationCancel(Animator animator) {} public void onAnimationRepeat(Animator animator) {} }) .start(); } else { removeView(squatter); } } } for (final Point oc : occupied) { mCells[oc.y * mColumns + oc.x] = v; mFreeList.remove(oc); } final float rot = (float) irand(0, 4) * 90f; if (animate) { v.bringToFront(); AnimatorSet set1 = new AnimatorSet(); set1.playTogether( ObjectAnimator.ofFloat(v, View.SCALE_X, (float) scale), ObjectAnimator.ofFloat(v, View.SCALE_Y, (float) scale)); set1.setInterpolator(new AnticipateOvershootInterpolator()); set1.setDuration(DURATION); AnimatorSet set2 = new AnimatorSet(); set2.playTogether( ObjectAnimator.ofFloat(v, View.ROTATION, rot), ObjectAnimator.ofFloat(v, View.X, i * mCellSize + (scale - 1) * mCellSize / 2), ObjectAnimator.ofFloat(v, View.Y, j * mCellSize + (scale - 1) * mCellSize / 2)); set2.setInterpolator(new DecelerateInterpolator()); set2.setDuration(DURATION); set1.addListener(makeHardwareLayerListener(v)); set1.start(); set2.start(); } else { v.setX(i * mCellSize + (scale - 1) * mCellSize / 2); v.setY(j * mCellSize + (scale - 1) * mCellSize / 2); v.setScaleX((float) scale); v.setScaleY((float) scale); v.setRotation(rot); } }
@Override public void onClick(View v) { Log.i(this.TAG, "onClick(" + v + ")"); v.bringToFront(); }
// Show(or hide) one view with some effects private void showView(int viewId, int delay, int b) { View myView = findViewById(viewId); final int behavior = b; if (android.os.Build.VERSION.SDK_INT >= 21) { float x = myView.getX(); float y = myView.getY(); Path path1 = new Path(); Path path2 = new Path(); // Show with bounce effect if (behavior == 0) { path1.moveTo(x, y + 100); path1.rLineTo(0, -100); path2.moveTo(0, 0); path2.lineTo(1, 1); } // Show with bounce effect(and drop from top) else if (behavior == 1) { path1.moveTo(x, y - 300); path1.rLineTo(0, 300); path2.moveTo(1, 1); path2.lineTo(1, 1); } // Show with inflate effect else if (behavior == 2) { path1.moveTo(x, y); path1.rLineTo(0, 0); path2.moveTo(1, 1); path2.lineTo(10, 10); } // Hide with deflate effect(from large shape) else if (behavior == 3) { path1.moveTo(x, y); path1.rLineTo(0, 0); path2.moveTo(10, 10); path2.lineTo(1, 1); } // Fade in and float else if (behavior == 4) { path1.moveTo(x, y + 50); path1.rLineTo(0, -50); path2.moveTo(1, 1); path2.lineTo(1, 1); } // Fade out else if (behavior == 5) { path1.moveTo(x, y); path1.rLineTo(0, 0); path2.moveTo(1, 1); path2.lineTo(1, 1); } // Hide with deflate effect else if (behavior == 6) { path1.moveTo(x, y); path1.rLineTo(0, 0); path2.moveTo(1, 1); path2.lineTo(0, 0); } // Show with inflate effect else if (behavior == 7) { path1.moveTo(x, y); path1.rLineTo(0, 0); path2.moveTo(1, 1); path2.lineTo(20, 20); } // Hide with deflate effect(from large shape) else if (behavior == 8) { path1.moveTo(x, y); path1.rLineTo(0, 0); path2.moveTo(20, 20); path2.lineTo(1, 1); } // This effect only used for the flipTimes label else if (behavior == 9) { path1.moveTo(x, y); path1.rLineTo(0, 0); path2.moveTo(1, 1); path2.lineTo(1, 1); path2.lineTo(2, 2); } ObjectAnimator mAnimator1, mAnimator2, mAnimator3; mAnimator1 = ObjectAnimator.ofFloat(myView, View.X, View.Y, path1); mAnimator2 = ObjectAnimator.ofFloat(myView, View.SCALE_X, View.SCALE_Y, path2); mAnimator1.setDuration(300); mAnimator2.setDuration(300); mAnimator1.setStartDelay(delay); mAnimator2.setStartDelay(delay); if (behavior == 0 || behavior == 1) { mAnimator1.setInterpolator(new BounceInterpolator()); mAnimator2.setInterpolator(new BounceInterpolator()); mAnimator3 = ObjectAnimator.ofFloat(myView, "alpha", myView.getAlpha(), 1); mAnimator3.setDuration(10); mAnimator3.setStartDelay(delay); mAnimator3.start(); } else if (behavior == 2 || behavior == 7) { myView.bringToFront(); FrameLayout menuLayout = (FrameLayout) findViewById(R.id.menu); menuLayout.requestLayout(); menuLayout.invalidate(); mAnimator3 = ObjectAnimator.ofArgb( myView, "textColor", ((Button) myView).getCurrentTextColor(), Color.TRANSPARENT); mAnimator3.setDuration(100); mAnimator1.setInterpolator(new AccelerateInterpolator()); mAnimator2.setInterpolator(new AccelerateInterpolator()); mAnimator3.setStartDelay(delay); mAnimator3.start(); mSound.play(mSoundID[SOUND_OPEN], 1, 1, 1, 0, 1); } else if (behavior == 3 || behavior == 8) { mAnimator3 = ObjectAnimator.ofArgb( myView, "textColor", ((Button) myView).getCurrentTextColor(), Color.WHITE); mAnimator3.setDuration(100); mAnimator1.setInterpolator(new DecelerateInterpolator()); mAnimator2.setInterpolator(new DecelerateInterpolator()); mAnimator3.setStartDelay(delay + 200); mAnimator3.start(); mSound.play(mSoundID[SOUND_CLOSE], 1, 1, 1, 0, 1); } else if (behavior == 4) { mAnimator3 = ObjectAnimator.ofFloat(myView, "alpha", myView.getAlpha(), 1); mAnimator3.setDuration(300); mAnimator1.setInterpolator(new DecelerateInterpolator()); mAnimator2.setInterpolator(new DecelerateInterpolator()); mAnimator3.setStartDelay(delay); mAnimator3.start(); } else if (behavior == 5) { mAnimator3 = ObjectAnimator.ofFloat(myView, "alpha", myView.getAlpha(), 0); mAnimator3.setDuration(300); mAnimator1.setInterpolator(new DecelerateInterpolator()); mAnimator2.setInterpolator(new DecelerateInterpolator()); mAnimator3.setStartDelay(delay); mAnimator3.start(); } else if (behavior == 6) { mAnimator3 = ObjectAnimator.ofFloat(myView, "alpha", myView.getAlpha(), 0); mAnimator3.setDuration(300); mAnimator1.setInterpolator(new DecelerateInterpolator()); mAnimator2.setInterpolator(new DecelerateInterpolator()); mAnimator3.setStartDelay(delay); mAnimator3.start(); } else if (behavior == 9) { mAnimator3 = ObjectAnimator.ofFloat(myView, "alpha", 1, 0); mAnimator2.setDuration(1000); mAnimator3.setDuration(1000); mAnimator1.setInterpolator(new DecelerateInterpolator()); mAnimator2.setInterpolator(new DecelerateInterpolator()); mAnimator2.setRepeatCount(Animation.INFINITE); mAnimator3.setRepeatCount(Animation.INFINITE); mAnimator3.setStartDelay(delay); mAnimator3.start(); } if (behavior == 0 || behavior == 1 || behavior == 4) { mAnimator1.start(); } mAnimator2.start(); mAnimator1.addListener( new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { if (behavior == 0) { mSound.play(mSoundID[SOUND_BLOP], 1, 1, 1, 0, 1); } } @Override public void onAnimationEnd(Animator animation) {} @Override public void onAnimationCancel(Animator animation) {} @Override public void onAnimationRepeat(Animator animation) {} }); } // If the device OS is below Lollipop, the animation feature will be lost else { if (behavior == 5 || behavior == 6) { myView.setAlpha(0); } else { myView.setAlpha(1); } if (behavior == 2) { myView.setScaleX(10); myView.setScaleY(10); ((Button) myView).setTextColor(Color.TRANSPARENT); } else if (behavior == 3) { myView.setScaleX(1); myView.setScaleY(1); ((Button) myView).setTextColor(Color.WHITE); } if (behavior == 0) { mSound.play(mSoundID[SOUND_BLOP], 1, 1, 1, 0, 1); } else if (behavior == 2 || behavior == 7) { mSound.play(mSoundID[SOUND_OPEN], 1, 1, 1, 0, 1); } else if (behavior == 3 || behavior == 8) { mSound.play(mSoundID[SOUND_CLOSE], 1, 1, 1, 0, 1); } else if (behavior == 6) { mSound.play(mSoundID[SOUND_CLICK], 1, 1, 1, 0, 1); } } }
/** 指定光标相对位置 */ private void setBorderParams(final View item) { cursor.clearAnimation(); cursor.setVisibility(View.VISIBLE); final RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) item.getLayoutParams(); final int l = params.leftMargin + paddingLeft - boarderLeft; final int t = params.topMargin + paddingTop - boarderTop; final int r = l + itemWidth + boarderRight; final int b = t + itemHeight + boarderBottom; // 判断动画类型 switch (animationType) { case ANIM_DEFAULT: cursor.layout(l, t, r, b); item.bringToFront(); cursor.bringToFront(); if (scalable) { scaleToLarge(item); } break; case ANIM_TRASLATE: ValueAnimator transAnimatorX = ObjectAnimator.ofFloat(cursor, "x", cursor.getLeft(), l); ValueAnimator transAnimatorY = ObjectAnimator.ofFloat(cursor, "y", cursor.getTop(), t); cursor.layout(l, t, r, b); item.bringToFront(); cursor.bringToFront(); if (scalable) { scaleToLarge(item); } if (focusIsOut) { return; } animatorSet = new AnimatorSet(); animatorSet.play(transAnimatorY).with(transAnimatorX); animatorSet.setDuration(durationTraslate); animatorSet.setInterpolator(new DecelerateInterpolator(1)); // animatorSet.addListener(new AnimatorListener() { // // @Override // public void onAnimationStart(Animator arg0) { // } // // @Override // public void onAnimationRepeat(Animator arg0) { // } // // @Override // public void onAnimationEnd(Animator arg0) { // cursor.layout(l, t, r, b); // item.bringToFront(); // cursor.bringToFront(); // if (scalable) { // scaleToLarge(item); // } // } // // @Override // public void onAnimationCancel(Animator arg0) { // } // }); animatorSet.start(); break; } }