List of usage examples for android.view.animation RotateAnimation RotateAnimation
public RotateAnimation(float fromDegrees, float toDegrees, float pivotX, float pivotY)
From source file:com.fastbootmobile.encore.app.adapters.SongsListAdapter.java
/** * {@inheritDoc}//from ww w . j av a 2s . com */ @Override public View getView(final int position, final View convertView, ViewGroup parent) { final Context ctx = parent.getContext(); assert ctx != null; final ProviderAggregator aggregator = ProviderAggregator.getDefault(); View root = convertView; if (convertView == null) { // Recycle the existing view LayoutInflater inflater = LayoutInflater.from(ctx); root = inflater.inflate(R.layout.item_playlist_view, parent, false); assert root != null; ViewHolder holder = new ViewHolder(); holder.tvTitle = (TextView) root.findViewById(R.id.tvTitle); holder.tvArtist = (TextView) root.findViewById(R.id.tvArtist); holder.tvDuration = (TextView) root.findViewById(R.id.tvDuration); holder.ivOverflow = (ImageView) root.findViewById(R.id.ivOverflow); holder.ivAlbumArt = (AlbumArtImageView) root.findViewById(R.id.ivAlbumArt); holder.ivOffline = (ImageView) root.findViewById(R.id.ivOffline); holder.vCurrentIndicator = root.findViewById(R.id.currentSongIndicator); holder.vRoot = (ViewGroup) root; holder.vRoot.setLayerType(View.LAYER_TYPE_HARDWARE, null); if (mShowAlbumArt) { // Fixup some style stuff holder.ivAlbumArt.setVisibility(View.VISIBLE); } else { holder.ivAlbumArt.setVisibility(View.GONE); } holder.ivOverflow.setOnClickListener(mOverflowClickListener); holder.ivOverflow.setTag(holder); root.setTag(holder); } final Song song = getItem(position); final ViewHolder tag = (ViewHolder) root.getTag(); // Update tag tag.position = position; tag.song = song; root.setTag(tag); // Fill fields if (song != null && song.isLoaded()) { tag.tvTitle.setText(song.getTitle()); tag.tvDuration.setText(Utils.formatTrackLength(song.getDuration())); if (mShowAlbumArt) { tag.ivAlbumArt.loadArtForSong(song); } if (song.getArtist() == null) { tag.tvArtist.setText(null); } else { Artist artist = aggregator.retrieveArtist(song.getArtist(), song.getProvider()); if (artist != null) { tag.tvArtist.setText(artist.getName()); } else { tag.tvArtist.setText("..."); } } } else { tag.tvTitle.setText("..."); tag.tvDuration.setText("..."); tag.tvArtist.setText("..."); if (mShowAlbumArt) { tag.ivAlbumArt.setDefaultArt(); } } // Set current song indicator tag.vCurrentIndicator.setVisibility(View.INVISIBLE); Song currentSong = PlaybackProxy.getCurrentTrack(); if (currentSong != null && currentSong.equals(tag.song)) { tag.vCurrentIndicator.setVisibility(View.VISIBLE); } if (song != null) { // Set alpha based on offline availability and mode if ((aggregator.isOfflineMode() && song.getOfflineStatus() != BoundEntity.OFFLINE_STATUS_READY) || !song.isAvailable()) { Utils.setChildrenAlpha(tag.vRoot, Float.parseFloat(ctx.getResources().getString(R.string.unavailable_track_alpha))); } else { Utils.setChildrenAlpha(tag.vRoot, 1.0f); } // Show offline indicator in any case tag.ivOffline.setVisibility(View.VISIBLE); tag.ivOffline.clearAnimation(); if (song.getOfflineStatus() == BoundEntity.OFFLINE_STATUS_READY) { tag.ivOffline.setImageResource(R.drawable.ic_track_downloaded); } else if (song.getOfflineStatus() == BoundEntity.OFFLINE_STATUS_DOWNLOADING) { tag.ivOffline.setImageResource(R.drawable.ic_sync_in_progress); if (mSyncRotateAnimation == null && tag.ivOffline.getMeasuredWidth() != 0) { mSyncRotateAnimation = new RotateAnimation(0, -360, tag.ivOffline.getMeasuredWidth() / 2.0f, tag.ivOffline.getMeasuredHeight() / 2.0f); mSyncRotateAnimation.setRepeatMode(Animation.INFINITE); mSyncRotateAnimation.setRepeatCount(Animation.INFINITE); mSyncRotateAnimation.setDuration(1000); mSyncRotateAnimation.setInterpolator(new LinearInterpolator()); } if (mSyncRotateAnimation != null) { tag.ivOffline.startAnimation(mSyncRotateAnimation); } } else if (song.getOfflineStatus() == BoundEntity.OFFLINE_STATUS_ERROR) { tag.ivOffline.setImageResource(R.drawable.ic_sync_problem); } else if (song.getOfflineStatus() == BoundEntity.OFFLINE_STATUS_PENDING) { tag.ivOffline.setImageResource(R.drawable.ic_track_download_pending); } else { tag.ivOffline.setVisibility(View.GONE); } } return root; }
From source file:com.jackie.refresh.RefreshLayoutBase.java
private void rotateHeaderArrow() { Log.d(TAG, "rotateHeaderArrow() called with: mCurrentStatus = " + mCurrentStatus); if (mCurrentStatus == STATUS_REFRESHING) { return;//from ww w.ja va 2s.com } else if (mCurrentStatus == STATUS_PULL_TO_REFRESH && !isArrowUp) { return; } else if (mCurrentStatus == STATUS_RELEASE_TO_REFRESH && isArrowUp) { return; } mRefreshProgress.setVisibility(View.GONE); mArrowImg.setVisibility(View.VISIBLE); float pivotX = mArrowImg.getWidth() / 2f; float pivotY = mArrowImg.getHeight() / 2f; float fromDegrees = 0f; float toDegrees = 0f; if (mCurrentStatus == STATUS_PULL_TO_REFRESH) { fromDegrees = 180f; toDegrees = 360f; } else if (mCurrentStatus == STATUS_RELEASE_TO_REFRESH) { fromDegrees = 0f; toDegrees = 180f; } RotateAnimation animation = new RotateAnimation(fromDegrees, toDegrees, pivotX, pivotY); animation.setDuration(100); animation.setFillAfter(true); mArrowImg.startAnimation(animation); if (mCurrentStatus == STATUS_RELEASE_TO_REFRESH) { isArrowUp = true; } else { isArrowUp = false; } }
From source file:com.geecko.QuickLyric.fragment.LocalLyricsFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { final MainActivity mainActivity = ((MainActivity) this.getActivity()); super.onViewCreated(view, savedInstanceState); if (this.isHidden()) return;/*from w w w . ja v a 2 s .co m*/ DrawerAdapter drawerAdapter = ((DrawerAdapter) ((ListView) mainActivity.findViewById(R.id.drawer_list)) .getAdapter()); if (drawerAdapter.getSelectedItem() != 1) { drawerAdapter.setSelectedItem(1); drawerAdapter.notifyDataSetChanged(); } if (!megaListView.hasOnGroupClickListener()) megaListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { final ImageView indicator = (ImageView) v.findViewById(R.id.group_indicator); RotateAnimation anim; if (megaListView.isGroupExpanded(groupPosition)) { megaListView.collapseGroupWithAnimation(groupPosition); if (indicator != null) { anim = new RotateAnimation(180f, 360f, indicator.getWidth() / 2, indicator.getHeight() / 2); anim.setInterpolator(new DecelerateInterpolator(3)); anim.setDuration(500); anim.setFillAfter(true); indicator.startAnimation(anim); } } else { megaListView.expandGroupWithAnimation(groupPosition); if (indicator != null) { anim = new RotateAnimation(0f, 180f, indicator.getWidth() / 2, indicator.getHeight() / 2); anim.setInterpolator(new DecelerateInterpolator(2)); anim.setDuration(500); anim.setFillAfter(true); indicator.startAnimation(anim); } } return true; } }); if (!megaListView.hasOnChildClickListener()) megaListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { if (mSwiping) { mSwiping = false; return false; } final MainActivity mainActivity = (MainActivity) getActivity(); megaListView.setOnChildClickListener(null); // prevents bug on double tap mainActivity.updateLyricsFragment(R.animator.slide_out_start, R.animator.slide_in_start, true, ((LocalAdapter) megaListView.getExpandableListAdapter()).getChild(groupPosition, childPosition)); return true; } }); this.isActiveFragment = true; new DBContentLister(this).execute(); }
From source file:com.evandroid.musica.fragment.LocalLyricsFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (this.isHidden()) return;// w w w . jav a2 s . co m megaListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { final ImageView indicator = (ImageView) v.findViewById(R.id.group_indicator); RotateAnimation anim; if (megaListView.isGroupExpanded(groupPosition)) { megaListView.collapseGroupWithAnimation(groupPosition); if (indicator != null) { anim = new RotateAnimation(180f, 360f, indicator.getWidth() / 2, indicator.getHeight() / 2); anim.setInterpolator(new DecelerateInterpolator(3)); anim.setDuration(500); anim.setFillAfter(true); indicator.startAnimation(anim); } } else { megaListView.expandGroupWithAnimation(groupPosition); if (indicator != null) { anim = new RotateAnimation(0f, 180f, indicator.getWidth() / 2, indicator.getHeight() / 2); anim.setInterpolator(new DecelerateInterpolator(2)); anim.setDuration(500); anim.setFillAfter(true); indicator.startAnimation(anim); } } return true; } }); megaListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { if (mSwiping) { mSwiping = false; return false; } final MainLyricActivity mainLyricActivity = (MainLyricActivity) getActivity(); megaListView.setOnChildClickListener(null); // prevents bug on double tap mainLyricActivity.updateLyricsFragment(R.animator.slide_out_start, R.animator.slide_in_start, true, lyricsArray.get(groupPosition).get(childPosition)); return true; } }); this.isActiveFragment = true; new DBContentLister(this).execute(); }
From source file:ly.kite.journey.selection.ProductOverviewFragment.java
/***************************************************** * * Called when the details control is clicked. * *****************************************************/ private void toggleSliderState() { // We want to animation the following: // - Overlaid start button fade in / out // - Sliding drawer up / down // - Open / close drawer icon rotation boolean sliderWillBeOpening = !mSlidingOverlayFrame.sliderIsExpanded(); float overlaidComponentsInitialAlpha; float overlaidComponentsFinalAlpha; float openCloseIconInitialRotation; float openCloseIconFinalRotation; if (sliderWillBeOpening) { overlaidComponentsInitialAlpha = 1f; overlaidComponentsFinalAlpha = 0f; openCloseIconInitialRotation = OPEN_CLOSE_ICON_ROTATION_UP; openCloseIconFinalRotation = OPEN_CLOSE_ICON_ROTATION_DOWN; } else {// ww w .ja v a 2 s .co m overlaidComponentsInitialAlpha = 0f; overlaidComponentsFinalAlpha = 1f; openCloseIconInitialRotation = OPEN_CLOSE_ICON_ROTATION_DOWN; openCloseIconFinalRotation = OPEN_CLOSE_ICON_ROTATION_UP; } // Create the overlaid components animation Animation overlaidComponentsAnimation = new AlphaAnimation(overlaidComponentsInitialAlpha, overlaidComponentsFinalAlpha); overlaidComponentsAnimation.setDuration(SLIDE_ANIMATION_DURATION_MILLIS); overlaidComponentsAnimation.setFillAfter(true); // Create the open/close icon animation. // The rotation is delayed, but will finish at the same time as the slide animation. Animation openCloseIconAnimation = new RotateAnimation(openCloseIconInitialRotation, openCloseIconFinalRotation, mOpenCloseDrawerIconImageView.getWidth() * 0.5f, mOpenCloseDrawerIconImageView.getHeight() * 0.5f); openCloseIconAnimation.setStartOffset(OPEN_CLOSE_ICON_ANIMATION_DELAY_MILLIS); openCloseIconAnimation.setDuration(OPEN_CLOSE_ICON_ANIMATION_DURATION_MILLIS); openCloseIconAnimation.setFillAfter(true); if (mOverlaidComponents != null) { mOverlaidComponents.setAlpha(1f); // Clear any alpha already applied mOverlaidComponents.startAnimation(overlaidComponentsAnimation); } if (mOpenCloseDrawerIconImageView != null) { mOpenCloseDrawerIconImageView.setRotation(0f); // Clear any rotation already applied mOpenCloseDrawerIconImageView.startAnimation(openCloseIconAnimation); } mSlidingOverlayFrame.animateToExpandedState(sliderWillBeOpening); }
From source file:com.zainsoft.ramzantimetable.QiblaActivity.java
private double rotateImageView(double newAngle, double fromDegree, ImageView imageView) { newAngle = newAngle % 360;//from w w w . jav a2s. c o m double rotationDegree = fromDegree - newAngle; rotationDegree = rotationDegree % 360; long duration = new Double(Math.abs(rotationDegree) * 2000 / 360).longValue(); if (rotationDegree > 180) rotationDegree -= 360; FrameLayout frameLayout = (FrameLayout) findViewById(R.id.qiblaLayout); float toDegree = new Double(newAngle % 360).floatValue(); final int width = Math.abs(frameLayout.getRight() - frameLayout.getLeft()); final int height = Math.abs(frameLayout.getBottom() - frameLayout.getTop()); // LinearLayout main = (LinearLayout) findViewById(R.id.mainLayout); float pivotX = width / 2f; float pivotY = height / 2f; animation = new RotateAnimation(new Double(fromDegree).floatValue(), toDegree, pivotX, pivotY); animation.setRepeatCount(0); animation.setDuration(duration); animation.setInterpolator(new LinearInterpolator()); animation.setFillEnabled(true); animation.setFillAfter(true); animation.setAnimationListener(this); /*Log.d(NAMAZ_LOG_TAG, "rotating image from degree:" + fromDegree + " degree to rotate: " + rotationDegree + " ImageView: " + imageView.getId());*/ imageView.startAnimation(animation); return toDegree; }
From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java
private void initRotateNotification(int orientation) { if (rotatorLayout != null && showLandscapeNotification) { if (!isRecording && (orientation == 90 || orientation == 270)) { try { int height = (int) ApplicationScreen.getAppResources().getDimension(R.dimen.gui_element_2size); Animation rotation = new RotateAnimation(0, -180, height / 2, height / 2); rotation.setDuration(2000); rotation.setRepeatCount(1000); rotation.setInterpolator(new DecelerateInterpolator()); rotatorLayout.findViewById(R.id.rotatorImageView).startAnimation(rotation); rotatorLayout.findViewById(R.id.rotatorImageView).setVisibility(View.VISIBLE); rotatorLayout.findViewById(R.id.rotatorInnerImageView).setVisibility(View.VISIBLE); } catch (Exception e) { e.printStackTrace();/*from w w w . j a v a 2s. co m*/ } } else { rotatorLayout.findViewById(R.id.rotatorInnerImageView).setVisibility(View.GONE); rotatorLayout.findViewById(R.id.rotatorImageView).setVisibility(View.GONE); rotatorLayout.findViewById(R.id.rotatorImageView).clearAnimation(); } } else //if we started video but orientation change already fired. Save and set orientation on rotator layout creation videoOrientation = orientation; }
From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java
public ImageView.OnLayoutChangeListener hourglasslistener() { OnLayoutChangeListener olcl = new ImageView.OnLayoutChangeListener() { @Override//from www .j a v a 2 s . co m public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { RotateAnimation animation = new RotateAnimation(0f, 350f, v.getWidth() / 2, v.getHeight() / 2); animation.setInterpolator(new LinearInterpolator()); animation.setRepeatCount(Animation.INFINITE); animation.setDuration(700); ((ImageView) v).startAnimation(animation); } }; return olcl; }