List of usage examples for android.view.animation LinearInterpolator LinearInterpolator
public LinearInterpolator()
From source file:com.juick.android.MessagesFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final ViewConfiguration configuration = ViewConfiguration.get(getActivity()); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); databaseGetter = new Utils.ServiceGetter<DatabaseService>(getActivity(), DatabaseService.class); handler = new Handler(); sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); trackLastRead = sp.getBoolean("lastReadMessages", true); alternativeLongClick = sp.getBoolean("alternativeLongClick", false); Bundle args = getArguments();/*from w ww .j a v a 2s . co m*/ if (args != null) { messagesSource = (MessagesSource) args.getSerializable("messagesSource"); } if (messagesSource == null) messagesSource = new JuickCompatibleURLMessagesSource(getActivity(), "dummy"); if (messagesSource.getContext() == null) messagesSource.setContext(JuickAdvancedApplication.instance); mFlipAnimation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); mFlipAnimation.setInterpolator(new LinearInterpolator()); mFlipAnimation.setDuration(250); mFlipAnimation.setFillAfter(true); mReverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); mReverseFlipAnimation.setInterpolator(new LinearInterpolator()); mReverseFlipAnimation.setDuration(250); mReverseFlipAnimation.setFillAfter(true); if (Build.VERSION.SDK_INT >= 8) { mScaleDetector = new ScaleGestureDetector(getActivity(), new ScaleListener()); } }
From source file:com.aniruddhc.acemusic.player.ListViewFragment.ListViewFragment.java
/** * Displays the search field./* w ww . ja va 2 s .c om*/ */ private void showSearch() { mSearchLayout.setVisibility(View.VISIBLE); final TranslateAnimation searchAnim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, -2f, Animation.RELATIVE_TO_SELF, 0f); searchAnim.setDuration(500l); searchAnim.setInterpolator(new AccelerateDecelerateInterpolator()); final TranslateAnimation gridListAnim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 2f); gridListAnim.setDuration(500l); gridListAnim.setInterpolator(new LinearInterpolator()); gridListAnim.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { mListView.setAdapter(null); } @Override public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } @Override public void onAnimationStart(Animation animation) { mSearchLayout.startAnimation(searchAnim); mSearchLayout.setVisibility(View.VISIBLE); } }); searchAnim.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { if (mSearchEditText.requestFocus()) { mFragment.getActivity().getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } @Override public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } @Override public void onAnimationStart(Animation animation) { // TODO Auto-generated method stub } }); mListView.startAnimation(gridListAnim); }
From source file:com.diegocarloslima.byakugallery.TouchImageView.java
public TouchImageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (ANIMATION_DURATION == 0) ANIMATION_DURATION = context.getResources().getInteger(android.R.integer.config_shortAnimTime); final TouchGestureDetector.OnTouchGestureListener listener = new TouchGestureDetector.OnTouchGestureListener() { @Override//from w w w .ja v a 2 s . com public boolean onSingleTapConfirmed(MotionEvent e) { return performClick(); } @Override public void onLongPress(MotionEvent e) { performLongClick(); } @Override public boolean onDoubleTap(MotionEvent e) { loadMatrixValues(); // 3 stage scaling float targetScale = mCropScale; if (mScale == mMaxScale) targetScale = mMinScale; else if (mScale >= mCropScale) targetScale = mMaxScale; // First, we try to keep the focused point in the same position when the animation ends final float desiredTranslationX = e.getX() - (e.getX() - mTranslationX) * (targetScale / mScale); final float desiredTranslationY = e.getY() - (e.getY() - mTranslationY) * (targetScale / mScale); // Here, we apply a correction to avoid unwanted blank spaces final float targetTranslationX = desiredTranslationX + computeTranslation(getMeasuredWidth(), mDrawableIntrinsicWidth * targetScale, desiredTranslationX, 0); final float targetTranslationY = desiredTranslationY + computeTranslation(getMeasuredHeight(), mDrawableIntrinsicHeight * targetScale, desiredTranslationY, 0); clearAnimation(); final Animation animation = new TouchAnimation(targetScale, targetTranslationX, targetTranslationY); animation.setDuration(ANIMATION_DURATION); startAnimation(animation); return true; } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { // Sometimes, this method is called just after an onScaleEnd event. In this case, we want to wait until we animate back our image if (mIsAnimatingBack) { return false; } loadMatrixValues(); final float currentDrawableWidth = mDrawableIntrinsicWidth * mScale; final float currentDrawableHeight = mDrawableIntrinsicHeight * mScale; final float dx = computeTranslation(getMeasuredWidth(), currentDrawableWidth, mTranslationX, -distanceX); final float dy = computeTranslation(getMeasuredHeight(), currentDrawableHeight, mTranslationY, -distanceY); mMatrix.postTranslate(dx, dy); clearAnimation(); ViewCompat.postInvalidateOnAnimation(TouchImageView.this); return true; } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { // Sometimes, this method is called just after an onScaleEnd event. In this case, we want to wait until we animate back our image if (mIsAnimatingBack) { return false; } loadMatrixValues(); final float horizontalSideFreeSpace = (getMeasuredWidth() - mDrawableIntrinsicWidth * mScale) / 2F; final float minTranslationX = horizontalSideFreeSpace > 0 ? horizontalSideFreeSpace : getMeasuredWidth() - mDrawableIntrinsicWidth * mScale; final float maxTranslationX = horizontalSideFreeSpace > 0 ? horizontalSideFreeSpace : 0; final float verticalSideFreeSpace = (getMeasuredHeight() - mDrawableIntrinsicHeight * mScale) / 2F; final float minTranslationY = verticalSideFreeSpace > 0 ? verticalSideFreeSpace : getMeasuredHeight() - mDrawableIntrinsicHeight * mScale; final float maxTranslationY = verticalSideFreeSpace > 0 ? verticalSideFreeSpace : 0; // Using FlingScroller here. The results were better than the Scroller class // https://android.googlesource.com/platform/packages/apps/Gallery2/+/master/src/com/android/gallery3d/ui/FlingScroller.java mFlingScroller.fling(Math.round(mTranslationX), Math.round(mTranslationY), Math.round(velocityX), Math.round(velocityY), Math.round(minTranslationX), Math.round(maxTranslationX), Math.round(minTranslationY), Math.round(maxTranslationY)); clearAnimation(); final Animation animation = new FlingAnimation(); animation.setDuration(mFlingScroller.getDuration()); animation.setInterpolator(new LinearInterpolator()); startAnimation(animation); return true; } @Override public boolean onScaleBegin(ScaleGestureDetector detector) { mLastFocusX = null; mLastFocusY = null; return true; } @Override public boolean onScale(ScaleGestureDetector detector) { loadMatrixValues(); float currentDrawableWidth = mDrawableIntrinsicWidth * mScale; float currentDrawableHeight = mDrawableIntrinsicHeight * mScale; final float focusX = computeFocus(getMeasuredWidth(), currentDrawableWidth, mTranslationX, detector.getFocusX()); final float focusY = computeFocus(getMeasuredHeight(), currentDrawableHeight, mTranslationY, detector.getFocusY()); // Here, we provide the ability to scroll while scaling if (mLastFocusX != null && mLastFocusY != null) { final float dx = computeScaleTranslation(getMeasuredWidth(), currentDrawableWidth, mTranslationX, focusX - mLastFocusX); final float dy = computeScaleTranslation(getMeasuredHeight(), currentDrawableHeight, mTranslationY, focusY - mLastFocusY); if (dx != 0 || dy != 0) { mMatrix.postTranslate(dx, dy); } } final float scale = computeScale(mMinScale, mMaxScale, mScale, detector.getScaleFactor()); mMatrix.postScale(scale, scale, focusX, focusY); mLastFocusX = focusX; mLastFocusY = focusY; clearAnimation(); ViewCompat.postInvalidateOnAnimation(TouchImageView.this); return true; } @Override public void onScaleEnd(ScaleGestureDetector detector) { loadMatrixValues(); final float currentDrawableWidth = mDrawableIntrinsicWidth * mScale; final float currentDrawableHeight = mDrawableIntrinsicHeight * mScale; final float dx = computeTranslation(getMeasuredWidth(), currentDrawableWidth, mTranslationX, 0); final float dy = computeTranslation(getMeasuredHeight(), currentDrawableHeight, mTranslationY, 0); if (Math.abs(dx) < 1 && Math.abs(dy) < 1) { return; } final float targetTranslationX = mTranslationX + dx; final float targetTranslationY = mTranslationY + dy; float targetScale = MathUtils.clamp(mScale, mMinScale, mMaxScale); clearAnimation(); final Animation animation = new TouchAnimation(targetScale, targetTranslationX, targetTranslationY); animation.setDuration(ANIMATION_DURATION); startAnimation(animation); mIsAnimatingBack = true; } }; mTouchGestureDetector = new TouchGestureDetector(context, listener); super.setScaleType(ScaleType.MATRIX); }
From source file:com.airk.interpolatordiagram.app.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { menu.clear();/*from w w w .ja v a2 s.c o m*/ if (mDrawerLayout != null && mDrawerLayout.isDrawerOpen(mList)) { return true; } getMenuInflater().inflate(R.menu.main, menu); if (mSelectedInterpolator != -1) { menu.findItem(R.id.action_play).setVisible(true); View v = MenuItemCompat.getActionView(menu.findItem(R.id.action_play)); v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { final ObjectAnimator animator = ObjectAnimator.ofFloat(v, "rotationX", 0, 360); animator.setDuration(800).setRepeatCount(ObjectAnimator.INFINITE); animator.setInterpolator(new LinearInterpolator()); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); v.setClickable(false); } @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); v.setClickable(true); } @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); ObjectAnimator a = ObjectAnimator.ofFloat(v, "rotationX", 0); a.setDuration(1).start(); v.setClickable(true); } }); animator.start(); Fragment fragment = FragmentFactory.getInstance().getInterpolator(mSelectedInterpolator); ((BaseFragment) fragment).getDiagramView().playBalls(new DiagramView.AnimationListener() { @Override public void onAnimateFinished() { animator.cancel(); } }); } }); } return super.onCreateOptionsMenu(menu); }
From source file:com.gome.haoyuangong.views.SwipeRefreshLayout.java
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. * /*from w ww .j a v a2 s .c o m*/ * @param context * @param attrs */ public SwipeRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime); setWillNotDraw(false); mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR); mAccelerateInterpolator = new AccelerateInterpolator(ACCELERATE_INTERPOLATION_FACTOR); final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS); setEnabled(a.getBoolean(0, true)); a.recycle(); animation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); animation.setInterpolator(new LinearInterpolator()); animation.setDuration(250); animation.setFillAfter(true); reverseAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); reverseAnimation.setInterpolator(new LinearInterpolator()); reverseAnimation.setDuration(200); reverseAnimation.setFillAfter(true); state = DONE; headView = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.list_head, null); arrowImageView = (ImageView) headView.findViewById(R.id.head_arrowImageView); // arrowImageView.setMinimumWidth(70); // arrowImageView.setMinimumHeight(50); progressBar = (ProgressBar) headView.findViewById(R.id.head_progressBar); tipsTextview = (TextView) headView.findViewById(R.id.head_tipsTextView); lastUpdatedTextView = (TextView) headView.findViewById(R.id.head_lastUpdatedTextView); measureView(headView); mHeaderHeight = headView.getMeasuredHeight(); headView.setPadding(0, -mHeaderHeight, 0, 0); addView(headView); }
From source file:arun.com.chromer.shared.views.TabView.java
private Animator getIconSelectionAnimator() { Animator animator = null;//w w w . j a v a 2s . c o m switch (mTabType) { case TAB_TYPE_OPTIONS: animator = ObjectAnimator.ofFloat(tabIcon, "rotation", 180); break; case TAB_TYPE_WEB_HEADS: animator = ObjectAnimator.ofFloat(tabIcon, "rotation", 125); break; case TAB_TYPE_CUSTOMIZE: animator = ObjectAnimator.ofFloat(tabIcon, "scaleY", 1.2f); ((ObjectAnimator) animator).setRepeatMode(ValueAnimator.REVERSE); ((ObjectAnimator) animator).setRepeatCount(3); animator.setInterpolator(new LinearInterpolator()); break; } if (animator != null) animator.setDuration(250); return animator; }
From source file:org.mariotaku.twidere.view.TouchImageView.java
public TouchImageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final TouchGestureDetector.OnTouchGestureListener listener = new TouchGestureDetector.OnTouchGestureListener() { @Override/*from w w w.j a v a 2 s .co m*/ public boolean onSingleTapConfirmed(MotionEvent e) { return performClick(); } @Override public void onLongPress(MotionEvent e) { performLongClick(); } @Override public boolean onDoubleTap(MotionEvent e) { loadMatrixValues(); final float minScale = getMinScale(); // If we have already zoomed in, we should return to our initial scale value (minScale). Otherwise, scale to full size final boolean shouldZoomOut = mScale > minScale; final float targetScale = shouldZoomOut ? minScale : mMaxScale; // First, we try to keep the focused point in the same position when the animation ends final float desiredTranslationX = e.getX() - (e.getX() - mTranslationX) * (targetScale / mScale); final float desiredTranslationY = e.getY() - (e.getY() - mTranslationY) * (targetScale / mScale); // Here, we apply a correction to avoid unwanted blank spaces final float targetTranslationX = desiredTranslationX + computeTranslation(getMeasuredWidth(), mDrawableIntrinsicWidth * targetScale, desiredTranslationX, 0); final float targetTranslationY = desiredTranslationY + computeTranslation(getMeasuredHeight(), mDrawableIntrinsicHeight * targetScale, desiredTranslationY, 0); clearAnimation(); final Animation animation = new TouchAnimation(targetScale, targetTranslationX, targetTranslationY); animation.setDuration(DOUBLE_TAP_ANIMATION_DURATION); startAnimation(animation); if (mZoomListener != null) { if (shouldZoomOut) { mZoomListener.onZoomOut(); } else { mZoomListener.onZoomIn(); } } return true; } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { // Sometimes, this method is called just after an onScaleEnd event. In this case, we want to wait until we animate back our image if (mIsAnimatingBack) { return false; } loadMatrixValues(); final float currentDrawableWidth = mDrawableIntrinsicWidth * mScale; final float currentDrawableHeight = mDrawableIntrinsicHeight * mScale; final float dx = computeTranslation(getMeasuredWidth(), currentDrawableWidth, mTranslationX, -distanceX); final float dy = computeTranslation(getMeasuredHeight(), currentDrawableHeight, mTranslationY, -distanceY); mMatrix.postTranslate(dx, dy); clearAnimation(); ViewCompat.postInvalidateOnAnimation(TouchImageView.this); return true; } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { // Sometimes, this method is called just after an onScaleEnd event. In this case, we want to wait until we animate back our image if (mIsAnimatingBack) { return false; } loadMatrixValues(); final float horizontalSideFreeSpace = (getMeasuredWidth() - mDrawableIntrinsicWidth * mScale) / 2F; final float minTranslationX = horizontalSideFreeSpace > 0 ? horizontalSideFreeSpace : getMeasuredWidth() - mDrawableIntrinsicWidth * mScale; final float maxTranslationX = horizontalSideFreeSpace > 0 ? horizontalSideFreeSpace : 0; final float verticalSideFreeSpace = (getMeasuredHeight() - mDrawableIntrinsicHeight * mScale) / 2F; final float minTranslationY = verticalSideFreeSpace > 0 ? verticalSideFreeSpace : getMeasuredHeight() - mDrawableIntrinsicHeight * mScale; final float maxTranslationY = verticalSideFreeSpace > 0 ? verticalSideFreeSpace : 0; // Using FlingScroller here. The results were better than the Scroller class // https://android.googlesource.com/platform/packages/apps/Gallery2/+/master/src/com/android/gallery3d/ui/FlingScroller.java mFlingScroller.fling(Math.round(mTranslationX), Math.round(mTranslationY), Math.round(velocityX), Math.round(velocityY), Math.round(minTranslationX), Math.round(maxTranslationX), Math.round(minTranslationY), Math.round(maxTranslationY)); clearAnimation(); final Animation animation = new FlingAnimation(); animation.setDuration(mFlingScroller.getDuration()); animation.setInterpolator(new LinearInterpolator()); startAnimation(animation); return true; } @Override public boolean onScaleBegin(ScaleGestureDetector detector) { mLastFocusX = null; mLastFocusY = null; return true; } @Override public boolean onScale(ScaleGestureDetector detector) { loadMatrixValues(); float currentDrawableWidth = mDrawableIntrinsicWidth * mScale; float currentDrawableHeight = mDrawableIntrinsicHeight * mScale; final float focusX = computeFocus(getMeasuredWidth(), currentDrawableWidth, mTranslationX, detector.getFocusX()); final float focusY = computeFocus(getMeasuredHeight(), currentDrawableHeight, mTranslationY, detector.getFocusY()); // Here, we provide the ability to scroll while scaling if (mLastFocusX != null && mLastFocusY != null) { final float dx = computeScaleTranslation(getMeasuredWidth(), currentDrawableWidth, mTranslationX, focusX - mLastFocusX); final float dy = computeScaleTranslation(getMeasuredHeight(), currentDrawableHeight, mTranslationY, focusY - mLastFocusY); if (dx != 0 || dy != 0) { mMatrix.postTranslate(dx, dy); } } final float scale = computeScale(getMinScale(), mMaxScale, mScale, detector.getScaleFactor()); mMatrix.postScale(scale, scale, focusX, focusY); mLastFocusX = focusX; mLastFocusY = focusY; clearAnimation(); ViewCompat.postInvalidateOnAnimation(TouchImageView.this); return true; } @Override public void onScaleEnd(ScaleGestureDetector detector) { loadMatrixValues(); final float currentDrawableWidth = mDrawableIntrinsicWidth * mScale; final float currentDrawableHeight = mDrawableIntrinsicHeight * mScale; final float dx = computeTranslation(getMeasuredWidth(), currentDrawableWidth, mTranslationX, 0); final float dy = computeTranslation(getMeasuredHeight(), currentDrawableHeight, mTranslationY, 0); if (Math.abs(dx) < 1 && Math.abs(dy) < 1) { return; } final float targetTranslationX = mTranslationX + dx; final float targetTranslationY = mTranslationY + dy; clearAnimation(); final Animation animation = new TouchAnimation(mScale, targetTranslationX, targetTranslationY); animation.setDuration(SCALE_END_ANIMATION_DURATION); startAnimation(animation); mIsAnimatingBack = true; } }; mTouchGestureDetector = new TouchGestureDetector(context, listener); super.setScaleType(ScaleType.MATRIX); }
From source file:com.haibin.calendarview.CalendarView.java
public void closeSelectLayout(final int position) { mSelectLayout.setVisibility(GONE);/* ww w .ja va2s . co m*/ mLinearWeek.setVisibility(VISIBLE); mViewPager.setVisibility(VISIBLE); mViewPager.setCurrentItem(position, true); mLinearWeek.animate().translationY(0).setInterpolator(new LinearInterpolator()).setDuration(180) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mLinearWeek.setVisibility(VISIBLE); } }); mViewPager.animate().scaleX(1).scaleY(1).setDuration(180).setInterpolator(new LinearInterpolator()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mViewPager.setVisibility(VISIBLE); } }); }
From source file:ac.robinson.paperchains.PaperChainsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!CameraUtilities.getIsCameraAvailable(getPackageManager())) { Toast.makeText(PaperChainsActivity.this, getString(R.string.hint_no_camera), Toast.LENGTH_SHORT).show(); finish();/* w w w . j av a 2 s . c o m*/ return; } getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); setViews(R.id.viewfinder_view, R.id.preview_view, R.id.image_view); setResizeImageToView(false); // we want the high quality image setVolumeControlStream(AudioManager.STREAM_MUSIC); // set up action bar ActionBar actionBar = getSupportActionBar(); actionBar.setTitle(R.string.title_activity_capture); actionBar.setDisplayShowTitleEnabled(true); int resultPointColour = getResources().getColor(R.color.accent); ((ViewfinderView) findViewById(R.id.viewfinder_view)).setResultPointColour(resultPointColour); // set up SoundCloud API wrappers (without a user token - for playback only, initially) setupSoundCloudApiWrappers(); mCurrentMode = MODE_CAPTURE; // set up a zoomable view for the photo mImageView = (PaperChainsView) findViewById(R.id.image_view); mZoomControl = new DynamicZoomControl(); mImageView.setZoomState(mZoomControl.getZoomState()); mZoomControl.setAspectQuotient(mImageView.getAspectQuotient()); mZoomListener = new LongPressZoomListener(PaperChainsActivity.this); mZoomListener.setZoomControl(mZoomControl); // set up buttons/handlers mImageView.setOnTouchListener(mZoomListener); mImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onImageClick(); } }); mImageView.setScribbleCallback(new PaperChainsView.ScribbleCallback() { @Override public void scribbleCompleted(Path scribble) { processScribble(scribble); } }); mRecordButton = (AudioRecorderCircleButton) findViewById(R.id.record_button); mRecordButton.setOnClickListener(mRecordButtonListener); mPlayButton = (AudioRecorderCircleButton) findViewById(R.id.play_button); mPlayButton.setOnClickListener(mPlayButtonListener); mDeleteButton = (AudioRecorderCircleButton) findViewById(R.id.delete_button); mDeleteButton.setOnClickListener(mDeleteButtonListener); mSaveButton = (AudioRecorderCircleButton) findViewById(R.id.save_button); mSaveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { saveAudio(); } }); // set up animation for the play/save buttons mRotateAnimation = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateAnimation.setDuration(BUTTON_ANIMATION_DURATION); mRotateAnimation.setInterpolator(new LinearInterpolator()); mRotateAnimation.setRepeatCount(Animation.INFINITE); mRotateAnimation.setRepeatMode(Animation.RESTART); }
From source file:com.appsummary.luoxf.myappsummary.navigationtabstrip.NavigationTabStrip.java
public NavigationTabStrip(final Context context, final AttributeSet attrs, final int defStyleAttr) { super(context, attrs, defStyleAttr); //Init NTS//from w ww. j a v a2s. c o m // Always draw setWillNotDraw(false); // More speed! setLayerType(LAYER_TYPE_HARDWARE, null); final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NavigationTabStrip); try { setStripColor(typedArray.getColor(R.styleable.NavigationTabStrip_nts_color, DEFAULT_STRIP_COLOR)); setTitleSize(typedArray.getDimension(R.styleable.NavigationTabStrip_nts_size, DEFAULT_TITLE_SIZE)); setStripWeight( typedArray.getDimension(R.styleable.NavigationTabStrip_nts_weight, DEFAULT_STRIP_WEIGHT)); setStripFactor(typedArray.getFloat(R.styleable.NavigationTabStrip_nts_factor, DEFAULT_STRIP_FACTOR)); setStripType(typedArray.getInt(R.styleable.NavigationTabStrip_nts_type, StripType.LINE_INDEX)); setStripGravity( typedArray.getInt(R.styleable.NavigationTabStrip_nts_gravity, StripGravity.BOTTOM_INDEX)); setTypeface(typedArray.getString(R.styleable.NavigationTabStrip_nts_typeface)); setInactiveColor( typedArray.getColor(R.styleable.NavigationTabStrip_nts_inactive_color, DEFAULT_INACTIVE_COLOR)); setActiveColor( typedArray.getColor(R.styleable.NavigationTabStrip_nts_active_color, DEFAULT_ACTIVE_COLOR)); setAnimationDuration(typedArray.getInteger(R.styleable.NavigationTabStrip_nts_animation_duration, DEFAULT_ANIMATION_DURATION)); setCornersRadius(typedArray.getDimension(R.styleable.NavigationTabStrip_nts_corners_radius, DEFAULT_CORNER_RADIUS)); // Get titles String[] titles = null; try { final int titlesResId = typedArray.getResourceId(R.styleable.NavigationTabStrip_nts_titles, 0); titles = titlesResId == 0 ? null : typedArray.getResources().getStringArray(titlesResId); } catch (Exception exception) { titles = null; exception.printStackTrace(); } finally { if (titles == null) { if (isInEditMode()) { titles = new String[new Random().nextInt(5) + 1]; Arrays.fill(titles, PREVIEW_TITLE); } else titles = new String[0]; } setTitles(titles); } // Init animator mAnimator.setFloatValues(MIN_FRACTION, MAX_FRACTION); mAnimator.setInterpolator(new LinearInterpolator()); mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(final ValueAnimator animation) { updateIndicatorPosition((Float) animation.getAnimatedValue()); } }); } finally { typedArray.recycle(); } }